samples/boards/stm32: stm32_ble: Add bt_disable/bt_enable sequence
Demonstrate bt_disable/bt_enable. Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
This commit is contained in:
parent
3a041ca5c8
commit
f36a6abf9c
2 changed files with 30 additions and 3 deletions
|
@ -11,6 +11,9 @@ Zephyr power management enabled (:kconfig:option:`CONFIG_PM`).
|
|||
|
||||
After startup, a first 2 seconds beacon is performed, 1 second break and
|
||||
beacon is started again.
|
||||
BLE link is then disabled and started up again after 2 seconds, then same
|
||||
beacon sequence happens.
|
||||
|
||||
Finally, platform shutdown is triggered. It can be restarted by pressing the
|
||||
board reset button.
|
||||
|
||||
|
|
|
@ -98,6 +98,14 @@ static void bt_ready(int err)
|
|||
}
|
||||
|
||||
printk("Beacon started\n");
|
||||
|
||||
err = bt_le_adv_stop();
|
||||
if (err != 0) {
|
||||
printk("Advertising failed to stop: %d", err);
|
||||
return;
|
||||
}
|
||||
|
||||
printk("Beacon stopped\n");
|
||||
}
|
||||
|
||||
void main(void)
|
||||
|
@ -105,15 +113,31 @@ void main(void)
|
|||
int err;
|
||||
|
||||
printk("Starting Beacon Demo\n");
|
||||
|
||||
k_sleep(K_MSEC(500));
|
||||
|
||||
/* Initialize the Bluetooth Subsystem */
|
||||
err = bt_enable(bt_ready);
|
||||
if (err) {
|
||||
printk("Bluetooth init failed (err %d)\n", err);
|
||||
}
|
||||
|
||||
/* Give time to bt_ready sequence */
|
||||
k_sleep(K_SECONDS(6));
|
||||
|
||||
printk("BLE disable\n");
|
||||
err = bt_disable();
|
||||
if (err) {
|
||||
printk("Bluetooth disable failed (err %d)\n", err);
|
||||
}
|
||||
|
||||
k_sleep(K_SECONDS(2));
|
||||
|
||||
printk("BLE restart\n");
|
||||
/* Initialize the Bluetooth Subsystem */
|
||||
err = bt_enable(bt_ready);
|
||||
if (err) {
|
||||
printk("Bluetooth init failed (err %d)\n", err);
|
||||
}
|
||||
|
||||
/* Give time to bt_ready sequence */
|
||||
k_sleep(K_SECONDS(6));
|
||||
|
||||
printk("BLE disable\n");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue