Merge branch 'feat/implement_vendor_event_mask_vsc_v5.0' into 'release/v5.0'

feat(nimble): Add support for Vendor Event mask VSC(v5.0)

See merge request espressif/esp-idf!37733
This commit is contained in:
Rahul Tank
2025-03-19 20:45:08 +08:00
3 changed files with 37 additions and 1 deletions

View File

@ -160,4 +160,15 @@ 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

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