mirror of
https://github.com/h2zero/esp-nimble-cpp.git
synced 2024-11-25 06:30: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);
|
NimBLEDevice::getServer()->clearIndicateWait(event->subscribe.conn_handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_pCallbacks->onSubscribe(this, &desc, subVal);
|
|
||||||
|
|
||||||
auto it = m_subscribedVec.begin();
|
auto it = m_subscribedVec.begin();
|
||||||
for(;it != m_subscribedVec.end(); ++it) {
|
for(;it != m_subscribedVec.end(); ++it) {
|
||||||
|
@ -319,14 +318,14 @@ void NimBLECharacteristic::setSubscribe(struct ble_gap_event *event) {
|
||||||
if(subVal > 0) {
|
if(subVal > 0) {
|
||||||
if(it == m_subscribedVec.end()) {
|
if(it == m_subscribedVec.end()) {
|
||||||
m_subscribedVec.push_back({event->subscribe.conn_handle, subVal});
|
m_subscribedVec.push_back({event->subscribe.conn_handle, subVal});
|
||||||
return;
|
} else {
|
||||||
}
|
|
||||||
|
|
||||||
(*it).second = subVal;
|
(*it).second = subVal;
|
||||||
|
}
|
||||||
} else if(it != m_subscribedVec.end()) {
|
} else if(it != m_subscribedVec.end()) {
|
||||||
m_subscribedVec.erase(it);
|
m_subscribedVec.erase(it);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_pCallbacks->onSubscribe(this, &desc, subVal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue