diff --git a/android/handsfree-client.c b/android/handsfree-client.c
index 53fc917..0c172e4 100644
--- a/android/handsfree-client.c
+++ b/android/handsfree-client.c
static void handle_dial(const void *buf, uint16_t len)
{
const struct hal_cmd_hf_client_dial *cmd = buf;
+ struct device *dev;
+ uint8_t status;
+ bool ret;
- if (len != sizeof(*cmd) + cmd->number_len) {
- error("Malformed number data, size (%u bytes), terminating",
- len);
- raise(SIGTERM);
- return;
+ DBG("");
+
+ if (len != sizeof(*cmd) + cmd->number_len)
+ goto failed;
+
+ dev = find_default_device();
+ if (!dev) {
+ status = HAL_STATUS_FAILED;
+ goto done;
}
- DBG("Not Implemented");
+ if (cmd->number_len > 0) {
+ if (cmd->number[cmd->number_len - 1] != '\0')
+ goto failed;
+
+ DBG("Dialing %s", cmd->number);
+
+ ret = hfp_hf_send_command(dev->hf, cmd_complete_cb, NULL,
+ "ATD%s;", cmd->number);
+ } else {
+ DBG("Redialing");
+
+ ret = hfp_hf_send_command(dev->hf, cmd_complete_cb, NULL,
+ "AT+BLDN");
+ }
+
+ status = ret ? HAL_STATUS_SUCCESS : HAL_STATUS_FAILED;
+
+done:
ipc_send_rsp(hal_ipc, HAL_SERVICE_ID_HANDSFREE_CLIENT,
- HAL_OP_HF_CLIENT_DIAL, HAL_STATUS_UNSUPPORTED);
+ HAL_OP_HF_CLIENT_DIAL, status);
+
+ return;
+
+failed:
+ error("Malformed number data, size (%u bytes), terminating", len);
+ raise(SIGTERM);
}
static void handle_dial_memory(const void *buf, uint16_t len)
{
- DBG("Not Implemented");
+ const struct hal_cmd_hf_client_dial_memory *cmd = buf;
+ struct device *dev;
+ uint8_t status;
+
+ DBG("");
+
+ dev = find_default_device();
+ if (!dev) {
+ status = HAL_STATUS_FAILED;
+ goto done;
+ }
+
+ /* For some reason location in BT HAL is int. Therefore that check */
+ if (cmd->location < 0) {
+ status = HAL_STATUS_FAILED;
+ goto done;
+ }
+
+ if (hfp_hf_send_command(dev->hf, cmd_complete_cb, NULL , "ATD>%d;",
+ cmd->location))
+ status = HAL_STATUS_SUCCESS;
+ else
+ status = HAL_STATUS_FAILED;
+
+done:
ipc_send_rsp(hal_ipc, HAL_SERVICE_ID_HANDSFREE_CLIENT,
- HAL_OP_HF_CLIENT_DIAL_MEMORY, HAL_STATUS_UNSUPPORTED);
+ HAL_OP_HF_CLIENT_DIAL_MEMORY, status);
}
static void handle_call_action(const void *buf, uint16_t len)