mirror of
https://github.com/h2zero/esp-nimble-cpp.git
synced 2026-01-28 10:02:19 +01:00
Server: Add onSubscribe() callback for characteristics. (#21)
Server: Add onSubscribe() callback for characteristics. Adds a new method to NimBLECharacteristicCallbacks that gets called when a client changes it's subscription status. * Remove NimBLE2902 class. As the NimBLE2902 class usefulness was only related to callback functions that were replaced by the NimBLECharacteristicCallbacks:onSubscribe() method this removes the NimBLE2902 class and moves all subscription handling to NimBLECharacteristic. * Update documents and examples to reflect this change. * Add getSubscribedCount() to get the number of subscribed clients.
This commit is contained in:
@@ -182,10 +182,6 @@ void NimBLEServer::start() {
|
||||
// we do it now.
|
||||
if((chr->m_properties & BLE_GATT_CHR_F_INDICATE) ||
|
||||
(chr->m_properties & BLE_GATT_CHR_F_NOTIFY)) {
|
||||
|
||||
if(nullptr == chr->getDescriptorByUUID(uint16_t(0x2902))) {
|
||||
chr->createDescriptor(uint16_t(0x2902));
|
||||
}
|
||||
m_notifyChrVec.push_back(chr);
|
||||
}
|
||||
}
|
||||
@@ -303,9 +299,9 @@ size_t NimBLEServer::getConnectedCount() {
|
||||
} // BLE_GAP_EVENT_DISCONNECT
|
||||
|
||||
case BLE_GAP_EVENT_SUBSCRIBE: {
|
||||
NIMBLE_LOGI(LOG_TAG, "subscribe event; cur_notify=%d\n value handle; "
|
||||
"val_handle=%d\n",
|
||||
event->subscribe.cur_notify, event->subscribe.attr_handle);
|
||||
NIMBLE_LOGI(LOG_TAG, "subscribe event; attr_handle=%d, subscribed: %s",
|
||||
event->subscribe.attr_handle,
|
||||
(event->subscribe.cur_notify ? "true":"false"));
|
||||
|
||||
for(auto &it : server->m_notifyChrVec) {
|
||||
if(it->getHandle() == event->subscribe.attr_handle) {
|
||||
|
||||
Reference in New Issue
Block a user