|
|
@ -25,28 +25,14 @@ void SerialBLEInterface::begin(const char* device_name, uint32_t pin_code) { |
|
|
char charpin[20]; |
|
|
char charpin[20]; |
|
|
sprintf(charpin, "%d", pin_code); |
|
|
sprintf(charpin, "%d", pin_code); |
|
|
|
|
|
|
|
|
Bluefruit.configPrphBandwidth( |
|
|
Bluefruit.configPrphBandwidth(BANDWIDTH_MAX); |
|
|
|
|
|
Bluefruit.configPrphConn(250, BLE_GAP_EVENT_LENGTH_MIN, 16, 16); // increase MTU
|
|
|
#ifdef BLE_LOW_POWER |
|
|
#ifdef BLE_LOW_POWER |
|
|
BANDWIDTH_NORMAL |
|
|
Bluefruit.setTxPower(0); |
|
|
#else |
|
|
#else |
|
|
BANDWIDTH_MAX |
|
|
Bluefruit.setTxPower(4); |
|
|
#endif |
|
|
#endif |
|
|
); |
|
|
|
|
|
Bluefruit.configPrphConn( |
|
|
|
|
|
#ifdef BLE_LOW_POWER |
|
|
|
|
|
400, BLE_GAP_EVENT_LENGTH_MIN, 8, 8 |
|
|
|
|
|
#else |
|
|
|
|
|
250, BLE_GAP_EVENT_LENGTH_MIN, 16, 16 // increase MTU
|
|
|
|
|
|
#endif |
|
|
|
|
|
); |
|
|
|
|
|
Bluefruit.begin(); |
|
|
Bluefruit.begin(); |
|
|
Bluefruit.setTxPower( |
|
|
|
|
|
#ifdef BLE_LOW_POWER |
|
|
|
|
|
0 |
|
|
|
|
|
#else |
|
|
|
|
|
4 |
|
|
|
|
|
#endif |
|
|
|
|
|
); // Check bluefruit.h for supported values
|
|
|
|
|
|
Bluefruit.setName(device_name); |
|
|
Bluefruit.setName(device_name); |
|
|
|
|
|
|
|
|
Bluefruit.Security.setMITM(true); |
|
|
Bluefruit.Security.setMITM(true); |
|
|
@ -98,13 +84,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( |
|
|
Bluefruit.Advertising.setInterval(32, 1600); |
|
|
#ifdef BLE_LOW_POWER |
|
|
|
|
|
160, 1600 |
|
|
|
|
|
#else |
|
|
|
|
|
32, 244 |
|
|
|
|
|
#endif |
|
|
|
|
|
); // in unit of 0.625 ms
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|