nimble/controller: Send LE Scan Request Received Event

Notify host about SCAN_REQ received if event is enabled.

X-Original-Commit: 5524d9bca54e9fc83d68be314fe39c020546d17e
This commit is contained in:
Szymon Janc
2017-06-29 23:20:17 +02:00
parent 80075eb479
commit 79e2ff4772
4 changed files with 35 additions and 0 deletions
@@ -270,6 +270,8 @@ int ble_ll_hci_ev_ltk_req(struct ble_ll_conn_sm *connsm);
int ble_ll_hci_ev_hw_err(uint8_t hw_err);
void ble_ll_hci_ev_databuf_overflow(void);
void ble_ll_hci_ev_le_csa(struct ble_ll_conn_sm *connsm);
void ble_ll_hci_ev_send_scan_req_recv(uint8_t adv_handle, const uint8_t *peer,
uint8_t peer_addr_type);
int ble_ll_hci_ev_phy_update(struct ble_ll_conn_sm *connsm, uint8_t status);
void ble_ll_calc_session_key(struct ble_ll_conn_sm *connsm);
void ble_ll_ctrl_phy_update_proc_complete(struct ble_ll_conn_sm *connsm);
+6
View File
@@ -2027,6 +2027,7 @@ ble_ll_adv_multi_adv_cmd(uint8_t *cmdbuf, uint8_t cmdlen, uint8_t *rspbuf,
}
#endif
/**
* Called when the LL receives a scan request or connection request
*
@@ -2112,6 +2113,11 @@ ble_ll_adv_rx_req(uint8_t pdu_type, struct os_mbuf *rxpdu)
/* Setup to transmit the scan response if appropriate */
rc = -1;
if (pdu_type == BLE_ADV_PDU_TYPE_SCAN_REQ) {
if (advsm->scan_req_notif) {
ble_ll_hci_ev_send_scan_req_recv(advsm->adv_instance, peer,
peer_addr_type);
}
scan_rsp = ble_ll_adv_scan_rsp_pdu_make(advsm);
if (scan_rsp) {
/* XXX TODO: assume we do not need to change phy mode */
+24
View File
@@ -293,6 +293,30 @@ ble_ll_hci_ev_le_csa(struct ble_ll_conn_sm *connsm)
}
#endif
/**
* Sends the LE Scan Request Received event
*
*/
void
ble_ll_hci_ev_send_scan_req_recv(uint8_t adv_handle, const uint8_t *peer,
uint8_t peer_addr_type)
{
uint8_t *evbuf;
if (ble_ll_hci_is_le_event_enabled(BLE_HCI_LE_SUBEV_SCAN_REQ_RCVD)) {
evbuf = ble_hci_trans_buf_alloc(BLE_HCI_TRANS_BUF_EVT_HI);
if (evbuf) {
evbuf[0] = BLE_HCI_EVCODE_LE_META;
evbuf[1] = BLE_HCI_LE_SUBEV_SCAN_REQ_RCVD_LEN;
evbuf[2] = BLE_HCI_LE_SUBEV_SCAN_REQ_RCVD;
evbuf[3] = adv_handle;
evbuf[4] = peer_addr_type;
memcpy(&evbuf[5], peer, BLE_DEV_ADDR_LEN);
ble_ll_hci_event_send(evbuf);
}
}
}
/**
* Send a PHY update complete event
*
+3
View File
@@ -723,6 +723,9 @@ extern "C" {
/* LE PHY update complete event (sub event 0x0C) */
#define BLE_HCI_LE_PHY_UPD_LEN (6)
/* LE Scan Request Received event (sub event 0x13) */
#define BLE_HCI_LE_SUBEV_SCAN_REQ_RCVD_LEN (9)
/* LE Channel Selection Algorithm event (sub event 0x14) */
#define BLE_HCI_LE_SUBEV_CHAN_SEL_ALG_LEN (4)