From c1a85a007b1ee86857fdf49a64cc0598cc5b7cef Mon Sep 17 00:00:00 2001 From: Andrzej Kaczmarek Date: Mon, 14 May 2018 21:43:02 +0200 Subject: [PATCH] nimble/host: Enable auth payload tmo event only for >=4.1 LE Ping was added in Core 4.1 thus Authenticated Payload Timeout Event shall be only enabled for controller supporting >=4.1. Note it would be also good to check for controller features to confirm, but we do not have this implemented yet. --- nimble/host/src/ble_hs_startup.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/nimble/host/src/ble_hs_startup.c b/nimble/host/src/ble_hs_startup.c index 63428a0fb..00a0f86ef 100644 --- a/nimble/host/src/ble_hs_startup.c +++ b/nimble/host/src/ble_hs_startup.c @@ -279,8 +279,11 @@ static int ble_hs_startup_set_evmask_tx(void) { uint8_t buf[BLE_HCI_SET_EVENT_MASK_LEN]; + uint8_t version; int rc; + version = ble_hs_hci_get_hci_version(); + /** * Enable the following events: * 0x0000000000000010 Disconnection Complete Event @@ -298,16 +301,18 @@ ble_hs_startup_set_evmask_tx(void) return rc; } - /** - * Enable the following events: - * 0x0000000000800000 Authenticated Payload Timeout Event - */ - ble_hs_hci_cmd_build_set_event_mask2(0x0000000000800000, buf, sizeof buf); - rc = ble_hs_hci_cmd_tx_empty_ack(BLE_HCI_OP(BLE_HCI_OGF_CTLR_BASEBAND, - BLE_HCI_OCF_CB_SET_EVENT_MASK2), - buf, sizeof(buf)); - if (rc != 0) { - return rc; + if (version >= BLE_HCI_VER_BCS_4_1) { + /** + * Enable the following events: + * 0x0000000000800000 Authenticated Payload Timeout Event + */ + ble_hs_hci_cmd_build_set_event_mask2(0x0000000000800000, buf, sizeof buf); + rc = ble_hs_hci_cmd_tx_empty_ack(BLE_HCI_OP(BLE_HCI_OGF_CTLR_BASEBAND, + BLE_HCI_OCF_CB_SET_EVENT_MASK2), + buf, sizeof(buf)); + if (rc != 0) { + return rc; + } } return 0;