mirror of
https://github.com/h2zero/esp-nimble-cpp.git
synced 2024-11-21 20:50:55 +01:00
Call onSubscribe() after adding connection to subscribedVector
This allows for sending BLE messages in the onSubscribe() handler
This commit is contained in:
parent
9fa9531e50
commit
7815d89dbf
1 changed files with 4 additions and 5 deletions
|
@ -307,7 +307,6 @@ void NimBLECharacteristic::setSubscribe(struct ble_gap_event *event) {
|
|||
NimBLEDevice::getServer()->clearIndicateWait(event->subscribe.conn_handle);
|
||||
}
|
||||
|
||||
m_pCallbacks->onSubscribe(this, &desc, subVal);
|
||||
|
||||
auto it = m_subscribedVec.begin();
|
||||
for(;it != m_subscribedVec.end(); ++it) {
|
||||
|
@ -319,14 +318,14 @@ void NimBLECharacteristic::setSubscribe(struct ble_gap_event *event) {
|
|||
if(subVal > 0) {
|
||||
if(it == m_subscribedVec.end()) {
|
||||
m_subscribedVec.push_back({event->subscribe.conn_handle, subVal});
|
||||
return;
|
||||
}
|
||||
|
||||
} else {
|
||||
(*it).second = subVal;
|
||||
|
||||
}
|
||||
} else if(it != m_subscribedVec.end()) {
|
||||
m_subscribedVec.erase(it);
|
||||
}
|
||||
|
||||
m_pCallbacks->onSubscribe(this, &desc, subVal);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue