From c285052f6da2f72dc278735d06c97a143c9686b2 Mon Sep 17 00:00:00 2001 From: h2zero Date: Sat, 16 Apr 2022 12:45:13 -0600 Subject: [PATCH] Use write with response when writing 0x2902 descriptors. As per Bluetooth core specification we must write to 0x2902 descriptors with response request. This change ensures the correct procedure is used. Todo: Remove the "response" parameter from related functions. --- src/NimBLERemoteCharacteristic.cpp | 1 + src/NimBLERemoteCharacteristic.h | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/NimBLERemoteCharacteristic.cpp b/src/NimBLERemoteCharacteristic.cpp index 6cca615..68982f8 100644 --- a/src/NimBLERemoteCharacteristic.cpp +++ b/src/NimBLERemoteCharacteristic.cpp @@ -616,6 +616,7 @@ bool NimBLERemoteCharacteristic::setNotify(uint16_t val, notify_callback notifyC NIMBLE_LOGD(LOG_TAG, "<< setNotify()"); + response = true; // Always write with response as per Bluetooth core specification. return desc->writeValue((uint8_t *)&val, 2, response); } // setNotify diff --git a/src/NimBLERemoteCharacteristic.h b/src/NimBLERemoteCharacteristic.h index 353d832..7042b19 100644 --- a/src/NimBLERemoteCharacteristic.h +++ b/src/NimBLERemoteCharacteristic.h @@ -73,8 +73,8 @@ public: bool subscribe(bool notifications = true, notify_callback notifyCallback = nullptr, - bool response = false); - bool unsubscribe(bool response = false); + bool response = true); + bool unsubscribe(bool response = true); bool registerForNotify(notify_callback notifyCallback, bool notifications = true, bool response = true)