Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on May 12, 2022. It is now read-only.

Commit 434d02c

Browse filesBrowse files
BLERemoteCharacteristic::registerForNotify: Permit event registration without updating descriptor. (espressif#4659)
1 parent 15db297 commit 434d02c
Copy full SHA for 434d02c

File tree

2 files changed

+4
-4
lines changed
Filter options

2 files changed

+4
-4
lines changed

‎libraries/BLE/src/BLERemoteCharacteristic.cpp

Copy file name to clipboardExpand all lines: libraries/BLE/src/BLERemoteCharacteristic.cpp
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ std::string BLERemoteCharacteristic::readValue() {
453453
* unregistering a notification.
454454
* @return N/A.
455455
*/
456-
void BLERemoteCharacteristic::registerForNotify(notify_callback notifyCallback, bool notifications) {
456+
void BLERemoteCharacteristic::registerForNotify(notify_callback notifyCallback, bool notifications, bool descriptorRequiresRegistration) {
457457
log_v(">> registerForNotify(): %s", toString().c_str());
458458

459459
m_notifyCallback = notifyCallback; // Save the notification callback.
@@ -474,7 +474,7 @@ void BLERemoteCharacteristic::registerForNotify(notify_callback notifyCallback,
474474
uint8_t val[] = {0x01, 0x00};
475475
if(!notifications) val[0] = 0x02;
476476
BLERemoteDescriptor* desc = getDescriptor(BLEUUID((uint16_t)0x2902));
477-
if (desc != nullptr)
477+
if (desc != nullptr && descriptorRequiresRegistration)
478478
desc->writeValue(val, 2, true);
479479
} // End Register
480480
else { // If we weren't passed a callback function, then this is an unregistration.
@@ -490,7 +490,7 @@ void BLERemoteCharacteristic::registerForNotify(notify_callback notifyCallback,
490490

491491
uint8_t val[] = {0x00, 0x00};
492492
BLERemoteDescriptor* desc = getDescriptor((uint16_t)0x2902);
493-
if (desc != nullptr)
493+
if (desc != nullptr && descriptorRequiresRegistration)
494494
desc->writeValue(val, 2, true);
495495
} // End Unregister
496496

‎libraries/BLE/src/BLERemoteCharacteristic.h

Copy file name to clipboardExpand all lines: libraries/BLE/src/BLERemoteCharacteristic.h
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class BLERemoteCharacteristic {
4646
uint16_t readUInt16();
4747
uint32_t readUInt32();
4848
float readFloat();
49-
void registerForNotify(notify_callback _callback, bool notifications = true);
49+
void registerForNotify(notify_callback _callback, bool notifications = true, bool descriptorRequiresRegistration = true);
5050
void writeValue(uint8_t* data, size_t length, bool response = false);
5151
void writeValue(std::string newValue, bool response = false);
5252
void writeValue(uint8_t newValue, bool response = false);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.