Merge branch 'dev' into reciprocal-path-retry
This commit is contained in:
@@ -4,10 +4,7 @@ static SerialBLEInterface* instance;
|
|||||||
|
|
||||||
void SerialBLEInterface::onConnect(uint16_t connection_handle) {
|
void SerialBLEInterface::onConnect(uint16_t connection_handle) {
|
||||||
BLE_DEBUG_PRINTLN("SerialBLEInterface: connected");
|
BLE_DEBUG_PRINTLN("SerialBLEInterface: connected");
|
||||||
if(instance){
|
// we now set _isDeviceConnected=true in onSecured callback instead
|
||||||
instance->_isDeviceConnected = true;
|
|
||||||
// no need to stop advertising on connect, as the ble stack does this automatically
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SerialBLEInterface::onDisconnect(uint16_t connection_handle, uint8_t reason) {
|
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) {
|
void SerialBLEInterface::begin(const char* device_name, uint32_t pin_code) {
|
||||||
|
|
||||||
instance = this;
|
instance = this;
|
||||||
@@ -36,6 +41,7 @@ void SerialBLEInterface::begin(const char* device_name, uint32_t pin_code) {
|
|||||||
|
|
||||||
Bluefruit.Periph.setConnectCallback(onConnect);
|
Bluefruit.Periph.setConnectCallback(onConnect);
|
||||||
Bluefruit.Periph.setDisconnectCallback(onDisconnect);
|
Bluefruit.Periph.setDisconnectCallback(onDisconnect);
|
||||||
|
Bluefruit.Security.setSecuredCallback(onSecured);
|
||||||
|
|
||||||
// To be consistent OTA DFU should be added first if it exists
|
// To be consistent OTA DFU should be added first if it exists
|
||||||
//bledfu.begin();
|
//bledfu.begin();
|
||||||
@@ -80,7 +86,7 @@ void SerialBLEInterface::startAdv() {
|
|||||||
* https://developer.apple.com/library/content/qa/qa1931/_index.html
|
* https://developer.apple.com/library/content/qa/qa1931/_index.html
|
||||||
*/
|
*/
|
||||||
Bluefruit.Advertising.restartOnDisconnect(false); // don't restart automatically as we handle it in onDisconnect
|
Bluefruit.Advertising.restartOnDisconnect(false); // don't restart automatically as we handle it in onDisconnect
|
||||||
Bluefruit.Advertising.setInterval(32, 1600);
|
Bluefruit.Advertising.setInterval(32, 244);
|
||||||
Bluefruit.Advertising.setFastTimeout(30); // number of seconds in fast mode
|
Bluefruit.Advertising.setFastTimeout(30); // number of seconds in fast mode
|
||||||
Bluefruit.Advertising.start(0); // 0 = Don't stop advertising after n seconds
|
Bluefruit.Advertising.start(0); // 0 = Don't stop advertising after n seconds
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ class SerialBLEInterface : public BaseSerialInterface {
|
|||||||
void clearBuffers() { send_queue_len = 0; }
|
void clearBuffers() { send_queue_len = 0; }
|
||||||
static void onConnect(uint16_t connection_handle);
|
static void onConnect(uint16_t connection_handle);
|
||||||
static void onDisconnect(uint16_t connection_handle, uint8_t reason);
|
static void onDisconnect(uint16_t connection_handle, uint8_t reason);
|
||||||
|
static void onSecured(uint16_t connection_handle);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SerialBLEInterface() {
|
SerialBLEInterface() {
|
||||||
|
|||||||
Reference in New Issue
Block a user