mirror of
https://github.com/meshtastic/firmware.git
synced 2026-09-23 23:05:35 -04:00
Say never subscribed only when the peer never subscribed
Both handlers read the live CCCD flag at disconnect, so a peer that subscribed and then unsubscribed - what a BlueZ central does on every teardown - was reported as one that never subscribed at all.
This commit is contained in:
1 parent
9420980369
commit
783e3a497f
2 files changed
+10
-4
No files matched your search
@@ -32,7 +32,8 @@ struct Link {
|
||||
bool used;
|
||||
uint16_t conn;
|
||||
uint16_t chunk;
|
||||
bool subscribed; // wrote the CCCD: a notify target
|
||||
bool subscribed; // wrote the CCCD: a notify target
|
||||
bool everSubscribed; // subscribed at any point, which outlives an unsubscribe
|
||||
// Arrived through the mesh-peer advertisement (instance 2). Set in onGapEvent CONNECT and nowhere
|
||||
// else: it is the slot accounting for that advertisement and the "not the phone's session" signal
|
||||
// NimbleBluetooth's onDisconnect keys off, so it must mean exactly "came in on instance 2". It used
|
||||
@@ -94,6 +95,7 @@ Link *addLink(uint16_t conn, bool viaMeshAdv)
|
||||
l.conn = conn;
|
||||
l.chunk = chunkFor(conn);
|
||||
l.subscribed = false;
|
||||
l.everSubscribed = false;
|
||||
l.viaMeshAdv = viaMeshAdv;
|
||||
return &l;
|
||||
}
|
||||
@@ -191,6 +193,7 @@ class MeshPeerCallbacks : public BLECharacteristicCallbacks
|
||||
std::lock_guard<std::mutex> guard(lock);
|
||||
if (Link *l = addLink(desc->conn_handle, false)) {
|
||||
l->subscribed = subscribed;
|
||||
l->everSubscribed |= subscribed;
|
||||
l->chunk = chunkFor(desc->conn_handle);
|
||||
viaMeshAdv = l->viaMeshAdv;
|
||||
}
|
||||
@@ -361,7 +364,7 @@ bool ESP32BLEGattMesh::onDisconnect(uint16_t connHandle)
|
||||
std::lock_guard<std::mutex> guard(lock);
|
||||
if (Link *l = findLink(connHandle)) {
|
||||
viaMeshAdv = l->viaMeshAdv;
|
||||
subscribed = l->subscribed;
|
||||
subscribed = l->everSubscribed;
|
||||
l->used = false;
|
||||
pushRx(connHandle, nullptr, 0); // the pump drops its half-built packets
|
||||
}
|
||||
|
||||
@@ -18,7 +18,8 @@ concurrency::Lock lock;
|
||||
struct Link {
|
||||
bool used;
|
||||
uint16_t conn;
|
||||
bool subscribed; // wrote the CCCD: a notify target, and the mark of a mesh peer
|
||||
bool subscribed; // wrote the CCCD: a notify target, and the mark of a mesh peer
|
||||
bool everSubscribed; // subscribed at any point, which outlives an unsubscribe
|
||||
};
|
||||
std::array<Link, 4> links{};
|
||||
|
||||
@@ -68,6 +69,7 @@ Link *addLink(uint16_t conn)
|
||||
l.used = true;
|
||||
l.conn = conn;
|
||||
l.subscribed = false;
|
||||
l.everSubscribed = false;
|
||||
return &l;
|
||||
}
|
||||
return nullptr;
|
||||
@@ -117,6 +119,7 @@ void onCccd(uint16_t conn, BLECharacteristic *, uint16_t value)
|
||||
concurrency::LockGuard guard(&lock);
|
||||
if (Link *l = addLink(conn))
|
||||
l->subscribed = subscribed;
|
||||
l->everSubscribed |= subscribed;
|
||||
}
|
||||
LOG_INFO("BLE GATT mesh: conn %u %s (chunk %u)", conn, subscribed ? "subscribed" : "unsubscribed", chunkFor(conn));
|
||||
if (bleGattMeshHandler)
|
||||
@@ -183,7 +186,7 @@ bool NRF52BLEGattMesh::onDisconnect(uint16_t conn)
|
||||
{
|
||||
concurrency::LockGuard guard(&lock);
|
||||
if (Link *l = findLink(conn)) {
|
||||
subscribed = l->subscribed;
|
||||
subscribed = l->everSubscribed;
|
||||
l->used = false;
|
||||
pushRx(conn, nullptr, 0); // the pump drops its half-built packets
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user