Skip to content

Commit fa3e4f9

Browse files
author
Scott Powell
committed
Merge branch 'dev' into reciprocal-path-retry
2 parents c69d78b + d377ffd commit fa3e4f9

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/helpers/nrf52/SerialBLEInterface.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@ static SerialBLEInterface* instance;
44

55
void SerialBLEInterface::onConnect(uint16_t connection_handle) {
66
BLE_DEBUG_PRINTLN("SerialBLEInterface: connected");
7-
if(instance){
8-
instance->_isDeviceConnected = true;
9-
// no need to stop advertising on connect, as the ble stack does this automatically
10-
}
7+
// we now set _isDeviceConnected=true in onSecured callback instead
118
}
129

1310
void SerialBLEInterface::onDisconnect(uint16_t connection_handle, uint8_t reason) {
@@ -18,6 +15,14 @@ void SerialBLEInterface::onDisconnect(uint16_t connection_handle, uint8_t reason
1815
}
1916
}
2017

18+
void SerialBLEInterface::onSecured(uint16_t connection_handle) {
19+
BLE_DEBUG_PRINTLN("SerialBLEInterface: onSecured");
20+
if(instance){
21+
instance->_isDeviceConnected = true;
22+
// no need to stop advertising on connect, as the ble stack does this automatically
23+
}
24+
}
25+
2126
void SerialBLEInterface::begin(const char* device_name, uint32_t pin_code) {
2227

2328
instance = this;
@@ -36,6 +41,7 @@ void SerialBLEInterface::begin(const char* device_name, uint32_t pin_code) {
3641

3742
Bluefruit.Periph.setConnectCallback(onConnect);
3843
Bluefruit.Periph.setDisconnectCallback(onDisconnect);
44+
Bluefruit.Security.setSecuredCallback(onSecured);
3945

4046
// To be consistent OTA DFU should be added first if it exists
4147
//bledfu.begin();
@@ -80,7 +86,7 @@ void SerialBLEInterface::startAdv() {
8086
* https://developer.apple.com/library/content/qa/qa1931/_index.html
8187
*/
8288
Bluefruit.Advertising.restartOnDisconnect(false); // don't restart automatically as we handle it in onDisconnect
83-
Bluefruit.Advertising.setInterval(32, 1600);
89+
Bluefruit.Advertising.setInterval(32, 244);
8490
Bluefruit.Advertising.setFastTimeout(30); // number of seconds in fast mode
8591
Bluefruit.Advertising.start(0); // 0 = Don't stop advertising after n seconds
8692

src/helpers/nrf52/SerialBLEInterface.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class SerialBLEInterface : public BaseSerialInterface {
2525
void clearBuffers() { send_queue_len = 0; }
2626
static void onConnect(uint16_t connection_handle);
2727
static void onDisconnect(uint16_t connection_handle, uint8_t reason);
28+
static void onSecured(uint16_t connection_handle);
2829

2930
public:
3031
SerialBLEInterface() {

0 commit comments

Comments
 (0)