Files
ESP32-BLE-Gamepad/BleConnectionStatus.h
h2zero 2bec081589 Fix Windows notifications not being sent on reconnection.
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.
2025-01-11 16:47:47 -07:00

27 lines
812 B
C++

#ifndef ESP32_BLE_CONNECTION_STATUS_H
#define ESP32_BLE_CONNECTION_STATUS_H
#include "sdkconfig.h"
#if defined(CONFIG_BT_ENABLED)
#include "nimconfig.h"
#if defined(CONFIG_BT_NIMBLE_ROLE_PERIPHERAL)
#include <NimBLEServer.h>
#include "NimBLECharacteristic.h"
#include "NimBLEConnInfo.h"
class BleConnectionStatus : public NimBLEServerCallbacks
{
public:
BleConnectionStatus(void);
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;
};
#endif // CONFIG_BT_NIMBLE_ROLE_PERIPHERAL
#endif // CONFIG_BT_ENABLED
#endif // ESP32_BLE_CONNECTION_STATUS_H