diff --git a/android/bluetooth.c b/android/bluetooth.c
index 21221f7..d7cf2f9 100644
--- a/android/bluetooth.c
+++ b/android/bluetooth.c
#include "utils.h"
#include "bluetooth.h"
+#define DUT_MODE_FILE "/sys/kernel/debug/bluetooth/hci%u/dut_mode"
+
#define DEVICE_ID_SOURCE 0x0002 /* USB */
#define DEVICE_ID_VENDOR 0x1d6b /* Linux Foundation */
#define DEVICE_ID_PRODUCT 0x0247 /* BlueZ for Android */
static void handle_dut_mode_conf_cmd(const void *buf, uint16_t len)
{
const struct hal_cmd_dut_mode_conf *cmd = buf;
+ char path[FILENAME_MAX];
+ uint8_t status;
+ int fd, ret;
DBG("enable %u", cmd->enable);
- /* TODO */
+ snprintf(path, sizeof(path), DUT_MODE_FILE, adapter.index);
- ipc_send_rsp(HAL_SERVICE_ID_BLUETOOTH, HAL_OP_DUT_MODE_CONF,
- HAL_STATUS_FAILED);
+ fd = open(path, O_WRONLY);
+ if (fd < 0) {
+ status = HAL_STATUS_FAILED;
+ goto failed;
+ }
+
+ if (cmd->enable)
+ ret = write(fd, "1", sizeof("1"));
+ else
+ ret = write(fd, "0", sizeof("0"));
+
+ if (ret < 0)
+ status = HAL_STATUS_FAILED;
+ else
+ status = HAL_STATUS_SUCCESS;
+
+ close(fd);
+
+failed:
+ ipc_send_rsp(HAL_SERVICE_ID_BLUETOOTH, HAL_OP_DUT_MODE_CONF, status);
}
static void handle_dut_mode_send_cmd(const void *buf, uint16_t len)