* [PATCH 1/6] android: Use common exit path for commands in bt_adapter_handle_cmd
From: Szymon Janc @ 2013-10-25 15:14 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
All adapter commands return no parameters so putting error and success
response on common exit path. This will make function easier to follow
when more commands support will be added.
---
android/adapter.c | 34 ++++++++++++++++------------------
1 file changed, 16 insertions(+), 18 deletions(-)
diff --git a/android/adapter.c b/android/adapter.c
index ec90cca..685b00d 100644
--- a/android/adapter.c
+++ b/android/adapter.c
@@ -374,39 +374,37 @@ void bt_adapter_handle_cmd(GIOChannel *io, uint8_t opcode, void *buf,
case HAL_OP_ENABLE:
if (adapter->current_settings & MGMT_SETTING_POWERED) {
status = HAL_STATUS_DONE;
- break;
+ goto error;
}
- if (set_mode(MGMT_OP_SET_POWERED, 0x01)) {
- ipc_send(io, HAL_SERVICE_ID_BLUETOOTH, opcode, 0, NULL,
- -1);
- return;
- }
+ if (!set_mode(MGMT_OP_SET_POWERED, 0x01))
+ goto error;
+
break;
case HAL_OP_DISABLE:
if (!(adapter->current_settings & MGMT_SETTING_POWERED)) {
status = HAL_STATUS_DONE;
- break;
+ goto error;
}
- if (set_mode(MGMT_OP_SET_POWERED, 0x00)) {
- ipc_send(io, HAL_SERVICE_ID_BLUETOOTH, opcode, 0, NULL,
- -1);
- return;
- }
+ if (!set_mode(MGMT_OP_SET_POWERED, 0x00))
+ goto error;
+
break;
case HAL_OP_GET_ADAPTER_PROP:
- if (get_property(buf, len)) {
- ipc_send(io, HAL_SERVICE_ID_BLUETOOTH, opcode, 0, NULL,
- -1);
- return;
- }
+ if (!get_property(buf, len))
+ goto error;
+
break;
default:
DBG("Unhandled command, opcode 0x%x", opcode);
- break;
+ goto error;
}
+ ipc_send(io, HAL_SERVICE_ID_BLUETOOTH, opcode, 0, NULL, -1);
+ return;
+
+error:
ipc_send_rsp(io, HAL_SERVICE_ID_BLUETOOTH, status);
}
--
1.8.4.1
^ permalink raw reply related
* [PATCH 2/2] android/hal: Use debug helpers from hal client
From: Andrei Emeltchenko @ 2013-10-25 13:28 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1382707726-20118-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Debug helpers really helps a lot when debugging on Android target. The
patch uses helper functions already defined for hal test tool so
we do not need to reimplement them.
---
android/Android.mk | 1 +
android/hal-bluetooth.c | 6 ++++--
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/android/Android.mk b/android/Android.mk
index 946e9cd..56c43cb 100644
--- a/android/Android.mk
+++ b/android/Android.mk
@@ -73,6 +73,7 @@ LOCAL_SRC_FILES := \
hal-hidhost.c \
hal-pan.c \
hal-av.c \
+ client/textconv.c \
LOCAL_C_INCLUDES += \
$(call include-path-for, system-core) \
diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
index 282a680..5929fff 100644
--- a/android/hal-bluetooth.c
+++ b/android/hal-bluetooth.c
@@ -25,6 +25,8 @@
#include "hal-msg.h"
#include "hal-ipc.h"
+#include "client/textconv.h"
+
static const bt_callbacks_t *bt_hal_cbacks = NULL;
static void handle_adapter_state_changed(void *buf)
@@ -192,7 +194,7 @@ static int get_adapter_property(bt_property_type_t type)
{
struct hal_cmd_get_adapter_prop cmd;
- DBG("");
+ DBG("prop: %s", bt_property_type_t2str(type));
if (!interface_ready())
return BT_STATUS_NOT_READY;
@@ -224,7 +226,7 @@ static int set_adapter_property(const bt_property_t *property)
char buf[sizeof(struct hal_cmd_set_adapter_prop) + property->len];
struct hal_cmd_set_adapter_prop *cmd = (void *) buf;
- DBG("");
+ DBG("prop: %s", bt_property_type_t2str(property->type));
if (!interface_ready())
return BT_STATUS_NOT_READY;
--
1.7.10.4
^ permalink raw reply related
* [PATCH 1/2] android/hal: Use defined function to check that interface is ready
From: Andrei Emeltchenko @ 2013-10-25 13:28 UTC (permalink / raw)
To: linux-bluetooth
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
android/hal-bluetooth.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
index 894f5b5..282a680 100644
--- a/android/hal-bluetooth.c
+++ b/android/hal-bluetooth.c
@@ -78,10 +78,15 @@ void bt_thread_disassociate(void)
bt_hal_cbacks->thread_evt_cb(DISASSOCIATE_JVM);
}
+static bool interface_ready(void)
+{
+ return bt_hal_cbacks != NULL;
+}
+
/* will be called from notification thread context */
void bt_notify_adapter(uint16_t opcode, void *buf, uint16_t len)
{
- if (!bt_hal_cbacks)
+ if (!interface_ready())
return;
switch (opcode) {
@@ -97,11 +102,6 @@ void bt_notify_adapter(uint16_t opcode, void *buf, uint16_t len)
}
}
-static bool interface_ready(void)
-{
- return bt_hal_cbacks != NULL;
-}
-
static int init(bt_callbacks_t *callbacks)
{
struct hal_cmd_register_module cmd;
--
1.7.10.4
^ permalink raw reply related
* Re: [PATCH] android/hal: Associate thread to Java
From: Luiz Augusto von Dentz @ 2013-10-25 13:11 UTC (permalink / raw)
To: Andrei Emeltchenko; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <1382700886-6289-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
Hi Andrei,
On Fri, Oct 25, 2013 at 2:34 PM, Andrei Emeltchenko
<Andrei.Emeltchenko.news@gmail.com> wrote:
> From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
>
> Without thread assiciation callbacks are not received by Java.
> They are blocked by JNI:
> E/BluetoothServiceJni( 2844): Callback env check fail: env: 0x0, callback: 0x0
> E/BluetoothServiceJni( 2844): Callback: 'adapter_state_change_callback' is not
> called on the correct thread
> ---
> android/hal-bluetooth.c | 12 ++++++++++++
> android/hal-ipc.c | 4 ++++
> android/hal.h | 2 ++
> 3 files changed, 18 insertions(+)
>
> diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
> index f8ecec5..26f4fd9 100644
> --- a/android/hal-bluetooth.c
> +++ b/android/hal-bluetooth.c
> @@ -40,6 +40,18 @@ static bool interface_ready(void)
> return bt_hal_cbacks != NULL;
> }
>
> +void bt_thread_associate(void)
> +{
> + if (bt_hal_cbacks->thread_evt_cb)
> + bt_hal_cbacks->thread_evt_cb(ASSOCIATE_JVM);
> +}
> +
> +void bt_thread_disassociate(void)
> +{
> + if (bt_hal_cbacks->thread_evt_cb)
> + bt_hal_cbacks->thread_evt_cb(DISASSOCIATE_JVM);
> +}
> +
> /* will be called from notification thread context */
> void bt_notify_adapter(uint16_t opcode, void *buf, uint16_t len)
> {
> diff --git a/android/hal-ipc.c b/android/hal-ipc.c
> index 20421db..240ac9d 100644
> --- a/android/hal-ipc.c
> +++ b/android/hal-ipc.c
> @@ -67,6 +67,8 @@ static void *notification_handler(void *data)
> ssize_t ret;
> int fd;
>
> + bt_thread_associate();
> +
> while (true) {
> memset(&msg, 0, sizeof(msg));
> memset(buf, 0, sizeof(buf));
> @@ -133,6 +135,8 @@ static void *notification_handler(void *data)
> close(notif_sk);
> notif_sk = -1;
>
> + bt_thread_disassociate();
> +
> DBG("exit");
>
> return NULL;
> diff --git a/android/hal.h b/android/hal.h
> index ef9a107..5cd5cab 100644
> --- a/android/hal.h
> +++ b/android/hal.h
> @@ -27,3 +27,5 @@ 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);
> +void bt_thread_associate(void);
> +void bt_thread_disassociate(void);
> --
> 1.7.10.4
Pushed, thanks.
--
Luiz Augusto von Dentz
^ permalink raw reply
* Re: [PATCH v2 01/15] android: Remove not needed local variable in connect_hal
From: Luiz Augusto von Dentz @ 2013-10-25 12:29 UTC (permalink / raw)
To: Szymon Janc; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <1382698211-9123-1-git-send-email-szymon.janc@tieto.com>
Hi Szymon,
On Fri, Oct 25, 2013 at 1:49 PM, Szymon Janc <szymon.janc@tieto.com> wrote:
> err variable was set but never read.
> ---
> android/main.c | 10 ++++------
> 1 file changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/android/main.c b/android/main.c
> index 50b5901..18dc9f7 100644
> --- a/android/main.c
> +++ b/android/main.c
> @@ -239,12 +239,12 @@ static GIOChannel *connect_hal(GIOFunc connect_cb)
> struct sockaddr_un addr;
> GIOCondition cond;
> GIOChannel *io;
> - int err, sk;
> + int sk;
>
> sk = socket(PF_LOCAL, SOCK_SEQPACKET, 0);
> if (sk < 0) {
> - err = errno;
> - error("Failed to create socket: %d (%s)", err, strerror(err));
> + error("Failed to create socket: %d (%s)", errno,
> + strerror(errno));
> return NULL;
> }
>
> @@ -258,9 +258,7 @@ static GIOChannel *connect_hal(GIOFunc connect_cb)
>
> memcpy(addr.sun_path, BLUEZ_HAL_SK_PATH, sizeof(BLUEZ_HAL_SK_PATH));
>
> - err = connect(sk, (struct sockaddr *) &addr, sizeof(addr));
> - if (err < 0) {
> - err = -errno;
> + if (connect(sk, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
> error("Failed to connect HAL socket: %d (%s)", errno,
> strerror(errno));
> g_io_channel_unref(io);
> --
> 1.8.4.1
Applied, thanks.
--
Luiz Augusto von Dentz
^ permalink raw reply
* Re: [PATCH v2 0/2] Add basic scripting to haltest
From: Luiz Augusto von Dentz @ 2013-10-25 11:56 UTC (permalink / raw)
To: Jerzy Kasenberg; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <1382698306-30914-1-git-send-email-jerzy.kasenberg@tieto.com>
Hi Jerzy,
On Fri, Oct 25, 2013 at 1:51 PM, Jerzy Kasenberg
<jerzy.kasenberg@tieto.com> wrote:
> This patcheset adds command 'source' to interpret scripts
> and processing of .haltestrc to execute some commands automatically.
> v2:
> - small styl changed (fd == -1) changed to (fd < 0)
>
> Jerzy Kasenberg (2):
> android/client: Add source command to haltest
> android/client: Add processing of .haltestrc
>
> android/client/haltest.c | 55 +++++++++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 54 insertions(+), 1 deletion(-)
>
> --
> 1.7.9.5
Applied, thanks.
--
Luiz Augusto von Dentz
^ permalink raw reply
* [PATCH] android/hal: Associate thread to Java
From: Andrei Emeltchenko @ 2013-10-25 11:34 UTC (permalink / raw)
To: linux-bluetooth
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Without thread assiciation callbacks are not received by Java.
They are blocked by JNI:
E/BluetoothServiceJni( 2844): Callback env check fail: env: 0x0, callback: 0x0
E/BluetoothServiceJni( 2844): Callback: 'adapter_state_change_callback' is not
called on the correct thread
---
android/hal-bluetooth.c | 12 ++++++++++++
android/hal-ipc.c | 4 ++++
android/hal.h | 2 ++
3 files changed, 18 insertions(+)
diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
index f8ecec5..26f4fd9 100644
--- a/android/hal-bluetooth.c
+++ b/android/hal-bluetooth.c
@@ -40,6 +40,18 @@ static bool interface_ready(void)
return bt_hal_cbacks != NULL;
}
+void bt_thread_associate(void)
+{
+ if (bt_hal_cbacks->thread_evt_cb)
+ bt_hal_cbacks->thread_evt_cb(ASSOCIATE_JVM);
+}
+
+void bt_thread_disassociate(void)
+{
+ if (bt_hal_cbacks->thread_evt_cb)
+ bt_hal_cbacks->thread_evt_cb(DISASSOCIATE_JVM);
+}
+
/* will be called from notification thread context */
void bt_notify_adapter(uint16_t opcode, void *buf, uint16_t len)
{
diff --git a/android/hal-ipc.c b/android/hal-ipc.c
index 20421db..240ac9d 100644
--- a/android/hal-ipc.c
+++ b/android/hal-ipc.c
@@ -67,6 +67,8 @@ static void *notification_handler(void *data)
ssize_t ret;
int fd;
+ bt_thread_associate();
+
while (true) {
memset(&msg, 0, sizeof(msg));
memset(buf, 0, sizeof(buf));
@@ -133,6 +135,8 @@ static void *notification_handler(void *data)
close(notif_sk);
notif_sk = -1;
+ bt_thread_disassociate();
+
DBG("exit");
return NULL;
diff --git a/android/hal.h b/android/hal.h
index ef9a107..5cd5cab 100644
--- a/android/hal.h
+++ b/android/hal.h
@@ -27,3 +27,5 @@ 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);
+void bt_thread_associate(void);
+void bt_thread_disassociate(void);
--
1.7.10.4
^ permalink raw reply related
* [PATCH v2 2/2] android/client: Add processing of .haltestrc
From: Jerzy Kasenberg @ 2013-10-25 10:51 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Jerzy Kasenberg
In-Reply-To: <1382698306-30914-1-git-send-email-jerzy.kasenberg@tieto.com>
This patch allows tool to read commands from .haltestrc.
So it is possible to call some functions that are typically used.
So user can have:
adapter init
adapter get_profile_interface socket
adapter get_profile_interface pan
adapter get_profile_interface hidhost
adapter get_profile_interface a2dp
pan init
av init
---
android/client/haltest.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/android/client/haltest.c b/android/client/haltest.c
index ac43afb..6b4030b 100644
--- a/android/client/haltest.c
+++ b/android/client/haltest.c
@@ -314,6 +314,8 @@ static void stdin_handler(struct pollfd *pollfd)
int main(int argc, char **argv)
{
+ struct stat rcstat;
+
terminal_setup();
history_restore(".haltest_history");
@@ -321,6 +323,9 @@ int main(int argc, char **argv)
/* Register command line handler */
poll_register_fd(0, POLLIN, stdin_handler);
+ if (stat(".haltestrc", &rcstat) == 0 && (rcstat.st_mode & S_IFREG) != 0)
+ process_file(".haltestrc");
+
poll_dispatch_loop();
return 0;
--
1.7.9.5
^ permalink raw reply related
* [PATCH v2 1/2] android/client: Add source command to haltest
From: Jerzy Kasenberg @ 2013-10-25 10:51 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Jerzy Kasenberg
In-Reply-To: <1382698306-30914-1-git-send-email-jerzy.kasenberg@tieto.com>
New command allows to read script file into tool and
execute its contents as if it was typed.
---
android/client/haltest.c | 50 +++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 49 insertions(+), 1 deletion(-)
diff --git a/android/client/haltest.c b/android/client/haltest.c
index 189af0b..ac43afb 100644
--- a/android/client/haltest.c
+++ b/android/client/haltest.c
@@ -157,11 +157,47 @@ static void quit_p(int argc, const char **argv)
exit(0);
}
+static int fd_stack[10];
+static int fd_stack_pointer = 0;
+
+static void stdin_handler(struct pollfd *pollfd);
+
+static void process_file(const char *name)
+{
+ int fd = open(name, O_RDONLY);
+
+ if (fd < 0) {
+ haltest_error("Can't open file: %s for reading\n", name);
+ return;
+ }
+
+ if (fd_stack_pointer >= 10) {
+ haltest_error("To many open files\n");
+ close(fd);
+ return;
+ }
+
+ fd_stack[fd_stack_pointer++] = fd;
+ poll_unregister_fd(fd_stack[fd_stack_pointer - 2], stdin_handler);
+ poll_register_fd(fd_stack[fd_stack_pointer - 1], POLLIN, stdin_handler);
+}
+
+static void source_p(int argc, const char **argv)
+{
+ if (argc < 2) {
+ haltest_error("No file specified");
+ return;
+ }
+
+ process_file(argv[1]);
+}
+
/* Commands available without interface */
static struct method commands[] = {
STD_METHODCH(help, "[<interface>]"),
STD_METHOD(quit),
METHOD("exit", quit_p, NULL, NULL),
+ STD_METHODH(source, "<file>"),
END_METHOD
};
@@ -254,15 +290,26 @@ static void stdin_handler(struct pollfd *pollfd)
char buf[10];
if (pollfd->revents & POLLIN) {
- int count = read(0, buf, 10);
+ int count = read(fd_stack[fd_stack_pointer - 1], buf, 10);
if (count > 0) {
int i;
for (i = 0; i < count; ++i)
terminal_process_char(buf[i], process_line);
+ return;
}
}
+
+ if (fd_stack_pointer > 1)
+ poll_register_fd(fd_stack[fd_stack_pointer - 2], POLLIN,
+ stdin_handler);
+ if (fd_stack_pointer > 0) {
+ poll_unregister_fd(fd_stack[--fd_stack_pointer], stdin_handler);
+
+ if (fd_stack[fd_stack_pointer])
+ close(fd_stack[fd_stack_pointer]);
+ }
}
int main(int argc, char **argv)
@@ -270,6 +317,7 @@ int main(int argc, char **argv)
terminal_setup();
history_restore(".haltest_history");
+ fd_stack[fd_stack_pointer++] = 0;
/* Register command line handler */
poll_register_fd(0, POLLIN, stdin_handler);
--
1.7.9.5
^ permalink raw reply related
* [PATCH v2 0/2] Add basic scripting to haltest
From: Jerzy Kasenberg @ 2013-10-25 10:51 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Jerzy Kasenberg
This patcheset adds command 'source' to interpret scripts
and processing of .haltestrc to execute some commands automatically.
v2:
- small styl changed (fd == -1) changed to (fd < 0)
Jerzy Kasenberg (2):
android/client: Add source command to haltest
android/client: Add processing of .haltestrc
android/client/haltest.c | 55 +++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 54 insertions(+), 1 deletion(-)
--
1.7.9.5
^ permalink raw reply
* [PATCH v2 15/15] android: Add initial support for handling adapter get property command
From: Szymon Janc @ 2013-10-25 10:50 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1382698211-9123-1-git-send-email-szymon.janc@tieto.com>
Support for HAL_BT_PROP_BDADDR property only.
---
android/adapter.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 50 insertions(+)
diff --git a/android/adapter.c b/android/adapter.c
index 5837e99..df90db6 100644
--- a/android/adapter.c
+++ b/android/adapter.c
@@ -322,6 +322,49 @@ static bool set_mode(uint16_t opcode, uint8_t mode)
return false;
}
+static void send_adapter_name(void)
+{
+ struct hal_ev_adapter_props_changed *ev;
+ int len;
+
+ len = sizeof(*ev) + sizeof(struct hal_property) + sizeof(bdaddr_t);
+
+ ev = g_malloc(len);
+
+ ev->num_props = 1;
+ ev->status = HAL_ERROR_SUCCESS;
+
+ ev->props[0].type = HAL_PROP_ADAPTER_ADDR;
+ ev->props[0].len = sizeof(bdaddr_t);
+ baswap((bdaddr_t *) ev->props[0].val, &adapter->bdaddr);
+
+ ipc_send(notification_io, HAL_SERVICE_ID_BLUETOOTH,
+ HAL_EV_ADAPTER_PROPS_CHANGED, len, ev, -1);
+
+ g_free(ev);
+}
+
+static bool get_property(void *buf, uint16_t len)
+{
+ struct hal_cmd_get_adapter_prop *cmd = buf;
+
+ switch (cmd->type) {
+ case HAL_PROP_ADAPTER_ADDR:
+ send_adapter_name();
+ return true;
+ case HAL_PROP_ADAPTER_NAME:
+ case HAL_PROP_ADAPTER_UUIDS:
+ case HAL_PROP_ADAPTER_CLASS:
+ case HAL_PROP_ADAPTER_TYPE:
+ case HAL_PROP_ADAPTER_SERVICE_REC:
+ case HAL_PROP_ADAPTER_SCAN_MODE:
+ case HAL_PROP_ADAPTER_BONDED_DEVICES:
+ case HAL_PROP_ADAPTER_DISC_TIMEOUT:
+ default:
+ return false;
+ }
+}
+
void bt_adapter_handle_cmd(GIOChannel *io, uint8_t opcode, void *buf,
uint16_t len)
{
@@ -352,6 +395,13 @@ void bt_adapter_handle_cmd(GIOChannel *io, uint8_t opcode, void *buf,
return;
}
break;
+ case HAL_OP_GET_ADAPTER_PROP:
+ if (get_property(buf, len)) {
+ ipc_send(io, HAL_SERVICE_ID_BLUETOOTH, opcode, 0, NULL,
+ -1);
+ return;
+ }
+ break;
default:
DBG("Unhandled command, opcode 0x%x", opcode);
break;
--
1.8.4.1
^ permalink raw reply related
* [PATCH v2 14/15] android: Add missing success status definition to IPC header
From: Szymon Janc @ 2013-10-25 10:50 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1382698211-9123-1-git-send-email-szymon.janc@tieto.com>
This is used in HAL callbacks to indicate success.
---
android/hal-msg.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/android/hal-msg.h b/android/hal-msg.h
index 2a0b670..3703d55 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -49,6 +49,7 @@ struct hal_hdr {
/* Core Service */
+#define HAL_ERROR_SUCCESS 0x00
#define HAL_ERROR_FAILED 0x01
#define HAL_ERROR_NOT_READY 0x02
#define HAL_ERROR_NOMEM 0x03
--
1.8.4.1
^ permalink raw reply related
* [PATCH v2 13/15] android/hal: Add support for handling adapter properties change event
From: Szymon Janc @ 2013-10-25 10:50 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1382698211-9123-1-git-send-email-szymon.janc@tieto.com>
---
android/hal-bluetooth.c | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
index eb400ee..9c7fbea 100644
--- a/android/hal-bluetooth.c
+++ b/android/hal-bluetooth.c
@@ -35,6 +35,37 @@ static void handle_adapter_state_changed(void *buf)
bt_hal_cbacks->adapter_state_changed_cb(ev->state);
}
+static void handle_adapter_props_changed(void *buf, uint16_t len)
+{
+ struct hal_ev_adapter_props_changed *ev = buf;
+ bt_property_t props[ev->num_props];
+ struct hal_property *hal_prop;
+ void *p;
+ int i;
+
+ if (!bt_hal_cbacks->adapter_properties_cb)
+ return;
+
+ hal_prop = ev->props;
+ p = ev->props;
+
+ for (i = 0; i < ev->num_props; i++) {
+ if (p + sizeof(*hal_prop) + hal_prop->len > buf + len) {
+ error("invalid adapter properties event, aborting");
+ exit(EXIT_FAILURE);
+ }
+
+ props[i].type = hal_prop->type;
+ props[i].len = hal_prop->len;
+ props[i].val = hal_prop->val;
+
+ p += sizeof(*hal_prop) + hal_prop->len;
+ hal_prop = p;
+ }
+
+ bt_hal_cbacks->adapter_properties_cb(ev->status, ev->num_props, props);
+}
+
/* will be called from notification thread context */
void bt_notify_adapter(uint16_t opcode, void *buf, uint16_t len)
{
@@ -45,6 +76,9 @@ void bt_notify_adapter(uint16_t opcode, void *buf, uint16_t len)
case HAL_EV_ADAPTER_STATE_CHANGED:
handle_adapter_state_changed(buf);
break;
+ case HAL_EV_ADAPTER_PROPS_CHANGED:
+ handle_adapter_props_changed(buf, len);
+ break;
default:
DBG("Unhandled callback opcode=0x%x", opcode);
break;
--
1.8.4.1
^ permalink raw reply related
* [PATCH v2 12/15] android/hal: Add support for sending adapter SSP reply command
From: Szymon Janc @ 2013-10-25 10:50 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1382698211-9123-1-git-send-email-szymon.janc@tieto.com>
This allows HAL to reply to SSP request.
---
android/hal-bluetooth.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
index 6835db3..eb400ee 100644
--- a/android/hal-bluetooth.c
+++ b/android/hal-bluetooth.c
@@ -340,15 +340,21 @@ static int pin_reply(const bt_bdaddr_t *bd_addr, uint8_t accept,
static int ssp_reply(const bt_bdaddr_t *bd_addr, bt_ssp_variant_t variant,
uint8_t accept, uint32_t passkey)
{
+ struct hal_cmd_ssp_reply cmd;
+
DBG("");
if (!interface_ready())
return BT_STATUS_NOT_READY;
- if (!bd_addr)
- return BT_STATUS_PARM_INVALID;
+ memcpy(cmd.bdaddr, bd_addr, sizeof(cmd.bdaddr));
+ /* type match IPC type */
+ cmd.ssp_variant = variant;
+ cmd.accept = accept;
+ cmd.passkey = passkey;
- return BT_STATUS_UNSUPPORTED;
+ return hal_ipc_cmd(HAL_SERVICE_ID_BLUETOOTH, HAL_OP_SSP_REPLY,
+ sizeof(cmd), &cmd, 0, NULL, NULL);
}
static const void *get_profile_interface(const char *profile_id)
--
1.8.4.1
^ permalink raw reply related
* [PATCH v2 11/15] android: Add missing SSP variant definitions to IPC header
From: Szymon Janc @ 2013-10-25 10:50 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1382698211-9123-1-git-send-email-szymon.janc@tieto.com>
---
android/hal-msg.h | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/android/hal-msg.h b/android/hal-msg.h
index 352a64c..2a0b670 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -176,6 +176,11 @@ struct hal_cmd_pin_reply {
uint8_t pin_code[16];
} __attribute__((packed));
+#define HAL_BT_SSP_VARIANT_CONFIRM 0x00
+#define HAL_BT_SSP_VARIANT_ENTRY 0x01
+#define HAL_BT_SSP_VARIANT_CONSENT 0x02
+#define HAL_BT_SSP_VARIANT_NOTIF 0x03
+
#define HAL_OP_SSP_REPLY 0x11
struct hal_cmd_ssp_reply {
uint8_t bdaddr[6];
--
1.8.4.1
^ permalink raw reply related
* [PATCH v2 10/15] android: Add missing SSP Variant definitions to IPC document
From: Szymon Janc @ 2013-10-25 10:50 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1382698211-9123-1-git-send-email-szymon.janc@tieto.com>
Those are used to specify SSP association model.
---
android/hal-ipc-api.txt | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
index a5437c1..0c2fd25 100644
--- a/android/hal-ipc-api.txt
+++ b/android/hal-ipc-api.txt
@@ -281,6 +281,11 @@ Commands and responses:
Passkey (4 octets)
Response parameters: <none>
+ Valid SSP variant values: 0x00 = Passkey Confirmation
+ 0x01 = Passkey Entry
+ 0x02 = Consent (for Just Works)
+ 0x03 = Passkey Notification
+
In case of an error, the error response will be returned.
Opcode 0x12 - DUT Mode Configure command/response
--
1.8.4.1
^ permalink raw reply related
* [PATCH v2 09/15] android/hal: Add support for sending adapter PIN reply command
From: Szymon Janc @ 2013-10-25 10:50 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1382698211-9123-1-git-send-email-szymon.janc@tieto.com>
This allows HAL to reply to PIN code request.
---
android/hal-bluetooth.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
index ca443a6..6835db3 100644
--- a/android/hal-bluetooth.c
+++ b/android/hal-bluetooth.c
@@ -321,12 +321,20 @@ static int remove_bond(const bt_bdaddr_t *bd_addr)
static int pin_reply(const bt_bdaddr_t *bd_addr, uint8_t accept,
uint8_t pin_len, bt_pin_code_t *pin_code)
{
+ struct hal_cmd_pin_reply cmd;
+
DBG("");
if (!interface_ready())
return BT_STATUS_NOT_READY;
- return BT_STATUS_UNSUPPORTED;
+ memcpy(cmd.bdaddr, bd_addr, sizeof(cmd.bdaddr));
+ cmd.accept = accept;
+ cmd.pin_len = pin_len;
+ memcpy(cmd.pin_code, pin_code, sizeof(cmd.pin_code));
+
+ return hal_ipc_cmd(HAL_SERVICE_ID_BLUETOOTH, HAL_OP_PIN_REPLY,
+ sizeof(cmd), &cmd, 0, NULL, NULL);
}
static int ssp_reply(const bt_bdaddr_t *bd_addr, bt_ssp_variant_t variant,
--
1.8.4.1
^ permalink raw reply related
* [PATCH v2 08/15] android/hal: Add support for sending adapter remove bond command
From: Szymon Janc @ 2013-10-25 10:50 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1382698211-9123-1-git-send-email-szymon.janc@tieto.com>
This allows HAL to remove bonding.
---
android/hal-bluetooth.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
index ebaa877..ca443a6 100644
--- a/android/hal-bluetooth.c
+++ b/android/hal-bluetooth.c
@@ -305,12 +305,17 @@ static int cancel_bond(const bt_bdaddr_t *bd_addr)
static int remove_bond(const bt_bdaddr_t *bd_addr)
{
+ struct hal_cmd_remove_bond cmd;
+
DBG("");
if (!interface_ready())
return BT_STATUS_NOT_READY;
- return BT_STATUS_UNSUPPORTED;
+ memcpy(cmd.bdaddr, bd_addr, sizeof(cmd.bdaddr));
+
+ return hal_ipc_cmd(HAL_SERVICE_ID_BLUETOOTH, HAL_OP_REMOVE_BOND,
+ sizeof(cmd), &cmd, 0, NULL, NULL);
}
static int pin_reply(const bt_bdaddr_t *bd_addr, uint8_t accept,
--
1.8.4.1
^ permalink raw reply related
* [PATCH v2 07/15] android/hal: Add support for sending cancel bond command
From: Szymon Janc @ 2013-10-25 10:50 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1382698211-9123-1-git-send-email-szymon.janc@tieto.com>
This allows HAL to cancel pending bonding.
---
android/hal-bluetooth.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
index 6f7ef45..ebaa877 100644
--- a/android/hal-bluetooth.c
+++ b/android/hal-bluetooth.c
@@ -290,12 +290,17 @@ static int create_bond(const bt_bdaddr_t *bd_addr)
static int cancel_bond(const bt_bdaddr_t *bd_addr)
{
+ struct hal_cmd_cancel_bond cmd;
+
DBG("");
if (!interface_ready())
return BT_STATUS_NOT_READY;
- return BT_STATUS_UNSUPPORTED;
+ memcpy(cmd.bdaddr, bd_addr, sizeof(cmd.bdaddr));
+
+ return hal_ipc_cmd(HAL_SERVICE_ID_BLUETOOTH, HAL_OP_CANCEL_BOND,
+ sizeof(cmd), &cmd, 0, NULL, NULL);
}
static int remove_bond(const bt_bdaddr_t *bd_addr)
--
1.8.4.1
^ permalink raw reply related
* [PATCH v2 06/15] android/hal: Add support for sending create bond command
From: Szymon Janc @ 2013-10-25 10:50 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1382698211-9123-1-git-send-email-szymon.janc@tieto.com>
This allows HAL to start bonding.
---
android/hal-bluetooth.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
index b81f8dd..6f7ef45 100644
--- a/android/hal-bluetooth.c
+++ b/android/hal-bluetooth.c
@@ -275,15 +275,17 @@ static int cancel_discovery(void)
static int create_bond(const bt_bdaddr_t *bd_addr)
{
+ struct hal_cmd_create_bond cmd;
+
DBG("");
if (!interface_ready())
return BT_STATUS_NOT_READY;
- if (!bd_addr)
- return BT_STATUS_PARM_INVALID;
+ memcpy(cmd.bdaddr, bd_addr, sizeof(cmd.bdaddr));
- return BT_STATUS_UNSUPPORTED;
+ return hal_ipc_cmd(HAL_SERVICE_ID_BLUETOOTH, HAL_OP_CREATE_BOND,
+ sizeof(cmd), &cmd, 0, NULL, NULL);
}
static int cancel_bond(const bt_bdaddr_t *bd_addr)
--
1.8.4.1
^ permalink raw reply related
* [PATCH v2 05/15] android/hal: Add support for sending adapter get properties command
From: Szymon Janc @ 2013-10-25 10:50 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1382698211-9123-1-git-send-email-szymon.janc@tieto.com>
This allows HAL to get all adapter properties.
---
android/hal-bluetooth.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
index a71de83..b81f8dd 100644
--- a/android/hal-bluetooth.c
+++ b/android/hal-bluetooth.c
@@ -138,7 +138,8 @@ static int get_adapter_properties(void)
if (!interface_ready())
return BT_STATUS_NOT_READY;
- return BT_STATUS_UNSUPPORTED;
+ return hal_ipc_cmd(HAL_SERVICE_ID_BLUETOOTH, HAL_OP_GET_ADAPTER_PROPS,
+ 0, NULL, 0, NULL, NULL);
}
static int get_adapter_property(bt_property_type_t type)
--
1.8.4.1
^ permalink raw reply related
* [PATCH v2 04/15] android/hal: Add support for sending adapter get property command
From: Szymon Janc @ 2013-10-25 10:50 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1382698211-9123-1-git-send-email-szymon.janc@tieto.com>
This allows HAL to get adapter property.
---
android/hal-bluetooth.c | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)
diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
index aae6078..a71de83 100644
--- a/android/hal-bluetooth.c
+++ b/android/hal-bluetooth.c
@@ -143,12 +143,33 @@ static int get_adapter_properties(void)
static int get_adapter_property(bt_property_type_t type)
{
+ struct hal_cmd_get_adapter_prop cmd;
+
DBG("");
if (!interface_ready())
return BT_STATUS_NOT_READY;
- return BT_STATUS_UNSUPPORTED;
+ switch (type) {
+ case BT_PROPERTY_BDNAME:
+ case BT_PROPERTY_BDADDR:
+ case BT_PROPERTY_UUIDS:
+ case BT_PROPERTY_CLASS_OF_DEVICE:
+ case BT_PROPERTY_TYPE_OF_DEVICE:
+ case BT_PROPERTY_SERVICE_RECORD:
+ case BT_PROPERTY_ADAPTER_SCAN_MODE:
+ case BT_PROPERTY_ADAPTER_BONDED_DEVICES:
+ case BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT:
+ break;
+ default:
+ return BT_STATUS_PARM_INVALID;
+ }
+
+ /* type match IPC type */
+ cmd.type = type;
+
+ return hal_ipc_cmd(HAL_SERVICE_ID_BLUETOOTH, HAL_OP_GET_ADAPTER_PROP,
+ sizeof(cmd), &cmd, 0, NULL, NULL);
}
static int set_adapter_property(const bt_property_t *property)
--
1.8.4.1
^ permalink raw reply related
* [PATCH v2 03/15] android/hal: Add support for sending adapter set property command
From: Szymon Janc @ 2013-10-25 10:49 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1382698211-9123-1-git-send-email-szymon.janc@tieto.com>
This allows HAL to set adapter property.
---
android/hal-bluetooth.c | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
index 6e28c91..aae6078 100644
--- a/android/hal-bluetooth.c
+++ b/android/hal-bluetooth.c
@@ -153,15 +153,30 @@ static int get_adapter_property(bt_property_type_t type)
static int set_adapter_property(const bt_property_t *property)
{
+ char buf[sizeof(struct hal_cmd_set_adapter_prop) + property->len];
+ struct hal_cmd_set_adapter_prop *cmd = (void *) buf;
+
DBG("");
if (!interface_ready())
return BT_STATUS_NOT_READY;
- if (property == NULL)
+ switch (property->type) {
+ case BT_PROPERTY_BDNAME:
+ case BT_PROPERTY_ADAPTER_SCAN_MODE:
+ case BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT:
+ break;
+ default:
return BT_STATUS_PARM_INVALID;
+ }
- return BT_STATUS_UNSUPPORTED;
+ /* type match IPC type */
+ cmd->type = property->type;
+ cmd->len = property->len;
+ memcpy(cmd->val, property->val, property->len);
+
+ return hal_ipc_cmd(HAL_SERVICE_ID_BLUETOOTH, HAL_OP_SET_ADAPTER_PROP,
+ sizeof(buf), cmd, 0, NULL, NULL);
}
static int get_remote_device_properties(bt_bdaddr_t *remote_addr)
--
1.8.4.1
^ permalink raw reply related
* [PATCH v2 02/15] android: Add properties defines to hal-msg.h
From: Szymon Janc @ 2013-10-25 10:49 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1382698211-9123-1-git-send-email-szymon.janc@tieto.com>
Android HAL defines some properties as adapter specific, some as
device specific and some as common. We split those to separate
adapter and device properties hence overlaping or holes in codes.
---
android/hal-msg.h | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/android/hal-msg.h b/android/hal-msg.h
index 854e9b8..352a64c 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -91,6 +91,27 @@ struct hal_cmd_get_adapter_prop {
uint8_t type;
} __attribute__((packed));
+#define HAL_PROP_ADAPTER_NAME 0x01
+#define HAL_PROP_ADAPTER_ADDR 0x02
+#define HAL_PROP_ADAPTER_UUIDS 0x03
+#define HAL_PROP_ADAPTER_CLASS 0x04
+#define HAL_PROP_ADAPTER_TYPE 0x05
+#define HAL_PROP_ADAPTER_SERVICE_REC 0x06
+#define HAL_PROP_ADAPTER_SCAN_MODE 0x07
+#define HAL_PROP_ADAPTER_BONDED_DEVICES 0x08
+#define HAL_PROP_ADAPTER_DISC_TIMEOUT 0x09
+
+#define HAL_PROP_DEVICE_NAME 0x01
+#define HAL_PROP_DEVICE_ADDR 0x02
+#define HAL_PROP_DEVICE_UUIDS 0x03
+#define HAL_PROP_DEVICE_CLASS 0x04
+#define HAL_PROP_DEVICE_TYPE 0x05
+#define HAL_PROP_DEVICE_SERVICE_REC 0x06
+#define HAL_PROP_DEVICE_FRIENDLY_NAME 0x0a
+#define HAL_PROP_DEVICE_RSSI 0x0b
+#define HAL_PROP_DEVICE_VERSION_INFO 0x0c
+#define HAL_PROP_DEVICE_TIMESTAMP 0xFF
+
#define HAL_OP_SET_ADAPTER_PROP 0x05
struct hal_cmd_set_adapter_prop {
uint8_t type;
--
1.8.4.1
^ permalink raw reply related
* [PATCH v2 01/15] android: Remove not needed local variable in connect_hal
From: Szymon Janc @ 2013-10-25 10:49 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
err variable was set but never read.
---
android/main.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/android/main.c b/android/main.c
index 50b5901..18dc9f7 100644
--- a/android/main.c
+++ b/android/main.c
@@ -239,12 +239,12 @@ static GIOChannel *connect_hal(GIOFunc connect_cb)
struct sockaddr_un addr;
GIOCondition cond;
GIOChannel *io;
- int err, sk;
+ int sk;
sk = socket(PF_LOCAL, SOCK_SEQPACKET, 0);
if (sk < 0) {
- err = errno;
- error("Failed to create socket: %d (%s)", err, strerror(err));
+ error("Failed to create socket: %d (%s)", errno,
+ strerror(errno));
return NULL;
}
@@ -258,9 +258,7 @@ static GIOChannel *connect_hal(GIOFunc connect_cb)
memcpy(addr.sun_path, BLUEZ_HAL_SK_PATH, sizeof(BLUEZ_HAL_SK_PATH));
- err = connect(sk, (struct sockaddr *) &addr, sizeof(addr));
- if (err < 0) {
- err = -errno;
+ if (connect(sk, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
error("Failed to connect HAL socket: %d (%s)", errno,
strerror(errno));
g_io_channel_unref(io);
--
1.8.4.1
^ 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