mirror of
https://github.com/espressif/esp-nimble.git
synced 2026-10-07 07:07:23 +00:00
nimble/host: Check controller version on init
This allows to run NimBLE host with non-NimBLE controllers.
This commit is contained in:
@@ -184,8 +184,14 @@ static int
|
||||
ble_hs_startup_le_set_evmask_tx(void)
|
||||
{
|
||||
uint8_t buf[BLE_HCI_SET_LE_EVENT_MASK_LEN];
|
||||
uint8_t version;
|
||||
uint64_t mask;
|
||||
int rc;
|
||||
|
||||
version = ble_hs_hci_get_hci_version();
|
||||
|
||||
/* TODO should we also check for supported commands when setting this? */
|
||||
|
||||
/**
|
||||
* Enable the following LE events:
|
||||
* 0x0000000000000001 LE Connection Complete Event
|
||||
@@ -193,17 +199,39 @@ ble_hs_startup_le_set_evmask_tx(void)
|
||||
* 0x0000000000000004 LE Connection Update Complete Event
|
||||
* 0x0000000000000008 LE Read Remote Used Features Complete Event
|
||||
* 0x0000000000000010 LE Long Term Key Request Event
|
||||
* 0x0000000000000020 LE Remote Connection Parameter Request Event
|
||||
* 0x0000000000000040 LE Data Length Change Event
|
||||
* 0x0000000000000200 LE Enhanced Connection Complete Event
|
||||
* 0x0000000000000400 LE Directed Advertising Report Event
|
||||
* 0x0000000000000800 LE PHY Update Complete Event
|
||||
* 0x0000000000001000 LE Extended Advertising Report Event
|
||||
* 0x0000000000010000 LE Extended Scan Timeout Event
|
||||
* 0x0000000000020000 LE Extended Advertising Set Terminated Event
|
||||
* 0x0000000000040000 LE Scan Request Received Event
|
||||
* 0x0000000000080000 LE Channel Selection Algorithm Event
|
||||
*/
|
||||
mask = 0x000000000000001f;
|
||||
|
||||
if (version >= BLE_HCI_VER_BCS_4_1) {
|
||||
/**
|
||||
* Enable the following LE events:
|
||||
* 0x0000000000000020 LE Remote Connection Parameter Request Event */
|
||||
mask |= 0x0000000000000020;
|
||||
}
|
||||
|
||||
if (version >= BLE_HCI_VER_BCS_4_2) {
|
||||
/**
|
||||
* Enable the following LE events:
|
||||
* 0x0000000000000040 LE Data Length Change Event
|
||||
* 0x0000000000000200 LE Enhanced Connection Complete Event
|
||||
* 0x0000000000000400 LE Directed Advertising Report Event
|
||||
*/
|
||||
mask |= 0x0000000000000640;
|
||||
}
|
||||
|
||||
if (version >= BLE_HCI_VER_BCS_5_0) {
|
||||
/**
|
||||
* Enable the following LE events:
|
||||
* 0x0000000000000800 LE PHY Update Complete Event
|
||||
* 0x0000000000001000 LE Extended Advertising Report Event
|
||||
* 0x0000000000010000 LE Extended Scan Timeout Event
|
||||
* 0x0000000000020000 LE Extended Advertising Set Terminated Event
|
||||
* 0x0000000000040000 LE Scan Request Received Event
|
||||
* 0x0000000000080000 LE Channel Selection Algorithm Event
|
||||
*/
|
||||
mask |= 0x00000000000f1800;
|
||||
}
|
||||
|
||||
ble_hs_hci_cmd_build_le_set_event_mask(0x00000000000F1A7F, buf, sizeof buf);
|
||||
rc = ble_hs_hci_cmd_tx_empty_ack(BLE_HCI_OP(BLE_HCI_OGF_LE,
|
||||
BLE_HCI_OCF_LE_SET_EVENT_MASK),
|
||||
@@ -247,7 +275,7 @@ ble_hs_startup_set_evmask_tx(void)
|
||||
BLE_HCI_OCF_CB_SET_EVENT_MASK2),
|
||||
buf, sizeof(buf));
|
||||
if (rc != 0) {
|
||||
BLE_HS_LOG(WARN, "ble_hs_startup_set_evmask_tx() failed\n");
|
||||
return rc;
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -284,7 +312,14 @@ ble_hs_startup_go(void)
|
||||
}
|
||||
|
||||
/* XXX: Read local supported commands. */
|
||||
/* XXX: Read local supported features. */
|
||||
|
||||
/* we need to check this only if using external controller */
|
||||
#if !MYNEWT_VAL(BLE_DEVICE)
|
||||
if (ble_hs_hci_get_hci_version() < BLE_HCI_VER_BCS_4_0) {
|
||||
BLE_HS_LOG(ERROR, "Required controller version is 4.0 (6)");
|
||||
return BLE_HS_ECONTROLLER;
|
||||
}
|
||||
#endif
|
||||
|
||||
rc = ble_hs_startup_set_evmask_tx();
|
||||
if (rc != 0) {
|
||||
|
||||
Reference in New Issue
Block a user