Skip to content

Commit 963556f

Browse files
Updated BLE functionality for low power mode in SerialBLEInterface. Updated platformio.ini to enable low power mode and added DC/DC converter support in T1000eBoard for improved power efficiency.
1 parent 0e3933f commit 963556f

File tree

3 files changed

+32
-4
lines changed

3 files changed

+32
-4
lines changed

src/helpers/nrf52/SerialBLEInterface.cpp

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,28 @@ void SerialBLEInterface::begin(const char* device_name, uint32_t pin_code) {
2525
char charpin[20];
2626
sprintf(charpin, "%d", pin_code);
2727

28-
Bluefruit.configPrphBandwidth(BANDWIDTH_MAX);
29-
Bluefruit.configPrphConn(250, BLE_GAP_EVENT_LENGTH_MIN, 16, 16); // increase MTU
28+
Bluefruit.configPrphBandwidth(
29+
#ifdef BLE_LOW_POWER
30+
BANDWIDTH_NORMAL
31+
#else
32+
BANDWIDTH_MAX
33+
#endif
34+
);
35+
Bluefruit.configPrphConn(
36+
#ifdef BLE_LOW_POWER
37+
400, BLE_GAP_EVENT_LENGTH_MIN, 8, 8
38+
#else
39+
250, BLE_GAP_EVENT_LENGTH_MIN, 16, 16 // increase MTU
40+
#endif
41+
);
3042
Bluefruit.begin();
31-
Bluefruit.setTxPower(4); // Check bluefruit.h for supported values
43+
Bluefruit.setTxPower(
44+
#ifdef BLE_LOW_POWER
45+
0
46+
#else
47+
4
48+
#endif
49+
); // Check bluefruit.h for supported values
3250
Bluefruit.setName(device_name);
3351

3452
Bluefruit.Security.setMITM(true);
@@ -80,7 +98,13 @@ void SerialBLEInterface::startAdv() {
8098
* https://developer.apple.com/library/content/qa/qa1931/_index.html
8199
*/
82100
Bluefruit.Advertising.restartOnDisconnect(false); // don't restart automatically as we handle it in onDisconnect
83-
Bluefruit.Advertising.setInterval(32, 244); // in unit of 0.625 ms
101+
Bluefruit.Advertising.setInterval(
102+
#ifdef BLE_LOW_POWER
103+
160, 1600
104+
#else
105+
32, 244
106+
#endif
107+
); // in unit of 0.625 ms
84108
Bluefruit.Advertising.setFastTimeout(30); // number of seconds in fast mode
85109
Bluefruit.Advertising.start(0); // 0 = Don't stop advertising after n seconds
86110

variants/t1000-e/T1000eBoard.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ void T1000eBoard::begin() {
1111

1212
sd_power_mode_set(NRF_POWER_MODE_LOWPWR);
1313

14+
// Enable DC/DC converter for improved power efficiency
15+
NRF_POWER->DCDCEN = 1;
16+
1417
#ifdef BUTTON_PIN
1518
pinMode(BATTERY_PIN, INPUT);
1619
pinMode(BUTTON_PIN, INPUT);

variants/t1000-e/platformio.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ build_flags = ${t1000-e.build_flags}
100100
-D MAX_CONTACTS=100
101101
-D MAX_GROUP_CHANNELS=8
102102
-D BLE_PIN_CODE=123456
103+
-D BLE_LOW_POWER=1
103104
; -D BLE_DEBUG_LOGGING=1
104105
; -D MESH_PACKET_LOGGING=1
105106
; -D MESH_DEBUG=1

0 commit comments

Comments
 (0)