Just to reply to my own thread with more info (to help others who might be looking into some related work)…
There is a lot of trouble getting hcitool built, since it is part of bluez, which is not part of Android.
I found this thread discussing enabling dut_mode_send command in bdt “bluedroid tool”, which includes a patch.
http://processors.wiki.ti.com/index.php/WL18xx_Bluedroid_Bluetooth_RF_Testing#BLE_testing
Well, bluedroid is now called fluoride, and bdt has been renamed to “mcap_tool”, and some extra changes make it so the patch will not apply, so here is the patch updated for fluoride:
diff --git a/btif/src/btif_core.cc b/btif/src/btif_core.cc
index 296b9d7..42ae38b 100644
--- a/btif/src/btif_core.cc
+++ b/btif/src/btif_core.cc
@@ -554,7 +554,8 @@ bt_status_t btif_cleanup_bluetooth(void) {
*
******************************************************************************/
static void btif_dut_mode_cback(UNUSED_ATTR tBTM_VSC_CMPL* p) {
- /* For now nothing to be done. */
+ BTIF_TRACE_DEBUG1("%s", __FUNCTION__);
+ HAL_CBACK(bt_hal_cbacks, dut_mode_recv_cb, p->opcode, p->p_param_buf, p->param_len);
}
/*******************************************************************************
@@ -596,10 +597,10 @@ bt_status_t btif_dut_mode_configure(uint8_t enable) {
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_DEBUG("%s", __func__);
- if (!btif_is_dut_mode()) {
+ /*if (!btif_is_dut_mode()) {
BTIF_TRACE_ERROR("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;
}
diff --git a/tools/mcap_tool/mcap_tool.cc b/tools/mcap_tool/mcap_tool.cc
index 6ed26aa..f2a38c2 100644
--- a/tools/mcap_tool/mcap_tool.cc
+++ b/tools/mcap_tool/mcap_tool.cc
@@ -472,7 +472,13 @@ static void acl_state_changed(bt_status_t status, RawAddress* remote_bd_addr,
}
static void dut_mode_recv(uint16_t opcode, uint8_t* buf, uint8_t len) {
- LOG(INFO) << "DUT MODE RECV : NOT IMPLEMENTED";
+ uint8_t evt_param_index;
+
+ printf("DUT MODE RECV: [Opcode = 0x%4X] [Param_len = %d] [Param = ", opcode, len);
+
+ for(evt_param_index=0; evt_param_index<len; evt_param_index++)
+ printf(" 0x%02X", buf[evt_param_index]);
+ printf("]\n");
}
static bt_callbacks_t bt_callbacks = {
@@ -574,6 +580,67 @@ void adapter_dut_mode_configure(char* p) {
check_return_status(global_status);
}
+void bdt_dut_mode_send(char *p)
+{
+ uint16_t ogf = 0;
+ uint16_t ocf = 0;
+ char *tok_str;
+ uint16_t opcode;
+ uint8_t param[1024];
+ uint16_t opcode_field_count;
+ uint16_t param_index , param_len;
+ int status;
+
+ LOG(INFO) << "BT DUT MODE SEND";
+
+ param_len = 0;
+ param_index = 0;
+ opcode_field_count = 2;
+
+ if (!global_bt_enabled) {
+ LOG(INFO) << "Bluetooth must be enabled for test_mode to work.";
+ return;
+ }
+
+ tok_str = strtok (p," ");
+ while (tok_str != NULL) {
+ switch(opcode_field_count)
+ {
+ case 2:
+ ogf = strtol(tok_str, NULL, 16);
+ break;
+
+ case 1:
+ ocf = strtol(tok_str, NULL, 16);
+ break;
+
+ default:
+ param[param_index++] = strtol(tok_str, NULL, 16);
+ break;
+ }
+ opcode_field_count--;
+ tok_str = strtok (NULL, " ");
+ }
+
+ param_len = param_index;
+ LOG(INFO) << "ogf = (int)" << (int)ogf;
+ LOG(INFO) << "ocf = (int)" << (int)ocf;
+
+ opcode = (ocf & 0x03ff)|(ogf << 10);
+
+ LOG(INFO) << "opcode = (int)" << (int)opcode;
+ LOG(INFO) << "param_len = (int)" << (int)param_len;
+
+ printf("params: ");
+ for(param_index=0; param_index<param_len; param_index++)
+ printf("0x%02X ", param[param_index]);
+ printf("\n");
+
+ status = sBtInterface->dut_mode_send(opcode, param, param_len);
+
+ check_return_status((bt_status_t)status);
+}
+
void adapter_cleanup(void) {
LOG(INFO) << __func__;
sBtInterface->cleanup();
@@ -611,6 +678,10 @@ void do_enable(char* p) { adapter_enable(); }
void do_disable(char* p) { adapter_disable(); }
+void do_dut_mode_configure(char *p) { adapter_dut_mode_configure(p); }
+
+void do_dut_mode_send(char *p) { bdt_dut_mode_send(p); }
+
void do_cleanup(char* p) { adapter_cleanup(); }
/**
@@ -859,6 +930,8 @@ const cmd_t console_cmd_list[] = {
/* Init and Cleanup shall be called automatically */
{"enable_bluetooth", do_enable, "", 0},
{"disable_bluetooth", do_disable, "", 0},
+ {"dut_mode_configure", do_dut_mode_configure, ":: DUT mode - 1 to enter,0 to exit", 0},
+ {"dut_mode_send", do_dut_mode_send, ":: <ogf> <ocf> <parameters>", 0},
{"pair", do_pairing, "BD_ADDR<xx:xx:xx:xx:xx:xx>", 0},
{"register", do_mcap_register,
"ctrl_psm<hex> data_psm<hex> security_mask<0-10>", 0},