Skip to content

Commit b24f5e4

Browse files
committed
samples: bluetooth: Additional optimizations for Power Profiling
To reduce power consumption, the Bluetooth Peripheral power profiling samples can be configured further. This commit adds such optimizations and updates the documentation to inform the user how to reduce power even more. Signed-off-by: Dominik Kilian <[email protected]>
1 parent f495e97 commit b24f5e4

File tree

3 files changed

+31
-8
lines changed

3 files changed

+31
-8
lines changed

samples/bluetooth/peripheral_power_profiling/Kconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,15 @@ config BT_POWER_PROFILING_NON_CONNECTABLE_ADV_INTERVAL_MAX
7373

7474
config BT_POWER_PROFILING_LED_DISABLED
7575
bool "Disable LEDs"
76+
default y
7677
help
7778
Disables the LEDs to reduce power consumption.
7879

80+
config BT_POWER_PROFILING_NFC_DISABLED
81+
bool "Disable NFC"
82+
help
83+
Disables the NFC to reduce power consumption.
84+
7985
config SETTINGS
8086
default y
8187

samples/bluetooth/peripheral_power_profiling/README.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,17 @@ CONFIG_BT_POWER_PROFILING_NON_CONNECTABLE_ADV_INTERVAL_MAX - Non-connectable adv
224224
CONFIG_BT_POWER_PROFILING_LED_DISABLED - Disable LEDs
225225
Disables the LEDs to reduce power consumption.
226226

227+
.. _CONFIG_BT_POWER_PROFILING_NFC_DISABLED:
228+
229+
CONFIG_BT_POWER_PROFILING_NFC_DISABLED - Disable NFC
230+
Disables the NFC to reduce power consumption.
231+
232+
You can also consider using the following global configuration options to disable the console and UART, reducing power consumption:
233+
234+
* :kconfig:option:`CONFIG_SERIAL`
235+
* :kconfig:option:`CONFIG_CONSOLE`
236+
* :kconfig:option:`CONFIG_UART_CONSOLE`
237+
227238
Building and running
228239
********************
229240

samples/bluetooth/peripheral_power_profiling/src/main.c

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ static const struct bt_le_adv_param *connectable_ad_params =
104104
NULL);
105105

106106
static const struct bt_le_adv_param *non_connectable_ad_params =
107-
BT_LE_ADV_PARAM(BT_LE_ADV_OPT_SCANNABLE,
107+
BT_LE_ADV_PARAM(BT_LE_ADV_OPT_NONE,
108108
NON_CONNECTABLE_ADV_INTERVAL_MIN,
109109
NON_CONNECTABLE_ADV_INTERVAL_MAX,
110110
NULL);
@@ -774,10 +774,12 @@ int main(void)
774774
return 0;
775775
}
776776

777-
err = nfc_init();
778-
if (err) {
779-
printk("Failed to initialize NFC (err %d)\n", err);
780-
return 0;
777+
if (!IS_ENABLED(BT_POWER_PROFILING_NFC_DISABLED)) {
778+
err = nfc_init();
779+
if (err) {
780+
printk("Failed to initialize NFC (err %d)\n", err);
781+
return 0;
782+
}
781783
}
782784

783785
button_handler(button_state, has_changed);
@@ -786,8 +788,12 @@ int main(void)
786788
k_work_schedule(&system_off_work, K_SECONDS(SYSTEM_OFF_DELAY));
787789
}
788790

789-
for (;;) {
790-
set_led(RUN_STATUS_LED, (++blink_status) % 2);
791-
k_sleep(K_MSEC(RUN_LED_BLINK_INTERVAL));
791+
if (!IS_ENABLED(CONFIG_BT_POWER_PROFILING_LED_DISABLED)) {
792+
for (;;) {
793+
set_led(RUN_STATUS_LED, (++blink_status) % 2);
794+
k_sleep(K_MSEC(RUN_LED_BLINK_INTERVAL));
795+
}
796+
} else {
797+
return 0;
792798
}
793799
}

0 commit comments

Comments
 (0)