* [PATCH] android/hal: Fix receiving of commands with no response parameter
From: Szymon Janc @ 2013-10-22 12:03 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
This fix receiving of error response in case command has no reply
parameters.
---
android/hal-ipc.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/android/hal-ipc.c b/android/hal-ipc.c
index 041441d..b264bfe 100644
--- a/android/hal-ipc.c
+++ b/android/hal-ipc.c
@@ -260,6 +260,7 @@ int hal_ipc_cmd(uint8_t service_id, uint8_t opcode, uint16_t len, void *param,
if (!rsp || rsp_len == 0) {
memset(&err, 0, sizeof(err));
+ rsp_len = sizeof(err);
rsp = &err;
}
--
1.8.4
^ permalink raw reply related
* Re: [PATCH] android/hal: Fix receiving of commands with no response parameter
From: Luiz Augusto von Dentz @ 2013-10-22 12:11 UTC (permalink / raw)
To: Szymon Janc; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <1382443438-28452-1-git-send-email-szymon.janc@tieto.com>
Hi Szymon,
On Tue, Oct 22, 2013 at 3:03 PM, Szymon Janc <szymon.janc@tieto.com> wrote:
> This fix receiving of error response in case command has no reply
> parameters.
> ---
> android/hal-ipc.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/android/hal-ipc.c b/android/hal-ipc.c
> index 041441d..b264bfe 100644
> --- a/android/hal-ipc.c
> +++ b/android/hal-ipc.c
> @@ -260,6 +260,7 @@ int hal_ipc_cmd(uint8_t service_id, uint8_t opcode, uint16_t len, void *param,
>
> if (!rsp || rsp_len == 0) {
> memset(&err, 0, sizeof(err));
> + rsp_len = sizeof(err);
> rsp = &err;
> }
>
> --
> 1.8.4
Pushed, thanks.
--
Luiz Augusto von Dentz
^ permalink raw reply
* [PATCH] android: Add initial code for hidhost connect and disconnect
From: Ravi kumar Veeramally @ 2013-10-22 12:16 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Ravi kumar Veeramally
---
android/hal-hidhost.c | 45 +++++++++++++++++++++++++++++++++++++--------
1 file changed, 37 insertions(+), 8 deletions(-)
diff --git a/android/hal-hidhost.c b/android/hal-hidhost.c
index 8c47e27..d68ee6c 100644
--- a/android/hal-hidhost.c
+++ b/android/hal-hidhost.c
@@ -17,12 +17,17 @@
#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"
+
+#define BT_DEVICE_ADDRESS_LENGTH 6
bthh_callbacks_t *bt_hh_cbacks;
@@ -33,6 +38,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 +48,22 @@ 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, BT_DEVICE_ADDRESS_LENGTH);
+
+ 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 +72,16 @@ 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, BT_DEVICE_ADDRESS_LENGTH);
+
+ 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 +185,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 +210,6 @@ static void bt_hidhost_cleanup(void)
if (!interface_ready())
return;
- /* TODO: disable service */
-
- /* TODO: stop HID Host thread */
-
bt_hh_cbacks = NULL;
}
--
1.7.9.5
^ permalink raw reply related
* [PATCH v3 1/6] android/hal: Make hal.h self contained
From: Szymon Janc @ 2013-10-22 12:46 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
---
android/hal-av.c | 3 ---
android/hal-bluetooth.c | 5 -----
android/hal-hidhost.c | 3 ---
android/hal-pan.c | 3 ---
android/hal-sock.c | 3 ---
android/hal.h | 1 +
6 files changed, 1 insertion(+), 17 deletions(-)
diff --git a/android/hal-av.c b/android/hal-av.c
index ef45066..b1c5276 100644
--- a/android/hal-av.c
+++ b/android/hal-av.c
@@ -18,9 +18,6 @@
#include <stdbool.h>
#include <stddef.h>
-#include <hardware/bluetooth.h>
-#include <hardware/bt_av.h>
-
#include "hal-log.h"
#include "hal.h"
diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
index 5b07070..6adf0cb 100644
--- a/android/hal-bluetooth.c
+++ b/android/hal-bluetooth.c
@@ -20,11 +20,6 @@
#include <stdbool.h>
#include <string.h>
-#include <hardware/bluetooth.h>
-#include <hardware/bt_sock.h>
-#include <hardware/bt_hh.h>
-#include <hardware/bt_pan.h>
-
#include "hal-log.h"
#include "hal.h"
#include "hal-msg.h"
diff --git a/android/hal-hidhost.c b/android/hal-hidhost.c
index 8c47e27..2d5d091 100644
--- a/android/hal-hidhost.c
+++ b/android/hal-hidhost.c
@@ -18,9 +18,6 @@
#include <stdbool.h>
#include <stddef.h>
-#include <hardware/bluetooth.h>
-#include <hardware/bt_hh.h>
-
#include "hal-log.h"
#include "hal.h"
diff --git a/android/hal-pan.c b/android/hal-pan.c
index 645fe8c..f05a93b 100644
--- a/android/hal-pan.c
+++ b/android/hal-pan.c
@@ -18,9 +18,6 @@
#include <stdbool.h>
#include <stddef.h>
-#include <hardware/bluetooth.h>
-#include <hardware/bt_pan.h>
-
#include "hal-log.h"
#include "hal.h"
diff --git a/android/hal-sock.c b/android/hal-sock.c
index dab3756..364663c 100644
--- a/android/hal-sock.c
+++ b/android/hal-sock.c
@@ -17,9 +17,6 @@
#include <stdlib.h>
-#include <hardware/bluetooth.h>
-#include <hardware/bt_sock.h>
-
#include "hal-log.h"
#include "hal.h"
diff --git a/android/hal.h b/android/hal.h
index d984336..e3c4122 100644
--- a/android/hal.h
+++ b/android/hal.h
@@ -15,6 +15,7 @@
*
*/
+#include <hardware/bluetooth.h>
#include <hardware/bt_sock.h>
#include <hardware/bt_hh.h>
#include <hardware/bt_pan.h>
--
1.8.4
^ permalink raw reply related
* [PATCH v3 2/6] android: Define helper payload field in hal_msg_hdr
From: Szymon Janc @ 2013-10-22 12:46 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1382445973-8285-1-git-send-email-szymon.janc@tieto.com>
This will allow for convenient access to payload.
---
android/hal-msg.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/android/hal-msg.h b/android/hal-msg.h
index 9dcfbf6..a1b539f 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -29,6 +29,7 @@ struct hal_msg_hdr {
uint8_t service_id;
uint8_t opcode;
uint16_t len;
+ uint8_t payload[0];
} __attribute__((packed));
#define HAL_SERVICE_ID_CORE 0
--
1.8.4
^ permalink raw reply related
* [PATCH v3 3/6] android: Fix non-existing event definition
From: Szymon Janc @ 2013-10-22 12:46 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1382445973-8285-1-git-send-email-szymon.janc@tieto.com>
There is no ERROR notification id.
---
android/hal-msg.h | 1 -
1 file changed, 1 deletion(-)
diff --git a/android/hal-msg.h b/android/hal-msg.h
index a1b539f..33acd41 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -249,7 +249,6 @@ struct hal_msg_cmd_bt_hid_send_data {
/* Notifications and confirmations */
-#define HAL_MSG_EV_BT_ERROR 0x80
#define HAL_MSG_EV_BT_ADAPTER_STATE_CHANGED 0x81
struct hal_msg_ev_bt_adapter_state_changed {
--
1.8.4
^ permalink raw reply related
* [PATCH v3 4/6] android: Define minimum legal notification event ID
From: Szymon Janc @ 2013-10-22 12:46 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1382445973-8285-1-git-send-email-szymon.janc@tieto.com>
All legal events IDs should be above this value.
---
android/hal-msg.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/android/hal-msg.h b/android/hal-msg.h
index 33acd41..9ff0510 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -32,6 +32,8 @@ struct hal_msg_hdr {
uint8_t payload[0];
} __attribute__((packed));
+#define HAL_MSG_MINIMUM_EVENT 0x81
+
#define HAL_SERVICE_ID_CORE 0
#define HAL_SERVICE_ID_BLUETOOTH 1
#define HAL_SERVICE_ID_SOCK 2
--
1.8.4
^ permalink raw reply related
* [PATCH v3 5/6] android/hal: Add initial code for notification handling
From: Szymon Janc @ 2013-10-22 12:46 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1382445973-8285-1-git-send-email-szymon.janc@tieto.com>
This adds a dedicated thread that will read from notification sockets
and dispatch it to appropriate service notification function.
---
Makefile.android | 2 +
android/hal-ipc.c | 107 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 107 insertions(+), 2 deletions(-)
diff --git a/Makefile.android b/Makefile.android
index 720df69..052d755 100644
--- a/Makefile.android
+++ b/Makefile.android
@@ -55,6 +55,8 @@ android_haltest_LDADD = android/libhal-internal.la
android_haltest_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/android
+android_haltest_LDFLAGS = -pthread
+
endif
EXTRA_DIST += android/Android.mk android/log.c android/device.c \
diff --git a/android/hal-ipc.c b/android/hal-ipc.c
index 9aac9c0..f1a9d18 100644
--- a/android/hal-ipc.c
+++ b/android/hal-ipc.c
@@ -39,6 +39,95 @@ static int notif_sk = -1;
static pthread_mutex_t cmd_sk_mutex = PTHREAD_MUTEX_INITIALIZER;
+static pthread_t notif_th = 0;
+
+static void notification_dispatch(struct hal_msg_hdr *msg, int fd)
+{
+ switch (msg->service_id) {
+ default:
+ DBG("Unhandled notification service=%d opcode=0x%x",
+ msg->service_id, msg->opcode);
+ break;
+ }
+}
+
+static void *notification_handler(void *data)
+{
+ struct msghdr msg;
+ struct iovec iv;
+ struct cmsghdr *cmsg;
+ char cmsgbuf[CMSG_SPACE(sizeof(int))];
+ char buf[BLUEZ_HAL_MTU];
+ struct hal_msg_hdr *hal_msg = (void *) buf;
+ ssize_t ret;
+ int fd;
+
+ while (true) {
+ memset(&msg, 0, sizeof(msg));
+ memset(buf, 0, sizeof(buf));
+ memset(cmsgbuf, 0, sizeof(cmsgbuf));
+
+ iv.iov_base = hal_msg;
+ iv.iov_len = sizeof(buf);
+
+ msg.msg_iov = &iv;
+ msg.msg_iovlen = 1;
+
+ msg.msg_control = cmsgbuf;
+ msg.msg_controllen = sizeof(cmsgbuf);
+
+ ret = recvmsg(notif_sk, &msg, 0);
+ if (ret < 0) {
+ error("Receiving notifications failed, aborting :%s",
+ strerror(errno));
+ exit(EXIT_FAILURE);
+ }
+
+ /* socket was shutdown */
+ if (ret == 0)
+ break;
+
+ if (ret < (ssize_t) sizeof(*hal_msg)) {
+ error("Too small notification (%zd bytes), aborting",
+ ret);
+ exit(EXIT_FAILURE);
+ }
+
+ if (hal_msg->opcode < HAL_MSG_MINIMUM_EVENT) {
+ error("Invalid notification (0x%x), aborting",
+ hal_msg->opcode);
+ exit(EXIT_FAILURE);
+ }
+
+ if (ret != (ssize_t) (sizeof(*hal_msg) + hal_msg->len)) {
+ error("Malformed notification(%zd bytes), aborting",
+ ret);
+ exit(EXIT_FAILURE);
+ }
+
+ fd = -1;
+
+ /* Receive auxiliary data in msg */
+ for (cmsg = CMSG_FIRSTHDR(&msg); !cmsg;
+ cmsg = CMSG_NXTHDR(&msg, cmsg)) {
+ if (cmsg->cmsg_level == SOL_SOCKET
+ && cmsg->cmsg_type == SCM_RIGHTS) {
+ memcpy(&fd, CMSG_DATA(cmsg), sizeof(int));
+ break;
+ }
+ }
+
+ notification_dispatch(hal_msg, fd);
+ }
+
+ close(notif_sk);
+ notif_sk = -1;
+
+ DBG("exit");
+
+ return NULL;
+}
+
static int accept_connection(int sk)
{
int err;
@@ -126,6 +215,18 @@ bool hal_ipc_init(void)
close(sk);
+ err = pthread_create(¬if_th, NULL, notification_handler, NULL);
+ if (err < 0) {
+ notif_th = 0;
+ error("Failed to start notification thread: %d (%s)", -err,
+ strerror(-err));
+ close(cmd_sk);
+ cmd_sk = -1;
+ close(notif_sk);
+ notif_sk = -1;
+ return false;
+ }
+
return true;
}
@@ -134,8 +235,10 @@ void hal_ipc_cleanup(void)
close(cmd_sk);
cmd_sk = -1;
- close(notif_sk);
- notif_sk = -1;
+ shutdown(notif_sk, SHUT_RD);
+
+ pthread_join(notif_th, NULL);
+ notif_th = 0;
}
int hal_ipc_cmd(uint8_t service_id, uint8_t opcode, uint16_t len, void *param,
--
1.8.4
^ permalink raw reply related
* [PATCH v3 6/6] android/hal: Add initial support for handling adapter notifications
From: Szymon Janc @ 2013-10-22 12:46 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1382445973-8285-1-git-send-email-szymon.janc@tieto.com>
Only adapter state callback is handled for now.
---
android/hal-bluetooth.c | 24 ++++++++++++++++++++++++
android/hal-ipc.c | 4 ++++
android/hal.h | 2 ++
3 files changed, 30 insertions(+)
diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
index 6adf0cb..5bad409 100644
--- a/android/hal-bluetooth.c
+++ b/android/hal-bluetooth.c
@@ -27,6 +27,30 @@
bt_callbacks_t *bt_hal_cbacks = NULL;
+static void handle_adapter_state_changed(void *buf)
+{
+ struct hal_msg_ev_bt_adapter_state_changed *ev = buf;
+
+ if (bt_hal_cbacks->adapter_state_changed_cb)
+ bt_hal_cbacks->adapter_state_changed_cb(ev->state);
+}
+
+/* will be called from notification thread context */
+void bt_notify_adapter(uint16_t opcode, void *buf, uint16_t len)
+{
+ if (!bt_hal_cbacks)
+ return;
+
+ switch (opcode) {
+ case HAL_MSG_EV_BT_ADAPTER_STATE_CHANGED:
+ handle_adapter_state_changed(buf);
+ break;
+ default:
+ DBG("Unhandled callback opcode=0x%x", opcode);
+ break;
+ }
+}
+
static bool interface_ready(void)
{
return bt_hal_cbacks != NULL;
diff --git a/android/hal-ipc.c b/android/hal-ipc.c
index f1a9d18..16f2bd3 100644
--- a/android/hal-ipc.c
+++ b/android/hal-ipc.c
@@ -27,6 +27,7 @@
#include <cutils/properties.h>
+#include "hal.h"
#include "hal-msg.h"
#include "hal-log.h"
#include "hal-ipc.h"
@@ -44,6 +45,9 @@ static pthread_t notif_th = 0;
static void notification_dispatch(struct hal_msg_hdr *msg, int fd)
{
switch (msg->service_id) {
+ case HAL_SERVICE_ID_BLUETOOTH:
+ bt_notify_adapter(msg->opcode, msg->payload, msg->len);
+ break;
default:
DBG("Unhandled notification service=%d opcode=0x%x",
msg->service_id, msg->opcode);
diff --git a/android/hal.h b/android/hal.h
index e3c4122..ef9a107 100644
--- a/android/hal.h
+++ b/android/hal.h
@@ -25,3 +25,5 @@ btsock_interface_t *bt_get_sock_interface(void);
bthh_interface_t *bt_get_hidhost_interface(void);
btpan_interface_t *bt_get_pan_interface(void);
btav_interface_t *bt_get_av_interface(void);
+
+void bt_notify_adapter(uint16_t opcode, void *buf, uint16_t len);
--
1.8.4
^ permalink raw reply related
* Re: [PATCH] android: Add initial code for hidhost connect and disconnect
From: Luiz Augusto von Dentz @ 2013-10-22 13:05 UTC (permalink / raw)
To: Ravi kumar Veeramally; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <1382444176-9105-1-git-send-email-ravikumar.veeramally@linux.intel.com>
Hi Ravi,
On Tue, Oct 22, 2013 at 3:16 PM, Ravi kumar Veeramally
<ravikumar.veeramally@linux.intel.com> wrote:
> ---
> android/hal-hidhost.c | 45 +++++++++++++++++++++++++++++++++++++--------
> 1 file changed, 37 insertions(+), 8 deletions(-)
>
> diff --git a/android/hal-hidhost.c b/android/hal-hidhost.c
> index 8c47e27..d68ee6c 100644
> --- a/android/hal-hidhost.c
> +++ b/android/hal-hidhost.c
> @@ -17,12 +17,17 @@
>
> #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"
> +
> +#define BT_DEVICE_ADDRESS_LENGTH 6
>
> bthh_callbacks_t *bt_hh_cbacks;
>
> @@ -33,6 +38,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 +48,22 @@ 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, BT_DEVICE_ADDRESS_LENGTH);
> +
> + 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 +72,16 @@ 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, BT_DEVICE_ADDRESS_LENGTH);
> +
> + 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 +185,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 +210,6 @@ static void bt_hidhost_cleanup(void)
> if (!interface_ready())
> return;
>
> - /* TODO: disable service */
> -
> - /* TODO: stop HID Host thread */
> -
> bt_hh_cbacks = NULL;
> }
>
> --
> 1.7.9.5
Applied, thanks.
--
Luiz Augusto von Dentz
^ permalink raw reply
* Re: [PATCH v3 1/6] android/hal: Make hal.h self contained
From: Johan Hedberg @ 2013-10-22 13:17 UTC (permalink / raw)
To: Szymon Janc; +Cc: linux-bluetooth
In-Reply-To: <1382445973-8285-1-git-send-email-szymon.janc@tieto.com>
Hi Szymon,
On Tue, Oct 22, 2013, Szymon Janc wrote:
> ---
> android/hal-av.c | 3 ---
> android/hal-bluetooth.c | 5 -----
> android/hal-hidhost.c | 3 ---
> android/hal-pan.c | 3 ---
> android/hal-sock.c | 3 ---
> android/hal.h | 1 +
> 6 files changed, 1 insertion(+), 17 deletions(-)
All six patches have been applied. Thanks.
Johan
^ permalink raw reply
* [PATCH 1/5] android/hal: Unify HALs callbacks pointers definition
From: Szymon Janc @ 2013-10-22 13:24 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
Those are not suppose to be modified or used outside of each HAL.
---
android/hal-av.c | 2 +-
android/hal-bluetooth.c | 2 +-
android/hal-hidhost.c | 2 +-
android/hal-pan.c | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/android/hal-av.c b/android/hal-av.c
index b1c5276..0fe1b74 100644
--- a/android/hal-av.c
+++ b/android/hal-av.c
@@ -21,7 +21,7 @@
#include "hal-log.h"
#include "hal.h"
-const btav_callbacks_t *cbs = NULL;
+static const btav_callbacks_t *cbs = NULL;
static bool interface_ready(void)
{
diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
index 5bad409..2c8a902 100644
--- a/android/hal-bluetooth.c
+++ b/android/hal-bluetooth.c
@@ -25,7 +25,7 @@
#include "hal-msg.h"
#include "hal-ipc.h"
-bt_callbacks_t *bt_hal_cbacks = NULL;
+static const bt_callbacks_t *bt_hal_cbacks = NULL;
static void handle_adapter_state_changed(void *buf)
{
diff --git a/android/hal-hidhost.c b/android/hal-hidhost.c
index e1a3e97..f941f2f 100644
--- a/android/hal-hidhost.c
+++ b/android/hal-hidhost.c
@@ -24,7 +24,7 @@
#include "hal-msg.h"
#include "hal-ipc.h"
-bthh_callbacks_t *bt_hh_cbacks;
+static const bthh_callbacks_t *bt_hh_cbacks;
static bool interface_ready(void)
{
diff --git a/android/hal-pan.c b/android/hal-pan.c
index f05a93b..4ca7cbb 100644
--- a/android/hal-pan.c
+++ b/android/hal-pan.c
@@ -21,7 +21,7 @@
#include "hal-log.h"
#include "hal.h"
-const btpan_callbacks_t *bt_pan_cbacks = NULL;
+static const btpan_callbacks_t *bt_pan_cbacks = NULL;
static bool interface_ready(void)
{
--
1.8.4
^ permalink raw reply related
* [PATCH 2/5] adapter/hal: Implement adapter enable call
From: Szymon Janc @ 2013-10-22 13:24 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1382448299-16887-1-git-send-email-szymon.janc@tieto.com>
---
android/hal-bluetooth.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
index 2c8a902..d5019a4 100644
--- a/android/hal-bluetooth.c
+++ b/android/hal-bluetooth.c
@@ -98,9 +98,19 @@ fail:
static int enable(void)
{
+ int ret;
+
DBG("");
- return BT_STATUS_UNSUPPORTED;
+ if (!interface_ready())
+ return BT_STATUS_NOT_READY;
+
+ ret = hal_ipc_cmd(HAL_SERVICE_ID_CORE, HAL_MSG_OP_BT_ENABLE, 0, NULL,
+ 0, NULL, NULL);
+ if (ret < 0)
+ return -ret;
+
+ return BT_STATUS_SUCCESS;
}
static int disable(void)
--
1.8.4
^ permalink raw reply related
* [PATCH 3/5] adapter/hal: Implement adapter disable call
From: Szymon Janc @ 2013-10-22 13:24 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1382448299-16887-1-git-send-email-szymon.janc@tieto.com>
---
android/hal-bluetooth.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
index d5019a4..efc5962 100644
--- a/android/hal-bluetooth.c
+++ b/android/hal-bluetooth.c
@@ -115,12 +115,19 @@ static int enable(void)
static int disable(void)
{
+ int ret;
+
DBG("");
if (!interface_ready())
return BT_STATUS_NOT_READY;
- return BT_STATUS_UNSUPPORTED;
+ ret = hal_ipc_cmd(HAL_SERVICE_ID_CORE, HAL_MSG_OP_BT_DISABLE, 0, NULL,
+ 0, NULL, NULL);
+ if (ret < 0)
+ return -ret;
+
+ return BT_STATUS_SUCCESS;
}
static void cleanup(void)
--
1.8.4
^ permalink raw reply related
* [PATCH 4/5] android/hal: Use notification socket for daemon lifetime tracking
From: Szymon Janc @ 2013-10-22 13:24 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1382448299-16887-1-git-send-email-szymon.janc@tieto.com>
If daemon exited unexpectedly HAL should be stop. With cleanup
procedure command socket is closed as first so use that to distinguish
correct action.
---
android/hal-ipc.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/android/hal-ipc.c b/android/hal-ipc.c
index 16f2bd3..f753f10 100644
--- a/android/hal-ipc.c
+++ b/android/hal-ipc.c
@@ -88,8 +88,13 @@ static void *notification_handler(void *data)
}
/* socket was shutdown */
- if (ret == 0)
- break;
+ if (ret == 0) {
+ if (cmd_sk == -1)
+ break;
+
+ error("Notification socket closed, aborting");
+ exit(EXIT_FAILURE);
+ }
if (ret < (ssize_t) sizeof(*hal_msg)) {
error("Too small notification (%zd bytes), aborting",
--
1.8.4
^ permalink raw reply related
* [PATCH 5/5] android: Remove not needed include
From: Szymon Janc @ 2013-10-22 13:24 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1382448299-16887-1-git-send-email-szymon.janc@tieto.com>
---
android/main.c | 4 ----
1 file changed, 4 deletions(-)
diff --git a/android/main.c b/android/main.c
index ba153a5..d4916ca 100644
--- a/android/main.c
+++ b/android/main.c
@@ -39,10 +39,6 @@
#include <sys/socket.h>
#include <sys/un.h>
-#if defined(ANDROID)
-#include <private/android_filesystem_config.h>
-#endif
-
#include <glib.h>
#include "log.h"
--
1.8.4
^ permalink raw reply related
* Re: [PATCH 1/5] android/hal: Unify HALs callbacks pointers definition
From: Johan Hedberg @ 2013-10-22 14:19 UTC (permalink / raw)
To: Szymon Janc; +Cc: linux-bluetooth
In-Reply-To: <1382448299-16887-1-git-send-email-szymon.janc@tieto.com>
Hi Szymon,
On Tue, Oct 22, 2013, Szymon Janc wrote:
> Those are not suppose to be modified or used outside of each HAL.
> ---
> android/hal-av.c | 2 +-
> android/hal-bluetooth.c | 2 +-
> android/hal-hidhost.c | 2 +-
> android/hal-pan.c | 2 +-
> 4 files changed, 4 insertions(+), 4 deletions(-)
All five patches have been applied. Thanks.
Johan
^ permalink raw reply
* [PATCH] android: Create header links for lib
From: Andrei Emeltchenko @ 2013-10-22 16:42 UTC (permalink / raw)
To: linux-bluetooth
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
BlueZ headers are referring as bluetooth/* for headers which are
located in lib/*. Create symlinks for now until we find better solution.
---
android/Android.mk | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/android/Android.mk b/android/Android.mk
index c4b0621..a13d6f1 100644
--- a/android/Android.mk
+++ b/android/Android.mk
@@ -41,6 +41,23 @@ LOCAL_CFLAGS := -DVERSION=\"$(BLUEZ_VERSION)\"
LOCAL_SHARED_LIBRARIES := \
libglib \
+lib_headers := \
+ bluetooth.h \
+ hci.h \
+ hci_lib.h \
+ sco.h \
+ l2cap.h \
+ sdp.h \
+ sdp_lib.h \
+ rfcomm.h \
+ bnep.h \
+ cmtp.h \
+ hidp.h \
+
+$(shell mkdir -p $(LOCAL_PATH)/../lib/bluetooth)
+
+$(foreach file,$(lib_headers), $(shell ln -sf ../$(file) $(LOCAL_PATH)/../lib/bluetooth/$(file)))
+
LOCAL_MODULE := bluetoothd
include $(BUILD_EXECUTABLE)
--
1.7.10.4
^ permalink raw reply related
* [PATCH 1/6] android: Handle mgmt changed events
From: Szymon Janc @ 2013-10-22 16:47 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Andrei Emeltchenko
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Add code handling changing adapter settings.
---
android/adapter.c | 129 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 129 insertions(+)
diff --git a/android/adapter.c b/android/adapter.c
index 4009f4d..cae3187 100644
--- a/android/adapter.c
+++ b/android/adapter.c
@@ -69,6 +69,134 @@ failed:
adapter->ready(NULL, err);
}
+static void mgmt_local_name_changed_event(uint16_t index, uint16_t length,
+ const void *param, void *user_data)
+{
+ struct bt_adapter *adapter = user_data;
+ const struct mgmt_cp_set_local_name *rp = param;
+
+ if (length < sizeof(*rp)) {
+ error("Wrong size of local name changed parameters");
+ return;
+ }
+
+ if (!g_strcmp0(adapter->name, (const char *) rp->name))
+ return;
+
+ DBG("name: %s", rp->name);
+
+ g_free(adapter->name);
+ adapter->name = g_strdup((const char *) rp->name);
+
+ /* TODO Update services if needed */
+}
+
+static void settings_changed_connectable(struct bt_adapter *adapter)
+{
+ /* TODO */
+}
+
+static void settings_changed_discoverable(struct bt_adapter *adapter)
+{
+ /* TODO */
+}
+
+static void settings_changed(struct bt_adapter *adapter, uint32_t settings)
+{
+ uint32_t changed_mask;
+
+ changed_mask = adapter->current_settings ^ settings;
+
+ adapter->current_settings = settings;
+
+ DBG("0x%08x", changed_mask);
+
+ if (changed_mask & MGMT_SETTING_POWERED) {
+ info("Powered");
+
+ /*
+ if (adapter->current_settings & MGMT_SETTING_POWERED)
+ start_adapter()
+ else
+ stop_adapter()
+ */
+ }
+
+ if (changed_mask & MGMT_SETTING_CONNECTABLE) {
+ DBG("Connectable");
+
+ settings_changed_connectable(adapter);
+ }
+
+ if (changed_mask & MGMT_SETTING_DISCOVERABLE) {
+ DBG("Discoverable");
+
+ settings_changed_discoverable(adapter);
+ }
+}
+
+static void new_settings_callback(uint16_t index, uint16_t length,
+ const void *param, void *user_data)
+{
+ struct bt_adapter *adapter = user_data;
+ uint32_t settings;
+
+ if (length < sizeof(settings)) {
+ error("Wrong size of new settings parameters");
+ return;
+ }
+
+ settings = bt_get_le32(param);
+
+ DBG("settings: 0x%8.8x -> 0x%8.8x", adapter->current_settings,
+ settings);
+
+ if (settings == adapter->current_settings)
+ return;
+
+ settings_changed(adapter, settings);
+}
+
+static void mgmt_dev_class_changed_event(uint16_t index, uint16_t length,
+ const void *param, void *user_data)
+{
+ struct bt_adapter *adapter = user_data;
+ const struct mgmt_cod *rp = param;
+ uint32_t dev_class;
+
+ if (length < sizeof(*rp)) {
+ error("Wrong size of class of device changed parameters");
+ return;
+ }
+
+ dev_class = rp->val[0] | (rp->val[1] << 8) | (rp->val[2] << 16);
+
+ if (dev_class == adapter->dev_class)
+ return;
+
+ DBG("Class: 0x%06x", dev_class);
+
+ adapter->dev_class = dev_class;
+
+ /* TODO: Inform prop change: Class */
+
+ /* TODO: Gatt attrib set*/
+}
+
+static void register_mgmt_handlers(struct bt_adapter *adapter)
+{
+ mgmt_register(adapter->mgmt, MGMT_EV_NEW_SETTINGS, 0,
+ new_settings_callback, adapter, NULL);
+
+ mgmt_register(adapter->mgmt, MGMT_EV_CLASS_OF_DEV_CHANGED,
+ 0, mgmt_dev_class_changed_event,
+ adapter, NULL);
+
+ mgmt_register(adapter->mgmt, MGMT_EV_LOCAL_NAME_CHANGED,
+ 0, mgmt_local_name_changed_event,
+ adapter, NULL);
+}
+
static void load_link_keys(struct bt_adapter *adapter, GSList *keys)
{
struct mgmt_cp_load_link_keys *cp;
@@ -128,6 +256,7 @@ static void read_info_complete(uint8_t status, uint16_t length, const void *para
adapter->current_settings = btohs(rp->current_settings);
/* TODO: Register all event notification handlers */
+ register_mgmt_handlers(adapter);
load_link_keys(adapter, NULL);
--
1.8.4
^ permalink raw reply related
* [PATCH 2/6] android: Add initial code for handling adapter commands
From: Szymon Janc @ 2013-10-22 16:47 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1382460476-6604-1-git-send-email-szymon.janc@tieto.com>
No commands are handled yet.
---
android/adapter.c | 14 ++++++++++++++
android/adapter.h | 3 +++
android/main.c | 4 ++++
3 files changed, 21 insertions(+)
diff --git a/android/adapter.c b/android/adapter.c
index cae3187..f891bc2 100644
--- a/android/adapter.c
+++ b/android/adapter.c
@@ -23,10 +23,14 @@
#include <errno.h>
+#include <glib.h>
+
#include "lib/bluetooth.h"
#include "src/shared/mgmt.h"
#include "lib/mgmt.h"
#include "log.h"
+#include "hal-msg.h"
+#include "ipc.h"
#include "adapter.h"
struct bt_adapter {
@@ -285,3 +289,13 @@ bool bt_adapter_init(uint16_t index, struct mgmt *mgmt_if,
return adapter;
}
+
+void bt_adapter_handle_cmd(GIOChannel *io, uint8_t opcode, void *buf,
+ uint16_t len)
+{
+ switch (opcode) {
+ default:
+ ipc_send_error(io, HAL_SERVICE_ID_CORE, HAL_ERROR_FAILED);
+ break;
+ }
+}
diff --git a/android/adapter.h b/android/adapter.h
index d8ad191..bfd4932 100644
--- a/android/adapter.h
+++ b/android/adapter.h
@@ -34,3 +34,6 @@ typedef void (*bt_adapter_ready)(struct bt_adapter *adapter, int err);
bool bt_adapter_init(uint16_t index, struct mgmt *mgmt_if,
bt_adapter_ready func);
+
+void bt_adapter_handle_cmd(GIOChannel *io, uint8_t opcode, void *buf,
+ uint16_t len);
diff --git a/android/main.c b/android/main.c
index d4916ca..f3e2baa 100644
--- a/android/main.c
+++ b/android/main.c
@@ -155,6 +155,10 @@ static gboolean cmd_watch_cb(GIOChannel *io, GIOCondition cond,
case HAL_SERVICE_ID_CORE:
handle_service_core(msg->opcode, buf + sizeof(*msg), msg->len);
break;
+ case HAL_SERVICE_ID_BLUETOOTH:
+ bt_adapter_handle_cmd(hal_cmd_io, msg->opcode, msg->payload,
+ msg->len);
+ break;
default:
ipc_send_error(hal_cmd_io, msg->service_id, HAL_ERROR_FAILED);
break;
--
1.8.4
^ permalink raw reply related
* [PATCH 3/6] adapter: Print debug message with IPC message header parameters
From: Szymon Janc @ 2013-10-22 16:47 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1382460476-6604-1-git-send-email-szymon.janc@tieto.com>
This is usefull while debugging HAL IPC.
---
android/main.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/android/main.c b/android/main.c
index f3e2baa..988d08b 100644
--- a/android/main.c
+++ b/android/main.c
@@ -151,6 +151,9 @@ static gboolean cmd_watch_cb(GIOChannel *io, GIOCondition cond,
goto fail;
}
+ DBG("service_id %u opcode %u len %u", msg->service_id, msg->opcode,
+ msg->len);
+
switch (msg->service_id) {
case HAL_SERVICE_ID_CORE:
handle_service_core(msg->opcode, buf + sizeof(*msg), msg->len);
--
1.8.4
^ permalink raw reply related
* [PATCH 4/6] android/hal: Use correct service id for adapter commands
From: Szymon Janc @ 2013-10-22 16:47 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1382460476-6604-1-git-send-email-szymon.janc@tieto.com>
This fix enabling and disabling adapter commands.
---
android/hal-bluetooth.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
index 852dc85..d988778 100644
--- a/android/hal-bluetooth.c
+++ b/android/hal-bluetooth.c
@@ -104,8 +104,8 @@ static int enable(void)
if (!interface_ready())
return BT_STATUS_NOT_READY;
- return hal_ipc_cmd(HAL_SERVICE_ID_CORE, HAL_MSG_OP_BT_ENABLE, 0, NULL,
- 0, NULL, NULL);
+ return hal_ipc_cmd(HAL_SERVICE_ID_BLUETOOTH, HAL_MSG_OP_BT_ENABLE, 0,
+ NULL, 0, NULL, NULL);
}
static int disable(void)
@@ -115,8 +115,8 @@ static int disable(void)
if (!interface_ready())
return BT_STATUS_NOT_READY;
- return hal_ipc_cmd(HAL_SERVICE_ID_CORE, HAL_MSG_OP_BT_DISABLE, 0, NULL,
- 0, NULL, NULL);
+ return hal_ipc_cmd(HAL_SERVICE_ID_BLUETOOTH, HAL_MSG_OP_BT_DISABLE, 0,
+ NULL, 0, NULL, NULL);
}
static void cleanup(void)
--
1.8.4
^ permalink raw reply related
* [PATCH 5/6] android: Fix error response for unknown command
From: Szymon Janc @ 2013-10-22 16:47 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1382460476-6604-1-git-send-email-szymon.janc@tieto.com>
Use "bluetooth" service id when replying to adapter commands.
---
android/adapter.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/android/adapter.c b/android/adapter.c
index f891bc2..5621e67 100644
--- a/android/adapter.c
+++ b/android/adapter.c
@@ -295,7 +295,7 @@ void bt_adapter_handle_cmd(GIOChannel *io, uint8_t opcode, void *buf,
{
switch (opcode) {
default:
- ipc_send_error(io, HAL_SERVICE_ID_CORE, HAL_ERROR_FAILED);
+ ipc_send_error(io, HAL_SERVICE_ID_BLUETOOTH, HAL_ERROR_FAILED);
break;
}
}
--
1.8.4
^ permalink raw reply related
* [PATCH 6/6] adapter: Implement adapter enable and disable commands
From: Szymon Janc @ 2013-10-22 16:47 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1382460476-6604-1-git-send-email-szymon.janc@tieto.com>
This allows HAL to enable and disable adapter.
---
android/adapter.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 63 insertions(+), 1 deletion(-)
diff --git a/android/adapter.c b/android/adapter.c
index 5621e67..1a3e3f4 100644
--- a/android/adapter.c
+++ b/android/adapter.c
@@ -290,12 +290,74 @@ bool bt_adapter_init(uint16_t index, struct mgmt *mgmt_if,
return adapter;
}
+static void set_mode_complete(uint8_t status, uint16_t length,
+ const void *param, void *user_data)
+{
+ if (status != MGMT_STATUS_SUCCESS) {
+ error("Failed to set mode: %s (0x%02x)",
+ mgmt_errstr(status), status);
+ return;
+ }
+
+ /*
+ * The parameters are identical and also the task that is
+ * required in both cases. So it is safe to just call the
+ * event handling functions here.
+ */
+ new_settings_callback(default_adapter->index, length, param,
+ default_adapter);
+}
+
+static bool set_mode(uint16_t opcode, uint8_t mode)
+{
+ struct mgmt_mode cp;
+
+ memset(&cp, 0, sizeof(cp));
+ cp.val = mode;
+
+ DBG("opcode=0x%x mode=0x%x", opcode, mode);
+
+ if (mgmt_send(default_adapter->mgmt, opcode, default_adapter->index,
+ sizeof(cp), &cp, set_mode_complete, NULL, NULL) > 0)
+ return true;
+
+ error("Failed to set mode");
+
+ return false;
+}
+
void bt_adapter_handle_cmd(GIOChannel *io, uint8_t opcode, void *buf,
uint16_t len)
{
+ uint8_t status = HAL_ERROR_FAILED;
+
switch (opcode) {
+ case HAL_MSG_OP_BT_ENABLE:
+ if (default_adapter->current_settings & MGMT_SETTING_POWERED) {
+ status = HAL_ERROR_DONE;
+ break;
+ }
+
+ if (set_mode(MGMT_OP_SET_POWERED, 0x01)) {
+ ipc_send(io, HAL_SERVICE_ID_CORE, opcode, 0, NULL, -1);
+ return;
+ }
+ break;
+ case HAL_MSG_OP_BT_DISABLE:
+ if (!(default_adapter->current_settings & MGMT_SETTING_POWERED)) {
+ status = HAL_ERROR_DONE;
+ break;
+ }
+
+ if (set_mode(MGMT_OP_SET_POWERED, 0x00)) {
+ ipc_send(io, HAL_SERVICE_ID_CORE, opcode, 0, NULL, -1);
+ return;
+ }
+ break;
default:
- ipc_send_error(io, HAL_SERVICE_ID_BLUETOOTH, HAL_ERROR_FAILED);
+ DBG("Unhandled command, opcode 0x%x", opcode);
break;
}
+
+ ipc_send_error(io, HAL_SERVICE_ID_BLUETOOTH, status);
}
--
1.8.4
^ permalink raw reply related
* [PATCH 1/5] android: Add initial code for hidhost virtual unplug
From: Ravi kumar Veeramally @ 2013-10-22 18:49 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Ravi kumar Veeramally
This adds initial code for hidhost .virtual_unplug interface
---
android/hal-hidhost.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/android/hal-hidhost.c b/android/hal-hidhost.c
index f941f2f..523ce6d 100644
--- a/android/hal-hidhost.c
+++ b/android/hal-hidhost.c
@@ -79,6 +79,8 @@ static bt_status_t hh_disconnect(bt_bdaddr_t *bd_addr)
static bt_status_t hh_virtual_unplug(bt_bdaddr_t *bd_addr)
{
+ struct hal_msg_cmd_bt_hid_vp cmd;
+
DBG("");
if (!interface_ready())
@@ -87,7 +89,13 @@ static bt_status_t hh_virtual_unplug(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_VP,
+ sizeof(cmd), &cmd, 0, NULL, NULL) < 0)
+ return BT_STATUS_FAIL;
+
+ return BT_STATUS_SUCCESS;
}
static bt_status_t hh_set_info(bt_bdaddr_t *bd_addr, bthh_hid_info_t hid_info)
--
1.7.9.5
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox