Skip to content

Commit 1b9deaa

Browse files
aykevldeadprogram
authored andcommitted
sd: send the correct response to BLE_GAP_EVT_PHY_UPDATE_REQUEST
This fixes an issue on my Android phone where the connection would break after 40s because the PHY update was never responded to - or at least not correctly.
1 parent 5c61529 commit 1b9deaa

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

adapter_nrf528xx-full.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ func handleEvent() {
111111
case C.BLE_GAP_EVT_DATA_LENGTH_UPDATE:
112112
// ignore confirmation of data length successfully updated
113113
case C.BLE_GAP_EVT_PHY_UPDATE_REQUEST:
114-
phyUpdateRequest := gapEvent.params.unionfield_phy_update_request()
115-
C.sd_ble_gap_phy_update(gapEvent.conn_handle, &phyUpdateRequest.peer_preferred_phys)
114+
// Tell the Bluetooth stack to update the PHY as it sees fit.
115+
C.sd_ble_gap_phy_update(gapEvent.conn_handle, &phyUpdateResponse)
116116
case C.BLE_GAP_EVT_PHY_UPDATE:
117117
// ignore confirmation of phy successfully updated
118118
case C.BLE_GAP_EVT_TIMEOUT:

adapter_nrf528xx-peripheral.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ func handleEvent() {
6060
case C.BLE_GAP_EVT_DATA_LENGTH_UPDATE:
6161
// ignore confirmation of data length successfully updated
6262
case C.BLE_GAP_EVT_PHY_UPDATE_REQUEST:
63-
phyUpdateRequest := gapEvent.params.unionfield_phy_update_request()
64-
C.sd_ble_gap_phy_update(gapEvent.conn_handle, &phyUpdateRequest.peer_preferred_phys)
63+
// Tell the Bluetooth stack to update the PHY as it sees fit.
64+
C.sd_ble_gap_phy_update(gapEvent.conn_handle, &phyUpdateResponse)
6565
case C.BLE_GAP_EVT_PHY_UPDATE:
6666
// ignore confirmation of phy successfully updated
6767
default:

adapter_nrf528xx.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,9 @@ func makeMACAddress(addr C.ble_gap_addr_t) MACAddress {
6767
isRandom: addr.bitfield_addr_type() != 0,
6868
}
6969
}
70+
71+
// Always let the BLE stack pick the right PHY.
72+
var phyUpdateResponse = C.ble_gap_phys_t{
73+
tx_phys: C.BLE_GAP_PHY_AUTO,
74+
rx_phys: C.BLE_GAP_PHY_AUTO,
75+
}

0 commit comments

Comments
 (0)