Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions samples/bluetooth/peripheral_power_profiling/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,15 @@ config BT_POWER_PROFILING_NON_CONNECTABLE_ADV_INTERVAL_MAX

config BT_POWER_PROFILING_LED_DISABLED
bool "Disable LEDs"
default y
help
Disables the LEDs to reduce power consumption.

config BT_POWER_PROFILING_NFC_DISABLED
bool "Disable NFC"
help
Disables the NFC to reduce power consumption.

config SETTINGS
default y

Expand Down
11 changes: 11 additions & 0 deletions samples/bluetooth/peripheral_power_profiling/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,17 @@ CONFIG_BT_POWER_PROFILING_NON_CONNECTABLE_ADV_INTERVAL_MAX - Non-connectable adv
CONFIG_BT_POWER_PROFILING_LED_DISABLED - Disable LEDs
Disables the LEDs to reduce power consumption.

.. _CONFIG_BT_POWER_PROFILING_NFC_DISABLED:

CONFIG_BT_POWER_PROFILING_NFC_DISABLED - Disable NFC
Disables the NFC to reduce power consumption.

You can also consider using the following global configuration options to disable the console and UART, reducing power consumption:

* :kconfig:option:`CONFIG_SERIAL`
* :kconfig:option:`CONFIG_CONSOLE`
* :kconfig:option:`CONFIG_UART_CONSOLE`

Building and running
********************

Expand Down
22 changes: 14 additions & 8 deletions samples/bluetooth/peripheral_power_profiling/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ static const struct bt_le_adv_param *connectable_ad_params =
NULL);

static const struct bt_le_adv_param *non_connectable_ad_params =
BT_LE_ADV_PARAM(BT_LE_ADV_OPT_SCANNABLE,
BT_LE_ADV_PARAM(BT_LE_ADV_OPT_NONE,
NON_CONNECTABLE_ADV_INTERVAL_MIN,
NON_CONNECTABLE_ADV_INTERVAL_MAX,
NULL);
Expand Down Expand Up @@ -774,10 +774,12 @@ int main(void)
return 0;
}

err = nfc_init();
if (err) {
printk("Failed to initialize NFC (err %d)\n", err);
return 0;
if (!IS_ENABLED(BT_POWER_PROFILING_NFC_DISABLED)) {
err = nfc_init();
if (err) {
printk("Failed to initialize NFC (err %d)\n", err);
return 0;
}
}

button_handler(button_state, has_changed);
Expand All @@ -786,8 +788,12 @@ int main(void)
k_work_schedule(&system_off_work, K_SECONDS(SYSTEM_OFF_DELAY));
}

for (;;) {
set_led(RUN_STATUS_LED, (++blink_status) % 2);
k_sleep(K_MSEC(RUN_LED_BLINK_INTERVAL));
if (!IS_ENABLED(CONFIG_BT_POWER_PROFILING_LED_DISABLED)) {
for (;;) {
set_led(RUN_STATUS_LED, (++blink_status) % 2);
k_sleep(K_MSEC(RUN_LED_BLINK_INTERVAL));
}
} else {
return 0;
}
}