diff options
author | Kausik Sinnaswamy <kausik@broadcom.com> | 2012-08-08 22:11:39 +0530 |
---|---|---|
committer | Matthew Xie <mattx@google.com> | 2012-08-13 23:22:54 -0700 |
commit | a4eaddaccd236ec5c5add065e1b393072bdb8386 (patch) | |
tree | 2e6c52cacc63cc036b72b02c3082c3ba6972ddf2 /btif | |
parent | 1a0ab4d5bee3bea4c8153a3d147d5adca3be0bed (diff) | |
download | external_bluetooth_bluedroid-a4eaddaccd236ec5c5add065e1b393072bdb8386.zip external_bluetooth_bluedroid-a4eaddaccd236ec5c5add065e1b393072bdb8386.tar.gz external_bluetooth_bluedroid-a4eaddaccd236ec5c5add065e1b393072bdb8386.tar.bz2 |
Enhanced bluetooth HAL with DUT mode APIs
These APIs are needed to allow the bluetooth chip to be put into DUT
mode so that RF/BB BQB tests can be run
Change-Id: Ie5be00da567bc94173f35b098abcaf6f6603a129
Diffstat (limited to 'btif')
-rw-r--r-- | btif/include/btif_api.h | 23 | ||||
-rw-r--r-- | btif/include/btif_util.h | 1 | ||||
-rw-r--r-- | btif/src/bluetooth.c | 25 | ||||
-rw-r--r-- | btif/src/btif_core.c | 94 |
4 files changed, 138 insertions, 5 deletions
diff --git a/btif/include/btif_api.h b/btif/include/btif_api.h index d90ee58..7916b3d 100644 --- a/btif/include/btif_api.h +++ b/btif/include/btif_api.h @@ -377,5 +377,28 @@ bt_status_t btif_dm_get_remote_service_record(bt_bdaddr_t *remote_addr, *******************************************************************************/ bt_status_t btif_dm_get_remote_services(bt_bdaddr_t *remote_addr); +/******************************************************************************* +** +** Function btif_dut_mode_configure +** +** Description Configure Test Mode - 'enable' to 1 puts the device in test mode and 0 exits +** test mode +** +** Returns BT_STATUS_SUCCESS on success +** +*******************************************************************************/ +bt_status_t btif_dut_mode_configure(uint8_t enable); + +/******************************************************************************* +** +** Function btif_dut_mode_send +** +** Description Sends a HCI Vendor specific command to the controller +** +** Returns BT_STATUS_SUCCESS on success +** +*******************************************************************************/ +bt_status_t btif_dut_mode_send(uint16_t opcode, uint8_t *buf, uint8_t len); + #endif /* BTIF_API_H */ diff --git a/btif/include/btif_util.h b/btif/include/btif_util.h index a15d1ca..fd16a40 100644 --- a/btif/include/btif_util.h +++ b/btif/include/btif_util.h @@ -109,4 +109,3 @@ void string_to_uuid(char *str, bt_uuid_t *p_uuid); int ascii_2_hex (char *p_ascii, int len, UINT8 *p_hex); #endif /* BTIF_UTIL_H */ - diff --git a/btif/src/bluetooth.c b/btif/src/bluetooth.c index f7e80d9..0b9d542 100644 --- a/btif/src/bluetooth.c +++ b/btif/src/bluetooth.c @@ -347,6 +347,27 @@ static const void* get_profile_interface (const char *profile_id) return NULL; } +int dut_mode_configure(uint8_t enable) +{ + ALOGI("dut_mode_configure"); + + /* sanity check */ + if (interface_ready() == FALSE) + return BT_STATUS_NOT_READY; + + return btif_dut_mode_configure(enable); +} + +int dut_mode_send(uint16_t opcode, uint8_t* buf, uint8_t len) +{ + ALOGI("dut_mode_send"); + + /* sanity check */ + if (interface_ready() == FALSE) + return BT_STATUS_NOT_READY; + + return btif_dut_mode_send(opcode, buf, len); +} static const bt_interface_t bluetoothInterface = { sizeof(bt_interface_t), init, @@ -368,7 +389,9 @@ static const bt_interface_t bluetoothInterface = { cancel_bond, pin_reply, ssp_reply, - get_profile_interface + get_profile_interface, + dut_mode_configure, + dut_mode_send }; const bt_interface_t* bluetooth__get_bluetooth_interface () diff --git a/btif/src/btif_core.c b/btif/src/btif_core.c index 0b0734e..666efa7 100644 --- a/btif/src/btif_core.c +++ b/btif/src/btif_core.c @@ -135,6 +135,14 @@ static btif_core_state_t btif_core_state = BTIF_CORE_STATE_DISABLED; static int btif_shutdown_pending = 0; static tBTA_SERVICE_MASK btif_enabled_services = 0; +/* +* This variable should be set to 1, if the Bluedroid+BTIF libraries are to +* function in DUT mode. +* +* To set this, the btif_init_bluetooth needs to be called with argument as 1 +*/ +static UINT8 btif_dut_mode = 0; + /************************************************************************************ ** Static functions ************************************************************************************/ @@ -249,6 +257,20 @@ bt_status_t btif_transfer_context (tBTIF_CBACK *p_cback, UINT16 event, char* p_p } } +/******************************************************************************* +** +** Function btif_is_dut_mode +** +** Description checks if BTIF is currently in DUT mode +** +** Returns 1 if test mode, otherwize 0 +** +*******************************************************************************/ + +UINT8 btif_is_dut_mode(void) +{ + return (btif_dut_mode == 1); +} /******************************************************************************* ** @@ -262,7 +284,7 @@ bt_status_t btif_transfer_context (tBTIF_CBACK *p_cback, UINT16 event, char* p_p int btif_is_enabled(void) { - return (btif_core_state == BTIF_CORE_STATE_ENABLED); + return ((!btif_is_dut_mode()) && (btif_core_state == BTIF_CORE_STATE_ENABLED)); } /******************************************************************************* @@ -294,7 +316,6 @@ static void btif_task(UINT32 params) * Wait for the trigger to init chip and stack. This trigger will * be received by btu_task once the UART is opened and ready */ - if (event == BT_EVT_TRIGGER_STACK_INIT) { BTIF_TRACE_DEBUG0("btif_task: received trigger stack init event"); @@ -432,7 +453,7 @@ static void btif_fetch_local_bdaddr(bt_bdaddr_t *local_addr) ** *******************************************************************************/ -bt_status_t btif_init_bluetooth(void) +bt_status_t btif_init_bluetooth() { UINT8 status; @@ -672,6 +693,8 @@ bt_status_t btif_shutdown_bluetooth(void) btif_queue_release(); bte_main_shutdown(); + btif_dut_mode = 0; + BTIF_TRACE_DEBUG1("%s done", __FUNCTION__); return BT_STATUS_SUCCESS; @@ -701,8 +724,73 @@ static bt_status_t btif_disassociate_evt(void) return BT_STATUS_SUCCESS; } +/**************************************************************************** +** +** BTIF Test Mode APIs +** +*****************************************************************************/ +/******************************************************************************* +** +** Function btif_dut_mode_cback +** +** Description Callback invoked on completion of vendor specific test mode command +** +** Returns None +** +*******************************************************************************/ +static void btif_dut_mode_cback( tBTM_VSC_CMPL *p ) +{ + /* For now nothing to be done. */ +} + +/******************************************************************************* +** +** Function btif_dut_mode_configure +** +** Description Configure Test Mode - 'enable' to 1 puts the device in test mode and 0 exits +** test mode +** +** Returns BT_STATUS_SUCCESS on success +** +*******************************************************************************/ +bt_status_t btif_dut_mode_configure(uint8_t enable) +{ + BTIF_TRACE_DEBUG1("%s", __FUNCTION__); + if (btif_core_state != BTIF_CORE_STATE_ENABLED) { + BTIF_TRACE_ERROR0("btif_dut_mode_configure : Bluetooth not enabled"); + return BT_STATUS_NOT_READY; + } + btif_dut_mode = enable; + if (enable == 1) { + BTA_EnableTestMode(); + } else { + BTA_DisableTestMode(); + } + return BT_STATUS_SUCCESS; +} + +/******************************************************************************* +** +** Function btif_dut_mode_send +** +** Description Sends a HCI Vendor specific command to the controller +** +** Returns BT_STATUS_SUCCESS on success +** +*******************************************************************************/ +bt_status_t btif_dut_mode_send(uint16_t opcode, uint8_t *buf, uint8_t len) +{ + /* TODO: Check that opcode is a vendor command group */ + BTIF_TRACE_DEBUG1("%s", __FUNCTION__); + if (!btif_is_dut_mode()) { + BTIF_TRACE_ERROR0("Bluedroid HAL needs to be init with test_mode set to 1."); + return BT_STATUS_FAIL; + } + BTM_VendorSpecificCommand(opcode, len, buf, btif_dut_mode_cback); + return BT_STATUS_SUCCESS; +} /***************************************************************************** ** ** btif api adapter property functions |