/*******************************************************************************
**
-** Function bta_dm_process_remove_device
+** Function bta_dm_hci_raw_command
+**
+** Description Send a HCI RAW command to the controller
+**
+**
+** Returns void
+**
+*******************************************************************************/
+void bta_dm_hci_raw_command (tBTA_DM_MSG *p_data)
+{
+ tBTM_STATUS status;
+ APPL_TRACE_API("bta_dm_hci_raw_command");
+ status = BTM_Hci_Raw_Command(p_data->btc_command.opcode,p_data->btc_command.param_len,p_data->btc_command.p_param_buf, p_data->btc_command.p_cback);
+
+}
+
+/*******************************************************************************
+**
+** Function bta_dm_process_remove_deviced
+**
+**
+** Returns void
**
** Description Removes device, Disconnects ACL link if required.
****
/*******************************************************************************
**
+** Function BTA_DmHciRawCommand
+**
+** Description This function sends the HCI Raw command
+** to the controller
+**
+**
+** Returns tBTA_STATUS
+**
+*******************************************************************************/
+tBTA_STATUS BTA_DmHciRawCommand (UINT16 opcode, UINT8 param_len,
+ UINT8 *p_param_buf,
+ tBTA_RAW_CMPL_CBACK *p_cback)
+{
+
+ tBTA_DM_API_RAW_COMMAND *p_msg;
+ UINT16 size;
+
+ size = sizeof (tBTA_DM_API_RAW_COMMAND) + param_len;
+ p_msg = (tBTA_DM_API_RAW_COMMAND *) osi_malloc(size);
+ if (p_msg != NULL)
+ {
+ p_msg->hdr.event = BTA_DM_API_HCI_RAW_COMMAND_EVT;
+ p_msg->opcode = opcode;
+ p_msg->param_len = param_len;
+ p_msg->p_param_buf = (UINT8 *)(p_msg + 1);
+ p_msg->p_cback = p_cback;
+
+ memcpy (p_msg->p_param_buf, p_param_buf, param_len);
+
+ bta_sys_sendmsg(p_msg);
+ }
+ return BTA_SUCCESS;
+
+}
+
+/*******************************************************************************
+**
** Function BTA_DmSearch
**
** Description This function searches for peer Bluetooth devices. It performs
BTA_DM_API_EXECUTE_CBACK_EVT,
BTA_DM_API_REMOVE_ALL_ACL_EVT,
BTA_DM_API_REMOVE_DEVICE_EVT,
+ BTA_DM_API_HCI_RAW_COMMAND_EVT,
BTA_DM_MAX_EVT
};
UINT8 conn_paired_only;
} tBTA_DM_API_SET_VISIBILITY;
+/* data type for BTA_DM_API_HCI_RAW_COMMAND_EVT */
+typedef struct
+{
+ BT_HDR hdr;
+ UINT16 opcode;
+ UINT8 param_len;
+ UINT8 *p_param_buf;
+ tBTA_RAW_CMPL_CBACK *p_cback;
+} tBTA_DM_API_RAW_COMMAND;
+
enum
{
BTA_DM_RS_NONE, /* straight API call */
tBTA_DM_API_REMOVE_ACL remove_acl;
tBTA_DM_API_REMOVE_ALL_ACL remove_all_acl;
+ tBTA_DM_API_RAW_COMMAND btc_command;
} tBTA_DM_MSG;
extern void bta_dm_remove_all_acl(tBTA_DM_MSG *p_data);
+extern void bta_dm_hci_raw_command(tBTA_DM_MSG *p_data);
#endif /* BTA_DM_INT_H */
bta_dm_remove_all_acl, /* BTA_DM_API_REMOVE_ALL_ACL_EVT */
bta_dm_remove_device, /* BTA_DM_API_REMOVE_DEVICE_EVT */
+ bta_dm_hci_raw_command /* BTA_DM_API_HCI_RAW_COMMAND_EVT */
};
tBTA_DM_BLE_PF_ADV_TRACK_ENTRIES num_of_tracking_entries;
} tBTA_DM_BLE_PF_FILT_PARAMS;
+/* HCI RAW Command Callback */
+typedef tBTM_RAW_CMPL_CB tBTA_RAW_CMPL_CBACK;
+
/* Search callback events */
#define BTA_DM_INQ_RES_EVT 0 /* Inquiry result for a peer device. */
#define BTA_DM_INQ_CMPL_EVT 1 /* Inquiry complete. */
/*******************************************************************************
**
+** Function BTA_DmHciRawCommand
+**
+** Description This function sends the HCI RAW command
+** to the controller
+**
+**
+** Returns tBTA_STATUS
+**
+*******************************************************************************/
+extern tBTA_STATUS BTA_DmHciRawCommand (UINT16 opcode, UINT8 param_len,UINT8 *p_param_buf, tBTA_RAW_CMPL_CBACK *p_cback);
+
+
+/*******************************************************************************
+**
** Function BTA_DmSearch
**
** Description This function searches for peer Bluetooth devices. It
/*******************************************************************************
**
+** Function btif_hci_cmd_send
+**
+** Description Sends a HCI Raw command to the controller
+**
+** Returns BT_STATUS_SUCCESS on success
+**
+*******************************************************************************/
+bt_status_t btif_hci_cmd_send(uint16_t opcode, uint8_t *buf, uint8_t len);
+
+/*******************************************************************************
+**
** Function btif_le_test_mode
**
** Description Sends a HCI BLE Test command to the Controller
return btif_dut_mode_send(opcode, buf, len);
}
+#if HCI_RAW_CMD_INCLUDED == TRUE
+int hci_cmd_send(uint16_t opcode, uint8_t* buf, uint8_t len)
+{
+ ALOGI("hci_cmd_send");
+
+ /* sanity check */
+ if (interface_ready() == FALSE)
+ return BT_STATUS_NOT_READY;
+
+ return btif_hci_cmd_send(opcode, buf, len);
+}
+#endif
+
#if BLE_INCLUDED == TRUE
int le_test_mode(uint16_t opcode, uint8_t* buf, uint8_t len)
{
get_profile_interface,
dut_mode_configure,
dut_mode_send,
+#if HCI_RAW_CMD_INCLUDED == TRUE
+ hci_cmd_send,
+#else
+ NULL,
+#endif
#if BLE_INCLUDED == TRUE
le_test_mode,
#else
/*******************************************************************************
**
+** BTIF Test Mode APIs
+**
+*****************************************************************************/
+#if HCI_RAW_CMD_INCLUDED == TRUE
+/*******************************************************************************
+**
+** Function btif_hci_event_cback
+**
+** Description Callback invoked on receiving HCI event
+**
+** Returns None
+**
+*******************************************************************************/
+static void btif_hci_event_cback ( tBTM_RAW_CMPL *p )
+{
+ BTIF_TRACE_DEBUG("%s", __FUNCTION__);
+ if(p != NULL)
+ {
+ HAL_CBACK(bt_hal_cbacks, hci_event_recv_cb, p->event_code, p->p_param_buf,
+ p->param_len);
+ }
+}
+
+/*******************************************************************************
+**
+** Function btif_hci_cmd_send
+**
+** Description Sends a HCI raw command to the controller
+**
+** Returns BT_STATUS_SUCCESS on success
+**
+*******************************************************************************/
+bt_status_t btif_hci_cmd_send(uint16_t opcode, uint8_t *buf, uint8_t len)
+{
+ BTIF_TRACE_DEBUG("%s", __FUNCTION__);
+
+ BTM_Hci_Raw_Command(opcode, len, buf, btif_hci_event_cback);
+ return BT_STATUS_SUCCESS;
+}
+#endif
+
+/*******************************************************************************
+**
** Function btif_dut_mode_cback
**
** Description Callback invoked on completion of vendor specific test mode command
#endif
+
+#ifndef HCI_RAW_CMD_INCLUDED
+#define HCI_RAW_CMD_INCLUDED TRUE
+#endif
+
/******************************************************************************
**
** BLE
ThreadEventCallback,
nullptr, /* dut_mode_recv_cb */
nullptr, /* le_test_mode_cb */
- nullptr /* energy_info_cb */
+ nullptr, /* energy_info_cb */
+ nullptr /*hci_event_recv_cb */
};
bt_os_callouts_t bt_os_callouts = {
nullptr, /* dump */
nullptr, /* config clear */
nullptr, /* interop_database_clear */
- nullptr /* interop_database_add */
+ nullptr, /* interop_database_add */
+ nullptr /* hci_cmd_send */
};
} // namespace
return (p_prev);
}
+
+/*******************************************************************************
+**
+** Function BTM_Hci_Raw_Command
+**
+** Description Send HCI raw command to the controller.
+**
+** Returns
+** BTM_SUCCESS Command sent. Does not expect command complete
+** event. (command cmpl callback param is NULL)
+** BTM_CMD_STARTED Command sent. Waiting for command cmpl event.
+**
+**
+*******************************************************************************/
+tBTM_STATUS BTM_Hci_Raw_Command(UINT16 opcode, UINT8 param_len,
+ UINT8 *p_param_buf, tBTM_RAW_CMPL_CB *p_cb)
+{
+ void *p_buf;
+#if HCI_RAW_CMD_INCLUDED == TRUE
+ tBTM_DEVCB *p_devcb = &btm_cb.devcb;
+#endif
+
+ BTM_TRACE_EVENT ("BTM: BTM_Hci_Raw_Command: Opcode: 0x%04X, ParamLen: %i.",
+ opcode, param_len);
+
+ /* Allocate a buffer to hold HCI command plus the callback function */
+ p_buf = osi_malloc((UINT16)(sizeof(BT_HDR) + sizeof (tBTM_CMPL_CB *) +
+ param_len + HCIC_PREAMBLE_SIZE));
+ if (p_buf != NULL)
+ {
+ btsnd_hcic_raw_cmd (p_buf, opcode, param_len, p_param_buf, (void *)p_cb);
+
+ /* Return value */
+#if HCI_RAW_CMD_INCLUDED == TRUE
+ if (p_cb != NULL) {
+ if(p_cb != (p_devcb->p_hci_evt_cb)) {
+ p_devcb->p_hci_evt_cb = p_cb;
+ }
+ return BTM_CMD_STARTED;
+ }
+#else
+ if (p_cb != NULL)
+ return BTM_CMD_STARTED;
+#endif
+ else
+ return BTM_SUCCESS;
+ }
+ else
+ return BTM_NO_RESOURCES;
+
+}
+
/*******************************************************************************
**
** Function BTM_VendorSpecificCommand
return (BTM_SUCCESS);
}
+#if HCI_RAW_CMD_INCLUDED == TRUE
+/*******************************************************************************
+**
+** Function btm_hci_event
+**
+** Description This function is called when HCI event is received
+** from the HCI layer.
+**
+** Returns void
+**
+*******************************************************************************/
+void btm_hci_event(UINT8 *p, UINT8 event_code, UINT8 param_len)
+{
+ tBTM_DEVCB *p_devcb = &btm_cb.devcb;
+ tBTM_RAW_CMPL raw_cplt_params;
+
+ /* If there was a callback address for raw cmd complete, call it */
+ if (p_devcb->p_hci_evt_cb)
+ {
+ /* Pass paramters to the callback function */
+ raw_cplt_params.event_code = event_code; /* Number of bytes in return info */
+ raw_cplt_params.param_len = param_len; /* Number of bytes in return info */
+ raw_cplt_params.p_param_buf = p;
+ (p_devcb->p_hci_evt_cb) (&raw_cplt_params); /* Call the cmd complete callback function */
+ }
+}
+#endif
/*******************************************************************************
**
#endif /* BLE_INCLUDED */
+#if HCI_RAW_CMD_INCLUDED == TRUE
+ tBTM_RAW_CMPL_CB *p_hci_evt_cb; /* Callback function to be called when
+ HCI event is received successfully */
+#endif
+
tBTM_IO_CAP loc_io_caps; /* IO capability of the local device */
tBTM_AUTH_REQ loc_auth_req; /* the auth_req flag */
BOOLEAN secure_connections_only; /* Rejects service level 0 connections if */
extern void btm_ble_resolving_list_remove_dev(tBTM_SEC_DEV_REC *p_dev_rec);
#endif /* BLE_INCLUDED */
+/* HCI event handler */
+#if HCI_RAW_CMD_INCLUDED == TRUE
+extern void btm_hci_event(UINT8 *p, UINT8 event_code, UINT8 param_len);
+#endif
/* Vendor Specific Command complete evt handler */
extern void btm_vsc_complete (UINT8 *p, UINT16 cc_opcode, UINT16 evt_len,
tBTM_CMPL_CB *p_vsc_cplt_cback);
btm_vendor_specific_evt (p, hci_evt_len);
break;
}
+#if HCI_RAW_CMD_INCLUDED == TRUE
+ btm_hci_event (p, hci_evt_code , hci_evt_len);
+#endif
}
/*******************************************************************************
#error "HCI_CMD_BUF_SIZE must be larger than 268"
#endif
+
+void btsnd_hcic_raw_cmd (void *buffer, UINT16 opcode, UINT8 len,
+ UINT8 *p_data, void *p_cmd_cplt_cback)
+{
+ BT_HDR *p = (BT_HDR *)buffer;
+ UINT8 *pp = (UINT8 *)(p + 1);
+
+ p->len = HCIC_PREAMBLE_SIZE + len;
+ p->offset = sizeof(void *);
+
+ *((void **)pp) = p_cmd_cplt_cback; /* Store command complete callback in buffer */
+ pp += sizeof(void *); /* Skip over callback pointer */
+
+ UINT16_TO_STREAM (pp, opcode);
+ UINT8_TO_STREAM (pp, len);
+ ARRAY_TO_STREAM (pp, p_data, len);
+
+ btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
+}
+
void btsnd_hcic_vendor_spec_cmd (void *buffer, UINT16 opcode, UINT8 len,
UINT8 *p_data, void *p_cmd_cplt_cback)
{
UINT8 *p_param_buf;
} tBTM_VSC_CMPL;
+/* Structure returned with HCI Raw Command complete callback */
+typedef struct
+{
+ UINT8 event_code;
+ UINT8 param_len;
+ UINT8 *p_param_buf;
+} tBTM_RAW_CMPL;
+
#define BTM_VSC_CMPL_DATA_SIZE (BTM_MAX_VENDOR_SPECIFIC_LEN + sizeof(tBTM_VSC_CMPL))
/**************************************************
** Device Control and General Callback Functions
*/
typedef void (tBTM_VSC_CMPL_CB) (tBTM_VSC_CMPL *p1);
+/* HCI RAW CMD callback function for notifying an application that a synchronous
+** BTM function is complete. The pointer contains the address of any returned data.
+*/
+typedef void (tBTM_RAW_CMPL_CB) (tBTM_RAW_CMPL *p1);
+
/* Callback for apps to check connection and inquiry filters.
** Parameters are the BD Address of remote and the Dev Class of remote.
** If the app returns none zero, the connection or inquiry result will be dropped.
/*******************************************************************************
**
+** Function BTM_Hci_Raw_Command
+**
+** Description Send a HCI RAW started testingcommand to the controller.
+**
+*******************************************************************************/
+extern tBTM_STATUS BTM_Hci_Raw_Command(UINT16 opcode,
+ UINT8 param_len,
+ UINT8 *p_param_buf,
+ tBTM_RAW_CMPL_CB *p_cb);
+
+/*******************************************************************************
+**
** Function BTM_VendorSpecificCommand
**
** Description Send a vendor specific HCI command to the controller.
#define HCID_HEADER_SIZE 4
#define HCID_GET_SCO_LEN(p) (*((UINT8 *)((p) + 1) + p->offset + 2))
+extern void btsnd_hcic_raw_cmd (void *buffer, UINT16 opcode, UINT8 len,
+ UINT8 *p_data, void *p_cmd_cplt_cback);
extern void btsnd_hcic_vendor_spec_cmd (void *buffer, UINT16 opcode,
UINT8 len, UINT8 *p_data,