mirror of
https://github.com/espressif/esp-nimble.git
synced 2026-10-22 04:37:55 +00:00
nimble/host: Add APIs to handle vs HCI commands and events
This adds API to send a vs hci command and an event to handle vs hci events.
This commit is contained in:
committed by
Rahul Tank
parent
a2dc547005
commit
e617a79507
@@ -141,6 +141,7 @@ struct hci_conn_update;
|
||||
#define BLE_GAP_EVENT_SCAN_REQ_RCVD 23
|
||||
#define BLE_GAP_EVENT_PERIODIC_TRANSFER 24
|
||||
#define BLE_GAP_EVENT_REATTEMPT_COUNT 25
|
||||
#define BLE_GAP_EVENT_VS_HCI 26
|
||||
|
||||
/*** Reason codes for the subscribe GAP event. */
|
||||
|
||||
@@ -999,6 +1000,19 @@ struct ble_gap_event {
|
||||
uint8_t count;
|
||||
} reattempt_cnt;
|
||||
#endif
|
||||
|
||||
#if MYNEWT_VAL(BLE_HCI_VS)
|
||||
/**
|
||||
* Represents a received vendor-specific HCI event
|
||||
*
|
||||
* Valid for the following event types:
|
||||
* o BLE_GAP_EVENT_VS_HCI
|
||||
*/
|
||||
struct {
|
||||
const void *ev;
|
||||
uint8_t length;
|
||||
} vs_hci;
|
||||
#endif
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -87,6 +87,24 @@ int ble_hs_hci_read_chan_map(uint16_t conn_handle, uint8_t *out_chan_map);
|
||||
*/
|
||||
int ble_hs_hci_set_chan_class(const uint8_t *chan_map);
|
||||
|
||||
#if MYNEWT_VAL(BLE_HCI_VS)
|
||||
/**
|
||||
* Send an arbitrary HCI command to the controller.
|
||||
*
|
||||
* The command has to be a vendor-specific command, i.e. OGF=0x3f is always
|
||||
* assumed.
|
||||
*
|
||||
* @param ocf OCF for vendor-specific HCI command
|
||||
* @param cmdbuf command buffer
|
||||
* @param cmdlen length of command buffer
|
||||
* @param rspbuf response buffer
|
||||
* @param rsplen length of response buffer
|
||||
* @return 0 on success, error code on failure
|
||||
*/
|
||||
int ble_hs_hci_send_vs_cmd(uint16_t ocf, const void *cmdbuf, uint8_t cmdlen,
|
||||
void *rspbuf, uint8_t rsplen);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -6355,6 +6355,21 @@ ble_gap_mtu_event(uint16_t conn_handle, uint16_t cid, uint16_t mtu)
|
||||
ble_gap_call_conn_event_cb(&event, conn_handle);
|
||||
}
|
||||
|
||||
#if MYNEWT_VAL(BLE_HCI_VS)
|
||||
void
|
||||
ble_gap_vs_hci_event(const void *buf, uint8_t len)
|
||||
{
|
||||
struct ble_gap_event event;
|
||||
|
||||
memset(&event, 0, sizeof event);
|
||||
event.type = BLE_GAP_EVENT_VS_HCI;
|
||||
event.vs_hci.ev = buf;
|
||||
event.vs_hci.length = len;
|
||||
|
||||
ble_gap_event_listener_call(&event);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*****************************************************************************
|
||||
* $preempt *
|
||||
*****************************************************************************/
|
||||
|
||||
@@ -130,6 +130,7 @@ void ble_gap_subscribe_event(uint16_t conn_handle, uint16_t attr_handle,
|
||||
void ble_gap_mtu_event(uint16_t conn_handle, uint16_t cid, uint16_t mtu);
|
||||
void ble_gap_identity_event(uint16_t conn_handle);
|
||||
int ble_gap_repeat_pairing_event(const struct ble_gap_repeat_pairing *rp);
|
||||
void ble_gap_vs_hci_event(const void *buf, uint8_t len);
|
||||
int ble_gap_master_in_progress(void);
|
||||
|
||||
void ble_gap_preempt(void);
|
||||
|
||||
@@ -353,6 +353,20 @@ done:
|
||||
return rc;
|
||||
}
|
||||
|
||||
#if MYNEWT_VAL(BLE_HCI_VS)
|
||||
int
|
||||
ble_hs_hci_send_vs_cmd(uint16_t ocf, const void *cmdbuf, uint8_t cmdlen,
|
||||
void *rspbuf, uint8_t rsplen)
|
||||
{
|
||||
int rc;
|
||||
|
||||
rc = ble_hs_hci_cmd_tx(BLE_HCI_OP(BLE_HCI_OGF_VENDOR, ocf),
|
||||
cmdbuf, cmdlen, rspbuf, rsplen);
|
||||
|
||||
return rc;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
ble_hs_hci_rx_ack(uint8_t *ack_ev)
|
||||
{
|
||||
|
||||
@@ -54,6 +54,9 @@ static ble_hs_hci_evt_fn ble_hs_hci_evt_hw_error;
|
||||
static ble_hs_hci_evt_fn ble_hs_hci_evt_num_completed_pkts;
|
||||
static ble_hs_hci_evt_fn ble_hs_hci_evt_enc_key_refresh;
|
||||
static ble_hs_hci_evt_fn ble_hs_hci_evt_le_meta;
|
||||
#if MYNEWT_VAL(BLE_HCI_VS)
|
||||
static ble_hs_hci_evt_fn ble_hs_hci_evt_vs;
|
||||
#endif
|
||||
|
||||
typedef int ble_hs_hci_evt_le_fn(uint8_t subevent, const void *data,
|
||||
unsigned int len);
|
||||
@@ -99,6 +102,9 @@ static const struct ble_hs_hci_evt_dispatch_entry ble_hs_hci_evt_dispatch[] = {
|
||||
{ BLE_HCI_EVCODE_ENCRYPT_CHG, ble_hs_hci_evt_encrypt_change },
|
||||
{ BLE_HCI_EVCODE_ENC_KEY_REFRESH, ble_hs_hci_evt_enc_key_refresh },
|
||||
{ BLE_HCI_EVCODE_HW_ERROR, ble_hs_hci_evt_hw_error },
|
||||
#if MYNEWT_VAL(BLE_HCI_VS)
|
||||
{ BLE_HCI_EVCODE_VS, ble_hs_hci_evt_vs },
|
||||
#endif
|
||||
};
|
||||
|
||||
#define BLE_HS_HCI_EVT_DISPATCH_SZ \
|
||||
@@ -312,6 +318,22 @@ ble_hs_hci_evt_num_completed_pkts(uint8_t event_code, const void *data,
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if MYNEWT_VAL(BLE_HCI_VS)
|
||||
static int
|
||||
ble_hs_hci_evt_vs(uint8_t event_code, const void *data, unsigned int len)
|
||||
{
|
||||
const struct ble_hci_ev_vs *ev = data;
|
||||
|
||||
if (len < sizeof(*ev)) {
|
||||
return BLE_HS_ECONTROLLER;
|
||||
}
|
||||
|
||||
ble_gap_vs_hci_event(data, len);
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int
|
||||
ble_hs_hci_evt_le_meta(uint8_t event_code, const void *data, unsigned int len)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user