diff --git a/components/bt/host/nimble/nimble b/components/bt/host/nimble/nimble index 149eec704a..0a221c0693 160000 --- a/components/bt/host/nimble/nimble +++ b/components/bt/host/nimble/nimble @@ -1 +1 @@ -Subproject commit 149eec704a13a077efbba9470e7ef8f0ad9b1613 +Subproject commit 0a221c0693af1c67622d0d10a9a96c0bd976b83a diff --git a/examples/bluetooth/nimble/power_save/main/Kconfig.projbuild b/examples/bluetooth/nimble/power_save/main/Kconfig.projbuild index 3baf775104..a6bc42ed40 100644 --- a/examples/bluetooth/nimble/power_save/main/Kconfig.projbuild +++ b/examples/bluetooth/nimble/power_save/main/Kconfig.projbuild @@ -177,4 +177,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 e31c5f628d..4028b29f6e 100644 --- a/examples/bluetooth/nimble/power_save/main/main.c +++ b/examples/bluetooth/nimble/power_save/main/main.c @@ -58,6 +58,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 @@ -146,6 +150,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 /** @@ -445,6 +456,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;