From 97f1cf9499dc128d6cbb675c167eece7cc4d3fd8 Mon Sep 17 00:00:00 2001 From: Yurii Soldak Date: Mon, 1 May 2023 14:54:20 +0200 Subject: [PATCH] nrf528xx: handle BLE_GAP_EVT_PHY_UPDATE_REQUEST and explicitly ignore some other events --- adapter_nrf528xx-full.go | 9 +++++++++ adapter_nrf528xx-peripheral.go | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/adapter_nrf528xx-full.go b/adapter_nrf528xx-full.go index a0be0a9a..987907c9 100644 --- a/adapter_nrf528xx-full.go +++ b/adapter_nrf528xx-full.go @@ -99,6 +99,13 @@ func handleEvent() { // We need to respond with sd_ble_gap_data_length_update. Setting // both parameters to nil will make sure we send the default values. C.sd_ble_gap_data_length_update(gapEvent.conn_handle, nil, nil) + case C.BLE_GAP_EVT_DATA_LENGTH_UPDATE: + // ignore confirmation of data length successfully updated + case C.BLE_GAP_EVT_PHY_UPDATE_REQUEST: + phyUpdateRequest := gapEvent.params.unionfield_phy_update_request() + C.sd_ble_gap_phy_update(gapEvent.conn_handle, &phyUpdateRequest.peer_preferred_phys) + case C.BLE_GAP_EVT_PHY_UPDATE: + // ignore confirmation of phy successfully updated default: if debug { println("unknown GAP event:", id) @@ -129,6 +136,8 @@ func handleEvent() { // This event is generated by some devices. While we could support // larger MTUs, this default MTU is supported everywhere. C.sd_ble_gatts_exchange_mtu_reply(gattsEvent.conn_handle, C.BLE_GATT_ATT_MTU_DEFAULT) + case C.BLE_GATTS_EVT_HVN_TX_COMPLETE: + // ignore confirmation of a notification successfully sent default: if debug { println("unknown GATTS event:", id, id-C.BLE_GATTS_EVT_BASE) diff --git a/adapter_nrf528xx-peripheral.go b/adapter_nrf528xx-peripheral.go index 84e7c578..1d949bc4 100644 --- a/adapter_nrf528xx-peripheral.go +++ b/adapter_nrf528xx-peripheral.go @@ -54,6 +54,13 @@ func handleEvent() { // We need to respond with sd_ble_gap_data_length_update. Setting // both parameters to nil will make sure we send the default values. C.sd_ble_gap_data_length_update(gapEvent.conn_handle, nil, nil) + case C.BLE_GAP_EVT_DATA_LENGTH_UPDATE: + // ignore confirmation of data length successfully updated + case C.BLE_GAP_EVT_PHY_UPDATE_REQUEST: + phyUpdateRequest := gapEvent.params.unionfield_phy_update_request() + C.sd_ble_gap_phy_update(gapEvent.conn_handle, &phyUpdateRequest.peer_preferred_phys) + case C.BLE_GAP_EVT_PHY_UPDATE: + // ignore confirmation of phy successfully updated default: if debug { println("unknown GAP event:", id) @@ -84,6 +91,8 @@ func handleEvent() { // This event is generated by some devices. While we could support // larger MTUs, this default MTU is supported everywhere. C.sd_ble_gatts_exchange_mtu_reply(gattsEvent.conn_handle, C.BLE_GATT_ATT_MTU_DEFAULT) + case C.BLE_GATTS_EVT_HVN_TX_COMPLETE: + // ignore confirmation of a notification successfully sent default: if debug { println("unknown GATTS event:", id, id-C.BLE_GATTS_EVT_BASE)