Unverified Commit 434d02c4 authored by Andrew's avatar Andrew Committed by GitHub

BLERemoteCharacteristic::registerForNotify: Permit event registration without...

BLERemoteCharacteristic::registerForNotify: Permit event registration without updating descriptor. (#4659)
parent 15db2971
......@@ -453,7 +453,7 @@ std::string BLERemoteCharacteristic::readValue() {
* unregistering a notification.
* @return N/A.
*/
void BLERemoteCharacteristic::registerForNotify(notify_callback notifyCallback, bool notifications) {
void BLERemoteCharacteristic::registerForNotify(notify_callback notifyCallback, bool notifications, bool descriptorRequiresRegistration) {
log_v(">> registerForNotify(): %s", toString().c_str());
m_notifyCallback = notifyCallback; // Save the notification callback.
......@@ -474,7 +474,7 @@ void BLERemoteCharacteristic::registerForNotify(notify_callback notifyCallback,
uint8_t val[] = {0x01, 0x00};
if(!notifications) val[0] = 0x02;
BLERemoteDescriptor* desc = getDescriptor(BLEUUID((uint16_t)0x2902));
if (desc != nullptr)
if (desc != nullptr && descriptorRequiresRegistration)
desc->writeValue(val, 2, true);
} // End Register
else { // If we weren't passed a callback function, then this is an unregistration.
......@@ -490,7 +490,7 @@ void BLERemoteCharacteristic::registerForNotify(notify_callback notifyCallback,
uint8_t val[] = {0x00, 0x00};
BLERemoteDescriptor* desc = getDescriptor((uint16_t)0x2902);
if (desc != nullptr)
if (desc != nullptr && descriptorRequiresRegistration)
desc->writeValue(val, 2, true);
} // End Unregister
......
......@@ -46,7 +46,7 @@ public:
uint16_t readUInt16();
uint32_t readUInt32();
float readFloat();
void registerForNotify(notify_callback _callback, bool notifications = true);
void registerForNotify(notify_callback _callback, bool notifications = true, bool descriptorRequiresRegistration = true);
void writeValue(uint8_t* data, size_t length, bool response = false);
void writeValue(std::string newValue, bool response = false);
void writeValue(uint8_t newValue, bool response = false);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment