feat(nimble): support vendor event mask set and vendor HCI event on nimble host

This commit is contained in:
Shreeyash
2025-03-13 11:22:16 +05:30
committed by Rahul Tank
parent 68ef1bdfe0
commit 105b3d7816
3 changed files with 36 additions and 1 deletions

View File

@ -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

View File

@ -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;