diff --git a/components/bt/host/nimble/nimble b/components/bt/host/nimble/nimble index 86f11a236f..188615f08f 160000 --- a/components/bt/host/nimble/nimble +++ b/components/bt/host/nimble/nimble @@ -1 +1 @@ -Subproject commit 86f11a236f47ab93f25374d23d9318ac227872db +Subproject commit 188615f08f1578faca95c95017384b0dc1e633a8 diff --git a/examples/bluetooth/nimble/power_save/main/Kconfig.projbuild b/examples/bluetooth/nimble/power_save/main/Kconfig.projbuild index ca160813fe..7922ff8131 100644 --- a/examples/bluetooth/nimble/power_save/main/Kconfig.projbuild +++ b/examples/bluetooth/nimble/power_save/main/Kconfig.projbuild @@ -171,4 +171,14 @@ menu "Example Configuration" help Used for internal test ONLY. Use this option to advertise in a specific random address. + + config EXAMPLE_SLEEP_WAKEUP + bool "Enable Vendor-Specific Sleep Wake-Up Event" + depends on BT_NIMBLE_VS_SUPPORT + default n + help + When enabled, the Nimble Host allows setting a Vendor-Specific + Event Mask for processing sleep wake-up events from the controller. + The controller sends a wake-up event (HCI_LE_SLEEP_WAKE_UP 0xFF 0xC3) + when it resumes from sleep. endmenu diff --git a/examples/bluetooth/nimble/power_save/main/main.c b/examples/bluetooth/nimble/power_save/main/main.c index 47a5144cc9..3700c34c83 100644 --- a/examples/bluetooth/nimble/power_save/main/main.c +++ b/examples/bluetooth/nimble/power_save/main/main.c @@ -56,6 +56,10 @@ static uint8_t own_addr_type; void ble_store_config_init(void); +#if MYNEWT_VAL(BLE_HCI_VS) +static struct ble_gap_event_listener vs_event_listener; +#endif + #if MYNEWT_VAL(BLE_POWER_CONTROL) static struct ble_gap_event_listener power_control_event_listener; #endif @@ -144,6 +148,13 @@ ext_bleprph_advertise(void) /* start advertising */ rc = ble_gap_ext_adv_start(instance, 0, 0); assert (rc == 0); + +#if CONFIG_EXAMPLE_SLEEP_WAKEUP + rc = ble_hs_send_vs_event_mask(ESP_BLE_VENDOR_SLEEP_WAKEUP_EVT_MASK); + + rc = ble_gap_event_listener_register(&vs_event_listener, + bleprph_gap_event,NULL); +#endif } #else /** @@ -443,6 +454,20 @@ bleprph_gap_event(struct ble_gap_event *event, void *arg) } return 0; +#if CONFIG_EXAMPLE_SLEEP_WAKEUP + case BLE_GAP_EVENT_VS_HCI: + const struct ble_hci_ev_vs *ev = event->vs_hci.ev; + + switch(ev->id) { + case BLE_HCI_VS_SUBEV_LE_SLEEP_WAKE_UP: + MODLOG_DFLT(INFO, "Got Sleep wake up "); + break; + + default: + break; + } +#endif + } return 0;