Skip to content

Commit

Permalink
Fix Windows notifications not being sent on reconnection.
Browse files Browse the repository at this point in the history
When Windows bonds with a device and subscribes to notifications/indications of the device characteristics it does not re-subscribe on subsequent connections.
If a notification is sent when Windows reconnects it will overwrite the stored subscription value in the NimBLE stack configuration with an invalid value which results in notifications/indications not being sent.

This change will ensure that no notification or indication is sent before authentication upon reconnection, avoiding the described issue described above.
  • Loading branch information
h2zero committed Jan 11, 2025
1 parent a255104 commit 2bec081
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion BleConnectionStatus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@ BleConnectionStatus::BleConnectionStatus(void)
void BleConnectionStatus::onConnect(NimBLEServer *pServer, NimBLEConnInfo& connInfo)
{
pServer->updateConnParams(connInfo.getConnHandle(), 6, 7, 0, 600);
this->connected = true;
}

void BleConnectionStatus::onDisconnect(NimBLEServer* pServer, NimBLEConnInfo& connInfo, int reason)
{
this->connected = false;
}

void BleConnectionStatus::onAuthenticationComplete(NimBLEConnInfo& connInfo)
{
this->connected = true;
}
1 change: 1 addition & 0 deletions BleConnectionStatus.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class BleConnectionStatus : public NimBLEServerCallbacks
bool connected = false;
void onConnect(NimBLEServer *pServer, NimBLEConnInfo& connInfo) override;
void onDisconnect(NimBLEServer *pServer, NimBLEConnInfo& connInfo, int reason) override;
void onAuthenticationComplete(NimBLEConnInfo& connInfo) override;
NimBLECharacteristic *inputGamepad;
};

Expand Down

0 comments on commit 2bec081

Please sign in to comment.