From: Szymon Janc <szymon.janc@tieto.com>
To: linux-bluetooth@vger.kernel.org
Cc: Szymon Janc <szymon.janc@tieto.com>
Subject: [PATCH 2/2] android/hal: Add initial support for handling adapter notifications
Date: Tue, 22 Oct 2013 12:59:09 +0200 [thread overview]
Message-ID: <1382439549-18281-2-git-send-email-szymon.janc@tieto.com> (raw)
In-Reply-To: <1382439549-18281-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 | 6 ++++++
android/hal.h | 2 ++
3 files changed, 32 insertions(+)
diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
index 5b07070..37edb41 100644
--- a/android/hal-bluetooth.c
+++ b/android/hal-bluetooth.c
@@ -32,6 +32,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, int fd)
+{
+ 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 ef58a7c..ccdcb9f 100644
--- a/android/hal-ipc.c
+++ b/android/hal-ipc.c
@@ -27,6 +27,9 @@
#include <cutils/properties.h>
+#include <hardware/bluetooth.h>
+#include "hal.h"
+
#include "hal-msg.h"
#include "hal-log.h"
#include "hal-ipc.h"
@@ -44,6 +47,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 + 1, msg->len, fd);
+ 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 d984336..889fce6 100644
--- a/android/hal.h
+++ b/android/hal.h
@@ -24,3 +24,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, int fd);
--
1.8.4
prev parent reply other threads:[~2013-10-22 10:59 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-22 10:59 [PATCH 1/2] android/hal: Add initial code for notification handling Szymon Janc
2013-10-22 10:59 ` Szymon Janc [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1382439549-18281-2-git-send-email-szymon.janc@tieto.com \
--to=szymon.janc@tieto.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox