From fbfb706aa48dc164c6571702340904bc053a1b11 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Rey Date: Thu, 1 Dec 2022 15:33:26 +0100 Subject: [PATCH 1/2] Update bluetooth.h event 'indicateconfirmed' created. Raised upon reception of an 'BLE_GATTS_EVT_HVC' softdevice event. See https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s132.api.v7.2.0/msc_inline_mscgraph_90.png for more info. This event can be used in the application to provide app-to-app data transfer reliability. Primarily added to prevent any buffer overflow or data loss between the server and client. --- libs/bluetooth/bluetooth.h | 1 + 1 file changed, 1 insertion(+) diff --git a/libs/bluetooth/bluetooth.h b/libs/bluetooth/bluetooth.h index 6449e7ca35..b2ee2209a1 100644 --- a/libs/bluetooth/bluetooth.h +++ b/libs/bluetooth/bluetooth.h @@ -163,6 +163,7 @@ typedef enum { BLEP_CENTRAL_NOTIFICATION, //< A characteristic we were watching has changed BLEP_CENTRAL_DISCONNECTED, //< Central: Disconnected (reason as data low byte, index in m_central_conn_handles as high byte ) BLEP_TASK_BONDING, //< Bonding negotiation complete (success in data) + BLEP_TASK_CHARACTERISTIC_WRITE_HVC, //< Central: ATT Handle Value Confirmation after an indication packet #endif BLEP_WRITE, //< One of our characteristics written by someone else BLEP_TASK_PASSKEY_DISPLAY, //< We're pairing and have been provided with a passkey to display (data = conn_handle) From 7a8371f1692b1fb03ee8d5bee25c706012fcfa4a Mon Sep 17 00:00:00 2001 From: Jean-Philippe Rey Date: Thu, 1 Dec 2022 15:35:38 +0100 Subject: [PATCH 2/2] Update bluetooth.c event 'indicateconfirmed' created. Raised upon reception of an 'BLE_GATTS_EVT_HVC' softdevice event. See https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s132.api.v7.2.0/msc_inline_mscgraph_90.png for more info. This event can be used in the application to provide app-to-app data transfer reliability. Primarily added to prevent any buffer overflow or data loss between the server and client. --- targets/nrf5x/bluetooth.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/targets/nrf5x/bluetooth.c b/targets/nrf5x/bluetooth.c index 22eb0e2366..ea53704b4a 100644 --- a/targets/nrf5x/bluetooth.c +++ b/targets/nrf5x/bluetooth.c @@ -386,6 +386,11 @@ int jsble_exec_pending(IOEvent *event) { } break; } + case BLEP_TASK_CHARACTERISTIC_WRITE_HVC: { + bleQueueEventAndUnLock(JS_EVENT_PREFIX"indicateconfirmed", 0); + jshHadEvent(); + break; + } #if CENTRAL_LINK_COUNT>0 case BLEP_RSSI_CENTRAL: { // rssi as data low byte, index in m_central_conn_handles as high byte int centralIdx = data>>8; // index in m_central_conn_handles @@ -1451,6 +1456,14 @@ static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context) { jsble_peripheral_activity(); // flag that we've been busy break; } + + case BLE_GATTS_EVT_HVC: { + // Peripheral sent a ATT Handle Value Confirmation + const ble_gatts_evt_hvc_t * p_evt_hvc = &p_ble_evt->evt.gatts_evt.params.hvc; + jsble_queue_pending(BLEP_TASK_CHARACTERISTIC_WRITE_HVC, 0); // send HVC event + jsble_peripheral_activity(); // flag that we've been busy + break; + } #if CENTRAL_LINK_COUNT>0 // For discovery....