Skip to content

Commit 0ba9ba4

Browse files
committed
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
2 parents e6c139e + c05421b commit 0ba9ba4

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

examples/bluetooth/nimble/power_save/main/Kconfig.projbuild

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,4 +160,15 @@ menu "Example Configuration"
160160
help
161161
Used for internal test ONLY.
162162
Use this option to advertise in a specific random address.
163+
164+
config EXAMPLE_SLEEP_WAKEUP
165+
bool "Enable Vendor-Specific Sleep Wake-Up Event"
166+
depends on BT_NIMBLE_VS_SUPPORT
167+
default n
168+
help
169+
When enabled, the Nimble Host allows setting a Vendor-Specific
170+
Event Mask for processing sleep wake-up events from the controller.
171+
The controller sends a wake-up event (HCI_LE_SLEEP_WAKE_UP 0xFF 0xC3)
172+
when it resumes from sleep.
173+
163174
endmenu

examples/bluetooth/nimble/power_save/main/main.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ static uint8_t own_addr_type;
5656

5757
void ble_store_config_init(void);
5858

59+
#if MYNEWT_VAL(BLE_HCI_VS)
60+
static struct ble_gap_event_listener vs_event_listener;
61+
#endif
62+
5963
#if MYNEWT_VAL(BLE_POWER_CONTROL)
6064
static struct ble_gap_event_listener power_control_event_listener;
6165
#endif
@@ -144,6 +148,13 @@ ext_bleprph_advertise(void)
144148
/* start advertising */
145149
rc = ble_gap_ext_adv_start(instance, 0, 0);
146150
assert (rc == 0);
151+
152+
#if CONFIG_EXAMPLE_SLEEP_WAKEUP
153+
rc = ble_hs_send_vs_event_mask(ESP_BLE_VENDOR_SLEEP_WAKEUP_EVT_MASK);
154+
155+
rc = ble_gap_event_listener_register(&vs_event_listener,
156+
bleprph_gap_event,NULL);
157+
#endif
147158
}
148159
#else
149160
/**
@@ -443,6 +454,20 @@ bleprph_gap_event(struct ble_gap_event *event, void *arg)
443454
}
444455
return 0;
445456

457+
#if CONFIG_EXAMPLE_SLEEP_WAKEUP
458+
case BLE_GAP_EVENT_VS_HCI:
459+
const struct ble_hci_ev_vs *ev = event->vs_hci.ev;
460+
461+
switch(ev->id) {
462+
case BLE_HCI_VS_SUBEV_LE_SLEEP_WAKE_UP:
463+
MODLOG_DFLT(INFO, "Got Sleep wake up ");
464+
break;
465+
466+
default:
467+
break;
468+
}
469+
#endif
470+
446471
}
447472

448473
return 0;

0 commit comments

Comments
 (0)