mirror of
https://github.com/espressif/esp-idf.git
synced 2025-09-30 19:19:21 +00:00
component/bt: use fixed_pkt_queue instead of fixed_queue for hci commands
some fixes after modifications: 1. removed the use of waiting_command_t 2. fix assert for HCI write_eir command 3. fixed the crash upon handling command status event when trying to free to the HCI command buffer 4. fixed the issue in transmitting HCI vendor specific commands 5. fixed the lost command complete callbacks for HCI commands LE_RAND and LE_ENCRYPT
This commit is contained in:
@@ -19,9 +19,66 @@
|
||||
#ifndef HCIMSGS_H
|
||||
#define HCIMSGS_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include "common/bt_target.h"
|
||||
#include "stack/hcidefs.h"
|
||||
#include "stack/bt_types.h"
|
||||
#include "osi/pkt_queue.h"
|
||||
#include "osi/allocator.h"
|
||||
|
||||
#define HCI_CMD_BUF_TYPE_METADATA (0xa56e)
|
||||
|
||||
#define HCI_CMD_MSG_F_SRC_NOACK (0x01)
|
||||
|
||||
typedef void (*hci_cmd_cmpl_cb)(BT_HDR *response, void *context);
|
||||
typedef void (*hci_cmd_stat_cb)(uint8_t status, BT_HDR *command, void *context);
|
||||
typedef void (*hci_cmd_free_cb)(pkt_linked_item_t *linked_pkt);
|
||||
|
||||
typedef struct {
|
||||
uint8_t flags_src;
|
||||
uint8_t flags_vnd; // used for downstream layer
|
||||
uint16_t opcode;
|
||||
hci_cmd_cmpl_cb command_complete_cb;
|
||||
hci_cmd_stat_cb command_status_cb;
|
||||
void *context;
|
||||
void *complete_future;
|
||||
hci_cmd_free_cb command_free_cb;
|
||||
BT_HDR command;
|
||||
} hci_cmd_metadata_t;
|
||||
|
||||
#define HCI_CMD_METADATA_HDR_SIZE (sizeof(hci_cmd_metadata_t))
|
||||
|
||||
#define HCI_CMD_LINKED_BUF_SIZE(paramlen) (BT_PKT_LINKED_HDR_SIZE + HCI_CMD_METADATA_HDR_SIZE + HCIC_PREAMBLE_SIZE + (paramlen))
|
||||
|
||||
#define HCI_GET_CMD_METAMSG(cmd_ptr) (hci_cmd_metadata_t *)((void *)(cmd_ptr) - offsetof(hci_cmd_metadata_t, command))
|
||||
#define HCI_GET_CMD_LINKED_STRUCT(metadata_ptr) (pkt_linked_item_t *)((void *)(metadata_ptr) - offsetof(pkt_linked_item_t, data))
|
||||
|
||||
static inline BT_HDR *hci_get_cmd_buf(size_t param_len)
|
||||
{
|
||||
pkt_linked_item_t *linked_pkt = osi_calloc(HCI_CMD_LINKED_BUF_SIZE(param_len));
|
||||
if (linked_pkt == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
hci_cmd_metadata_t *metadata = (hci_cmd_metadata_t *)linked_pkt->data;
|
||||
BT_HDR *command = &metadata->command;
|
||||
|
||||
command->layer_specific = HCI_CMD_BUF_TYPE_METADATA;
|
||||
command->len = HCIC_PREAMBLE_SIZE + param_len;
|
||||
command->offset = 0;
|
||||
|
||||
return command;
|
||||
}
|
||||
|
||||
static inline void hci_free_cmd_buf(BT_HDR *buf)
|
||||
{
|
||||
assert(buf->layer_specific == HCI_CMD_BUF_TYPE_METADATA);
|
||||
hci_cmd_metadata_t *metadata = HCI_GET_CMD_METAMSG(buf);
|
||||
pkt_linked_item_t *linked_pkt = HCI_GET_CMD_LINKED_STRUCT(metadata);
|
||||
osi_free(linked_pkt);
|
||||
}
|
||||
|
||||
#define HCI_GET_CMD_BUF(param_len) hci_get_cmd_buf(param_len)
|
||||
#define HCI_FREE_CMD_BUF(buf) hci_free_cmd_buf(buf)
|
||||
|
||||
void bte_main_hci_send(BT_HDR *p_msg, UINT16 event);
|
||||
void bte_main_lpm_allow_bt_device_sleep(void);
|
||||
@@ -378,7 +435,7 @@ BOOLEAN btsnd_hcic_sniff_sub_rate(UINT16 handle, UINT16 max_lat,
|
||||
#endif /* BTM_SSR_INCLUDED */
|
||||
|
||||
/* Extended Inquiry Response */
|
||||
void btsnd_hcic_write_ext_inquiry_response(void *buffer, UINT8 fec_req);
|
||||
void btsnd_hcic_write_ext_inquiry_response(BT_HDR *buffer, UINT8 fec_req);
|
||||
|
||||
#define HCIC_PARAM_SIZE_EXT_INQ_RESP 241
|
||||
|
||||
@@ -641,7 +698,7 @@ BOOLEAN btsnd_hcic_write_inquiry_mode(UINT8 type); /* Write Inquiry
|
||||
|
||||
#define HCID_GET_SCO_LEN(p) (*((UINT8 *)((p) + 1) + p->offset + 2))
|
||||
|
||||
void btsnd_hcic_vendor_spec_cmd (void *buffer, UINT16 opcode,
|
||||
void btsnd_hcic_vendor_spec_cmd (BT_HDR *buffer, UINT16 opcode,
|
||||
UINT8 len, UINT8 *p_data,
|
||||
void *p_cmd_cplt_cback);
|
||||
|
||||
|
Reference in New Issue
Block a user