* [RFC 3/7] android/unit: Update test-ipc with failure handler support
From: Szymon Janc @ 2014-02-25 10:50 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1393325419-16544-1-git-send-email-szymon.janc@tieto.com>
---
android/test-ipc.c | 117 +++++++++++++++++------------------------------------
1 file changed, 37 insertions(+), 80 deletions(-)
diff --git a/android/test-ipc.c b/android/test-ipc.c
index 054af84..84cb764 100644
--- a/android/test-ipc.c
+++ b/android/test-ipc.c
@@ -35,7 +35,6 @@
#include <fcntl.h>
#include <sys/socket.h>
#include <sys/un.h>
-#include <sys/signalfd.h>
#include <glib.h>
#include "src/shared/util.h"
@@ -43,10 +42,8 @@
#include "android/hal-msg.h"
#include "android/ipc.h"
-static struct ipc *ipc = NULL;
-
struct test_data {
- uint32_t expected_signal;
+ bool disconnect;
const void *cmd;
uint16_t cmd_size;
uint8_t service;
@@ -65,13 +62,13 @@ struct context {
GIOChannel *cmd_io;
GIOChannel *notif_io;
- GIOChannel *signal_io;
-
- guint signal_source;
const struct test_data *data;
};
+
+static struct ipc *ipc = NULL;
+
static void context_quit(struct context *context)
{
g_main_loop_quit(context->main_loop);
@@ -92,13 +89,13 @@ static gboolean cmd_watch(GIOChannel *io, GIOCondition cond,
.len = 0,
};
- g_assert(test_data->expected_signal == 0);
-
if (cond & (G_IO_HUP | G_IO_ERR | G_IO_NVAL)) {
- g_assert(FALSE);
+ g_assert(test_data->disconnect);
return FALSE;
}
+ g_assert(!test_data->disconnect);
+
sk = g_io_channel_unix_get_fd(io);
g_assert(read(sk, buf, sizeof(buf)) == sizeof(struct hal_hdr));
@@ -112,11 +109,16 @@ static gboolean cmd_watch(GIOChannel *io, GIOCondition cond,
static gboolean notif_watch(GIOChannel *io, GIOCondition cond,
gpointer user_data)
{
+ struct context *context = user_data;
+ const struct test_data *test_data = context->data;
+
if (cond & (G_IO_HUP | G_IO_ERR | G_IO_NVAL)) {
- g_assert(FALSE);
+ g_assert(test_data->disconnect);
return FALSE;
}
+ g_assert(!test_data->disconnect);
+
return TRUE;
}
@@ -162,62 +164,6 @@ static gboolean connect_handler(GIOChannel *io, GIOCondition cond,
return TRUE;
}
-static gboolean signal_handler(GIOChannel *channel, GIOCondition cond,
- gpointer user_data)
-{
- struct context *context = user_data;
- const struct test_data *test_data = context->data;
- struct signalfd_siginfo si;
- ssize_t result;
- int fd;
-
- if (cond & (G_IO_NVAL | G_IO_ERR | G_IO_HUP))
- return FALSE;
-
- fd = g_io_channel_unix_get_fd(channel);
-
- result = read(fd, &si, sizeof(si));
- if (result != sizeof(si))
- return FALSE;
-
- g_assert(test_data->expected_signal == si.ssi_signo);
- context_quit(context);
- return TRUE;
-}
-
-static guint setup_signalfd(gpointer user_data)
-{
- GIOChannel *channel;
- guint source;
- sigset_t mask;
- int ret;
- int fd;
-
- sigemptyset(&mask);
- sigaddset(&mask, SIGINT);
- sigaddset(&mask, SIGTERM);
-
- ret = sigprocmask(SIG_BLOCK, &mask, NULL);
- g_assert(ret == 0);
-
- fd = signalfd(-1, &mask, 0);
- g_assert(fd >= 0);
-
- channel = g_io_channel_unix_new(fd);
-
- g_io_channel_set_close_on_unref(channel, TRUE);
- g_io_channel_set_encoding(channel, NULL, NULL);
- g_io_channel_set_buffered(channel, FALSE);
-
- source = g_io_add_watch(channel,
- G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
- signal_handler, user_data);
-
- g_io_channel_unref(channel);
-
- return source;
-}
-
static struct context *create_context(gconstpointer data)
{
struct context *context = g_new0(struct context, 1);
@@ -228,9 +174,6 @@ static struct context *create_context(gconstpointer data)
context->main_loop = g_main_loop_new(NULL, FALSE);
g_assert(context->main_loop);
- context->signal_source = setup_signalfd(context);
- g_assert(context->signal_source);
-
sk = socket(AF_LOCAL, SOCK_SEQPACKET, 0);
g_assert(sk >= 0);
@@ -272,7 +215,6 @@ static void execute_context(struct context *context)
g_io_channel_unref(context->notif_io);
g_source_remove(context->notif_source);
- g_source_remove(context->signal_source);
g_source_remove(context->cmd_source);
g_source_remove(context->source);
@@ -281,6 +223,15 @@ static void execute_context(struct context *context)
g_free(context);
}
+static void disconnected(void *data)
+{
+ struct context *context = data;
+
+ g_assert(context->data->disconnect);
+
+ context_quit(context);
+}
+
static void test_init(gconstpointer data)
{
struct context *context = create_context(data);
@@ -341,6 +292,8 @@ static void test_cmd(gconstpointer data)
g_assert(ipc);
+ ipc_set_fail_handler(ipc, disconnected, context);
+
g_idle_add(send_cmd, context);
execute_context(context);
@@ -359,6 +312,8 @@ static void test_cmd_reg(gconstpointer data)
g_assert(ipc);
+ ipc_set_fail_handler(ipc, disconnected, context);
+
g_idle_add(register_service, context);
g_idle_add(send_cmd, context);
@@ -379,6 +334,8 @@ static void test_cmd_reg_1(gconstpointer data)
g_assert(ipc);
+ ipc_set_fail_handler(ipc, disconnected, context);
+
g_idle_add(register_service, context);
g_idle_add(unregister_service, context);
g_idle_add(send_cmd, context);
@@ -401,7 +358,7 @@ static void test_cmd_handler_2(const void *buf, uint16_t len)
static void test_cmd_handler_invalid(const void *buf, uint16_t len)
{
- raise(SIGTERM);
+ g_assert(false);
}
static const struct test_data test_init_1 = {};
@@ -421,7 +378,7 @@ static const struct hal_hdr test_cmd_2_hdr = {
static const struct test_data test_cmd_service_invalid_1 = {
.cmd = &test_cmd_1_hdr,
.cmd_size = sizeof(test_cmd_1_hdr),
- .expected_signal = SIGTERM
+ .disconnect = true,
};
static const struct ipc_handler cmd_handlers[] = {
@@ -442,7 +399,7 @@ static const struct test_data test_cmd_service_invalid_2 = {
.service = 0,
.handlers = cmd_handlers,
.handlers_size = 1,
- .expected_signal = SIGTERM
+ .disconnect = true,
};
static const struct ipc_handler cmd_handlers_invalid_2[] = {
@@ -477,7 +434,7 @@ static const struct test_data test_cmd_opcode_invalid_1 = {
.service = 0,
.handlers = cmd_handlers,
.handlers_size = 1,
- .expected_signal = SIGTERM
+ .disconnect = true,
};
static const struct test_data test_cmd_hdr_invalid = {
@@ -486,7 +443,7 @@ static const struct test_data test_cmd_hdr_invalid = {
.service = 0,
.handlers = cmd_handlers,
.handlers_size = 1,
- .expected_signal = SIGTERM
+ .disconnect = true,
};
#define VARDATA_EX1 "some data example"
@@ -533,7 +490,7 @@ static const struct test_data test_cmd_vardata_invalid_1 = {
.service = 0,
.handlers = cmd_vardata_handlers,
.handlers_size = 1,
- .expected_signal = SIGTERM
+ .disconnect = true,
};
static const struct hal_hdr test_cmd_service_offrange_hdr = {
@@ -548,7 +505,7 @@ static const struct test_data test_cmd_service_offrange = {
.service = 0,
.handlers = cmd_handlers,
.handlers_size = 1,
- .expected_signal = SIGTERM
+ .disconnect = true,
};
static const struct vardata test_cmd_invalid_data_1 = {
@@ -564,7 +521,7 @@ static const struct test_data test_cmd_msg_invalid_1 = {
.service = 0,
.handlers = cmd_handlers,
.handlers_size = 1,
- .expected_signal = SIGTERM
+ .disconnect = true,
};
static const struct vardata test_cmd_invalid_data_2 = {
@@ -580,7 +537,7 @@ static const struct test_data test_cmd_msg_invalid_2 = {
.service = 0,
.handlers = cmd_handlers,
.handlers_size = 1,
- .expected_signal = SIGTERM
+ .disconnect = true,
};
int main(int argc, char *argv[])
--
1.8.3.2
^ permalink raw reply related
* [RFC 4/7] android: Add support for disabling notifications in IPC
From: Szymon Janc @ 2014-02-25 10:50 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1393325419-16544-1-git-send-email-szymon.janc@tieto.com>
---
android/ipc.c | 20 ++++++++++++++++++--
android/ipc.h | 2 ++
2 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/android/ipc.c b/android/ipc.c
index 4bddb58..e356439 100644
--- a/android/ipc.c
+++ b/android/ipc.c
@@ -50,6 +50,7 @@ struct ipc {
GIOChannel *cmd_io;
guint cmd_watch;
+ bool notif_disabled;
GIOChannel *notif_io;
guint notif_watch;
@@ -246,7 +247,7 @@ static gboolean notif_connect_cb(GIOChannel *io, GIOCondition cond,
ipc->cmd_watch = g_io_add_watch(ipc->cmd_io, cond, cmd_watch_cb, ipc);
- info("IPC: successfully connected");
+ info("IPC: successfully connected (with notifications)");
return FALSE;
}
@@ -263,13 +264,23 @@ static gboolean cmd_connect_cb(GIOChannel *io, GIOCondition cond,
goto failed;
}
+ if (ipc->notif_disabled) {
+ cond = G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL;
+
+ ipc->cmd_watch = g_io_add_watch(ipc->cmd_io, cond, cmd_watch_cb,
+ ipc);
+
+ info("IPC: successfully connected (without notifications)");
+
+ return FALSE;
+ }
+
ipc->notif_io = ipc_connect(ipc->path, ipc->size, notif_connect_cb,
ipc);
if (!ipc->notif_io)
goto failed;
return FALSE;
-
failed:
ipc_disconnect(ipc, true);
@@ -312,6 +323,11 @@ void ipc_set_fail_handler(struct ipc *ipc, ipc_failed_cb cb, void *data)
ipc->failed_cb_data = data;
}
+void ipc_disable_notifications(struct ipc *ipc)
+{
+ ipc->notif_disabled = true;
+}
+
void ipc_send(int sk, uint8_t service_id, uint8_t opcode, uint16_t len,
void *param, int fd)
{
diff --git a/android/ipc.h b/android/ipc.h
index 3a6adc8..c4f8c41 100644
--- a/android/ipc.h
+++ b/android/ipc.h
@@ -40,6 +40,8 @@ void ipc_cleanup(struct ipc *ipc);
typedef void (*ipc_failed_cb) (void *data);
void ipc_set_fail_handler(struct ipc *ipc, ipc_failed_cb cb, void *data);
+void ipc_disable_notifications(struct ipc *ipc);
+
GIOChannel *ipc_connect(const char *path, size_t size, GIOFunc connect_cb,
void *user_data);
int ipc_handle_msg(struct service_handler *handlers, size_t max_index,
--
1.8.3.2
^ permalink raw reply related
* [RFC 5/7] android/a2dp: Use common IPC for audio socket
From: Szymon Janc @ 2014-02-25 10:50 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1393325419-16544-1-git-send-email-szymon.janc@tieto.com>
This makes audio HAL to use same code for IPC as BT HAL.
---
android/Android.mk | 1 -
android/Makefile.am | 1 -
android/a2dp.c | 72 ++++++++++++++++--------
android/audio-ipc.c | 155 ----------------------------------------------------
android/audio-ipc.h | 31 -----------
android/audio-msg.h | 1 +
6 files changed, 49 insertions(+), 212 deletions(-)
delete mode 100644 android/audio-ipc.c
delete mode 100644 android/audio-ipc.h
diff --git a/android/Android.mk b/android/Android.mk
index 82c834b..56b86ba 100644
--- a/android/Android.mk
+++ b/android/Android.mk
@@ -35,7 +35,6 @@ LOCAL_SRC_FILES := \
bluez/android/hidhost.c \
bluez/android/socket.c \
bluez/android/ipc.c \
- bluez/android/audio-ipc.c \
bluez/android/avdtp.c \
bluez/android/a2dp.c \
bluez/android/avctp.c \
diff --git a/android/Makefile.am b/android/Makefile.am
index b93b840..b09948f 100644
--- a/android/Makefile.am
+++ b/android/Makefile.am
@@ -32,7 +32,6 @@ android_bluetoothd_SOURCES = android/main.c \
android/bluetooth.h android/bluetooth.c \
android/hidhost.h android/hidhost.c \
android/ipc.h android/ipc.c \
- android/audio-ipc.h android/audio-ipc.c \
android/avdtp.h android/avdtp.c \
android/a2dp.h android/a2dp.c \
android/avctp.h android/avctp.c \
diff --git a/android/a2dp.c b/android/a2dp.c
index b05d4bd..3ac6452 100644
--- a/android/a2dp.c
+++ b/android/a2dp.c
@@ -47,7 +47,6 @@
#include "avdtp.h"
#include "avrcp.h"
#include "audio-msg.h"
-#include "audio-ipc.h"
#define L2CAP_PSM_AVDTP 0x19
#define SVC_HINT_CAPTURING 0x08
@@ -64,6 +63,7 @@ static guint audio_retry_id = 0;
static bool audio_retrying = false;
static struct ipc *hal_ipc = NULL;
+static struct ipc *audio_ipc = NULL;
struct a2dp_preset {
void *data;
@@ -1298,12 +1298,14 @@ static void bt_audio_open(const void *buf, uint16_t len)
g_slist_free(presets);
- audio_ipc_send_rsp_full(AUDIO_OP_OPEN, sizeof(rsp), &rsp, -1);
+ ipc_send_rsp_full(audio_ipc, AUDIO_SERVICE_ID, AUDIO_OP_OPEN,
+ sizeof(rsp), &rsp, -1);
return;
failed:
- audio_ipc_send_rsp(AUDIO_OP_OPEN, AUDIO_STATUS_FAILED);
+ ipc_send_rsp(audio_ipc, AUDIO_SERVICE_ID, AUDIO_OP_OPEN,
+ AUDIO_STATUS_FAILED);
}
static struct a2dp_endpoint *find_endpoint(uint8_t id)
@@ -1330,14 +1332,16 @@ static void bt_audio_close(const void *buf, uint16_t len)
endpoint = find_endpoint(cmd->id);
if (!endpoint) {
error("Unable to find endpoint %u", cmd->id);
- audio_ipc_send_rsp(AUDIO_OP_CLOSE, AUDIO_STATUS_FAILED);
+ ipc_send_rsp(audio_ipc, AUDIO_SERVICE_ID, AUDIO_OP_CLOSE,
+ AUDIO_STATUS_FAILED);
return;
}
endpoints = g_slist_remove(endpoints, endpoint);
unregister_endpoint(endpoint);
- audio_ipc_send_rsp(AUDIO_OP_CLOSE, AUDIO_STATUS_SUCCESS);
+ ipc_send_rsp(audio_ipc, AUDIO_SERVICE_ID, AUDIO_OP_CLOSE,
+ AUDIO_STATUS_SUCCESS);
}
static void bt_stream_open(const void *buf, uint16_t len)
@@ -1353,14 +1357,16 @@ static void bt_stream_open(const void *buf, uint16_t len)
setup = find_setup(cmd->id);
if (!setup) {
error("Unable to find stream for endpoint %u", cmd->id);
- audio_ipc_send_rsp(AUDIO_OP_OPEN_STREAM, AUDIO_STATUS_FAILED);
+ ipc_send_rsp(audio_ipc, AUDIO_SERVICE_ID, AUDIO_OP_OPEN_STREAM,
+ AUDIO_STATUS_FAILED);
return;
}
if (!avdtp_stream_get_transport(setup->stream, &fd, NULL, &omtu,
NULL)) {
error("avdtp_stream_get_transport: failed");
- audio_ipc_send_rsp(AUDIO_OP_OPEN_STREAM, AUDIO_STATUS_FAILED);
+ ipc_send_rsp(audio_ipc, AUDIO_SERVICE_ID, AUDIO_OP_OPEN_STREAM,
+ AUDIO_STATUS_FAILED);
return;
}
@@ -1371,7 +1377,8 @@ static void bt_stream_open(const void *buf, uint16_t len)
rsp->preset->len = setup->preset->len;
memcpy(rsp->preset->data, setup->preset->data, setup->preset->len);
- audio_ipc_send_rsp_full(AUDIO_OP_OPEN_STREAM, len, rsp, fd);
+ ipc_send_rsp_full(audio_ipc, AUDIO_SERVICE_ID, AUDIO_OP_OPEN_STREAM,
+ len, rsp, fd);
g_free(rsp);
}
@@ -1396,12 +1403,14 @@ static void bt_stream_close(const void *buf, uint16_t len)
goto failed;
}
- audio_ipc_send_rsp(AUDIO_OP_CLOSE_STREAM, AUDIO_STATUS_SUCCESS);
+ ipc_send_rsp(audio_ipc, AUDIO_SERVICE_ID, AUDIO_OP_CLOSE_STREAM,
+ AUDIO_STATUS_SUCCESS);
return;
failed:
- audio_ipc_send_rsp(AUDIO_OP_CLOSE_STREAM, AUDIO_STATUS_FAILED);
+ ipc_send_rsp(audio_ipc, AUDIO_SERVICE_ID, AUDIO_OP_CLOSE_STREAM,
+ AUDIO_STATUS_FAILED);
}
static void bt_stream_resume(const void *buf, uint16_t len)
@@ -1426,12 +1435,14 @@ static void bt_stream_resume(const void *buf, uint16_t len)
}
}
- audio_ipc_send_rsp(AUDIO_OP_RESUME_STREAM, AUDIO_STATUS_SUCCESS);
+ ipc_send_rsp(audio_ipc, AUDIO_SERVICE_ID, AUDIO_OP_RESUME_STREAM,
+ AUDIO_STATUS_SUCCESS);
return;
failed:
- audio_ipc_send_rsp(AUDIO_OP_RESUME_STREAM, AUDIO_STATUS_FAILED);
+ ipc_send_rsp(audio_ipc, AUDIO_SERVICE_ID, AUDIO_OP_RESUME_STREAM,
+ AUDIO_STATUS_FAILED);
}
static void bt_stream_suspend(const void *buf, uint16_t len)
@@ -1454,12 +1465,14 @@ static void bt_stream_suspend(const void *buf, uint16_t len)
goto failed;
}
- audio_ipc_send_rsp(AUDIO_OP_SUSPEND_STREAM, AUDIO_STATUS_SUCCESS);
+ ipc_send_rsp(audio_ipc, AUDIO_SERVICE_ID, AUDIO_OP_SUSPEND_STREAM,
+ AUDIO_STATUS_SUCCESS);
return;
failed:
- audio_ipc_send_rsp(AUDIO_OP_SUSPEND_STREAM, AUDIO_STATUS_FAILED);
+ ipc_send_rsp(audio_ipc, AUDIO_SERVICE_ID, AUDIO_OP_SUSPEND_STREAM,
+ AUDIO_STATUS_FAILED);
}
static const struct ipc_handler audio_handlers[] = {
@@ -1490,16 +1503,26 @@ static void bt_audio_unregister(void)
g_slist_free_full(setups, setup_free);
setups = NULL;
- audio_ipc_cleanup();
+ ipc_cleanup(audio_ipc);
+ audio_ipc = NULL;
}
-static void bt_audio_register(GDestroyNotify destroy)
+static bool bt_audio_register(GDestroyNotify destroy)
{
DBG("");
- audio_ipc_init(destroy);
+ audio_ipc = ipc_init(BLUEZ_AUDIO_SK_PATH, sizeof(BLUEZ_AUDIO_SK_PATH),
+ AUDIO_SERVICE_ID_MAX);
+ if (!audio_ipc)
+ return false;
+
+ ipc_set_fail_handler(audio_ipc, destroy, NULL);
+ ipc_disable_notifications(audio_ipc);
- audio_ipc_register(audio_handlers, G_N_ELEMENTS(audio_handlers));
+ ipc_register(audio_ipc, AUDIO_SERVICE_ID, audio_handlers,
+ G_N_ELEMENTS(audio_handlers));
+
+ return true;
}
static gboolean audio_retry_register(void *data)
@@ -1581,9 +1604,8 @@ bool bt_a2dp_register(struct ipc *ipc, const bdaddr_t *addr)
ipc_register(hal_ipc, HAL_SERVICE_ID_A2DP, cmd_handlers,
G_N_ELEMENTS(cmd_handlers));
- bt_audio_register(audio_disconnected);
-
- return true;
+ if (bt_audio_register(audio_disconnected))
+ return true;
fail:
g_io_channel_shutdown(server, TRUE, NULL);
@@ -1608,8 +1630,6 @@ void bt_a2dp_unregister(void)
ipc_unregister(hal_ipc, HAL_SERVICE_ID_A2DP);
hal_ipc = NULL;
- audio_ipc_unregister();
-
bt_adapter_remove_record(record_id);
record_id = 0;
@@ -1619,5 +1639,9 @@ void bt_a2dp_unregister(void)
server = NULL;
}
- audio_ipc_cleanup();
+ if (audio_ipc) {
+ ipc_unregister(audio_ipc, AUDIO_SERVICE_ID);
+ ipc_cleanup(audio_ipc);
+ audio_ipc = NULL;
+ }
}
diff --git a/android/audio-ipc.c b/android/audio-ipc.c
deleted file mode 100644
index ce2d86d..0000000
--- a/android/audio-ipc.c
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- *
- * BlueZ - Bluetooth protocol stack for Linux
- *
- * Copyright (C) 2013-2014 Intel Corporation. All rights reserved.
- *
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; 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 <stddef.h>
-#include <errno.h>
-#include <stdint.h>
-#include <string.h>
-#include <signal.h>
-#include <stdbool.h>
-#include <unistd.h>
-#include <glib.h>
-
-#include "src/log.h"
-#include "ipc.h"
-#include "audio-msg.h"
-#include "audio-ipc.h"
-
-static GIOChannel *audio_io = NULL;
-
-static struct service_handler service;
-
-static gboolean audio_watch_cb(GIOChannel *io, GIOCondition cond,
- gpointer user_data)
-{
- GDestroyNotify destroy = user_data;
- char buf[BLUEZ_AUDIO_MTU];
- ssize_t ret;
- int fd, err;
-
- if (cond & (G_IO_NVAL | G_IO_ERR | G_IO_HUP)) {
- info("Audio IPC: command socket closed");
- goto fail;
- }
-
- fd = g_io_channel_unix_get_fd(io);
-
- ret = read(fd, buf, sizeof(buf));
- if (ret < 0) {
- error("Audio IPC: command read failed (%s)", strerror(errno));
- goto fail;
- }
-
- err = ipc_handle_msg(&service, AUDIO_SERVICE_ID, buf, ret);
- if (err < 0) {
- error("Audio IPC: failed to handle message (%s)",
- strerror(-err));
- goto fail;
- }
-
- return TRUE;
-
-fail:
- audio_ipc_cleanup();
- if (destroy)
- destroy(NULL);
- return FALSE;
-}
-
-static gboolean audio_connect_cb(GIOChannel *io, GIOCondition cond,
- gpointer user_data)
-{
- GDestroyNotify destroy = user_data;
-
- DBG("");
-
- if (cond & (G_IO_NVAL | G_IO_ERR | G_IO_HUP)) {
- error("Audio IPC: socket connect failed");
- audio_ipc_cleanup();
- if (destroy)
- destroy(NULL);
- return FALSE;
- }
-
- cond = G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL;
-
- g_io_add_watch(audio_io, cond, audio_watch_cb, user_data);
-
- info("Audio IPC: successfully connected");
-
- return FALSE;
-}
-
-void audio_ipc_init(GDestroyNotify destroy)
-{
- audio_io = ipc_connect(BLUEZ_AUDIO_SK_PATH, sizeof(BLUEZ_AUDIO_SK_PATH),
- audio_connect_cb, destroy);
-}
-
-void audio_ipc_cleanup(void)
-{
- if (audio_io) {
- g_io_channel_shutdown(audio_io, TRUE, NULL);
- g_io_channel_unref(audio_io);
- audio_io = NULL;
- }
-}
-
-void audio_ipc_register(const struct ipc_handler *handlers, uint8_t size)
-{
- service.handler = handlers;
- service.size = size;
-}
-
-void audio_ipc_unregister(void)
-{
- service.handler = NULL;
- service.size = 0;
-}
-
-void audio_ipc_send_rsp(uint8_t opcode, uint8_t status)
-{
- struct audio_status s;
- int sk;
-
- sk = g_io_channel_unix_get_fd(audio_io);
-
- if (status == AUDIO_STATUS_SUCCESS) {
- ipc_send(sk, AUDIO_SERVICE_ID, opcode, 0, NULL, -1);
- return;
- }
-
- s.code = status;
-
- ipc_send(sk, AUDIO_SERVICE_ID, AUDIO_OP_STATUS, sizeof(s), &s, -1);
-}
-
-void audio_ipc_send_rsp_full(uint8_t opcode, uint16_t len, void *param, int fd)
-{
- ipc_send(g_io_channel_unix_get_fd(audio_io), AUDIO_SERVICE_ID, opcode,
- len, param, fd);
-}
diff --git a/android/audio-ipc.h b/android/audio-ipc.h
deleted file mode 100644
index 83207c8..0000000
--- a/android/audio-ipc.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- *
- * BlueZ - Bluetooth protocol stack for Linux
- *
- * Copyright (C) 2013-2014 Intel Corporation. All rights reserved.
- *
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-void audio_ipc_init(GDestroyNotify destroy);
-void audio_ipc_cleanup(void);
-
-void audio_ipc_register(const struct ipc_handler *handlers, uint8_t size);
-void audio_ipc_unregister(void);
-
-void audio_ipc_send_rsp(uint8_t opcode, uint8_t status);
-void audio_ipc_send_rsp_full(uint8_t opcode, uint16_t len, void *param, int fd);
diff --git a/android/audio-msg.h b/android/audio-msg.h
index 17cde09..d4fc68a 100644
--- a/android/audio-msg.h
+++ b/android/audio-msg.h
@@ -26,6 +26,7 @@
static const char BLUEZ_AUDIO_SK_PATH[] = "\0bluez_audio_socket";
#define AUDIO_SERVICE_ID 0
+#define AUDIO_SERVICE_ID_MAX AUDIO_SERVICE_ID
#define AUDIO_STATUS_SUCCESS 0x00
#define AUDIO_STATUS_FAILED 0x01
--
1.8.3.2
^ permalink raw reply related
* [RFC 6/7] android: Remove not used functions from IPC API
From: Szymon Janc @ 2014-02-25 10:50 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1393325419-16544-1-git-send-email-szymon.janc@tieto.com>
Those are used only internally and can be made static.
---
android/ipc.c | 8 ++++----
android/ipc.h | 7 -------
2 files changed, 4 insertions(+), 11 deletions(-)
diff --git a/android/ipc.c b/android/ipc.c
index e356439..636e1d8 100644
--- a/android/ipc.c
+++ b/android/ipc.c
@@ -86,7 +86,7 @@ static void ipc_disconnect(struct ipc *ipc, bool failed)
ipc->failed_cb(ipc->failed_cb_data);
}
-int ipc_handle_msg(struct service_handler *handlers, size_t max_index,
+static int ipc_handle_msg(struct service_handler *handlers, size_t max_index,
const void *buf, ssize_t len)
{
const struct hal_hdr *msg = buf;
@@ -190,8 +190,8 @@ static gboolean notif_watch_cb(GIOChannel *io, GIOCondition cond,
return FALSE;
}
-GIOChannel *ipc_connect(const char *path, size_t size, GIOFunc connect_cb,
- void *user_data)
+static GIOChannel *ipc_connect(const char *path, size_t size,
+ GIOFunc connect_cb, void *user_data)
{
struct sockaddr_un addr;
GIOCondition cond;
@@ -328,7 +328,7 @@ void ipc_disable_notifications(struct ipc *ipc)
ipc->notif_disabled = true;
}
-void ipc_send(int sk, uint8_t service_id, uint8_t opcode, uint16_t len,
+static void ipc_send(int sk, uint8_t service_id, uint8_t opcode, uint16_t len,
void *param, int fd)
{
struct msghdr msg;
diff --git a/android/ipc.h b/android/ipc.h
index c4f8c41..6fdc162 100644
--- a/android/ipc.h
+++ b/android/ipc.h
@@ -42,19 +42,12 @@ void ipc_set_fail_handler(struct ipc *ipc, ipc_failed_cb cb, void *data);
void ipc_disable_notifications(struct ipc *ipc);
-GIOChannel *ipc_connect(const char *path, size_t size, GIOFunc connect_cb,
- void *user_data);
-int ipc_handle_msg(struct service_handler *handlers, size_t max_index,
- const void *buf, ssize_t len);
-
void ipc_send_rsp(struct ipc *ipc, uint8_t service_id, uint8_t opcode,
uint8_t status);
void ipc_send_rsp_full(struct ipc *ipc, uint8_t service_id, uint8_t opcode,
uint16_t len, void *param, int fd);
void ipc_send_notif(struct ipc *ipc, uint8_t service_id, uint8_t opcode,
uint16_t len, void *param);
-void ipc_send(int sk, uint8_t service_id, uint8_t opcode, uint16_t len,
- void *param, int fd);
void ipc_register(struct ipc *ipc, uint8_t service,
const struct ipc_handler *handlers, uint8_t size);
void ipc_unregister(struct ipc *ipc, uint8_t service);
--
1.8.3.2
^ permalink raw reply related
* [RFC 7/7] android: Create comon header for IPC
From: Szymon Janc @ 2014-02-25 10:50 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1393325419-16544-1-git-send-email-szymon.janc@tieto.com>
This header contains IPC specific structures and code not related to
BT and audio HAL protocols. This allows to fully decouple IPC from
HAL messages.
This is first step to make HAL part of IPC unit-testable and reusable
between BT HAL and audio HAL.
---
android/a2dp.c | 1 +
android/audio-msg.h | 7 ++----
android/bluetooth.c | 7 +++---
android/hal-audio.c | 7 +++---
android/hal-avrcp.c | 39 +++++++++++++++++----------------
android/hal-bluetooth.c | 9 ++++----
android/hal-handsfree.c | 9 ++++----
android/hal-hidhost.c | 5 +++--
android/hal-ipc.c | 11 +++++-----
android/hal-msg.h | 16 ++------------
android/handsfree.c | 1 +
android/hidhost.c | 1 +
android/ipc-common.h | 38 ++++++++++++++++++++++++++++++++
android/ipc-tester.c | 58 +++++++++++++++++++++++++------------------------
android/ipc.c | 16 +++++++-------
android/main.c | 1 +
android/pan.c | 1 +
android/socket.c | 2 +-
android/test-ipc.c | 52 ++++++++++++++++++++++----------------------
19 files changed, 159 insertions(+), 122 deletions(-)
create mode 100644 android/ipc-common.h
diff --git a/android/a2dp.c b/android/a2dp.c
index 3ac6452..2cd59e3 100644
--- a/android/a2dp.c
+++ b/android/a2dp.c
@@ -40,6 +40,7 @@
#include "profiles/audio/a2dp-codecs.h"
#include "src/log.h"
#include "hal-msg.h"
+#include "ipc-common.h"
#include "ipc.h"
#include "a2dp.h"
#include "utils.h"
diff --git a/android/audio-msg.h b/android/audio-msg.h
index d4fc68a..5981355 100644
--- a/android/audio-msg.h
+++ b/android/audio-msg.h
@@ -28,13 +28,10 @@ static const char BLUEZ_AUDIO_SK_PATH[] = "\0bluez_audio_socket";
#define AUDIO_SERVICE_ID 0
#define AUDIO_SERVICE_ID_MAX AUDIO_SERVICE_ID
-#define AUDIO_STATUS_SUCCESS 0x00
+#define AUDIO_STATUS_SUCCESS IPC_STATUS_SUCCESS
#define AUDIO_STATUS_FAILED 0x01
-#define AUDIO_OP_STATUS 0x00
-struct audio_status {
- uint8_t code;
-} __attribute__((packed));
+#define AUDIO_OP_STATUS IPC_OP_STATUS
#define AUDIO_OP_OPEN 0x01
struct audio_preset {
diff --git a/android/bluetooth.c b/android/bluetooth.c
index 26493f7..8ad7d5d 100644
--- a/android/bluetooth.c
+++ b/android/bluetooth.c
@@ -46,6 +46,7 @@
#include "src/sdpd.h"
#include "src/log.h"
#include "hal-msg.h"
+#include "ipc-common.h"
#include "ipc.h"
#include "utils.h"
#include "bluetooth.h"
@@ -1062,7 +1063,7 @@ static bool rssi_above_threshold(int old, int new)
static void update_new_device(struct device *dev, int8_t rssi,
const struct eir_data *eir)
{
- uint8_t buf[BLUEZ_HAL_MTU];
+ uint8_t buf[IPC_MTU];
struct hal_ev_device_found *ev = (void*) buf;
bdaddr_t android_bdaddr;
uint8_t android_type;
@@ -1115,7 +1116,7 @@ static void update_new_device(struct device *dev, int8_t rssi,
static void update_device(struct device *dev, int8_t rssi,
const struct eir_data *eir)
{
- uint8_t buf[BLUEZ_HAL_MTU];
+ uint8_t buf[IPC_MTU];
struct hal_ev_remote_device_props *ev = (void *) buf;
int size;
@@ -1157,7 +1158,7 @@ static void update_found_device(const bdaddr_t *bdaddr, uint8_t bdaddr_type,
int8_t rssi, bool confirm,
const uint8_t *data, uint8_t data_len)
{
- uint8_t buf[BLUEZ_HAL_MTU];
+ uint8_t buf[IPC_MTU];
struct eir_data eir;
struct device *dev;
diff --git a/android/hal-audio.c b/android/hal-audio.c
index e72e097..e1f3f0d 100644
--- a/android/hal-audio.c
+++ b/android/hal-audio.c
@@ -33,6 +33,7 @@
#include <sbc/sbc.h>
#include "audio-msg.h"
+#include "ipc-common.h"
#include "hal-log.h"
#include "hal-msg.h"
#include "../profiles/audio/a2dp-codecs.h"
@@ -614,9 +615,9 @@ static int audio_ipc_cmd(uint8_t service_id, uint8_t opcode, uint16_t len,
ssize_t ret;
struct msghdr msg;
struct iovec iv[2];
- struct hal_hdr cmd;
+ struct ipc_hdr cmd;
char cmsgbuf[CMSG_SPACE(sizeof(int))];
- struct hal_status s;
+ struct ipc_status s;
size_t s_len = sizeof(s);
pthread_mutex_lock(&sk_mutex);
@@ -708,7 +709,7 @@ static int audio_ipc_cmd(uint8_t service_id, uint8_t opcode, uint16_t len,
}
if (cmd.opcode == AUDIO_OP_STATUS) {
- struct hal_status *s = rsp;
+ struct ipc_status *s = rsp;
if (sizeof(*s) != cmd.len) {
error("audio: Invalid status length");
diff --git a/android/hal-avrcp.c b/android/hal-avrcp.c
index a11aaa3..46e25a0 100644
--- a/android/hal-avrcp.c
+++ b/android/hal-avrcp.c
@@ -23,6 +23,7 @@
#include "hal-log.h"
#include "hal.h"
#include "hal-msg.h"
+#include "ipc-common.h"
#include "hal-ipc.h"
static const btrc_callbacks_t *cbs = NULL;
@@ -252,7 +253,7 @@ static bt_status_t get_play_status_rsp(btrc_play_status_t status,
static bt_status_t list_player_app_attr_rsp(int num_attr,
btrc_player_attr_t *p_attrs)
{
- char buf[BLUEZ_HAL_MTU];
+ char buf[IPC_MTU];
struct hal_cmd_avrcp_list_player_attrs *cmd = (void *) buf;
size_t len;
@@ -265,7 +266,7 @@ static bt_status_t list_player_app_attr_rsp(int num_attr,
return BT_STATUS_PARM_INVALID;
len = sizeof(*cmd) + num_attr;
- if (len > BLUEZ_HAL_MTU)
+ if (len > IPC_MTU)
return BT_STATUS_PARM_INVALID;
cmd->number = num_attr;
@@ -278,7 +279,7 @@ static bt_status_t list_player_app_attr_rsp(int num_attr,
static bt_status_t list_player_app_value_rsp(int num_val, uint8_t *p_vals)
{
- char buf[BLUEZ_HAL_MTU];
+ char buf[IPC_MTU];
struct hal_cmd_avrcp_list_player_values *cmd = (void *) buf;
size_t len;
@@ -292,7 +293,7 @@ static bt_status_t list_player_app_value_rsp(int num_val, uint8_t *p_vals)
len = sizeof(*cmd) + num_val;
- if (len > BLUEZ_HAL_MTU)
+ if (len > IPC_MTU)
return BT_STATUS_PARM_INVALID;
cmd->number = num_val;
@@ -305,7 +306,7 @@ static bt_status_t list_player_app_value_rsp(int num_val, uint8_t *p_vals)
static bt_status_t get_player_app_value_rsp(btrc_player_settings_t *p_vals)
{
- char buf[BLUEZ_HAL_MTU];
+ char buf[IPC_MTU];
struct hal_cmd_avrcp_get_player_attrs *cmd = (void *) buf;
size_t len, attrs_len;
int i;
@@ -322,7 +323,7 @@ static bt_status_t get_player_app_value_rsp(btrc_player_settings_t *p_vals)
sizeof(struct hal_avrcp_player_attr_value);
len = sizeof(*cmd) + attrs_len;
- if (len > BLUEZ_HAL_MTU)
+ if (len > IPC_MTU)
return BT_STATUS_PARM_INVALID;
cmd->number = p_vals->num_attr;
@@ -342,7 +343,7 @@ static int write_text(uint8_t *ptr, uint8_t id, uint8_t *text, size_t *len)
struct hal_avrcp_player_setting_text *value = (void *) ptr;
size_t attr_len = sizeof(*value);
- if (attr_len + *len > BLUEZ_HAL_MTU)
+ if (attr_len + *len > IPC_MTU)
return 0;
value->id = id;
@@ -351,8 +352,8 @@ static int write_text(uint8_t *ptr, uint8_t id, uint8_t *text, size_t *len)
*len += attr_len;
ptr += attr_len;
- if (value->len + *len > BLUEZ_HAL_MTU)
- value->len = BLUEZ_HAL_MTU - *len;
+ if (value->len + *len > IPC_MTU)
+ value->len = IPC_MTU - *len;
memcpy(value->text, text, value->len);
@@ -367,7 +368,7 @@ static uint8_t write_player_setting_text(uint8_t *ptr, uint8_t num_attr,
{
int i;
- for (i = 0; i < num_attr && *len < BLUEZ_HAL_MTU; i++) {
+ for (i = 0; i < num_attr && *len < IPC_MTU; i++) {
int ret;
ret = write_text(ptr, p_attrs[i].id, p_attrs[i].text, len);
@@ -383,7 +384,7 @@ static uint8_t write_player_setting_text(uint8_t *ptr, uint8_t num_attr,
static bt_status_t get_player_app_attr_text_rsp(int num_attr,
btrc_player_setting_text_t *p_attrs)
{
- char buf[BLUEZ_HAL_MTU];
+ char buf[IPC_MTU];
struct hal_cmd_avrcp_get_player_attrs_text *cmd = (void *) buf;
uint8_t *ptr;
size_t len;
@@ -408,7 +409,7 @@ static bt_status_t get_player_app_attr_text_rsp(int num_attr,
static bt_status_t get_player_app_value_text_rsp(int num_val,
btrc_player_setting_text_t *p_vals)
{
- char buf[BLUEZ_HAL_MTU];
+ char buf[IPC_MTU];
struct hal_cmd_avrcp_get_player_values_text *cmd = (void *) buf;
uint8_t *ptr;
size_t len;
@@ -436,7 +437,7 @@ static uint8_t write_element_attr_text(uint8_t *ptr, uint8_t num_attr,
{
int i;
- for (i = 0; i < num_attr && *len < BLUEZ_HAL_MTU; i++) {
+ for (i = 0; i < num_attr && *len < IPC_MTU; i++) {
int ret;
ret = write_text(ptr, p_attrs[i].attr_id, p_attrs[i].text, len);
@@ -452,7 +453,7 @@ static uint8_t write_element_attr_text(uint8_t *ptr, uint8_t num_attr,
static bt_status_t get_element_attr_rsp(uint8_t num_attr,
btrc_element_attr_val_t *p_attrs)
{
- char buf[BLUEZ_HAL_MTU];
+ char buf[IPC_MTU];
struct hal_cmd_avrcp_get_element_attrs_text *cmd = (void *) buf;
size_t len;
uint8_t *ptr;
@@ -490,7 +491,7 @@ static bt_status_t set_player_app_value_rsp(btrc_status_t rsp_status)
static bt_status_t play_status_changed_rsp(btrc_notification_type_t type,
btrc_play_status_t *play_status)
{
- char buf[BLUEZ_HAL_MTU];
+ char buf[IPC_MTU];
struct hal_cmd_avrcp_register_notification *cmd = (void *) buf;
size_t len;
@@ -509,7 +510,7 @@ static bt_status_t play_status_changed_rsp(btrc_notification_type_t type,
static bt_status_t track_change_rsp(btrc_notification_type_t type,
btrc_uid_t *track)
{
- char buf[BLUEZ_HAL_MTU];
+ char buf[IPC_MTU];
struct hal_cmd_avrcp_register_notification *cmd = (void *) buf;
size_t len;
@@ -554,7 +555,7 @@ static bt_status_t track_reached_start_rsp(btrc_notification_type_t type)
static bt_status_t play_pos_changed_rsp(btrc_notification_type_t type,
uint32_t *song_pos)
{
- char buf[BLUEZ_HAL_MTU];
+ char buf[IPC_MTU];
struct hal_cmd_avrcp_register_notification *cmd = (void *) buf;
size_t len;
@@ -573,7 +574,7 @@ static bt_status_t play_pos_changed_rsp(btrc_notification_type_t type,
static bt_status_t settings_changed_rsp(btrc_notification_type_t type,
btrc_player_settings_t *player_setting)
{
- char buf[BLUEZ_HAL_MTU];
+ char buf[IPC_MTU];
struct hal_cmd_avrcp_register_notification *cmd = (void *) buf;
struct hal_avrcp_player_attr_value *attrs;
size_t len, param_len;
@@ -582,7 +583,7 @@ static bt_status_t settings_changed_rsp(btrc_notification_type_t type,
param_len = player_setting->num_attr * sizeof(*attrs);
len = sizeof(*cmd) + param_len;
- if (len > BLUEZ_HAL_MTU)
+ if (len > IPC_MTU)
return BT_STATUS_PARM_INVALID;
cmd->event = BTRC_EVT_APP_SETTINGS_CHANGED;
diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
index 3160d7b..6871f5d 100644
--- a/android/hal-bluetooth.c
+++ b/android/hal-bluetooth.c
@@ -25,6 +25,7 @@
#include "hal-log.h"
#include "hal.h"
#include "hal-msg.h"
+#include "ipc-common.h"
#include "hal-ipc.h"
#include "hal-utils.h"
@@ -525,7 +526,7 @@ static int get_adapter_property(bt_property_type_t type)
static int set_adapter_property(const bt_property_t *property)
{
- char buf[BLUEZ_HAL_MTU];
+ char buf[IPC_MTU];
struct hal_cmd_set_adapter_prop *cmd = (void *) buf;
size_t len;
@@ -582,7 +583,7 @@ static int get_remote_device_property(bt_bdaddr_t *remote_addr,
static int set_remote_device_property(bt_bdaddr_t *remote_addr,
const bt_property_t *property)
{
- char buf[BLUEZ_HAL_MTU];
+ char buf[IPC_MTU];
struct hal_cmd_set_remote_device_prop *cmd = (void *) buf;
size_t len;
@@ -792,7 +793,7 @@ static int dut_mode_configure(uint8_t enable)
static int dut_mode_send(uint16_t opcode, uint8_t *buf, uint8_t buf_len)
{
- char cmd_buf[BLUEZ_HAL_MTU];
+ char cmd_buf[IPC_MTU];
struct hal_cmd_dut_mode_send *cmd = (void *) cmd_buf;
size_t len;
@@ -813,7 +814,7 @@ static int dut_mode_send(uint16_t opcode, uint8_t *buf, uint8_t buf_len)
static int le_test_mode(uint16_t opcode, uint8_t *buf, uint8_t buf_len)
{
- char cmd_buf[BLUEZ_HAL_MTU];
+ char cmd_buf[IPC_MTU];
struct hal_cmd_le_test_mode *cmd = (void *) cmd_buf;
size_t len;
diff --git a/android/hal-handsfree.c b/android/hal-handsfree.c
index ab65d95..1b150c3 100644
--- a/android/hal-handsfree.c
+++ b/android/hal-handsfree.c
@@ -23,6 +23,7 @@
#include "hal-log.h"
#include "hal.h"
#include "hal-msg.h"
+#include "ipc-common.h"
#include "hal-ipc.h"
static const bthf_callbacks_t *cbs = NULL;
@@ -360,7 +361,7 @@ static bt_status_t device_status_notification(bthf_network_state_t state,
static bt_status_t cops_response(const char *cops)
{
- char buf[BLUEZ_HAL_MTU];
+ char buf[IPC_MTU];
struct hal_cmd_handsfree_cops_response *cmd = (void *) buf;
size_t len;
@@ -408,7 +409,7 @@ static bt_status_t cind_response(int svc, int num_active, int num_held,
static bt_status_t formatted_at_response(const char *rsp)
{
- char buf[BLUEZ_HAL_MTU];
+ char buf[IPC_MTU];
struct hal_cmd_handsfree_formatted_at_response *cmd = (void *) buf;
size_t len;
@@ -454,7 +455,7 @@ static bt_status_t clcc_response(int index, bthf_call_direction_t dir,
const char *number,
bthf_call_addrtype_t type)
{
- char buf[BLUEZ_HAL_MTU];
+ char buf[IPC_MTU];
struct hal_cmd_handsfree_clcc_response *cmd = (void *) buf;
size_t len;
@@ -489,7 +490,7 @@ static bt_status_t phone_state_change(int num_active, int num_held,
const char *number,
bthf_call_addrtype_t type)
{
- char buf[BLUEZ_HAL_MTU];
+ char buf[IPC_MTU];
struct hal_cmd_handsfree_phone_state_change *cmd = (void *) buf;
size_t len;
diff --git a/android/hal-hidhost.c b/android/hal-hidhost.c
index dcaf996..c758d2a 100644
--- a/android/hal-hidhost.c
+++ b/android/hal-hidhost.c
@@ -23,6 +23,7 @@
#include "hal-log.h"
#include "hal.h"
#include "hal-msg.h"
+#include "ipc-common.h"
#include "hal-ipc.h"
static const bthh_callbacks_t *cbacks;
@@ -293,7 +294,7 @@ static bt_status_t set_report(bt_bdaddr_t *bd_addr,
bthh_report_type_t report_type,
char *report)
{
- uint8_t buf[BLUEZ_HAL_MTU];
+ uint8_t buf[IPC_MTU];
struct hal_cmd_hidhost_set_report *cmd = (void *) buf;
DBG("");
@@ -317,7 +318,7 @@ static bt_status_t set_report(bt_bdaddr_t *bd_addr,
static bt_status_t send_data(bt_bdaddr_t *bd_addr, char *data)
{
- uint8_t buf[BLUEZ_HAL_MTU];
+ uint8_t buf[IPC_MTU];
struct hal_cmd_hidhost_send_data *cmd = (void *) buf;
DBG("");
diff --git a/android/hal-ipc.c b/android/hal-ipc.c
index 1ba03f5..fda3228 100644
--- a/android/hal-ipc.c
+++ b/android/hal-ipc.c
@@ -31,6 +31,7 @@
#include "hal.h"
#include "hal-msg.h"
#include "hal-log.h"
+#include "ipc-common.h"
#include "hal-ipc.h"
#define CONNECT_TIMEOUT (5 * 1000)
@@ -64,7 +65,7 @@ void hal_ipc_unregister(uint8_t service)
static void handle_msg(void *buf, ssize_t len)
{
- struct hal_hdr *msg = buf;
+ struct ipc_hdr *msg = buf;
const struct hal_ipc_handler *handler;
uint8_t opcode;
@@ -130,7 +131,7 @@ static void *notification_handler(void *data)
struct iovec iv;
struct cmsghdr *cmsg;
char cmsgbuf[CMSG_SPACE(sizeof(int))];
- char buf[BLUEZ_HAL_MTU];
+ char buf[IPC_MTU];
ssize_t ret;
int fd;
@@ -320,9 +321,9 @@ int hal_ipc_cmd(uint8_t service_id, uint8_t opcode, uint16_t len, void *param,
ssize_t ret;
struct msghdr msg;
struct iovec iv[2];
- struct hal_hdr cmd;
+ struct ipc_hdr cmd;
char cmsgbuf[CMSG_SPACE(sizeof(int))];
- struct hal_status s;
+ struct ipc_status s;
size_t s_len = sizeof(s);
if (cmd_sk < 0) {
@@ -418,7 +419,7 @@ int hal_ipc_cmd(uint8_t service_id, uint8_t opcode, uint16_t len, void *param,
}
if (cmd.opcode == HAL_OP_STATUS) {
- struct hal_status *s = rsp;
+ struct ipc_status *s = rsp;
if (sizeof(*s) != cmd.len) {
error("Invalid status length, aborting");
diff --git a/android/hal-msg.h b/android/hal-msg.h
index 836dbbf..31e5d6c 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -21,17 +21,8 @@
*
*/
-#define BLUEZ_HAL_MTU 1024
-
static const char BLUEZ_HAL_SK_PATH[] = "\0bluez_hal_socket";
-struct hal_hdr {
- uint8_t service_id;
- uint8_t opcode;
- uint16_t len;
- uint8_t payload[0];
-} __attribute__((packed));
-
#define HAL_MINIMUM_EVENT 0x81
#define HAL_SERVICE_ID_CORE 0
@@ -49,7 +40,7 @@ struct hal_hdr {
/* Core Service */
-#define HAL_STATUS_SUCCESS 0x00
+#define HAL_STATUS_SUCCESS IPC_STATUS_SUCCESS
#define HAL_STATUS_FAILED 0x01
#define HAL_STATUS_NOT_READY 0x02
#define HAL_STATUS_NOMEM 0x03
@@ -61,10 +52,7 @@ struct hal_hdr {
#define HAL_STATUS_AUTH_FAILURE 0x09
#define HAL_STATUS_REMOTE_DEVICE_DOWN 0x0a
-#define HAL_OP_STATUS 0x00
-struct hal_status {
- uint8_t code;
-} __attribute__((packed));
+#define HAL_OP_STATUS IPC_OP_STATUS
#define HAL_OP_REGISTER_MODULE 0x01
struct hal_cmd_register_module {
diff --git a/android/handsfree.c b/android/handsfree.c
index ef8c776..81ddcc7 100644
--- a/android/handsfree.c
+++ b/android/handsfree.c
@@ -39,6 +39,7 @@
#include "src/shared/hfp.h"
#include "btio/btio.h"
#include "hal-msg.h"
+#include "ipc-common.h"
#include "ipc.h"
#include "handsfree.h"
#include "bluetooth.h"
diff --git a/android/hidhost.c b/android/hidhost.c
index 0c6eb7d..e469210 100644
--- a/android/hidhost.c
+++ b/android/hidhost.c
@@ -44,6 +44,7 @@
#include "src/log.h"
#include "hal-msg.h"
+#include "ipc-common.h"
#include "ipc.h"
#include "hidhost.h"
#include "utils.h"
diff --git a/android/ipc-common.h b/android/ipc-common.h
new file mode 100644
index 0000000..27736e4
--- /dev/null
+++ b/android/ipc-common.h
@@ -0,0 +1,38 @@
+/*
+ *
+ * BlueZ - Bluetooth protocol stack for Linux
+ *
+ * Copyright (C) 2014 Intel Corporation. All rights reserved.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#define IPC_MTU 1024
+
+#define IPC_STATUS_SUCCESS 0x00
+
+struct ipc_hdr {
+ uint8_t service_id;
+ uint8_t opcode;
+ uint16_t len;
+ uint8_t payload[0];
+} __attribute__((packed));
+
+#define IPC_OP_STATUS 0x00
+struct ipc_status {
+ uint8_t code;
+} __attribute__((packed));
diff --git a/android/ipc-tester.c b/android/ipc-tester.c
index eab8ea5..2378101 100644
--- a/android/ipc-tester.c
+++ b/android/ipc-tester.c
@@ -45,6 +45,8 @@
#include "src/shared/hciemu.h"
#include "hal-msg.h"
+#include "ipc-common.h"
+
#include <cutils/properties.h>
#define WAIT_FOR_SIGNAL_TIME 2 /* in seconds */
@@ -72,7 +74,7 @@ struct generic_data {
};
struct regmod_msg {
- struct hal_hdr header;
+ struct ipc_hdr header;
struct hal_cmd_register_module cmd;
} __attribute__((packed));
@@ -413,8 +415,8 @@ static gboolean check_for_daemon(gpointer user_data)
static bool setup_module(int service_id)
{
- struct hal_hdr response;
- struct hal_hdr expected_response;
+ struct ipc_hdr response;
+ struct ipc_hdr expected_response;
struct regmod_msg btmodule_msg = {
.header = {
@@ -564,7 +566,7 @@ static void ipc_send_tc(const void *data)
#define test_opcode_valid(_name, _service, _opcode, _len, _servicelist...) \
do { \
- static struct hal_hdr hdr = { \
+ static struct ipc_hdr hdr = { \
.service_id = _service, \
.opcode = _opcode, \
.len = _len, \
@@ -578,8 +580,8 @@ static void ipc_send_tc(const void *data)
} while (0)
struct vardata {
- struct hal_hdr hdr;
- uint8_t buf[BLUEZ_HAL_MTU];
+ struct ipc_hdr hdr;
+ uint8_t buf[IPC_MTU];
} __attribute__((packed));
#define test_datasize_valid(_name, _service, _opcode, _hlen, _addatasize, \
@@ -642,24 +644,24 @@ static struct malformed_data3_struct malformed_data3_msg = {
. redundant_data = 666,
};
-struct hal_hdr enable_unknown_service_hdr = {
+struct ipc_hdr enable_unknown_service_hdr = {
.service_id = HAL_SERVICE_ID_MAX + 1,
.opcode = HAL_OP_REGISTER_MODULE,
.len = 0,
};
-struct hal_hdr enable_bt_service_hdr = {
+struct ipc_hdr enable_bt_service_hdr = {
.service_id = HAL_SERVICE_ID_BLUETOOTH,
.opcode = HAL_OP_ENABLE,
.len = 0,
};
struct bt_set_adapter_prop_data {
- struct hal_hdr hdr;
+ struct ipc_hdr hdr;
struct hal_cmd_set_adapter_prop prop;
/* data placeholder for hal_cmd_set_adapter_prop.val[0] */
- uint8_t buf[BLUEZ_HAL_MTU - sizeof(struct hal_hdr) -
+ uint8_t buf[IPC_MTU - sizeof(struct ipc_hdr) -
sizeof(struct hal_cmd_set_adapter_prop)];
} __attribute__((packed));
@@ -692,11 +694,11 @@ static struct bt_set_adapter_prop_data bt_set_adapter_prop_data_unders = {
};
struct bt_set_remote_prop_data {
- struct hal_hdr hdr;
+ struct ipc_hdr hdr;
struct hal_cmd_set_remote_device_prop prop;
/* data placeholder for hal_cmd_set_remote_device_prop.val[0] */
- uint8_t buf[BLUEZ_HAL_MTU - sizeof(struct hal_hdr) -
+ uint8_t buf[IPC_MTU - sizeof(struct ipc_hdr) -
sizeof(struct hal_cmd_set_remote_device_prop)];
} __attribute__((packed));
@@ -727,11 +729,11 @@ static struct bt_set_remote_prop_data bt_set_remote_prop_data_unders = {
};
struct hidhost_set_info_data {
- struct hal_hdr hdr;
+ struct ipc_hdr hdr;
struct hal_cmd_hidhost_set_info info;
/* data placeholder for hal_cmd_hidhost_set_info.descr[0] field */
- uint8_t buf[BLUEZ_HAL_MTU - sizeof(struct hal_hdr) -
+ uint8_t buf[IPC_MTU - sizeof(struct ipc_hdr) -
sizeof(struct hal_cmd_hidhost_set_info)];
} __attribute__((packed));
@@ -762,11 +764,11 @@ static struct hidhost_set_info_data hidhost_set_info_data_unders = {
};
struct hidhost_set_report_data {
- struct hal_hdr hdr;
+ struct ipc_hdr hdr;
struct hal_cmd_hidhost_set_report report;
/* data placeholder for hal_cmd_hidhost_set_report.data[0] field */
- uint8_t buf[BLUEZ_HAL_MTU - sizeof(struct hal_hdr) -
+ uint8_t buf[IPC_MTU - sizeof(struct ipc_hdr) -
sizeof(struct hal_cmd_hidhost_set_report)];
} __attribute__((packed));
@@ -797,11 +799,11 @@ static struct hidhost_set_report_data hidhost_set_report_data_unders = {
};
struct hidhost_send_data_data {
- struct hal_hdr hdr;
+ struct ipc_hdr hdr;
struct hal_cmd_hidhost_send_data hiddata;
/* data placeholder for hal_cmd_hidhost_send_data.data[0] field */
- uint8_t buf[BLUEZ_HAL_MTU - sizeof(struct hal_hdr) -
+ uint8_t buf[IPC_MTU - sizeof(struct ipc_hdr) -
sizeof(struct hal_cmd_hidhost_send_data)];
} __attribute__((packed));
@@ -935,14 +937,14 @@ int main(int argc, char *argv[])
test_generic("Data size BT Set Adapter Prop Vardata+",
ipc_send_tc, setup, teardown,
&bt_set_adapter_prop_data_overs,
- (sizeof(struct hal_hdr) +
+ (sizeof(struct ipc_hdr) +
sizeof(struct hal_cmd_set_adapter_prop) +
sizeof(set_name)),
HAL_SERVICE_ID_BLUETOOTH);
test_generic("Data size BT Set Adapter Prop Vardata+",
ipc_send_tc, setup, teardown,
&bt_set_adapter_prop_data_unders,
- (sizeof(struct hal_hdr) +
+ (sizeof(struct ipc_hdr) +
sizeof(struct hal_cmd_set_adapter_prop) +
sizeof(set_name)),
HAL_SERVICE_ID_BLUETOOTH);
@@ -973,14 +975,14 @@ int main(int argc, char *argv[])
test_generic("Data size BT Set Remote Prop Vardata+",
ipc_send_tc, setup, teardown,
&bt_set_remote_prop_data_overs,
- (sizeof(struct hal_hdr) +
+ (sizeof(struct ipc_hdr) +
sizeof(struct hal_cmd_set_remote_device_prop) +
sizeof(set_name)),
HAL_SERVICE_ID_BLUETOOTH);
test_generic("Data size BT Set Remote Prop Vardata-",
ipc_send_tc, setup, teardown,
&bt_set_remote_prop_data_unders,
- (sizeof(struct hal_hdr) +
+ (sizeof(struct ipc_hdr) +
sizeof(struct hal_cmd_set_remote_device_prop) +
sizeof(set_name)),
HAL_SERVICE_ID_BLUETOOTH);
@@ -1127,14 +1129,14 @@ int main(int argc, char *argv[])
test_generic("Data size HIDHOST Set Info Vardata+",
ipc_send_tc, setup, teardown,
&hidhost_set_info_data_overs,
- (sizeof(struct hal_hdr) +
+ (sizeof(struct ipc_hdr) +
sizeof(struct hal_cmd_hidhost_set_info) +
sizeof(set_info_data)),
HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
test_generic("Data size HIDHOST Set Info Vardata-",
ipc_send_tc, setup, teardown,
&hidhost_set_info_data_unders,
- (sizeof(struct hal_hdr) +
+ (sizeof(struct ipc_hdr) +
sizeof(struct hal_cmd_hidhost_set_info) +
sizeof(set_info_data)),
HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
@@ -1173,14 +1175,14 @@ int main(int argc, char *argv[])
test_generic("Data size HIDHOST Set Report Vardata+",
ipc_send_tc, setup, teardown,
&hidhost_set_report_data_overs,
- (sizeof(struct hal_hdr) +
+ (sizeof(struct ipc_hdr) +
sizeof(struct hal_cmd_hidhost_set_report) +
sizeof(set_rep_data)),
HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
test_generic("Data size HIDHOST Set Report Vardata-",
ipc_send_tc, setup, teardown,
&hidhost_set_report_data_unders,
- (sizeof(struct hal_hdr) +
+ (sizeof(struct ipc_hdr) +
sizeof(struct hal_cmd_hidhost_set_report) +
sizeof(set_rep_data)),
HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
@@ -1195,14 +1197,14 @@ int main(int argc, char *argv[])
test_generic("Data size HIDHOST Send Vardata+",
ipc_send_tc, setup, teardown,
&hidhost_send_data_overs,
- (sizeof(struct hal_hdr) +
+ (sizeof(struct ipc_hdr) +
sizeof(struct hal_cmd_hidhost_send_data) +
sizeof(send_data_data)),
HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
test_generic("Data size HIDHOST Send Vardata-",
ipc_send_tc, setup, teardown,
&hidhost_send_data_unders,
- (sizeof(struct hal_hdr) +
+ (sizeof(struct ipc_hdr) +
sizeof(struct hal_cmd_hidhost_send_data) +
sizeof(send_data_data)),
HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
diff --git a/android/ipc.c b/android/ipc.c
index 636e1d8..9105868 100644
--- a/android/ipc.c
+++ b/android/ipc.c
@@ -36,7 +36,7 @@
#include <unistd.h>
#include <glib.h>
-#include "hal-msg.h"
+#include "ipc-common.h"
#include "ipc.h"
#include "src/log.h"
@@ -89,7 +89,7 @@ static void ipc_disconnect(struct ipc *ipc, bool failed)
static int ipc_handle_msg(struct service_handler *handlers, size_t max_index,
const void *buf, ssize_t len)
{
- const struct hal_hdr *msg = buf;
+ const struct ipc_hdr *msg = buf;
const struct ipc_handler *handler;
if (len < (ssize_t) sizeof(*msg)) {
@@ -115,7 +115,7 @@ static int ipc_handle_msg(struct service_handler *handlers, size_t max_index,
}
/* if opcode is valid */
- if (msg->opcode == HAL_OP_STATUS ||
+ if (msg->opcode == IPC_OP_STATUS ||
msg->opcode > handlers[msg->service_id].size) {
DBG("invalid opcode 0x%x for service 0x%x", msg->opcode,
msg->service_id);
@@ -143,7 +143,7 @@ static gboolean cmd_watch_cb(GIOChannel *io, GIOCondition cond,
{
struct ipc *ipc = user_data;
- char buf[BLUEZ_HAL_MTU];
+ char buf[IPC_MTU];
ssize_t ret;
int fd, err;
@@ -333,7 +333,7 @@ static void ipc_send(int sk, uint8_t service_id, uint8_t opcode, uint16_t len,
{
struct msghdr msg;
struct iovec iv[2];
- struct hal_hdr m;
+ struct ipc_hdr m;
char cmsgbuf[CMSG_SPACE(sizeof(int))];
struct cmsghdr *cmsg;
@@ -378,19 +378,19 @@ static void ipc_send(int sk, uint8_t service_id, uint8_t opcode, uint16_t len,
void ipc_send_rsp(struct ipc *ipc, uint8_t service_id, uint8_t opcode,
uint8_t status)
{
- struct hal_status s;
+ struct ipc_status s;
int sk;
sk = g_io_channel_unix_get_fd(ipc->cmd_io);
- if (status == HAL_STATUS_SUCCESS) {
+ if (status == IPC_STATUS_SUCCESS) {
ipc_send(sk, service_id, opcode, 0, NULL, -1);
return;
}
s.code = status;
- ipc_send(sk, service_id, HAL_OP_STATUS, sizeof(s), &s, -1);
+ ipc_send(sk, service_id, IPC_OP_STATUS, sizeof(s), &s, -1);
}
void ipc_send_rsp_full(struct ipc *ipc, uint8_t service_id, uint8_t opcode,
diff --git a/android/main.c b/android/main.c
index a821dfa..6f7c426 100644
--- a/android/main.c
+++ b/android/main.c
@@ -48,6 +48,7 @@
#include "lib/bluetooth.h"
+#include "ipc-common.h"
#include "ipc.h"
#include "bluetooth.h"
#include "socket.h"
diff --git a/android/pan.c b/android/pan.c
index b4a3494..1e404ab 100644
--- a/android/pan.c
+++ b/android/pan.c
@@ -50,6 +50,7 @@
#include "src/log.h"
#include "hal-msg.h"
+#include "ipc-common.h"
#include "ipc.h"
#include "utils.h"
#include "bluetooth.h"
diff --git a/android/socket.c b/android/socket.c
index d463255..ee98b54 100644
--- a/android/socket.c
+++ b/android/socket.c
@@ -39,7 +39,7 @@
#include "src/log.h"
#include "hal-msg.h"
-#include "hal-ipc.h"
+#include "ipc-common.h"
#include "ipc.h"
#include "utils.h"
#include "bluetooth.h"
diff --git a/android/test-ipc.c b/android/test-ipc.c
index 84cb764..79821a0 100644
--- a/android/test-ipc.c
+++ b/android/test-ipc.c
@@ -39,9 +39,13 @@
#include <glib.h>
#include "src/shared/util.h"
#include "src/log.h"
-#include "android/hal-msg.h"
+#include "android/ipc-common.h"
#include "android/ipc.h"
+static const char HAL_SK_PATH[] = "\0test_hal_socket";
+
+#define SERVICE_ID_MAX 10
+
struct test_data {
bool disconnect;
const void *cmd;
@@ -79,11 +83,11 @@ static gboolean cmd_watch(GIOChannel *io, GIOCondition cond,
{
struct context *context = user_data;
const struct test_data *test_data = context->data;
- const struct hal_hdr *sent_msg = test_data->cmd;
+ const struct ipc_hdr *sent_msg = test_data->cmd;
uint8_t buf[128];
int sk;
- struct hal_hdr success_resp = {
+ struct ipc_hdr success_resp = {
.service_id = sent_msg->service_id,
.opcode = sent_msg->opcode,
.len = 0,
@@ -98,8 +102,8 @@ static gboolean cmd_watch(GIOChannel *io, GIOCondition cond,
sk = g_io_channel_unix_get_fd(io);
- g_assert(read(sk, buf, sizeof(buf)) == sizeof(struct hal_hdr));
- g_assert(!memcmp(&success_resp, buf, sizeof(struct hal_hdr)));
+ g_assert(read(sk, buf, sizeof(buf)) == sizeof(struct ipc_hdr));
+ g_assert(!memcmp(&success_resp, buf, sizeof(struct ipc_hdr)));
context_quit(context);
@@ -180,7 +184,7 @@ static struct context *create_context(gconstpointer data)
memset(&addr, 0, sizeof(addr));
addr.sun_family = AF_UNIX;
- memcpy(addr.sun_path, BLUEZ_HAL_SK_PATH, sizeof(BLUEZ_HAL_SK_PATH));
+ memcpy(addr.sun_path, HAL_SK_PATH, sizeof(HAL_SK_PATH));
ret = bind(sk, (struct sockaddr *) &addr, sizeof(addr));
g_assert(ret == 0);
@@ -236,8 +240,7 @@ static void test_init(gconstpointer data)
{
struct context *context = create_context(data);
- ipc = ipc_init(BLUEZ_HAL_SK_PATH, sizeof(BLUEZ_HAL_SK_PATH),
- HAL_SERVICE_ID_MAX);
+ ipc = ipc_init(HAL_SK_PATH, sizeof(HAL_SK_PATH), SERVICE_ID_MAX);
g_assert(ipc);
@@ -287,8 +290,7 @@ static void test_cmd(gconstpointer data)
{
struct context *context = create_context(data);
- ipc = ipc_init(BLUEZ_HAL_SK_PATH, sizeof(BLUEZ_HAL_SK_PATH),
- HAL_SERVICE_ID_MAX);
+ ipc = ipc_init(HAL_SK_PATH, sizeof(HAL_SK_PATH), SERVICE_ID_MAX);
g_assert(ipc);
@@ -307,8 +309,7 @@ static void test_cmd_reg(gconstpointer data)
struct context *context = create_context(data);
const struct test_data *test_data = context->data;
- ipc = ipc_init(BLUEZ_HAL_SK_PATH, sizeof(BLUEZ_HAL_SK_PATH),
- HAL_SERVICE_ID_MAX);
+ ipc = ipc_init(HAL_SK_PATH, sizeof(HAL_SK_PATH), SERVICE_ID_MAX);
g_assert(ipc);
@@ -329,8 +330,7 @@ static void test_cmd_reg_1(gconstpointer data)
{
struct context *context = create_context(data);
- ipc = ipc_init(BLUEZ_HAL_SK_PATH, sizeof(BLUEZ_HAL_SK_PATH),
- HAL_SERVICE_ID_MAX);
+ ipc = ipc_init(HAL_SK_PATH, sizeof(HAL_SK_PATH), SERVICE_ID_MAX);
g_assert(ipc);
@@ -363,13 +363,13 @@ static void test_cmd_handler_invalid(const void *buf, uint16_t len)
static const struct test_data test_init_1 = {};
-static const struct hal_hdr test_cmd_1_hdr = {
+static const struct ipc_hdr test_cmd_1_hdr = {
.service_id = 0,
.opcode = 1,
.len = 0
};
-static const struct hal_hdr test_cmd_2_hdr = {
+static const struct ipc_hdr test_cmd_2_hdr = {
.service_id = 0,
.opcode = 2,
.len = 0
@@ -449,8 +449,8 @@ static const struct test_data test_cmd_hdr_invalid = {
#define VARDATA_EX1 "some data example"
struct vardata {
- struct hal_hdr hdr;
- uint8_t data[BLUEZ_HAL_MTU - sizeof(struct hal_hdr)];
+ struct ipc_hdr hdr;
+ uint8_t data[IPC_MTU - sizeof(struct ipc_hdr)];
} __attribute__((packed));
static const struct vardata test_cmd_vardata = {
@@ -466,7 +466,7 @@ static const struct ipc_handler cmd_vardata_handlers[] = {
static const struct test_data test_cmd_vardata_valid = {
.cmd = &test_cmd_vardata,
- .cmd_size = sizeof(struct hal_hdr) + sizeof(VARDATA_EX1),
+ .cmd_size = sizeof(struct ipc_hdr) + sizeof(VARDATA_EX1),
.service = 0,
.handlers = cmd_vardata_handlers,
.handlers_size = 1,
@@ -478,7 +478,7 @@ static const struct ipc_handler cmd_vardata_handlers_valid2[] = {
static const struct test_data test_cmd_vardata_valid_2 = {
.cmd = &test_cmd_vardata,
- .cmd_size = sizeof(struct hal_hdr) + sizeof(VARDATA_EX1),
+ .cmd_size = sizeof(struct ipc_hdr) + sizeof(VARDATA_EX1),
.service = 0,
.handlers = cmd_vardata_handlers_valid2,
.handlers_size = 1,
@@ -486,22 +486,22 @@ static const struct test_data test_cmd_vardata_valid_2 = {
static const struct test_data test_cmd_vardata_invalid_1 = {
.cmd = &test_cmd_vardata,
- .cmd_size = sizeof(struct hal_hdr) + sizeof(VARDATA_EX1) - 1,
+ .cmd_size = sizeof(struct ipc_hdr) + sizeof(VARDATA_EX1) - 1,
.service = 0,
.handlers = cmd_vardata_handlers,
.handlers_size = 1,
.disconnect = true,
};
-static const struct hal_hdr test_cmd_service_offrange_hdr = {
- .service_id = HAL_SERVICE_ID_MAX + 1,
+static const struct ipc_hdr test_cmd_service_offrange_hdr = {
+ .service_id = SERVICE_ID_MAX + 1,
.opcode = 1,
.len = 0
};
static const struct test_data test_cmd_service_offrange = {
.cmd = &test_cmd_service_offrange_hdr,
- .cmd_size = sizeof(struct hal_hdr),
+ .cmd_size = sizeof(struct ipc_hdr),
.service = 0,
.handlers = cmd_handlers,
.handlers_size = 1,
@@ -517,7 +517,7 @@ static const struct vardata test_cmd_invalid_data_1 = {
static const struct test_data test_cmd_msg_invalid_1 = {
.cmd = &test_cmd_invalid_data_1,
- .cmd_size = sizeof(struct hal_hdr) + sizeof(VARDATA_EX1) - 1,
+ .cmd_size = sizeof(struct ipc_hdr) + sizeof(VARDATA_EX1) - 1,
.service = 0,
.handlers = cmd_handlers,
.handlers_size = 1,
@@ -533,7 +533,7 @@ static const struct vardata test_cmd_invalid_data_2 = {
static const struct test_data test_cmd_msg_invalid_2 = {
.cmd = &test_cmd_invalid_data_2,
- .cmd_size = sizeof(struct hal_hdr) + sizeof(VARDATA_EX1),
+ .cmd_size = sizeof(struct ipc_hdr) + sizeof(VARDATA_EX1),
.service = 0,
.handlers = cmd_handlers,
.handlers_size = 1,
--
1.8.3.2
^ permalink raw reply related
* [PATCH 01/13] android/hal-gatt-api: Add missing opcodes in GATT Service
From: Jakub Tyszkowski @ 2014-02-25 11:08 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Jakub Tyszkowski
Add missing Listen and Set Advertising Data opcodes and reorder them as
they appear in HAL's headers.
---
android/hal-ipc-api.txt | 107 ++++++++++++++++++++++++++++--------------------
1 file changed, 63 insertions(+), 44 deletions(-)
diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
index 5c3933a..49d704e 100644
--- a/android/hal-ipc-api.txt
+++ b/android/hal-ipc-api.txt
@@ -1406,39 +1406,56 @@ Bluetooth GATT HAL (ID 9)
Android HAL name: "gatt" (BT_PROFILE_GATT_ID)
Opcode 0x00 - Error response
+
+ Response parameters: Status (1 octet)
+
+ Valid status values: 0x01 = Fail
+ 0x02 = Not ready
+ 0x03 = No memory
+ 0x04 = Busy
+ 0x05 = Done (already completed)
+ 0x06 = Unsupported
+ 0x07 = Parameter invalid
+ 0x08 = Unhandled
+ 0x09 = Authentication failure
+ 0x0a = Remote device down
+
Opcode 0x01 - Register Client command/response
Opcode 0x02 - Unregister Client command/response
Opcode 0x03 - Scan command/response
Opcode 0x04 - Connect Device command/response
Opcode 0x05 - Disconnect Device command/response
- Opcode 0x06 - Refresh command/response
- Opcode 0x07 - Search Service command/response
- Opcode 0x08 - Get Included Service command/response
- Opcode 0x09 - Get Characteristic command/response
- Opcode 0x0a - Get Descriptor command/response
- Opcode 0x0b - Read Characteristic command/response
- Opcode 0x0c - Write Characteristic command/response
- Opcode 0x0d - Read Descriptor command/response
- Opcode 0x0e - Write Descriptor command/response
- Opcode 0x0f - Execute Write command/response
- Opcode 0x10 - Register For Notification command/response
- Opcode 0x11 - Deregister For Notification command/response
- Opcode 0x12 - Read Remote RSSI command/response
- Opcode 0x13 - Get Device Type command/response
- Opcode 0x14 - Test Command command/response
- Opcode 0x15 - Register Server command/response
- Opcode 0x16 - Unregister Server command/response
- Opcode 0x17 - Connect Peripheral command/response
- Opcode 0x18 - Disconnect Peripheral command/response
- Opcode 0x19 - Add Service command/response
- Opcode 0x1a - Add Included Service command/response
- Opcode 0x1b - Add Characteristic command/response
- Opcode 0x1c - Add Descriptor command/response
- Opcode 0x1d - Start Service command/response
- Opcode 0x1e - Stop Service command/response
- Opcode 0x1f - Delete Service command/response
- Opcode 0x20 - Send Indication command/response
- Opcode 0x21 - Send Response command/response
+ Opcode 0x06 - Listen command/response
+ Opcode 0x07 - Refresh command/response
+ Opcode 0x08 - Search Service command/response
+ Opcode 0x09 - Get Included Service command/response
+ Opcode 0x0a - Get Characteristic command/response
+ Opcode 0x0b - Get Descriptor command/response
+ Opcode 0x0c - Read Characteristic command/response
+ Opcode 0x0d - Write Characteristic command/response
+ Opcode 0x0e - Read Descriptor command/response
+ Opcode 0x0f - Write Descriptor command/response
+ Opcode 0x10 - Execute Write command/response
+ Opcode 0x11 - Register For Notification command/response
+ Opcode 0x12 - Deregister For Notification command/response
+ Opcode 0x13 - Read Remote RSSI command/response
+ Opcode 0x14 - Get Device Type command/response
+ Opcode 0x15 - Set Advertising data command/response
+ Opcode 0x16 - Test Command command/response
+
+ Opcode 0x17 - Register Server command/response
+ Opcode 0x18 - Unregister Server command/response
+ Opcode 0x19 - Connect Peripheral command/response
+ Opcode 0x1a - Disconnect Peripheral command/response
+ Opcode 0x1b - Add Service command/response
+ Opcode 0x1c - Add Included Service command/response
+ Opcode 0x1d - Add Characteristic command/response
+ Opcode 0x1e - Add Descriptor command/response
+ Opcode 0x1f - Start Service command/response
+ Opcode 0x20 - Stop Service command/response
+ Opcode 0x21 - Delete Service command/response
+ Opcode 0x22 - Send Indication command/response
+ Opcode 0x23 - Send Response command/response
Opcode 0x81 - Register Client notification
Opcode 0x82 - Scan Result notification
@@ -1453,20 +1470,22 @@ Android HAL name: "gatt" (BT_PROFILE_GATT_ID)
Opcode 0x8b - Notify notification
Opcode 0x8c - Read Characteristic notification
Opcode 0x8d - Write Characteristic notification
- Opcode 0x8e - Execute Write notification
- Opcode 0x8f - Read Descriptor notification
- Opcode 0x90 - Write Descriptor notification
+ Opcode 0x8e - Read Descriptor notification
+ Opcode 0x8f - Write Descriptor notification
+ Opcode 0x90 - Execute Write notification
Opcode 0x91 - Read Remote RSSI notification
- Opcode 0x92 - Register Server notification
- Opcode 0x93 - Connection notification
- Opcode 0x94 - Service Added notification
- Opcode 0x95 - Included Service Added notification
- Opcode 0x96 - Characteristic Added notification
- Opcode 0x97 - Descriptor Added notification
- Opcode 0x98 - Service Started notification
- Opcode 0x99 - Service Stopped notification
- Opcode 0x9a - Service Deleted notification
- Opcode 0x9b - Request Read notification
- Opcode 0x9c - Request Write notification
- Opcode 0x9d - Request Execute Write notification
- Opcode 0x9e - Response Confirmation notification
+ Opcode 0x92 - Listen notification
+
+ Opcode 0x93 - Register Server notification
+ Opcode 0x94 - Connection notification
+ Opcode 0x95 - Service Added notification
+ Opcode 0x96 - Included Service Added notification
+ Opcode 0x97 - Characteristic Added notification
+ Opcode 0x98 - Descriptor Added notification
+ Opcode 0x99 - Service Started notification
+ Opcode 0x9a - Service Stopped notification
+ Opcode 0x9b - Service Deleted notification
+ Opcode 0x9c - Request Read notification
+ Opcode 0x9d - Request Write notification
+ Opcode 0x9e - Request Execute Write notification
+ Opcode 0x9f - Response Confirmation notification
--
1.9.0
^ permalink raw reply related
* [PATCH 02/13] android/hal-gatt-api: Add Register Client
From: Jakub Tyszkowski @ 2014-02-25 11:08 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Jakub Tyszkowski
In-Reply-To: <1393326512-16373-1-git-send-email-jakub.tyszkowski@tieto.com>
---
android/hal-ipc-api.txt | 6 ++++++
android/hal-msg.h | 7 +++++++
2 files changed, 13 insertions(+)
diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
index 49d704e..70c451d 100644
--- a/android/hal-ipc-api.txt
+++ b/android/hal-ipc-api.txt
@@ -1421,6 +1421,12 @@ Android HAL name: "gatt" (BT_PROFILE_GATT_ID)
0x0a = Remote device down
Opcode 0x01 - Register Client command/response
+
+ Command parameters: Service UUID (16 octets)
+ Response parameters: <none>
+
+ In case of an error, the error response will be returned.
+
Opcode 0x02 - Unregister Client command/response
Opcode 0x03 - Scan command/response
Opcode 0x04 - Connect Device command/response
diff --git a/android/hal-msg.h b/android/hal-msg.h
index 836dbbf..6032aea 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -957,3 +957,10 @@ struct hal_ev_avrcp_passthrough_cmd {
uint8_t id;
uint8_t state;
} __attribute__((packed));
+
+/* GAT CLIENT HAL API */
+
+#define HAL_OP_GATT_CLIENT_REGISTER 0x01
+struct hal_cmd_gatt_client_register {
+ uint8_t uuid[16];
+} __attribute__((packed));
--
1.9.0
^ permalink raw reply related
* [PATCH 03/13] android/hal-gatt-api: Add Unregister Client
From: Jakub Tyszkowski @ 2014-02-25 11:08 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Jakub Tyszkowski
In-Reply-To: <1393326512-16373-1-git-send-email-jakub.tyszkowski@tieto.com>
---
android/hal-ipc-api.txt | 6 ++++++
android/hal-msg.h | 5 +++++
2 files changed, 11 insertions(+)
diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
index 70c451d..53fa5b9 100644
--- a/android/hal-ipc-api.txt
+++ b/android/hal-ipc-api.txt
@@ -1428,6 +1428,12 @@ Android HAL name: "gatt" (BT_PROFILE_GATT_ID)
In case of an error, the error response will be returned.
Opcode 0x02 - Unregister Client command/response
+
+ Command parameters: Client Interface (4 octets)
+ Response parameters: <none>
+
+ In case of an error, the error response will be returned.
+
Opcode 0x03 - Scan command/response
Opcode 0x04 - Connect Device command/response
Opcode 0x05 - Disconnect Device command/response
diff --git a/android/hal-msg.h b/android/hal-msg.h
index 6032aea..4587142 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -964,3 +964,8 @@ struct hal_ev_avrcp_passthrough_cmd {
struct hal_cmd_gatt_client_register {
uint8_t uuid[16];
} __attribute__((packed));
+
+#define HAL_OP_GATT_CLIENT_UNREGISTER 0x02
+struct hal_cmd_gatt_client_unregister {
+ int32_t client_if;
+} __attribute__((packed));
--
1.9.0
^ permalink raw reply related
* [PATCH 04/13] android/hal-gatt-api: Add Client Scan
From: Jakub Tyszkowski @ 2014-02-25 11:08 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Jakub Tyszkowski
In-Reply-To: <1393326512-16373-1-git-send-email-jakub.tyszkowski@tieto.com>
---
android/hal-ipc-api.txt | 7 +++++++
android/hal-msg.h | 6 ++++++
2 files changed, 13 insertions(+)
diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
index 53fa5b9..51aaba1 100644
--- a/android/hal-ipc-api.txt
+++ b/android/hal-ipc-api.txt
@@ -1435,6 +1435,13 @@ Android HAL name: "gatt" (BT_PROFILE_GATT_ID)
In case of an error, the error response will be returned.
Opcode 0x03 - Scan command/response
+
+ Command parameters: Client Interface (4 octets)
+ Start (1 octet)
+ Response parameters: <none>
+
+ In case of an error, the error response will be returned.
+
Opcode 0x04 - Connect Device command/response
Opcode 0x05 - Disconnect Device command/response
Opcode 0x06 - Listen command/response
diff --git a/android/hal-msg.h b/android/hal-msg.h
index 4587142..0c6df68 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -969,3 +969,9 @@ struct hal_cmd_gatt_client_register {
struct hal_cmd_gatt_client_unregister {
int32_t client_if;
} __attribute__((packed));
+
+#define HAL_OP_GATT_CLIENT_SCAN 0x03
+struct hal_cmd_gatt_client_scan {
+ int32_t client_if;
+ uint8_t start;
+} __attribute__((packed));
--
1.9.0
^ permalink raw reply related
* [PATCH 05/13] android/hal-gatt-api: Add Client Connect Remote
From: Jakub Tyszkowski @ 2014-02-25 11:08 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Jakub Tyszkowski
In-Reply-To: <1393326512-16373-1-git-send-email-jakub.tyszkowski@tieto.com>
---
android/hal-ipc-api.txt | 8 ++++++++
android/hal-msg.h | 7 +++++++
2 files changed, 15 insertions(+)
diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
index 51aaba1..bbb94a9 100644
--- a/android/hal-ipc-api.txt
+++ b/android/hal-ipc-api.txt
@@ -1443,6 +1443,14 @@ Android HAL name: "gatt" (BT_PROFILE_GATT_ID)
In case of an error, the error response will be returned.
Opcode 0x04 - Connect Device command/response
+
+ Command parameters: Client Interface (4 octets)
+ Remote address (6 octets)
+ Is Direct (1 octet)
+ Response parameters: <none>
+
+ In case of an error, the error response will be returned.
+
Opcode 0x05 - Disconnect Device command/response
Opcode 0x06 - Listen command/response
Opcode 0x07 - Refresh command/response
diff --git a/android/hal-msg.h b/android/hal-msg.h
index 0c6df68..032c6f1 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -975,3 +975,10 @@ struct hal_cmd_gatt_client_scan {
int32_t client_if;
uint8_t start;
} __attribute__((packed));
+
+#define HAL_OP_GATT_CLIENT_CONNECT 0x04
+struct hal_cmd_gatt_client_connect {
+ int32_t client_if;
+ uint8_t bdaddr[6];
+ uint8_t is_direct;
+} __attribute__((packed));
--
1.9.0
^ permalink raw reply related
* [PATCH 06/13] android/hal-gatt-api: Add Client Disconnect Remote
From: Jakub Tyszkowski @ 2014-02-25 11:08 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Jakub Tyszkowski
In-Reply-To: <1393326512-16373-1-git-send-email-jakub.tyszkowski@tieto.com>
---
android/hal-ipc-api.txt | 8 ++++++++
android/hal-msg.h | 7 +++++++
2 files changed, 15 insertions(+)
diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
index bbb94a9..ffc903a 100644
--- a/android/hal-ipc-api.txt
+++ b/android/hal-ipc-api.txt
@@ -1452,6 +1452,14 @@ Android HAL name: "gatt" (BT_PROFILE_GATT_ID)
In case of an error, the error response will be returned.
Opcode 0x05 - Disconnect Device command/response
+
+ Command parameters: Client Interface (4 octets)
+ Remote address (6 octets)
+ Connection ID (4 octets)
+ Response parameters: <none>
+
+ In case of an error, the error response will be returned.
+
Opcode 0x06 - Listen command/response
Opcode 0x07 - Refresh command/response
Opcode 0x08 - Search Service command/response
diff --git a/android/hal-msg.h b/android/hal-msg.h
index 032c6f1..22cfaf4 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -982,3 +982,10 @@ struct hal_cmd_gatt_client_connect {
uint8_t bdaddr[6];
uint8_t is_direct;
} __attribute__((packed));
+
+#define HAL_OP_GATT_CLIENT_DISCONNECT 0x05
+struct hal_cmd_gatt_client_disconnect {
+ int32_t client_if;
+ uint8_t bdaddr[6];
+ int32_t conn_id;
+} __attribute__((packed));
--
1.9.0
^ permalink raw reply related
* [PATCH 07/13] android/hal-gatt-api: Add Client Listen
From: Jakub Tyszkowski @ 2014-02-25 11:08 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Jakub Tyszkowski
In-Reply-To: <1393326512-16373-1-git-send-email-jakub.tyszkowski@tieto.com>
---
android/hal-ipc-api.txt | 7 +++++++
android/hal-msg.h | 6 ++++++
2 files changed, 13 insertions(+)
diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
index ffc903a..9021154 100644
--- a/android/hal-ipc-api.txt
+++ b/android/hal-ipc-api.txt
@@ -1461,6 +1461,13 @@ Android HAL name: "gatt" (BT_PROFILE_GATT_ID)
In case of an error, the error response will be returned.
Opcode 0x06 - Listen command/response
+
+ Command parameters: Client Interface (4 octets)
+ Start (1 octet)
+ Response parameters: <none>
+
+ In case of an error, the error response will be returned.
+
Opcode 0x07 - Refresh command/response
Opcode 0x08 - Search Service command/response
Opcode 0x09 - Get Included Service command/response
diff --git a/android/hal-msg.h b/android/hal-msg.h
index 22cfaf4..de714dd 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -989,3 +989,9 @@ struct hal_cmd_gatt_client_disconnect {
uint8_t bdaddr[6];
int32_t conn_id;
} __attribute__((packed));
+
+#define HAL_OP_GATT_CLIENT_LISTEN 0x06
+struct hal_cmd_gatt_client_listen {
+ int32_t client_if;
+ uint8_t start;
+} __attribute__((packed));
--
1.9.0
^ permalink raw reply related
* [PATCH 08/13] android/hal-gatt-api: Add Client Refresh Remote Cache
From: Jakub Tyszkowski @ 2014-02-25 11:08 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Jakub Tyszkowski
In-Reply-To: <1393326512-16373-1-git-send-email-jakub.tyszkowski@tieto.com>
---
android/hal-ipc-api.txt | 7 +++++++
android/hal-msg.h | 6 ++++++
2 files changed, 13 insertions(+)
diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
index 9021154..9a3c776 100644
--- a/android/hal-ipc-api.txt
+++ b/android/hal-ipc-api.txt
@@ -1469,6 +1469,13 @@ Android HAL name: "gatt" (BT_PROFILE_GATT_ID)
In case of an error, the error response will be returned.
Opcode 0x07 - Refresh command/response
+
+ Command parameters: Client Interface (4 octets)
+ Remote address (6 octets)
+ Response parameters: <none>
+
+ In case of an error, the error response will be returned.
+
Opcode 0x08 - Search Service command/response
Opcode 0x09 - Get Included Service command/response
Opcode 0x0a - Get Characteristic command/response
diff --git a/android/hal-msg.h b/android/hal-msg.h
index de714dd..3a7ccd6 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -995,3 +995,9 @@ struct hal_cmd_gatt_client_listen {
int32_t client_if;
uint8_t start;
} __attribute__((packed));
+
+#define HAL_OP_GATT_CLIENT_REFRESH 0x07
+struct hal_cmd_gatt_client_refresh {
+ int32_t client_if;
+ uint8_t bdaddr[6];
+} __attribute__((packed));
--
1.9.0
^ permalink raw reply related
* [PATCH 09/13] android/hal-gatt-api: Add Client Search Service
From: Jakub Tyszkowski @ 2014-02-25 11:08 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Jakub Tyszkowski
In-Reply-To: <1393326512-16373-1-git-send-email-jakub.tyszkowski@tieto.com>
---
android/hal-ipc-api.txt | 10 ++++++++++
android/hal-msg.h | 7 +++++++
2 files changed, 17 insertions(+)
diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
index 9a3c776..b5f302b 100644
--- a/android/hal-ipc-api.txt
+++ b/android/hal-ipc-api.txt
@@ -1477,6 +1477,16 @@ Android HAL name: "gatt" (BT_PROFILE_GATT_ID)
In case of an error, the error response will be returned.
Opcode 0x08 - Search Service command/response
+
+ Command parameters: Connection ID (4 octets)
+ Number of UUID Filters (1 octet)
+ UUID Filter (variable)
+ Valid Number of UUID Filters: 0x00
+ 0x01
+ Response parameters: <none>
+
+ In case of an error, the error response will be returned.
+
Opcode 0x09 - Get Included Service command/response
Opcode 0x0a - Get Characteristic command/response
Opcode 0x0b - Get Descriptor command/response
diff --git a/android/hal-msg.h b/android/hal-msg.h
index 3a7ccd6..0f2b011 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -1001,3 +1001,10 @@ struct hal_cmd_gatt_client_refresh {
int32_t client_if;
uint8_t bdaddr[6];
} __attribute__((packed));
+
+#define HAL_OP_GATT_CLIENT_SEARCH_SERVICE 0x08
+struct hal_cmd_gatt_client_search_service {
+ int32_t conn_id;
+ uint8_t number;
+ uint8_t uuid[0];
+} __attribute__((packed));
--
1.9.0
^ permalink raw reply related
* [PATCH 10/13] android/hal-gatt-api: Add Client Get Included Service
From: Jakub Tyszkowski @ 2014-02-25 11:08 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Jakub Tyszkowski
In-Reply-To: <1393326512-16373-1-git-send-email-jakub.tyszkowski@tieto.com>
---
android/hal-ipc-api.txt | 14 ++++++++++++++
android/hal-msg.h | 17 +++++++++++++++++
2 files changed, 31 insertions(+)
diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
index b5f302b..13974c7 100644
--- a/android/hal-ipc-api.txt
+++ b/android/hal-ipc-api.txt
@@ -1488,6 +1488,20 @@ Android HAL name: "gatt" (BT_PROFILE_GATT_ID)
In case of an error, the error response will be returned.
Opcode 0x09 - Get Included Service command/response
+
+ Command parameters: Connection ID (4 octets)
+ Number of Service ID Elements (1 octet)
+ Service ID Elements (variable)
+ Valid Number of Service ID Elements: 0x01
+ 0x02
+ Valid Service ID Element: GATT ID (17 octets)
+ Is Primary (1 octet)
+ Valid GATT ID: UUID (16 octets)
+ Instance ID (1 octet)
+ Response parameters: <none>
+
+ In case of an error, the error response will be returned.
+
Opcode 0x0a - Get Characteristic command/response
Opcode 0x0b - Get Descriptor command/response
Opcode 0x0c - Read Characteristic command/response
diff --git a/android/hal-msg.h b/android/hal-msg.h
index 0f2b011..cd13b0c 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -1008,3 +1008,20 @@ struct hal_cmd_gatt_client_search_service {
uint8_t number;
uint8_t uuid[0];
} __attribute__((packed));
+
+#define HAL_OP_GATT_CLIENT_GET_INCLUDED_SERVICE 0x09
+struct hal_gatt_gatt_id {
+ uint8_t uuid[16];
+ uint8_t inst_id;
+} __attribute__((packed));
+
+struct hal_gatt_srvc_id {
+ struct hal_gatt_gatt_id gatt_id;
+ uint8_t is_primary;
+} __attribute__((packed));
+
+struct hal_cmd_gatt_client_get_service {
+ int32_t conn_id;
+ uint8_t number;
+ uint8_t srvc_id[0];
+} __attribute__((packed));
--
1.9.0
^ permalink raw reply related
* [PATCH 11/13] android/hal-gatt-api: Add Client Get Characteristic
From: Jakub Tyszkowski @ 2014-02-25 11:08 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Jakub Tyszkowski
In-Reply-To: <1393326512-16373-1-git-send-email-jakub.tyszkowski@tieto.com>
---
android/hal-ipc-api.txt | 13 +++++++++++++
android/hal-msg.h | 8 ++++++++
2 files changed, 21 insertions(+)
diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
index 13974c7..e490bd1 100644
--- a/android/hal-ipc-api.txt
+++ b/android/hal-ipc-api.txt
@@ -1503,6 +1503,19 @@ Android HAL name: "gatt" (BT_PROFILE_GATT_ID)
In case of an error, the error response will be returned.
Opcode 0x0a - Get Characteristic command/response
+
+ Command parameters: Connection ID (4 octets)
+ Service ID (18 octets)
+ Number of GATT ID Elements (1 octet)
+ GATT ID Elements (variable)
+ Valid Service ID: as described in Get Included Service
+ Valid Number of GATT ID Elements: 0x00
+ 0x01
+ Valid GATT ID Element: as described in Get Included Service
+ Response parameters: <none>
+
+ In case of an error, the error response will be returned.
+
Opcode 0x0b - Get Descriptor command/response
Opcode 0x0c - Read Characteristic command/response
Opcode 0x0d - Write Characteristic command/response
diff --git a/android/hal-msg.h b/android/hal-msg.h
index cd13b0c..d0ebad8 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -1025,3 +1025,11 @@ struct hal_cmd_gatt_client_get_service {
uint8_t number;
uint8_t srvc_id[0];
} __attribute__((packed));
+
+#define HAL_OP_GATT_CLIENT_GET_CHARACTERISTIC 0x0a
+struct hal_cmd_gatt_client_get_characteristic {
+ int32_t connection_id;
+ struct hal_gatt_srvc_id srvc_id;
+ uint8_t number;
+ uint8_t gatt_id[0];
+} __attribute__((packed));
--
1.9.0
^ permalink raw reply related
* [PATCH 12/13] android/hal-gatt-api: Add Client Get Descriptor
From: Jakub Tyszkowski @ 2014-02-25 11:08 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Jakub Tyszkowski
In-Reply-To: <1393326512-16373-1-git-send-email-jakub.tyszkowski@tieto.com>
---
android/hal-ipc-api.txt | 13 +++++++++++++
android/hal-msg.h | 8 ++++++++
2 files changed, 21 insertions(+)
diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
index e490bd1..a6d23dd 100644
--- a/android/hal-ipc-api.txt
+++ b/android/hal-ipc-api.txt
@@ -1517,6 +1517,19 @@ Android HAL name: "gatt" (BT_PROFILE_GATT_ID)
In case of an error, the error response will be returned.
Opcode 0x0b - Get Descriptor command/response
+
+ Command parameters: Connection ID (4 octets)
+ Service ID (18 octets)
+ Number of GATT ID Elements (1 octet)
+ GATT ID Elements (variable)
+ Valid Service ID: as described in Get Included Service
+ Valid Number of GATT ID Elements: 0x01
+ 0x02
+ Valid GATT ID Element: as described in Get Included Service
+ Response parameters: <none>
+
+ In case of an error, the error response will be returned.
+
Opcode 0x0c - Read Characteristic command/response
Opcode 0x0d - Write Characteristic command/response
Opcode 0x0e - Read Descriptor command/response
diff --git a/android/hal-msg.h b/android/hal-msg.h
index d0ebad8..576d4d5 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -1033,3 +1033,11 @@ struct hal_cmd_gatt_client_get_characteristic {
uint8_t number;
uint8_t gatt_id[0];
} __attribute__((packed));
+
+#define HAL_OP_GATT_CLIENT_GET_DESCRIPTOR 0x0b
+struct hal_cmd_gatt_client_get_descroptor {
+ int32_t connection_id;
+ struct hal_gatt_srvc_id srvc_id;
+ uint8_t number;
+ uint8_t gatt_id[0];
+} __attribute__((packed));
--
1.9.0
^ permalink raw reply related
* [PATCH 13/13] android/hal-gatt-api: Add Read Characteristic
From: Jakub Tyszkowski @ 2014-02-25 11:08 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Jakub Tyszkowski
In-Reply-To: <1393326512-16373-1-git-send-email-jakub.tyszkowski@tieto.com>
---
android/hal-ipc-api.txt | 11 +++++++++++
android/hal-msg.h | 8 ++++++++
2 files changed, 19 insertions(+)
diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
index a6d23dd..5349c53 100644
--- a/android/hal-ipc-api.txt
+++ b/android/hal-ipc-api.txt
@@ -1531,6 +1531,17 @@ Android HAL name: "gatt" (BT_PROFILE_GATT_ID)
In case of an error, the error response will be returned.
Opcode 0x0c - Read Characteristic command/response
+
+ Command parameters: Connection ID (4 octets)
+ Service ID (18 octets)
+ GATT ID (17 octets)
+ Authorization (4 octets)
+ Valid Service ID: as described in Get Included Service
+ Valid GATT ID: as described in Get Included Service
+ Response parameters: <none>
+
+ In case of an error, the error response will be returned.
+
Opcode 0x0d - Write Characteristic command/response
Opcode 0x0e - Read Descriptor command/response
Opcode 0x0f - Write Descriptor command/response
diff --git a/android/hal-msg.h b/android/hal-msg.h
index 576d4d5..e7a5b6d 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -1041,3 +1041,11 @@ struct hal_cmd_gatt_client_get_descroptor {
uint8_t number;
uint8_t gatt_id[0];
} __attribute__((packed));
+
+#define HAL_OP_GATT_CLIENT_READ_CHARACTERISTIC 0x0c
+struct hal_cmd_gatt_client_read_characteristic {
+ int32_t connection_id;
+ struct hal_gatt_srvc_id srvc_id;
+ struct hal_gatt_gatt_id gatt_id;
+ int32_t authorization;
+} __attribute__((packed));
--
1.9.0
^ permalink raw reply related
* Re: [PATCH 1/4] unit/avrcp: Add /TP/PTT/BV-02-I test
From: Luiz Augusto von Dentz @ 2014-02-25 11:21 UTC (permalink / raw)
To: Andrei Emeltchenko; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <1393322970-27451-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
Hi Andrei,
On Tue, Feb 25, 2014 at 12:09 PM, Andrei Emeltchenko
<Andrei.Emeltchenko.news@gmail.com> wrote:
> From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
>
> Test verifies that the Target reacts to the PASS THROUGH command in
> category 2 from the Controller. The command chosen is VOLUME_UP.
> ---
> unit/test-avrcp.c | 16 ++++++++++++++++
> 1 file changed, 16 insertions(+)
>
> diff --git a/unit/test-avrcp.c b/unit/test-avrcp.c
> index 9bd27da..7308443 100644
> --- a/unit/test-avrcp.c
> +++ b/unit/test-avrcp.c
> @@ -251,11 +251,21 @@ static void execute_context(struct context *context)
>
> static bool handle_play(struct avrcp *session)
> {
> + DBG("");
> +
> + return true;
> +}
> +
> +static bool handle_volume_up(struct avrcp *session)
> +{
> + DBG("");
> +
> return true;
> }
>
> static const struct avrcp_passthrough_handler passthrough_handlers[] = {
> { AVC_PLAY, handle_play },
> + { AVC_VOLUME_UP, handle_volume_up },
> { },
> };
>
> @@ -310,5 +320,11 @@ int main(int argc, char *argv[])
> raw_pdu(0x02, 0x11, 0x0e, 0x09, 0x48, 0x7c,
> 0x44, 0x00));
>
> + define_test("/TP/PTT/BV-02-I", test_server,
> + raw_pdu(0x00, 0x11, 0x0e, 0x00, 0x48, 0x7c,
> + AVC_VOLUME_UP, 0x00),
> + raw_pdu(0x02, 0x11, 0x0e, 0x09, 0x48, 0x7c,
> + AVC_VOLUME_UP, 0x00));
> +
> return g_test_run();
> }
> --
> 1.8.3.2
Patches 1-3 applied, not sure where is 4/4 so Im waiting to see it
does show up otherwise you have to resend it.
--
Luiz Augusto von Dentz
^ permalink raw reply
* [v2] android/pics: Add PICS and PIXIT for HSP
From: Sebastian Chlad @ 2014-02-25 12:07 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Sebastian Chlad
In-Reply-To: <1393242895-19447-1-git-send-email-sebastian.chlad@tieto.com>
Added PICS and PIXIT target Android 4.4
---
android/Makefile.am | 2 +
android/pics-hsp.txt | 103 ++++++++++++++++++++++++++++++++++++++++++++++++++
android/pixit-hsp.txt | 30 +++++++++++++++
3 files changed, 135 insertions(+)
create mode 100644 android/pics-hsp.txt
create mode 100644 android/pixit-hsp.txt
diff --git a/android/Makefile.am b/android/Makefile.am
index 50d0dc0..58cfbae 100644
--- a/android/Makefile.am
+++ b/android/Makefile.am
@@ -188,6 +188,7 @@ EXTRA_DIST += android/Android.mk android/README \
android/pics-a2dp.txt \
android/pics-avctp.txt \
android/pics-avrcp.txt \
+ android/pics-hsp.txt \
android/pixit-l2cap.txt \
android/pixit-gap.txt \
android/pixit-did.txt \
@@ -199,6 +200,7 @@ EXTRA_DIST += android/Android.mk android/README \
android/pixit-a2dp.txt \
android/pixit-avctp.txt \
android/pixit-avrcp.txt \
+ android/pixit-hsp.txt \
android/pts-l2cap.txt \
android/pts-gap.txt \
android/pts-did.txt \
diff --git a/android/pics-hsp.txt b/android/pics-hsp.txt
new file mode 100644
index 0000000..3e996ab
--- /dev/null
+++ b/android/pics-hsp.txt
@@ -0,0 +1,103 @@
+HSP PICS for the PTS tool.
+
+PTS version: 5.0
+
+* - different than PTS defaults
+# - not yet implemented/supported
+
+M - mandatory
+O - optional
+
+ Version
+-------------------------------------------------------------------------------
+Parameter Name Selected Description
+-------------------------------------------------------------------------------
+TSPC_HSP_0_1 False Version: Headset Profile v1.1 (C.1)
+TSPC_HSP_0_2 True (*) Version: Headset Profile v1.2 (C.1)
+-------------------------------------------------------------------------------
+C.1: Mandatory to support one and only one of these versions.
+-------------------------------------------------------------------------------
+
+
+ Roles
+-------------------------------------------------------------------------------
+Parameter Name Selected Description
+-------------------------------------------------------------------------------
+TSPC_HSP_1_1 True (*) Role: Audio Gateway (AG) (C.1)
+TSPC_HSP_1_2 False Role: Headset (HS) (C.1)
+-------------------------------------------------------------------------------
+C.1: Mandatory to support at least one of the defined roles.
+-------------------------------------------------------------------------------
+
+
+ Audio Gateway Role
+-------------------------------------------------------------------------------
+Parameter Name Selected Description
+-------------------------------------------------------------------------------
+TSPC_HSP_2_1 True Incoming audio connection establishment (M)
+TSPC_HSP_2_2 True (*) Ring (AT command) (C.3)
+TSPC_HSP_2_3 False Inband ring tone (O)
+TSPC_HSP_2_4 True (*) Outgoing audio connection establishment (O)
+TSPC_HSP_2_5 True (*) Audio connection release from HS (C.5)
+TSPC_HSP_2_6 True Audio connection release from AG (M)
+TSPC_HSP_2_7 True Audio connection transfer: AG to HS (M)
+TSPC_HSP_2_8 True Audio connection transfer: HS to AG (M)
+TSPC_HSP_2_9 False Remote audio volume control (C.1)
+TSPC_HSP_2_10 False HS informs AG about local changes of audio
+ volume (O)
+TSPC_HSP_2_11 False Audio volume setting storage by HS (O)
+TSPC_HSP_2_12 False Remote microphone gain control (C.2)
+TSPC_HSP_2_13 False HS informs AG about local changes of microphone
+ gain (O)
+TSPC_HSP_2_14 False Microphone gain setting storage by HS (O)
+TSPC_HSP_2_15 True Connection handling with Detach/Page (M)
+TSPC_HSP_2_16 False Connection handling with Park Mode (C.4)
+-------------------------------------------------------------------------------
+C.1: Mandatory if TSPC_HSP_2_10 is supported, otherwise optional
+C:2: Mandatory if TSPC_HSP_2_13 is supported, otherwise optional
+C.3: Excluded if TSPC_HSP_2_3 and TSPC_HSP_4_1 ("Show that in-band
+ ringing and RING are mutually exclusive") are supported,
+ otherwise optional
+C.4: Excluded if TSPC_HSP_0_2 is supported, otherwise optional
+C.5: Mandatory if TSPC_HSP_0_1 is supported, otherwise optional
+-------------------------------------------------------------------------------
+
+
+ Headset Application Features
+-------------------------------------------------------------------------------
+Parameter Name Selected Description
+-------------------------------------------------------------------------------
+TSPC_HSP_3_1 False (*) Incoming audio connection establishment (M)
+TSPC_HSP_3_2 False (*) Ring (AT command) (M)
+TSPC_HSP_3_3 False (*) Inband ring tone (M)
+TSPC_HSP_3_4 False (*) Outgoing audio connection establishment (M)
+TSPC_HSP_3_5 False (*) Audio connection release from HS (M)
+TSPC_HSP_3_6 False (*) Audio connection release from AG (M)
+TSPC_HSP_3_7 False (*) Audio connection transfer: AG to HS (M)
+TSPC_HSP_3_8 False (*) Audio connection transfer: HS to AG (M)
+TSPC_HSP_3_9 False Remote audio volume control (C.1)
+TSPC_HSP_3_10 False HS informs AG about local changes of audio
+ volume (O)
+TSPC_HSP_3_11 False Audio volume setting storage by HS (O)
+TSPC_HSP_3_12 False Remote microphone gain control (C.2)
+TSPC_HSP_3_13 False HS informs AG about local changes of microphone
+ gain (O)
+TSPC_HSP_3_14 False (*) Microphone gain setting storage by HS (O)
+TSPC_HSP_3_15 False Connection handling with Detach/Page (M)
+TSPC_HSP_3_16 False Connection handling with Park Mode (C.3)
+-------------------------------------------------------------------------------
+C.1: Mandatory if TSPC_HSP_3_10 is supported, otherwise optional
+C.2: Mandatory if TSPC_HSP_2_13 is supported, otherwise optional
+C.3: Excluded if TSPC_HSP_0_2 is supported, otherwise optional
+-------------------------------------------------------------------------------
+
+
+ Errata Service Releases
+-------------------------------------------------------------------------------
+Parameter Name Selected Description
+-------------------------------------------------------------------------------
+TSPC_HSP_4_1 False Show that in-band ringing and RING are
+ mutually exclusive (C.1)
+-------------------------------------------------------------------------------
+C.1: Excluded if TSPC_HSP_0_2 is supported, otherwise optional
+-------------------------------------------------------------------------------
diff --git a/android/pixit-hsp.txt b/android/pixit-hsp.txt
new file mode 100644
index 0000000..a2c1181
--- /dev/null
+++ b/android/pixit-hsp.txt
@@ -0,0 +1,30 @@
+HSP PIXIT for the PTS tool.
+
+PTS version: 5.0
+
+* - different than PTS defaults
+& - should be set to IUT Bluetooth address
+
+ Required PIXIT settings
+-------------------------------------------------------------------------------
+Parameter Name Value
+-------------------------------------------------------------------------------
+TSPX_security_enabled TRUE
+TSPX_bd_addr_iut 012345678901 (*&)
+TSPX_hs_class_of_device 200404
+TSPX_ag_class_of_device 400204
+TSPX_packet_type_sco 00A0
+TSPX_pin_code 0000
+TSPX_time_guard 20000000
+TSPX_use_implicit_send TRUE
+TSPX_verbose_implicit_send FALSE
+TSPX_delete_link_key FALSE
+TSPX_server_channel_tester 01
+TSPX_server_channel_iut 00
+TSPX_no_fail_verdict FALSE
+TSPX_remote_audio_volume_control TRUE
+TSPX_secure_simple_pairing_pass_key_confirmation FALSE
+TSPX_inband_ring_only FALSE
+TSPX_no_ring_or_inband_ring_tone FALSE
+TSPX_iut_establish_audio_before_RING FALSE
+-------------------------------------------------------------------------------
--
1.8.5.3
^ permalink raw reply related
* [PATCH] Bluetooth: Fix advertising address type when toggling connectable
From: johan.hedberg @ 2014-02-25 13:10 UTC (permalink / raw)
To: linux-bluetooth
From: Johan Hedberg <johan.hedberg@intel.com>
When the connectable setting is toggled using mgmt_set_connectable the
HCI_CONNECTABLE flag will only be set once the related HCI commands
succeed. When determining what kind of advertising to do we need to
therefore also check whether there is a pending Set Connectable command
in addition to the current flag value.
The enable_advertising function was already taking care of this for the
advertising type with the help of the get_adv_type function, but was
failing to do the same for the address type selection. This patch
converts the get_adv_type function to be more generic in that it returns
the expected connectable state and updates the enable_advertising
function to use the return value both for the advertising type as well
as the advertising address type.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
net/bluetooth/mgmt.c | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 25b8b278debd..a02828ad4c0e 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -817,10 +817,9 @@ static void update_class(struct hci_request *req)
hci_req_add(req, HCI_OP_WRITE_CLASS_OF_DEV, sizeof(cod), cod);
}
-static u8 get_adv_type(struct hci_dev *hdev)
+static bool get_connectable(struct hci_dev *hdev)
{
struct pending_cmd *cmd;
- bool connectable;
/* If there's a pending mgmt command the flag will not yet have
* it's final value, so check for this first.
@@ -828,12 +827,10 @@ static u8 get_adv_type(struct hci_dev *hdev)
cmd = mgmt_pending_find(MGMT_OP_SET_CONNECTABLE, hdev);
if (cmd) {
struct mgmt_mode *cp = cmd->param;
- connectable = !!cp->val;
- } else {
- connectable = test_bit(HCI_CONNECTABLE, &hdev->dev_flags);
+ return cp->val;
}
- return connectable ? LE_ADV_IND : LE_ADV_NONCONN_IND;
+ return test_bit(HCI_CONNECTABLE, &hdev->dev_flags);
}
static void enable_advertising(struct hci_request *req)
@@ -841,9 +838,10 @@ static void enable_advertising(struct hci_request *req)
struct hci_dev *hdev = req->hdev;
struct hci_cp_le_set_adv_param cp;
u8 own_addr_type, enable = 0x01;
- bool require_privacy;
+ bool connectable, require_privacy;
- require_privacy = !test_bit(HCI_CONNECTABLE, &hdev->dev_flags);
+ connectable = get_connectable(hdev);
+ require_privacy = !connectable;
if (hci_update_random_address(req, require_privacy, &own_addr_type) < 0)
return;
@@ -851,7 +849,7 @@ static void enable_advertising(struct hci_request *req)
memset(&cp, 0, sizeof(cp));
cp.min_interval = __constant_cpu_to_le16(0x0800);
cp.max_interval = __constant_cpu_to_le16(0x0800);
- cp.type = get_adv_type(hdev);
+ cp.type = connectable ? LE_ADV_IND : LE_ADV_NONCONN_IND;
cp.own_address_type = own_addr_type;
cp.channel_map = hdev->le_adv_channel_map;
--
1.8.5.3
^ permalink raw reply related
* [PATCH] Bluetooth: Fix advertising address type when toggling connectable
From: johan.hedberg @ 2014-02-25 13:10 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1393333842-8380-1-git-send-email-johan.hedberg@gmail.com>
From: Johan Hedberg <johan.hedberg@intel.com>
When the connectable setting is toggled using mgmt_set_connectable the
HCI_CONNECTABLE flag will only be set once the related HCI commands
succeed. When determining what kind of advertising to do we need to
therefore also check whether there is a pending Set Connectable command
in addition to the current flag value.
The enable_advertising function was already taking care of this for the
advertising type with the help of the get_adv_type function, but was
failing to do the same for the address type selection. This patch
converts the get_adv_type function to be more generic in that it returns
the expected connectable state and updates the enable_advertising
function to use the return value both for the advertising type as well
as the advertising address type.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
net/bluetooth/mgmt.c | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 25b8b278debd..a02828ad4c0e 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -817,10 +817,9 @@ static void update_class(struct hci_request *req)
hci_req_add(req, HCI_OP_WRITE_CLASS_OF_DEV, sizeof(cod), cod);
}
-static u8 get_adv_type(struct hci_dev *hdev)
+static bool get_connectable(struct hci_dev *hdev)
{
struct pending_cmd *cmd;
- bool connectable;
/* If there's a pending mgmt command the flag will not yet have
* it's final value, so check for this first.
@@ -828,12 +827,10 @@ static u8 get_adv_type(struct hci_dev *hdev)
cmd = mgmt_pending_find(MGMT_OP_SET_CONNECTABLE, hdev);
if (cmd) {
struct mgmt_mode *cp = cmd->param;
- connectable = !!cp->val;
- } else {
- connectable = test_bit(HCI_CONNECTABLE, &hdev->dev_flags);
+ return cp->val;
}
- return connectable ? LE_ADV_IND : LE_ADV_NONCONN_IND;
+ return test_bit(HCI_CONNECTABLE, &hdev->dev_flags);
}
static void enable_advertising(struct hci_request *req)
@@ -841,9 +838,10 @@ static void enable_advertising(struct hci_request *req)
struct hci_dev *hdev = req->hdev;
struct hci_cp_le_set_adv_param cp;
u8 own_addr_type, enable = 0x01;
- bool require_privacy;
+ bool connectable, require_privacy;
- require_privacy = !test_bit(HCI_CONNECTABLE, &hdev->dev_flags);
+ connectable = get_connectable(hdev);
+ require_privacy = !connectable;
if (hci_update_random_address(req, require_privacy, &own_addr_type) < 0)
return;
@@ -851,7 +849,7 @@ static void enable_advertising(struct hci_request *req)
memset(&cp, 0, sizeof(cp));
cp.min_interval = __constant_cpu_to_le16(0x0800);
cp.max_interval = __constant_cpu_to_le16(0x0800);
- cp.type = get_adv_type(hdev);
+ cp.type = connectable ? LE_ADV_IND : LE_ADV_NONCONN_IND;
cp.own_address_type = own_addr_type;
cp.channel_map = hdev->le_adv_channel_map;
--
1.8.5.3
^ permalink raw reply related
* BUG REPORT: Bluetooth LE HID keyboard key stays pressed when device disappears
From: Peeter Vois @ 2014-02-25 13:23 UTC (permalink / raw)
To: linux-bluetooth
Hi everybody !
First of all thanks for the bluez library and hid over gatt profile. I
am developping a special purpuse keyboard and am using Linux as test
platform. There is not much of the systems available for real life
testing and luckily Linux does work well.
While developping, my firmware is ofcourse buggy and this helped me to
uncover one of the bluez HoG profile feature that will have unpleasant
result- the key stays pressed when bluetooth device disappears.
1. My device is sending key press, release and/or anotherkey press
notification when something happens with the keyboard.
2. It is possible that my device will disappear after sending key press
event. So far I have seen debug trap causing such thing- after the key
press is sent, the firmware stops working. I believe such situation can
happen even with firmware that does function correctly. I can imagine
sudden power loss / battery failure e.t.c.
3. The result will be, that the key stays pressed and repeated entry
will run where ever the keyboard focus will be placed.
4. By killing bluetoothd, the key will be released.
I believe the situation is rather complex, as the keyboard is not the
only HID device possible. I will be available if needed.
I am using bluez-5.14-1.fc20.x86_64
and kernel-3.13.3-201.fc20.x86_64
at the moment.
Best Regards ...
--
Lugupidamisega
Peeter Vois <tauria@tauria.ee>
mobiil: +372 55611689
Tauria OÜ
juhatuse liige
^ permalink raw reply
* [PATCH] android/avrcp: Fix passing wrong len
From: Andrei Emeltchenko @ 2014-02-25 13:47 UTC (permalink / raw)
To: linux-bluetooth
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
When handling vendor dependent pdus len was passed in wrong order to
callback.
---
android/avrcp-lib.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/android/avrcp-lib.c b/android/avrcp-lib.c
index c78881f..c280cf8 100644
--- a/android/avrcp-lib.c
+++ b/android/avrcp-lib.c
@@ -128,14 +128,14 @@ static size_t handle_vendordep_pdu(struct avctp *conn, uint8_t transaction,
const struct avrcp_control_handler *handler;
struct avrcp_header *pdu = (void *) operands;
uint32_t company_id = ntoh24(pdu->company_id);
+ uint16_t params_len = ntohs(pdu->params_len);
if (company_id != IEEEID_BTSIG) {
*code = AVC_CTYPE_NOT_IMPLEMENTED;
return 0;
}
- DBG("AVRCP PDU 0x%02X, len 0x%04X", pdu->pdu_id,
- ntohs(pdu->params_len));
+ DBG("AVRCP PDU 0x%02X, len 0x%04X", pdu->pdu_id, params_len);
pdu->packet_type = 0;
pdu->rsvd = 0;
@@ -163,10 +163,10 @@ static size_t handle_vendordep_pdu(struct avctp *conn, uint8_t transaction,
goto reject;
}
- *code = handler->func(session, transaction, &pdu->params_len,
+ *code = handler->func(session, transaction, ¶ms_len,
pdu->params, session->control_data);
- return AVRCP_HEADER_LENGTH + ntohs(pdu->params_len);
+ return AVRCP_HEADER_LENGTH + params_len;
reject:
pdu->params_len = htons(1);
--
1.8.3.2
^ permalink raw reply related
* [PATCH] android/avrcp: trivial header include cleanup
From: Andrei Emeltchenko @ 2014-02-25 13:51 UTC (permalink / raw)
To: linux-bluetooth
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
android/avrcp.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/android/avrcp.c b/android/avrcp.c
index acffd56..48444a4 100644
--- a/android/avrcp.c
+++ b/android/avrcp.c
@@ -34,10 +34,10 @@
#include "lib/sdp_lib.h"
#include "src/log.h"
#include "bluetooth.h"
-#include "avrcp.h"
-#include "avrcp-lib.h"
#include "hal-msg.h"
#include "ipc.h"
+#include "avrcp-lib.h"
+#include "avrcp.h"
#define L2CAP_PSM_AVCTP 0x17
--
1.8.3.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