* [PATCH v2 1/3] android: Rename a2dp HAL related IPC API to match service name
From: Szymon Janc @ 2013-11-07 15:32 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
Use 'Android HAL name' string from IPC doc as base for names.
---
v2:
- rebased
- minor style fixes
android/a2dp.c | 9 +++++----
android/hal-av.c | 16 ++++++++--------
android/hal-msg.h | 18 ++++++++++--------
3 files changed, 23 insertions(+), 20 deletions(-)
diff --git a/android/a2dp.c b/android/a2dp.c
index 0d3bfc5..052f4f3 100644
--- a/android/a2dp.c
+++ b/android/a2dp.c
@@ -40,14 +40,15 @@
static int notification_sk = -1;
-static uint8_t bt_a2dp_connect(struct hal_cmd_av_connect *cmd, uint16_t len)
+static uint8_t bt_a2dp_connect(struct hal_cmd_a2dp_connect *cmd, uint16_t len)
{
DBG("Not Implemented");
return HAL_STATUS_FAILED;
}
-static uint8_t bt_a2dp_disconnect(struct hal_cmd_av_connect *cmd, uint16_t len)
+static uint8_t bt_a2dp_disconnect(struct hal_cmd_a2dp_connect *cmd,
+ uint16_t len)
{
DBG("Not Implemented");
@@ -59,10 +60,10 @@ void bt_a2dp_handle_cmd(int sk, uint8_t opcode, void *buf, uint16_t len)
uint8_t status = HAL_STATUS_FAILED;
switch (opcode) {
- case HAL_OP_AV_CONNECT:
+ case HAL_OP_A2DP_CONNECT:
status = bt_a2dp_connect(buf, len);
break;
- case HAL_OP_AV_DISCONNECT:
+ case HAL_OP_A2DP_DISCONNECT:
status = bt_a2dp_disconnect(buf, len);
break;
default:
diff --git a/android/hal-av.c b/android/hal-av.c
index 9e1b3df..2ebf801 100644
--- a/android/hal-av.c
+++ b/android/hal-av.c
@@ -33,7 +33,7 @@ static bool interface_ready(void)
static void handle_connection_state(void *buf)
{
- struct hal_ev_av_connection_state *ev = buf;
+ struct hal_ev_a2dp_connection_state *ev = buf;
if (cbs->connection_state_cb)
cbs->connection_state_cb(ev->state,
@@ -42,7 +42,7 @@ static void handle_connection_state(void *buf)
static void handle_audio_state(void *buf)
{
- struct hal_ev_av_audio_state *ev = buf;
+ struct hal_ev_a2dp_audio_state *ev = buf;
if (cbs->audio_state_cb)
cbs->audio_state_cb(ev->state, (bt_bdaddr_t *)(ev->bdaddr));
@@ -55,10 +55,10 @@ void bt_notify_av(uint16_t opcode, void *buf, uint16_t len)
return;
switch (opcode) {
- case HAL_EV_AV_CONNECTION_STATE:
+ case HAL_EV_A2DP_CONNECTION_STATE:
handle_connection_state(buf);
break;
- case HAL_EV_AV_AUDIO_STATE:
+ case HAL_EV_A2DP_AUDIO_STATE:
handle_audio_state(buf);
break;
default:
@@ -69,7 +69,7 @@ void bt_notify_av(uint16_t opcode, void *buf, uint16_t len)
static bt_status_t av_connect(bt_bdaddr_t *bd_addr)
{
- struct hal_cmd_av_connect cmd;
+ struct hal_cmd_a2dp_connect cmd;
DBG("");
@@ -78,13 +78,13 @@ static bt_status_t av_connect(bt_bdaddr_t *bd_addr)
memcpy(cmd.bdaddr, bd_addr, sizeof(cmd.bdaddr));
- return hal_ipc_cmd(HAL_SERVICE_ID_A2DP, HAL_OP_AV_CONNECT,
+ return hal_ipc_cmd(HAL_SERVICE_ID_A2DP, HAL_OP_A2DP_CONNECT,
sizeof(cmd), &cmd, NULL, NULL, NULL);
}
static bt_status_t av_disconnect(bt_bdaddr_t *bd_addr)
{
- struct hal_cmd_av_disconnect cmd;
+ struct hal_cmd_a2dp_disconnect cmd;
DBG("");
@@ -93,7 +93,7 @@ static bt_status_t av_disconnect(bt_bdaddr_t *bd_addr)
memcpy(cmd.bdaddr, bd_addr, sizeof(cmd.bdaddr));
- return hal_ipc_cmd(HAL_SERVICE_ID_A2DP, HAL_OP_AV_DISCONNECT,
+ return hal_ipc_cmd(HAL_SERVICE_ID_A2DP, HAL_OP_A2DP_DISCONNECT,
sizeof(cmd), &cmd, NULL, NULL, NULL);
}
diff --git a/android/hal-msg.h b/android/hal-msg.h
index a5e5c76..e1feb19 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -301,13 +301,15 @@ struct hal_cmd_hid_send_data {
uint8_t bdaddr[6];
} __attribute__((packed));
-#define HAL_OP_AV_CONNECT 0x01
-struct hal_cmd_av_connect {
+/* a2dp HAL API */
+
+#define HAL_OP_A2DP_CONNECT 0x01
+struct hal_cmd_a2dp_connect {
uint8_t bdaddr[6];
} __attribute__((packed));
-#define HAL_OP_AV_DISCONNECT 0x02
-struct hal_cmd_av_disconnect {
+#define HAL_OP_A2DP_DISCONNECT 0x02
+struct hal_cmd_a2dp_disconnect {
uint8_t bdaddr[6];
} __attribute__((packed));
@@ -475,14 +477,14 @@ struct hal_ev_hid_get_report {
uint8_t data[0];
} __attribute__((packed));
-#define HAL_EV_AV_CONNECTION_STATE 0x81
-struct hal_ev_av_connection_state {
+#define HAL_EV_A2DP_CONNECTION_STATE 0x81
+struct hal_ev_a2dp_connection_state {
uint8_t state;
uint8_t bdaddr[6];
} __attribute__((packed));
-#define HAL_EV_AV_AUDIO_STATE 0x82
-struct hal_ev_av_audio_state {
+#define HAL_EV_A2DP_AUDIO_STATE 0x82
+struct hal_ev_a2dp_audio_state {
uint8_t state;
uint8_t bdaddr[6];
} __attribute__((packed));
--
1.8.4.2
^ permalink raw reply related
* [PATCH v2] android: Add set/get for discovery timeout
From: Lukasz Rymanowski @ 2013-11-07 15:26 UTC (permalink / raw)
To: linux-bluetooth; +Cc: johan.hedberg, szymon.janc, Lukasz Rymanowski
Android handles discoverable timeout in Settings app, however still
expects BT stack to maintain this value so we should do it as well.
Otherwise we will get some unexpected behaviour.
For now we keep discovery_timeout only during runtime, but we need to move
it to some local storage once we will have it.
Note: That since Android Settings up handles timer there is no reason to
use discovery timer we have in kernel.
---
android/adapter.c | 38 +++++++++++++++++++++++++++++++++++---
1 file changed, 35 insertions(+), 3 deletions(-)
diff --git a/android/adapter.c b/android/adapter.c
index 2e8d2df..d59778b 100644
--- a/android/adapter.c
+++ b/android/adapter.c
@@ -48,6 +48,9 @@
/* Default to DisplayYesNo */
#define DEFAULT_IO_CAPABILITY 0x01
+/* Default discoverable timeout 120sec as in Android */
+#define DEFAULT_DISCOVERABLE_TIMEOUT 120
+
#define BASELEN_PROP_CHANGED sizeof(struct hal_ev_adapter_props_changed) \
+ (sizeof(struct hal_property))
@@ -70,6 +73,7 @@ struct bt_adapter {
uint32_t current_settings;
bool discovering;
+ uint32_t discoverable_timeout;
};
struct browse_req {
@@ -1101,6 +1105,17 @@ static uint8_t set_adapter_name(uint8_t *name, uint16_t len)
return HAL_STATUS_FAILED;
}
+static uint8_t set_discoverable_timeout(uint8_t *timeout)
+{
+ /* Android handles discoverable timeout in Settings app.
+ * There is no need to use kernel feature for that.
+ * Just need to store this value here */
+
+ /* TODO: This should be in some storage */
+ memcpy(&adapter->discoverable_timeout, timeout, sizeof(uint32_t));
+
+ return HAL_STATUS_SUCCESS;
+}
static void read_info_complete(uint8_t status, uint16_t length, const void *param,
void *user_data)
{
@@ -1169,6 +1184,8 @@ void bt_adapter_init(uint16_t index, struct mgmt *mgmt, bt_adapter_ready cb)
adapter->index = index;
adapter->discovering = false;
adapter->ready = cb;
+ /* TODO: Read it from some storage */
+ adapter->discoverable_timeout = DEFAULT_DISCOVERABLE_TIMEOUT;
if (mgmt_send(mgmt, MGMT_OP_READ_INFO, index, 0, NULL,
read_info_complete, NULL, NULL) > 0)
@@ -1286,11 +1303,25 @@ static bool get_devices(void)
static bool get_discoverable_timeout(void)
{
- DBG("Not implemented");
+ struct hal_ev_adapter_props_changed *ev;
+ int len = sizeof(uint32_t);
+ uint8_t buf[BASELEN_PROP_CHANGED + len];
- /* TODO: Add implementation */
- return false;
+ memset(buf, 0, sizeof(buf));
+ ev = (void *) buf;
+
+ ev->num_props = 1;
+ ev->status = HAL_STATUS_SUCCESS;
+
+ ev->props[0].type = HAL_PROP_ADAPTER_DISC_TIMEOUT;
+ ev->props[0].len = len;
+ memcpy(&ev->props[0].val, &adapter->discoverable_timeout, sizeof(uint32_t));
+
+ ipc_send(notification_sk, HAL_SERVICE_ID_BLUETOOTH,
+ HAL_EV_ADAPTER_PROPS_CHANGED, sizeof(buf), ev, -1);
+
+ return true;
}
static bool get_property(void *buf, uint16_t len)
@@ -1441,6 +1472,7 @@ static uint8_t set_property(void *buf, uint16_t len)
case HAL_PROP_ADAPTER_NAME:
return set_adapter_name(cmd->val, cmd->len);
case HAL_PROP_ADAPTER_DISC_TIMEOUT:
+ return set_discoverable_timeout(cmd->val);
default:
DBG("Unhandled property type 0x%x", cmd->type);
return HAL_STATUS_FAILED;
--
1.8.4
^ permalink raw reply related
* [PATCH] android/ipc: Fix crash when sending file descriptor
From: Andrei Emeltchenko @ 2013-11-07 15:25 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <20131107151146.GE23283@x220.p-661hnu-f1>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Since CMSG_FIRSTHDR is defined as shown below:
((size_t) (mhdr)->msg_controllen >= sizeof (struct cmsghdr) \
? (struct cmsghdr *) (mhdr)->msg_control : (struct cmsghdr *) 0)
it return NULL if msg_controllen is not defined. Accessing
that pointer result in daemon crash.
---
android/ipc.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/android/ipc.c b/android/ipc.c
index 9a8657d..729f157 100644
--- a/android/ipc.c
+++ b/android/ipc.c
@@ -62,6 +62,9 @@ void ipc_send(int sk, uint8_t service_id, uint8_t opcode, uint16_t len,
msg.msg_iovlen = 2;
if (fd >= 0) {
+ msg.msg_control = cmsgbuf;
+ msg.msg_controllen = sizeof(cmsgbuf);
+
cmsg = CMSG_FIRSTHDR(&msg);
cmsg->cmsg_level = SOL_SOCKET;
cmsg->cmsg_type = SCM_RIGHTS;
@@ -69,9 +72,6 @@ void ipc_send(int sk, uint8_t service_id, uint8_t opcode, uint16_t len,
/* Initialize the payload */
memcpy(CMSG_DATA(cmsg), &fd, sizeof(int));
-
- msg.msg_control = cmsgbuf;
- msg.msg_controllen = sizeof(cmsgbuf);
}
if (sendmsg(sk, &msg, 0) < 0) {
--
1.7.10.4
^ permalink raw reply related
* Re: [PATCH] android/ipc: Fix receiving file descriptors
From: Johan Hedberg @ 2013-11-07 15:15 UTC (permalink / raw)
To: Andrei Emeltchenko; +Cc: linux-bluetooth
In-Reply-To: <1383835898-30110-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
Hi Andrei,
On Thu, Nov 07, 2013, Andrei Emeltchenko wrote:
> It does make sense iterate over !NULL controll headers. This fixes
> the bug that file descriptors cannot be send over IPC.
> ---
> android/hal-ipc.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Applied. Thanks.
Johan
^ permalink raw reply
* Re: [PATCH] android/ipc: Fix crash when sending file descriptor
From: Johan Hedberg @ 2013-11-07 15:11 UTC (permalink / raw)
To: Andrei Emeltchenko; +Cc: linux-bluetooth
In-Reply-To: <1383831409-16900-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
Hi Andrei,
On Thu, Nov 07, 2013, Andrei Emeltchenko wrote:
> Since CMSG_FIRSTHDR is defined as shown below:
>
> ((size_t) (mhdr)->msg_controllen >= sizeof (struct cmsghdr) \
> ? (struct cmsghdr *) (mhdr)->msg_control : (struct cmsghdr *) 0)
>
> it return NULL if msg_controllen is not defined. Accessing
> that pointer result in daemon crash.
> ---
> android/ipc.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
This one needs to be rebased. It doesn't apply.
Johan
^ permalink raw reply
* Re: [PATCH 1/3] android: Rename a2dp HAL related IPC API to match service name
From: Johan Hedberg @ 2013-11-07 15:11 UTC (permalink / raw)
To: Szymon Janc; +Cc: linux-bluetooth
In-Reply-To: <1383820057-15728-1-git-send-email-szymon.janc@tieto.com>
Hi Szymon,
On Thu, Nov 07, 2013, Szymon Janc wrote:
> Use 'Android HAL name' string from IPC doc as base for names.
> ---
> android/a2dp.c | 10 ++++++----
> android/hal-av.c | 16 ++++++++--------
> android/hal-msg.h | 18 ++++++++++--------
> 3 files changed, 24 insertions(+), 20 deletions(-)
Seems like this one (maybe others in this set too) needs rebasing as it
doesn't apply right now.
Johan
^ permalink raw reply
* Re: [PATCH 2/2] android: Add set/get for discovery timeout
From: Johan Hedberg @ 2013-11-07 15:10 UTC (permalink / raw)
To: Lukasz Rymanowski; +Cc: linux-bluetooth, szymon.janc
In-Reply-To: <1383815991-18523-2-git-send-email-lukasz.rymanowski@tieto.com>
Hi Lukasz,
On Thu, Nov 07, 2013, Lukasz Rymanowski wrote:
> Android handles discoverable timeout in Settings app, however still
> expects BT stack to maintain this value so we should do it as well.
> Otherwise we will get some unexpected behaviour.
> For now we keep discovery_timeout only during runtime, but we need to move
> it to some local storage once we will have it.
>
> Note: That since Android Settings up handles timer there is no reason to
> use discovery timer we have in kernel.
> ---
> android/adapter.c | 38 +++++++++++++++++++++++++++++++++++---
> 1 file changed, 35 insertions(+), 3 deletions(-)
You'll need to rebase this one due to the patches from Szymon that were
recently applied (right now it applies but doesn't compile).
Johan
^ permalink raw reply
* Re: [PATCH 1/2 v2] android: Use BASELEN define for property changed
From: Johan Hedberg @ 2013-11-07 15:09 UTC (permalink / raw)
To: Lukasz Rymanowski; +Cc: linux-bluetooth, szymon.janc
In-Reply-To: <1383815991-18523-1-git-send-email-lukasz.rymanowski@tieto.com>
Hi Lukasz,
On Thu, Nov 07, 2013, Lukasz Rymanowski wrote:
> ---
> android/adapter.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
This patch has been applied. Thanks.
Johan
^ permalink raw reply
* Re: [PATCH 1/4] android: Make IPC helpers accept file descriptor
From: Johan Hedberg @ 2013-11-07 15:06 UTC (permalink / raw)
To: Szymon Janc; +Cc: linux-bluetooth
In-Reply-To: <1383815437-521-1-git-send-email-szymon.janc@tieto.com>
Hi Szymon,
On Thu, Nov 07, 2013, Szymon Janc wrote:
> There is no need to pass GIOChannel as writes are done immediately.
> ---
> android/a2dp.c | 3 ++-
> android/adapter.c | 71 ++++++++++++++++++++++++++++++++-----------------------
> android/hid.c | 15 ++++++++----
> android/ipc.c | 10 ++++----
> android/ipc.h | 4 ++--
> android/main.c | 20 +++++++++-------
> android/pan.c | 3 ++-
> android/socket.c | 7 +++---
> 8 files changed, 77 insertions(+), 56 deletions(-)
All four patches have been applied. Thanks.
Johan
^ permalink raw reply
* [PATCH] android/ipc: Fix receiving file descriptors
From: Andrei Emeltchenko @ 2013-11-07 14:51 UTC (permalink / raw)
To: linux-bluetooth
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
It does make sense iterate over !NULL controll headers. This fixes
the bug that file descriptors cannot be send over IPC.
---
android/hal-ipc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/android/hal-ipc.c b/android/hal-ipc.c
index 14be69b..e4b0681 100644
--- a/android/hal-ipc.c
+++ b/android/hal-ipc.c
@@ -373,7 +373,7 @@ int hal_ipc_cmd(uint8_t service_id, uint8_t opcode, uint16_t len, void *param,
*fd = -1;
- for (cmsg = CMSG_FIRSTHDR(&msg); !cmsg;
+ for (cmsg = CMSG_FIRSTHDR(&msg); cmsg;
cmsg = CMSG_NXTHDR(&msg, cmsg)) {
if (cmsg->cmsg_level == SOL_SOCKET
&& cmsg->cmsg_type == SCM_RIGHTS) {
--
1.7.10.4
^ permalink raw reply related
* [PATCH] android/ipc: Fix crash when sending file descriptor
From: Andrei Emeltchenko @ 2013-11-07 13:36 UTC (permalink / raw)
To: linux-bluetooth
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Since CMSG_FIRSTHDR is defined as shown below:
((size_t) (mhdr)->msg_controllen >= sizeof (struct cmsghdr) \
? (struct cmsghdr *) (mhdr)->msg_control : (struct cmsghdr *) 0)
it return NULL if msg_controllen is not defined. Accessing
that pointer result in daemon crash.
---
android/ipc.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/android/ipc.c b/android/ipc.c
index e672bf8..943c196 100644
--- a/android/ipc.c
+++ b/android/ipc.c
@@ -64,6 +64,9 @@ void ipc_send(GIOChannel *io, uint8_t service_id, uint8_t opcode, uint16_t len,
msg.msg_iovlen = 2;
if (fd >= 0) {
+ msg.msg_control = cmsgbuf;
+ msg.msg_controllen = sizeof(cmsgbuf);
+
cmsg = CMSG_FIRSTHDR(&msg);
cmsg->cmsg_level = SOL_SOCKET;
cmsg->cmsg_type = SCM_RIGHTS;
@@ -71,9 +74,6 @@ void ipc_send(GIOChannel *io, uint8_t service_id, uint8_t opcode, uint16_t len,
/* Initialize the payload */
memcpy(CMSG_DATA(cmsg), &fd, sizeof(int));
-
- msg.msg_control = cmsgbuf;
- msg.msg_controllen = sizeof(cmsgbuf);
}
if (sendmsg(g_io_channel_unix_get_fd(io), &msg, 0) < 0) {
--
1.7.10.4
^ permalink raw reply related
* [PATCH 3/3] android/hal: Use a2dp instead of av in a2dp HAL
From: Szymon Janc @ 2013-11-07 10:27 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1383820057-15728-1-git-send-email-szymon.janc@tieto.com>
Match functions names to HAL name. Where not needed av prefix is
removed.
---
android/hal-a2dp.c | 20 ++++++++++----------
android/hal-bluetooth.c | 2 +-
android/hal-ipc.c | 2 +-
android/hal.h | 4 ++--
4 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/android/hal-a2dp.c b/android/hal-a2dp.c
index 2ebf801..f0c301e 100644
--- a/android/hal-a2dp.c
+++ b/android/hal-a2dp.c
@@ -49,7 +49,7 @@ static void handle_audio_state(void *buf)
}
/* will be called from notification thread context */
-void bt_notify_av(uint16_t opcode, void *buf, uint16_t len)
+void bt_notify_a2dp(uint16_t opcode, void *buf, uint16_t len)
{
if (!interface_ready())
return;
@@ -67,7 +67,7 @@ void bt_notify_av(uint16_t opcode, void *buf, uint16_t len)
}
}
-static bt_status_t av_connect(bt_bdaddr_t *bd_addr)
+static bt_status_t a2dp_connect(bt_bdaddr_t *bd_addr)
{
struct hal_cmd_a2dp_connect cmd;
@@ -82,7 +82,7 @@ static bt_status_t av_connect(bt_bdaddr_t *bd_addr)
sizeof(cmd), &cmd, NULL, NULL, NULL);
}
-static bt_status_t av_disconnect(bt_bdaddr_t *bd_addr)
+static bt_status_t disconnect(bt_bdaddr_t *bd_addr)
{
struct hal_cmd_a2dp_disconnect cmd;
@@ -97,7 +97,7 @@ static bt_status_t av_disconnect(bt_bdaddr_t *bd_addr)
sizeof(cmd), &cmd, NULL, NULL, NULL);
}
-static bt_status_t av_init(btav_callbacks_t *callbacks)
+static bt_status_t init(btav_callbacks_t *callbacks)
{
DBG("");
@@ -108,7 +108,7 @@ static bt_status_t av_init(btav_callbacks_t *callbacks)
return BT_STATUS_SUCCESS;
}
-static void av_cleanup()
+static void cleanup()
{
DBG("");
@@ -122,13 +122,13 @@ static void av_cleanup()
static btav_interface_t iface = {
.size = sizeof(iface),
- .init = av_init,
- .connect = av_connect,
- .disconnect = av_disconnect,
- .cleanup = av_cleanup
+ .init = init,
+ .connect = a2dp_connect,
+ .disconnect = disconnect,
+ .cleanup = cleanup
};
-btav_interface_t *bt_get_av_interface()
+btav_interface_t *bt_get_a2dp_interface()
{
return &iface;
}
diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
index 88c7b99..3e5d41f 100644
--- a/android/hal-bluetooth.c
+++ b/android/hal-bluetooth.c
@@ -654,7 +654,7 @@ static const void *get_profile_interface(const char *profile_id)
return bt_get_pan_interface();
if (!strcmp(profile_id, BT_PROFILE_ADVANCED_AUDIO_ID))
- return bt_get_av_interface();
+ return bt_get_a2dp_interface();
return NULL;
}
diff --git a/android/hal-ipc.c b/android/hal-ipc.c
index 14be69b..1d33374 100644
--- a/android/hal-ipc.c
+++ b/android/hal-ipc.c
@@ -53,7 +53,7 @@ static void notification_dispatch(struct hal_hdr *msg, int fd)
bt_notify_hh(msg->opcode, msg->payload, msg->len);
break;
case HAL_SERVICE_ID_A2DP:
- bt_notify_av(msg->opcode, msg->payload, msg->len);
+ bt_notify_a2dp(msg->opcode, msg->payload, msg->len);
break;
default:
DBG("Unhandled notification service=%d opcode=0x%x",
diff --git a/android/hal.h b/android/hal.h
index 5d6a93e..f47ec2a 100644
--- a/android/hal.h
+++ b/android/hal.h
@@ -24,10 +24,10 @@
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);
+btav_interface_t *bt_get_a2dp_interface(void);
void bt_notify_adapter(uint16_t opcode, void *buf, uint16_t len);
void bt_thread_associate(void);
void bt_thread_disassociate(void);
void bt_notify_hh(uint16_t opcode, void *buf, uint16_t len);
-void bt_notify_av(uint16_t opcode, void *buf, uint16_t len);
+void bt_notify_a2dp(uint16_t opcode, void *buf, uint16_t len);
--
1.8.4.2
^ permalink raw reply related
* [PATCH 2/3] android/hal: Rename hal-av.c to hal-a2dp.c
From: Szymon Janc @ 2013-11-07 10:27 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1383820057-15728-1-git-send-email-szymon.janc@tieto.com>
Name of HAL implementation will match Android HAL name. This will make
code navigation easier as daemon part and HAL library implementation
will be in foo.c and hal-foo.c respectively.
---
android/Android.mk | 2 +-
android/Makefile.am | 4 +-
android/hal-a2dp.c | 134 ++++++++++++++++++++++++++++++++++++++++++++++++++++
android/hal-av.c | 134 ----------------------------------------------------
4 files changed, 137 insertions(+), 137 deletions(-)
create mode 100644 android/hal-a2dp.c
delete mode 100644 android/hal-av.c
diff --git a/android/Android.mk b/android/Android.mk
index d76dfaf..f9bf070 100644
--- a/android/Android.mk
+++ b/android/Android.mk
@@ -86,7 +86,7 @@ LOCAL_SRC_FILES := \
hal-sock.c \
hal-hidhost.c \
hal-pan.c \
- hal-av.c \
+ hal-a2dp.c \
client/textconv.c \
LOCAL_C_INCLUDES += \
diff --git a/android/Makefile.am b/android/Makefile.am
index 8619641..6790f24 100644
--- a/android/Makefile.am
+++ b/android/Makefile.am
@@ -33,7 +33,7 @@ android_libhal_internal_la_SOURCES = android/hal.h android/hal-bluetooth.c \
android/hal-sock.c \
android/hal-hidhost.c \
android/hal-pan.c \
- android/hal-av.c \
+ android/hal-a2dp.c \
android/hardware/bluetooth.h \
android/hardware/bt_av.h \
android/hardware/bt_gatt.h \
@@ -86,7 +86,7 @@ EXTRA_DIST += android/hal-bluetooth.c \
android/hal-sock.c \
android/hal-hidhost.c \
android/hal-pan.c \
- android/hal-av.c \
+ android/hal-a2dp.c \
android/hal-log.h
EXTRA_DIST += android/client/terminal.c \
diff --git a/android/hal-a2dp.c b/android/hal-a2dp.c
new file mode 100644
index 0000000..2ebf801
--- /dev/null
+++ b/android/hal-a2dp.c
@@ -0,0 +1,134 @@
+/*
+ * Copyright (C) 2013 Intel Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdbool.h>
+#include <stddef.h>
+#include <string.h>
+
+#include "hal-log.h"
+#include "hal.h"
+#include "hal-msg.h"
+#include "hal-ipc.h"
+
+static const btav_callbacks_t *cbs = NULL;
+
+static bool interface_ready(void)
+{
+ return cbs != NULL;
+}
+
+static void handle_connection_state(void *buf)
+{
+ struct hal_ev_a2dp_connection_state *ev = buf;
+
+ if (cbs->connection_state_cb)
+ cbs->connection_state_cb(ev->state,
+ (bt_bdaddr_t *) (ev->bdaddr));
+}
+
+static void handle_audio_state(void *buf)
+{
+ struct hal_ev_a2dp_audio_state *ev = buf;
+
+ if (cbs->audio_state_cb)
+ cbs->audio_state_cb(ev->state, (bt_bdaddr_t *)(ev->bdaddr));
+}
+
+/* will be called from notification thread context */
+void bt_notify_av(uint16_t opcode, void *buf, uint16_t len)
+{
+ if (!interface_ready())
+ return;
+
+ switch (opcode) {
+ case HAL_EV_A2DP_CONNECTION_STATE:
+ handle_connection_state(buf);
+ break;
+ case HAL_EV_A2DP_AUDIO_STATE:
+ handle_audio_state(buf);
+ break;
+ default:
+ DBG("Unhandled callback opcode=0x%x", opcode);
+ break;
+ }
+}
+
+static bt_status_t av_connect(bt_bdaddr_t *bd_addr)
+{
+ struct hal_cmd_a2dp_connect cmd;
+
+ DBG("");
+
+ if (!interface_ready())
+ return BT_STATUS_NOT_READY;
+
+ memcpy(cmd.bdaddr, bd_addr, sizeof(cmd.bdaddr));
+
+ return hal_ipc_cmd(HAL_SERVICE_ID_A2DP, HAL_OP_A2DP_CONNECT,
+ sizeof(cmd), &cmd, NULL, NULL, NULL);
+}
+
+static bt_status_t av_disconnect(bt_bdaddr_t *bd_addr)
+{
+ struct hal_cmd_a2dp_disconnect cmd;
+
+ DBG("");
+
+ if (!interface_ready())
+ return BT_STATUS_NOT_READY;
+
+ memcpy(cmd.bdaddr, bd_addr, sizeof(cmd.bdaddr));
+
+ return hal_ipc_cmd(HAL_SERVICE_ID_A2DP, HAL_OP_A2DP_DISCONNECT,
+ sizeof(cmd), &cmd, NULL, NULL, NULL);
+}
+
+static bt_status_t av_init(btav_callbacks_t *callbacks)
+{
+ DBG("");
+
+ cbs = callbacks;
+
+ /* TODO: enable service */
+
+ return BT_STATUS_SUCCESS;
+}
+
+static void av_cleanup()
+{
+ DBG("");
+
+ if (!interface_ready())
+ return;
+
+ /* TODO: disable service */
+
+ cbs = NULL;
+}
+
+static btav_interface_t iface = {
+ .size = sizeof(iface),
+ .init = av_init,
+ .connect = av_connect,
+ .disconnect = av_disconnect,
+ .cleanup = av_cleanup
+};
+
+btav_interface_t *bt_get_av_interface()
+{
+ return &iface;
+}
diff --git a/android/hal-av.c b/android/hal-av.c
deleted file mode 100644
index 2ebf801..0000000
--- a/android/hal-av.c
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Copyright (C) 2013 Intel Corporation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <stdbool.h>
-#include <stddef.h>
-#include <string.h>
-
-#include "hal-log.h"
-#include "hal.h"
-#include "hal-msg.h"
-#include "hal-ipc.h"
-
-static const btav_callbacks_t *cbs = NULL;
-
-static bool interface_ready(void)
-{
- return cbs != NULL;
-}
-
-static void handle_connection_state(void *buf)
-{
- struct hal_ev_a2dp_connection_state *ev = buf;
-
- if (cbs->connection_state_cb)
- cbs->connection_state_cb(ev->state,
- (bt_bdaddr_t *) (ev->bdaddr));
-}
-
-static void handle_audio_state(void *buf)
-{
- struct hal_ev_a2dp_audio_state *ev = buf;
-
- if (cbs->audio_state_cb)
- cbs->audio_state_cb(ev->state, (bt_bdaddr_t *)(ev->bdaddr));
-}
-
-/* will be called from notification thread context */
-void bt_notify_av(uint16_t opcode, void *buf, uint16_t len)
-{
- if (!interface_ready())
- return;
-
- switch (opcode) {
- case HAL_EV_A2DP_CONNECTION_STATE:
- handle_connection_state(buf);
- break;
- case HAL_EV_A2DP_AUDIO_STATE:
- handle_audio_state(buf);
- break;
- default:
- DBG("Unhandled callback opcode=0x%x", opcode);
- break;
- }
-}
-
-static bt_status_t av_connect(bt_bdaddr_t *bd_addr)
-{
- struct hal_cmd_a2dp_connect cmd;
-
- DBG("");
-
- if (!interface_ready())
- return BT_STATUS_NOT_READY;
-
- memcpy(cmd.bdaddr, bd_addr, sizeof(cmd.bdaddr));
-
- return hal_ipc_cmd(HAL_SERVICE_ID_A2DP, HAL_OP_A2DP_CONNECT,
- sizeof(cmd), &cmd, NULL, NULL, NULL);
-}
-
-static bt_status_t av_disconnect(bt_bdaddr_t *bd_addr)
-{
- struct hal_cmd_a2dp_disconnect cmd;
-
- DBG("");
-
- if (!interface_ready())
- return BT_STATUS_NOT_READY;
-
- memcpy(cmd.bdaddr, bd_addr, sizeof(cmd.bdaddr));
-
- return hal_ipc_cmd(HAL_SERVICE_ID_A2DP, HAL_OP_A2DP_DISCONNECT,
- sizeof(cmd), &cmd, NULL, NULL, NULL);
-}
-
-static bt_status_t av_init(btav_callbacks_t *callbacks)
-{
- DBG("");
-
- cbs = callbacks;
-
- /* TODO: enable service */
-
- return BT_STATUS_SUCCESS;
-}
-
-static void av_cleanup()
-{
- DBG("");
-
- if (!interface_ready())
- return;
-
- /* TODO: disable service */
-
- cbs = NULL;
-}
-
-static btav_interface_t iface = {
- .size = sizeof(iface),
- .init = av_init,
- .connect = av_connect,
- .disconnect = av_disconnect,
- .cleanup = av_cleanup
-};
-
-btav_interface_t *bt_get_av_interface()
-{
- return &iface;
-}
--
1.8.4.2
^ permalink raw reply related
* [PATCH 1/3] android: Rename a2dp HAL related IPC API to match service name
From: Szymon Janc @ 2013-11-07 10:27 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
Use 'Android HAL name' string from IPC doc as base for names.
---
android/a2dp.c | 10 ++++++----
android/hal-av.c | 16 ++++++++--------
android/hal-msg.h | 18 ++++++++++--------
3 files changed, 24 insertions(+), 20 deletions(-)
diff --git a/android/a2dp.c b/android/a2dp.c
index 28ab4b1..88f49ea 100644
--- a/android/a2dp.c
+++ b/android/a2dp.c
@@ -40,14 +40,16 @@
static GIOChannel *notification_io = NULL;
-static uint8_t bt_a2dp_connect(struct hal_cmd_av_connect *cmd, uint16_t len)
+static uint8_t bt_a2dp_connect(struct hal_cmd_a2dp_connect *cmd,
+ uint16_t len)
{
DBG("Not Implemented");
return HAL_STATUS_FAILED;
}
-static uint8_t bt_a2dp_disconnect(struct hal_cmd_av_connect *cmd, uint16_t len)
+static uint8_t bt_a2dp_disconnect(struct hal_cmd_a2dp_connect *cmd,
+ uint16_t len)
{
DBG("Not Implemented");
@@ -60,10 +62,10 @@ void bt_a2dp_handle_cmd(GIOChannel *io, uint8_t opcode, void *buf,
uint8_t status = HAL_STATUS_FAILED;
switch (opcode) {
- case HAL_OP_AV_CONNECT:
+ case HAL_OP_A2DP_CONNECT:
status = bt_a2dp_connect(buf, len);
break;
- case HAL_OP_AV_DISCONNECT:
+ case HAL_OP_A2DP_DISCONNECT:
status = bt_a2dp_disconnect(buf, len);
break;
default:
diff --git a/android/hal-av.c b/android/hal-av.c
index 9e1b3df..2ebf801 100644
--- a/android/hal-av.c
+++ b/android/hal-av.c
@@ -33,7 +33,7 @@ static bool interface_ready(void)
static void handle_connection_state(void *buf)
{
- struct hal_ev_av_connection_state *ev = buf;
+ struct hal_ev_a2dp_connection_state *ev = buf;
if (cbs->connection_state_cb)
cbs->connection_state_cb(ev->state,
@@ -42,7 +42,7 @@ static void handle_connection_state(void *buf)
static void handle_audio_state(void *buf)
{
- struct hal_ev_av_audio_state *ev = buf;
+ struct hal_ev_a2dp_audio_state *ev = buf;
if (cbs->audio_state_cb)
cbs->audio_state_cb(ev->state, (bt_bdaddr_t *)(ev->bdaddr));
@@ -55,10 +55,10 @@ void bt_notify_av(uint16_t opcode, void *buf, uint16_t len)
return;
switch (opcode) {
- case HAL_EV_AV_CONNECTION_STATE:
+ case HAL_EV_A2DP_CONNECTION_STATE:
handle_connection_state(buf);
break;
- case HAL_EV_AV_AUDIO_STATE:
+ case HAL_EV_A2DP_AUDIO_STATE:
handle_audio_state(buf);
break;
default:
@@ -69,7 +69,7 @@ void bt_notify_av(uint16_t opcode, void *buf, uint16_t len)
static bt_status_t av_connect(bt_bdaddr_t *bd_addr)
{
- struct hal_cmd_av_connect cmd;
+ struct hal_cmd_a2dp_connect cmd;
DBG("");
@@ -78,13 +78,13 @@ static bt_status_t av_connect(bt_bdaddr_t *bd_addr)
memcpy(cmd.bdaddr, bd_addr, sizeof(cmd.bdaddr));
- return hal_ipc_cmd(HAL_SERVICE_ID_A2DP, HAL_OP_AV_CONNECT,
+ return hal_ipc_cmd(HAL_SERVICE_ID_A2DP, HAL_OP_A2DP_CONNECT,
sizeof(cmd), &cmd, NULL, NULL, NULL);
}
static bt_status_t av_disconnect(bt_bdaddr_t *bd_addr)
{
- struct hal_cmd_av_disconnect cmd;
+ struct hal_cmd_a2dp_disconnect cmd;
DBG("");
@@ -93,7 +93,7 @@ static bt_status_t av_disconnect(bt_bdaddr_t *bd_addr)
memcpy(cmd.bdaddr, bd_addr, sizeof(cmd.bdaddr));
- return hal_ipc_cmd(HAL_SERVICE_ID_A2DP, HAL_OP_AV_DISCONNECT,
+ return hal_ipc_cmd(HAL_SERVICE_ID_A2DP, HAL_OP_A2DP_DISCONNECT,
sizeof(cmd), &cmd, NULL, NULL, NULL);
}
diff --git a/android/hal-msg.h b/android/hal-msg.h
index a5e5c76..c52e495 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -301,13 +301,15 @@ struct hal_cmd_hid_send_data {
uint8_t bdaddr[6];
} __attribute__((packed));
-#define HAL_OP_AV_CONNECT 0x01
-struct hal_cmd_av_connect {
+/* a2dp HAL API*/
+
+#define HAL_OP_A2DP_CONNECT 0x01
+struct hal_cmd_a2dp_connect {
uint8_t bdaddr[6];
} __attribute__((packed));
-#define HAL_OP_AV_DISCONNECT 0x02
-struct hal_cmd_av_disconnect {
+#define HAL_OP_A2DP_DISCONNECT 0x02
+struct hal_cmd_a2dp_disconnect {
uint8_t bdaddr[6];
} __attribute__((packed));
@@ -475,14 +477,14 @@ struct hal_ev_hid_get_report {
uint8_t data[0];
} __attribute__((packed));
-#define HAL_EV_AV_CONNECTION_STATE 0x81
-struct hal_ev_av_connection_state {
+#define HAL_EV_A2DP_CONNECTION_STATE 0x81
+struct hal_ev_a2dp_connection_state {
uint8_t state;
uint8_t bdaddr[6];
} __attribute__((packed));
-#define HAL_EV_AV_AUDIO_STATE 0x82
-struct hal_ev_av_audio_state {
+#define HAL_EV_A2DP_AUDIO_STATE 0x82
+struct hal_ev_a2dp_audio_state {
uint8_t state;
uint8_t bdaddr[6];
} __attribute__((packed));
--
1.8.4.2
^ permalink raw reply related
* Re: Intel 7260 bluetooth malfunction when it is connected to EHCI bus
From: Stevie Trujillo @ 2013-11-07 10:07 UTC (permalink / raw)
To: Hui Wang; +Cc: marcel, tedd.an, linux-bluetooth
In-Reply-To: <527B0CF1.7010703@canonical.com>
On Thu, 07 Nov 2013 11:45:53 +0800
Hui Wang <hui.wang@canonical.com> wrote:
> Do you know any tools can decode the log generated by usbmon?
Hmm, I never actually used the usbmon program. I did "modprobe usbmon",
then Wireshark shows usbmon{1..4} (one for each bus) as an interface
like eth0 for ethernet. http://wiki.wireshark.org/CaptureSetup/USB
If it's difficult to compare two captures in Wireshark (I don't know any
other method than visual inspection), tshark (Wireshark's "command-line
counter-part") is able to decode to stdout. Maybe one can run the diff
program on that. The output seems a bit terse however.
Please be aware: in my Wireshark (1.10.2) one of the of the SCO setup
packets are decoded slightly wrong. It looks like Wireshark is missing
a BDADDR in the beginning, so all the other fields get shifted.
^ permalink raw reply
* [PATCH 2/2] android: Fix sending remote device name property
From: Jakub Tyszkowski @ 2013-11-07 9:31 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1383816710-31059-1-git-send-email-jakub.tyszkowski@tieto.com>
Android use the full string returned even if terminated with '\0'.
---
android/adapter.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/android/adapter.c b/android/adapter.c
index da5984a..495e725 100644
--- a/android/adapter.c
+++ b/android/adapter.c
@@ -672,9 +672,9 @@ static int fill_device_props(struct hal_property *prop, bdaddr_t *addr,
/* fill name */
if (name) {
prop->type = HAL_PROP_DEVICE_NAME;
- prop->len = HAL_MAX_NAME_LENGTH;
- strncpy((char *) prop->val, name, HAL_MAX_NAME_LENGTH - 1);
- prop = ((void *) prop) + sizeof(*prop) + HAL_MAX_NAME_LENGTH;
+ prop->len = strlen(name);
+ memcpy(prop->val, name, prop->len);
+ prop = ((void *) prop) + sizeof(*prop) + prop->len;
num_props++;
}
@@ -723,7 +723,7 @@ static void update_found_device(const bdaddr_t *bdaddr, uint8_t bdaddr_type,
props_size += sizeof(struct hal_property) + sizeof(rssi);
if (eir.name)
- props_size += sizeof(struct hal_property) + HAL_MAX_NAME_LENGTH;
+ props_size += sizeof(struct hal_property) + strlen(eir.name);
if (is_new_dev) {
struct hal_ev_device_found *ev = NULL;
--
1.8.4.1
^ permalink raw reply related
* [PATCH 1/2] android: Remove redundant command complete callback
From: Jakub Tyszkowski @ 2013-11-07 9:31 UTC (permalink / raw)
To: linux-bluetooth
This patch removes command complete callback used only for verbose error
reporting.
---
android/adapter.c | 11 +----------
1 file changed, 1 insertion(+), 10 deletions(-)
diff --git a/android/adapter.c b/android/adapter.c
index 1d462c8..da5984a 100644
--- a/android/adapter.c
+++ b/android/adapter.c
@@ -625,14 +625,6 @@ static void mgmt_discovering_event(uint16_t index, uint16_t length,
sizeof(cp), &cp, -1);
}
-static void confirm_name_complete(uint8_t status, uint16_t length,
- const void *param, void *user_data)
-{
- if (status != MGMT_STATUS_SUCCESS)
- error("Failed to confirm name: %s (0x%02x)",
- mgmt_errstr(status), status);
-}
-
static void confirm_device_name(const bdaddr_t *addr, uint8_t addr_type)
{
struct mgmt_cp_confirm_name cp;
@@ -642,8 +634,7 @@ static void confirm_device_name(const bdaddr_t *addr, uint8_t addr_type)
cp.addr.type = addr_type;
if (mgmt_reply(adapter->mgmt, MGMT_OP_CONFIRM_NAME, adapter->index,
- sizeof(cp), &cp, confirm_name_complete,
- NULL, NULL) == 0)
+ sizeof(cp), &cp, NULL, NULL, NULL) == 0)
error("Failed to send confirm name request");
}
--
1.8.4.1
^ permalink raw reply related
* [RFC 3/3] android/hid: Fix set report data format
From: Ravi kumar Veeramally @ 2013-11-07 9:27 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Ravi kumar Veeramally
In-Reply-To: <1383816421-18878-1-git-send-email-ravikumar.veeramally@linux.intel.com>
Data is in ascii format from HAL. Convert it to hex and send it to
hid device.
---
android/hal-msg.h | 2 +-
android/hid.c | 12 +++++++++---
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/android/hal-msg.h b/android/hal-msg.h
index a5e5c76..89366df 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -293,7 +293,7 @@ struct hal_cmd_hid_set_report {
uint8_t bdaddr[6];
uint8_t type;
uint16_t len;
- uint8_t data[670];
+ uint8_t data[0];
} __attribute__((packed));
#define HAL_OP_HID_SEND_DATA 0x09
diff --git a/android/hid.c b/android/hid.c
index c38c4c1..e28e22d 100644
--- a/android/hid.c
+++ b/android/hid.c
@@ -898,18 +898,24 @@ static uint8_t bt_hid_set_report(struct hal_cmd_hid_set_report *cmd,
return HAL_STATUS_FAILED;
dev = l->data;
- req_size = 1 + cmd->len;
+ /* Report data coming from HAL is in ascii format, so convert
+ * it to hex and calculate length according to it. */
+ req_size = 1 + ((cmd->len + 1) / 2);
req = g_try_malloc0(req_size);
if (!req)
return HAL_STATUS_NOMEM;
req[0] = HID_MSG_SET_REPORT | cmd->type;
- memcpy(req + 1, cmd->data, req_size - 1);
+
+ if (!ascii2hex(cmd->data, cmd->len, (req + 1))) {
+ g_free(req);
+ return HAL_STATUS_FAILED;
+ }
fd = g_io_channel_unix_get_fd(dev->ctrl_io);
if (write(fd, req, req_size) < 0) {
- error("error while querying device protocol");
+ error("error while sending report");
g_free(req);
return HAL_STATUS_FAILED;
}
--
1.8.3.2
^ permalink raw reply related
* [RFC 2/3] android/hid: Add a ascii2hex utility
From: Ravi kumar Veeramally @ 2013-11-07 9:27 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Ravi kumar Veeramally
In-Reply-To: <1383816421-18878-1-git-send-email-ravikumar.veeramally@linux.intel.com>
Data from few interfaces on HAL is in ascii format but it should be
in hex format. This conversion utility does that job.
---
android/Android.mk | 1 +
android/Makefile.am | 2 +-
android/utils.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++
android/utils.h | 3 +++
4 files changed, 65 insertions(+), 1 deletion(-)
create mode 100644 android/utils.c
diff --git a/android/Android.mk b/android/Android.mk
index d76dfaf..9493f89 100644
--- a/android/Android.mk
+++ b/android/Android.mk
@@ -27,6 +27,7 @@ LOCAL_SRC_FILES := \
ipc.c ipc.h \
a2dp.c \
pan.c \
+ utils.c \
../src/log.c \
../src/shared/mgmt.c \
../src/shared/util.c \
diff --git a/android/Makefile.am b/android/Makefile.am
index 8619641..eb0c8d7 100644
--- a/android/Makefile.am
+++ b/android/Makefile.am
@@ -9,7 +9,7 @@ noinst_PROGRAMS += android/bluetoothd
android_bluetoothd_SOURCES = android/main.c \
src/log.c \
android/hal-msg.h \
- android/utils.h \
+ android/utils.h android/utils.c \
src/sdpd-database.c src/sdpd-server.c \
src/sdpd-service.c src/sdpd-request.c \
src/glib-helper.h src/glib-helper.c \
diff --git a/android/utils.c b/android/utils.c
new file mode 100644
index 0000000..9179a6f
--- /dev/null
+++ b/android/utils.c
@@ -0,0 +1,60 @@
+/*
+ *
+ * BlueZ - Bluetooth protocol stack for Linux
+ *
+ * Copyright (C) 2013 Intel Corporation. All rights reserved.
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <glib.h>
+#include "utils.h"
+
+static inline uint8_t ascii2hex_c(uint8_t ascii)
+{
+ return g_ascii_isdigit(ascii) ? (ascii - '0') :
+ (g_ascii_toupper(ascii) - 'A' + 10);
+}
+
+int ascii2hex(const uint8_t *ascii, int ascii_len, uint8_t *hex)
+{
+ uint8_t h;
+ int i;
+
+ if (!ascii || !hex)
+ return -1;
+
+ i = 0;
+
+ while (i < ascii_len) {
+ h = ascii2hex_c(ascii[i++]) << 4;
+
+ if (!(i < ascii_len)) {
+ *hex++ = h;
+ break;
+ }
+
+ h |= ascii2hex_c(ascii[i++]);
+ *hex++ = h;
+ }
+
+ return 0;
+}
diff --git a/android/utils.h b/android/utils.h
index 5b009bc..2ec3fc1 100644
--- a/android/utils.h
+++ b/android/utils.h
@@ -21,6 +21,7 @@
*
*/
+#include "lib/bluetooth.h"
static inline void android2bdaddr(const void *buf, bdaddr_t *dst)
{
@@ -31,3 +32,5 @@ static inline void bdaddr2android(const bdaddr_t *src, void *buf)
{
baswap(buf, src);
}
+
+int ascii2hex(const uint8_t *ascii, int ascii_len, uint8_t *hex);
--
1.8.3.2
^ permalink raw reply related
* [RFC 1/3] android/hid: Remove fixed number of hid set report data length in ipc doc
From: Ravi kumar Veeramally @ 2013-11-07 9:26 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Ravi kumar Veeramally
In-Reply-To: <1383816421-18878-1-git-send-email-ravikumar.veeramally@linux.intel.com>
HAL receives data in ascii format but it should be in hex format. So remove
fixed size of report data length and depend on report length parameter.
---
android/hal-ipc-api.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
index c39cb0d..297f565 100644
--- a/android/hal-ipc-api.txt
+++ b/android/hal-ipc-api.txt
@@ -553,7 +553,7 @@ Commands and responses:
Command parameters: Remote address (6 octets)
Report type (1 octet)
Report length (2 octets)
- Report data (670 octets)
+ Report data (Report length)
Response parameters: <none>
--
1.8.3.2
^ permalink raw reply related
* [RFC 0/3] Fix ascii to hex conversion in HAL to deamon ipc PDU
From: Ravi kumar Veeramally @ 2013-11-07 9:26 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Ravi kumar Veeramally
In case of set report and send data HAL receives the data in ascii format
but it should be in hex. This patch set updates the document, provides
utility and fix the issue in set report case.
Ravi kumar Veeramally (3):
android/hid: Remove fixed number of hid set report data length in ipc
doc
android/hid: Add a ascii2hex utility
android/hid: Fix set report data format
android/Android.mk | 1 +
android/Makefile.am | 2 +-
android/hal-ipc-api.txt | 2 +-
android/hal-msg.h | 2 +-
android/hid.c | 12 +++++++---
android/utils.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++++
android/utils.h | 3 +++
7 files changed, 76 insertions(+), 6 deletions(-)
create mode 100644 android/utils.c
--
1.8.3.2
^ permalink raw reply
* [PATCH 2/2] android: Add set/get for discovery timeout
From: Lukasz Rymanowski @ 2013-11-07 9:19 UTC (permalink / raw)
To: linux-bluetooth; +Cc: johan.hedberg, szymon.janc, Lukasz Rymanowski
In-Reply-To: <1383815991-18523-1-git-send-email-lukasz.rymanowski@tieto.com>
Android handles discoverable timeout in Settings app, however still
expects BT stack to maintain this value so we should do it as well.
Otherwise we will get some unexpected behaviour.
For now we keep discovery_timeout only during runtime, but we need to move
it to some local storage once we will have it.
Note: That since Android Settings up handles timer there is no reason to
use discovery timer we have in kernel.
---
android/adapter.c | 38 +++++++++++++++++++++++++++++++++++---
1 file changed, 35 insertions(+), 3 deletions(-)
diff --git a/android/adapter.c b/android/adapter.c
index 45a40f9..92e51b2 100644
--- a/android/adapter.c
+++ b/android/adapter.c
@@ -47,6 +47,9 @@
/* Default to DisplayYesNo */
#define DEFAULT_IO_CAPABILITY 0x01
+/* Default discoverable timeout 120sec as in Android */
+#define DEFAULT_DISCOVERABLE_TIMEOUT 120
+
#define BASELEN_PROP_CHANGED sizeof(struct hal_ev_adapter_props_changed) \
+ (sizeof(struct hal_property))
@@ -69,6 +72,7 @@ struct bt_adapter {
uint32_t current_settings;
bool discovering;
+ uint32_t discoverable_timeout;
};
struct browse_req {
@@ -1103,6 +1107,17 @@ static uint8_t set_adapter_name(uint8_t *name, uint16_t len)
return HAL_STATUS_FAILED;
}
+static uint8_t set_discoverable_timeout(uint8_t *timeout)
+{
+ /* Android handles discoverable timeout in Settings app.
+ * There is no need to use kernel feature for that.
+ * Just need to store this value here */
+
+ /* TODO: This should be in some storage */
+ memcpy(&adapter->discoverable_timeout, timeout, sizeof(uint32_t));
+
+ return HAL_STATUS_SUCCESS;
+}
static void read_info_complete(uint8_t status, uint16_t length, const void *param,
void *user_data)
{
@@ -1171,6 +1186,8 @@ void bt_adapter_init(uint16_t index, struct mgmt *mgmt, bt_adapter_ready cb)
adapter->index = index;
adapter->discovering = false;
adapter->ready = cb;
+ /* TODO: Read it from some storage */
+ adapter->discoverable_timeout = DEFAULT_DISCOVERABLE_TIMEOUT;
if (mgmt_send(mgmt, MGMT_OP_READ_INFO, index, 0, NULL,
read_info_complete, NULL, NULL) > 0)
@@ -1288,11 +1305,25 @@ static bool get_devices(void)
static bool get_discoverable_timeout(void)
{
- DBG("Not implemented");
+ struct hal_ev_adapter_props_changed *ev;
+ int len = sizeof(uint32_t);
+ uint8_t buf[BASELEN_PROP_CHANGED + len];
- /* TODO: Add implementation */
- return false;
+ memset(buf, 0, sizeof(buf));
+ ev = (void *) buf;
+
+ ev->num_props = 1;
+ ev->status = HAL_STATUS_SUCCESS;
+
+ ev->props[0].type = HAL_PROP_ADAPTER_DISC_TIMEOUT;
+ ev->props[0].len = len;
+ memcpy(&ev->props[0].val, &adapter->discoverable_timeout, sizeof(uint32_t));
+
+ ipc_send(notification_io, HAL_SERVICE_ID_BLUETOOTH,
+ HAL_EV_ADAPTER_PROPS_CHANGED, sizeof(buf), ev, -1);
+
+ return true;
}
static bool get_property(void *buf, uint16_t len)
@@ -1443,6 +1474,7 @@ static uint8_t set_property(void *buf, uint16_t len)
case HAL_PROP_ADAPTER_NAME:
return set_adapter_name(cmd->val, cmd->len);
case HAL_PROP_ADAPTER_DISC_TIMEOUT:
+ return set_discoverable_timeout(cmd->val);
default:
DBG("Unhandled property type 0x%x", cmd->type);
return HAL_STATUS_FAILED;
--
1.8.4
^ permalink raw reply related
* [PATCH 1/2 v2] android: Use BASELEN define for property changed
From: Lukasz Rymanowski @ 2013-11-07 9:19 UTC (permalink / raw)
To: linux-bluetooth; +Cc: johan.hedberg, szymon.janc, Lukasz Rymanowski
---
android/adapter.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/android/adapter.c b/android/adapter.c
index 1d462c8..45a40f9 100644
--- a/android/adapter.c
+++ b/android/adapter.c
@@ -47,6 +47,8 @@
/* Default to DisplayYesNo */
#define DEFAULT_IO_CAPABILITY 0x01
+#define BASELEN_PROP_CHANGED sizeof(struct hal_ev_adapter_props_changed) \
+ + (sizeof(struct hal_property))
static GIOChannel *notification_io = NULL;
/* This list contains addresses which are asked for records */
@@ -90,7 +92,7 @@ static void adapter_name_changed(const uint8_t *name)
{
struct hal_ev_adapter_props_changed *ev;
size_t len = strlen((const char *) name);
- uint8_t buf[sizeof(*ev) + sizeof(struct hal_property) + len];
+ uint8_t buf[BASELEN_PROP_CHANGED + len];
memset(buf, 0, sizeof(buf));
ev = (void *) buf;
--
1.8.4
^ permalink raw reply related
* [PATCH 4/4] android: Use payload member to access message data
From: Szymon Janc @ 2013-11-07 9:10 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1383815437-521-1-git-send-email-szymon.janc@tieto.com>
This make it similar to other places in code.
---
android/main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/android/main.c b/android/main.c
index 2c587b1..71fc60b 100644
--- a/android/main.c
+++ b/android/main.c
@@ -254,7 +254,7 @@ static gboolean cmd_watch_cb(GIOChannel *io, GIOCondition cond,
switch (msg->service_id) {
case HAL_SERVICE_ID_CORE:
- handle_service_core(msg->opcode, buf + sizeof(*msg), msg->len);
+ handle_service_core(msg->opcode, msg->payload, msg->len);
break;
case HAL_SERVICE_ID_BLUETOOTH:
bt_adapter_handle_cmd(fd, msg->opcode, msg->payload, msg->len);
--
1.8.4.2
^ permalink raw reply related
* [PATCH 3/4] android: Remove includes from adapter.h
From: Szymon Janc @ 2013-11-07 9:10 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1383815437-521-1-git-send-email-szymon.janc@tieto.com>
This is internal header and dependencies should be included in
respective .c files.
---
android/adapter.c | 1 +
android/adapter.h | 6 ------
2 files changed, 1 insertion(+), 6 deletions(-)
diff --git a/android/adapter.c b/android/adapter.c
index 69b3695..a84aaf8 100644
--- a/android/adapter.c
+++ b/android/adapter.c
@@ -26,6 +26,7 @@
#endif
#include <errno.h>
+#include <stdlib.h>
#include <glib.h>
diff --git a/android/adapter.h b/android/adapter.h
index 08f4f48..c62b859 100644
--- a/android/adapter.h
+++ b/android/adapter.h
@@ -21,12 +21,6 @@
*
*/
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-#include "lib/bluetooth.h"
-
typedef void (*bt_adapter_ready)(int err);
void bt_adapter_init(uint16_t index, struct mgmt *mgmt_if,
--
1.8.4.2
^ 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