don't mark as connected until connection secured

此提交包含在:
liamcottle
2025-09-12 20:23:21 +12:00
父節點 d929d32569
當前提交 25ea953cc3
共有 2 個檔案被更改,包括 11 行新增4 行删除
+10 -4
查看文件
@@ -4,10 +4,7 @@ static SerialBLEInterface* instance;
void SerialBLEInterface::onConnect(uint16_t connection_handle) {
BLE_DEBUG_PRINTLN("SerialBLEInterface: connected");
if(instance){
instance->_isDeviceConnected = true;
// no need to stop advertising on connect, as the ble stack does this automatically
}
// we now set _isDeviceConnected=true in onSecured callback instead
}
void SerialBLEInterface::onDisconnect(uint16_t connection_handle, uint8_t reason) {
@@ -18,6 +15,14 @@ void SerialBLEInterface::onDisconnect(uint16_t connection_handle, uint8_t reason
}
}
void SerialBLEInterface::onSecured(uint16_t connection_handle) {
BLE_DEBUG_PRINTLN("SerialBLEInterface: onSecured");
if(instance){
instance->_isDeviceConnected = true;
// no need to stop advertising on connect, as the ble stack does this automatically
}
}
void SerialBLEInterface::begin(const char* device_name, uint32_t pin_code) {
instance = this;
@@ -36,6 +41,7 @@ void SerialBLEInterface::begin(const char* device_name, uint32_t pin_code) {
Bluefruit.Periph.setConnectCallback(onConnect);
Bluefruit.Periph.setDisconnectCallback(onDisconnect);
Bluefruit.Security.setSecuredCallback(onSecured);
// To be consistent OTA DFU should be added first if it exists
//bledfu.begin();
+1
查看文件
@@ -25,6 +25,7 @@ class SerialBLEInterface : public BaseSerialInterface {
void clearBuffers() { send_queue_len = 0; }
static void onConnect(uint16_t connection_handle);
static void onDisconnect(uint16_t connection_handle, uint8_t reason);
static void onSecured(uint16_t connection_handle);
public:
SerialBLEInterface() {