BLERemoteCharacteristic::registerForNotify: Permit event registration without updating descriptor. (#4659)
This commit is contained in:
parent
15db297130
commit
434d02c49f
@ -453,7 +453,7 @@ std::string BLERemoteCharacteristic::readValue() {
|
|||||||
* unregistering a notification.
|
* unregistering a notification.
|
||||||
* @return N/A.
|
* @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());
|
log_v(">> registerForNotify(): %s", toString().c_str());
|
||||||
|
|
||||||
m_notifyCallback = notifyCallback; // Save the notification callback.
|
m_notifyCallback = notifyCallback; // Save the notification callback.
|
||||||
@ -474,7 +474,7 @@ void BLERemoteCharacteristic::registerForNotify(notify_callback notifyCallback,
|
|||||||
uint8_t val[] = {0x01, 0x00};
|
uint8_t val[] = {0x01, 0x00};
|
||||||
if(!notifications) val[0] = 0x02;
|
if(!notifications) val[0] = 0x02;
|
||||||
BLERemoteDescriptor* desc = getDescriptor(BLEUUID((uint16_t)0x2902));
|
BLERemoteDescriptor* desc = getDescriptor(BLEUUID((uint16_t)0x2902));
|
||||||
if (desc != nullptr)
|
if (desc != nullptr && descriptorRequiresRegistration)
|
||||||
desc->writeValue(val, 2, true);
|
desc->writeValue(val, 2, true);
|
||||||
} // End Register
|
} // End Register
|
||||||
else { // If we weren't passed a callback function, then this is an unregistration.
|
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};
|
uint8_t val[] = {0x00, 0x00};
|
||||||
BLERemoteDescriptor* desc = getDescriptor((uint16_t)0x2902);
|
BLERemoteDescriptor* desc = getDescriptor((uint16_t)0x2902);
|
||||||
if (desc != nullptr)
|
if (desc != nullptr && descriptorRequiresRegistration)
|
||||||
desc->writeValue(val, 2, true);
|
desc->writeValue(val, 2, true);
|
||||||
} // End Unregister
|
} // End Unregister
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ public:
|
|||||||
uint16_t readUInt16();
|
uint16_t readUInt16();
|
||||||
uint32_t readUInt32();
|
uint32_t readUInt32();
|
||||||
float readFloat();
|
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(uint8_t* data, size_t length, bool response = false);
|
||||||
void writeValue(std::string newValue, bool response = false);
|
void writeValue(std::string newValue, bool response = false);
|
||||||
void writeValue(uint8_t newValue, bool response = false);
|
void writeValue(uint8_t newValue, bool response = false);
|
||||||
|
Loading…
Reference in New Issue
Block a user