diff options
author | Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com> | 2013-10-22 05:16:16 -0700 |
---|---|---|
committer | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2013-10-22 15:57:50 +0300 |
commit | 8dc3c01e7f329f5fa4d34ce11add649d7a77d5c7 (patch) | |
tree | ef8f2a4af7355d40db28ccfed4efb9d1dad99ab2 /android/hal-hidhost.c | |
parent | c7fca3757095c14a919fd57c5fb76e236a4a5421 (diff) | |
download | bluez-8dc3c01e7f329f5fa4d34ce11add649d7a77d5c7.tar.gz |
android: Add initial code for hidhost
This adds the initial implementation of .init, .connect and .disconnect
Diffstat (limited to 'android/hal-hidhost.c')
-rw-r--r-- | android/hal-hidhost.c | 41 |
1 files changed, 33 insertions, 8 deletions
diff --git a/android/hal-hidhost.c b/android/hal-hidhost.c index 8c47e2731..90755eb64 100644 --- a/android/hal-hidhost.c +++ b/android/hal-hidhost.c @@ -17,12 +17,15 @@ #include <stdbool.h> #include <stddef.h> +#include <string.h> #include <hardware/bluetooth.h> #include <hardware/bt_hh.h> #include "hal-log.h" #include "hal.h" +#include "hal-msg.h" +#include "hal-ipc.h" bthh_callbacks_t *bt_hh_cbacks; @@ -33,6 +36,8 @@ static bool interface_ready(void) static bt_status_t bt_hidhost_connect(bt_bdaddr_t *bd_addr) { + struct hal_msg_cmd_bt_hid_connect cmd; + DBG(""); if (!interface_ready()) @@ -41,11 +46,21 @@ static bt_status_t bt_hidhost_connect(bt_bdaddr_t *bd_addr) if (!bd_addr) return BT_STATUS_PARM_INVALID; - return BT_STATUS_UNSUPPORTED; + memcpy(cmd.bdaddr, bd_addr, sizeof(cmd.bdaddr)); + + if (hal_ipc_cmd(HAL_SERVICE_ID_HIDHOST, HAL_MSG_OP_BT_HID_CONNECT, + sizeof(cmd), &cmd, 0, NULL, NULL) < 0) { + error("Failed to connect hid device"); + return BT_STATUS_FAIL; + } + + return BT_STATUS_SUCCESS; } static bt_status_t bt_hidhost_disconnect(bt_bdaddr_t *bd_addr) { + struct hal_msg_cmd_bt_hid_disconnect cmd; + DBG(""); if (!interface_ready()) @@ -54,7 +69,15 @@ static bt_status_t bt_hidhost_disconnect(bt_bdaddr_t *bd_addr) if (!bd_addr) return BT_STATUS_PARM_INVALID; - return BT_STATUS_UNSUPPORTED; + memcpy(cmd.bdaddr, bd_addr, sizeof(cmd.bdaddr)); + + if (hal_ipc_cmd(HAL_SERVICE_ID_HIDHOST, HAL_MSG_OP_BT_HID_DISCONNECT, + sizeof(cmd), &cmd, 0, NULL, NULL) < 0) { + error("Failed to disconnect hid device"); + return BT_STATUS_FAIL; + } + + return BT_STATUS_SUCCESS; } static bt_status_t bt_hidhost_virtual_unplug(bt_bdaddr_t *bd_addr) @@ -158,14 +181,20 @@ static bt_status_t bt_hidhost_send_data(bt_bdaddr_t *bd_addr, char *data) static bt_status_t bt_hidhost_init(bthh_callbacks_t *callbacks) { + struct hal_msg_cmd_register_module cmd; DBG(""); /* store reference to user callbacks */ bt_hh_cbacks = callbacks; - /* TODO: start HID Host thread */ + cmd.service_id = HAL_SERVICE_ID_HIDHOST; - /* TODO: enable service */ + if (hal_ipc_cmd(HAL_SERVICE_ID_CORE, HAL_MSG_OP_REGISTER_MODULE, + sizeof(cmd), &cmd, 0, NULL, NULL) < 0) { + error("Failed to register 'hidhost'' service"); + + return BT_STATUS_FAIL; + } return BT_STATUS_SUCCESS; } @@ -177,10 +206,6 @@ static void bt_hidhost_cleanup(void) if (!interface_ready()) return; - /* TODO: disable service */ - - /* TODO: stop HID Host thread */ - bt_hh_cbacks = NULL; } |