From a7a0a74aa8d2a817ea9250dd3b93edf19ad0549e Mon Sep 17 00:00:00 2001 From: Paul Nettle Date: Mon, 8 Jan 2018 07:42:09 -0600 Subject: Improved handling of connection counts dealing with latent disconnects on startup. This includes a change to change to the behavior of change notifications for values, they no longer check for an active connection before transmitting - this is now up to the caller. --- src/HciAdapter.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/HciAdapter.cpp') diff --git a/src/HciAdapter.cpp b/src/HciAdapter.cpp index ad27ce0..eb1990f 100644 --- a/src/HciAdapter.cpp +++ b/src/HciAdapter.cpp @@ -346,13 +346,22 @@ void HciAdapter::runEventThread() { DeviceConnectedEvent event(responsePacket); activeConnections += 1; + Logger::debug(SSTR << " > Connection count incremented to " << activeConnections); break; } // Command status event case Mgmt::EDeviceDisconnectedEvent: { DeviceDisconnectedEvent event(responsePacket); - activeConnections -= 1; + if (activeConnections > 0) + { + activeConnections -= 1; + Logger::debug(SSTR << " > Connection count decremented to " << activeConnections); + } + else + { + Logger::debug(SSTR << " > Connection count already at zero, ignoring non-connected disconnect event"); + } break; } // Unsupported -- cgit v1.2.3