* [PATCH 4/6] android/hal: Add support for handling av audio state event
From: Grzegorz Kolodziejczyk @ 2013-10-25 15:52 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1382716327-25283-1-git-send-email-grzegorz.kolodziejczyk@tieto.com>
---
android/hal-av.c | 11 +++++++++++
android/hal-msg.h | 6 ++++++
2 files changed, 17 insertions(+)
diff --git a/android/hal-av.c b/android/hal-av.c
index 8aa096d..d537e84 100644
--- a/android/hal-av.c
+++ b/android/hal-av.c
@@ -38,6 +38,14 @@ static void handle_connection_state(void *buf)
(bt_bdaddr_t *) (ev->bdaddr));
}
+static void handle_audio_state(void *buf)
+{
+ struct hal_msg_ev_bt_av_audio_state *ev = buf;
+
+ if (cbs->audio_state_cb)
+ cbs->audio_state_cb(ev->state, (bt_bdaddr_t *)(ev->bdaddr));
+}
+
/* will be called from notification thread context */
void bt_notify_av(uint16_t opcode, void *buf, uint16_t len)
{
@@ -48,6 +56,9 @@ void bt_notify_av(uint16_t opcode, void *buf, uint16_t len)
case HAL_MSG_EV_BT_AV_CONNECTION_STATE:
handle_connection_state(buf);
break;
+ case HAL_MSG_EV_BT_AV_AUDIO_STATE:
+ handle_audio_state(buf);
+ break;
default:
DBG("Unhandled callback opcode=0x%x", opcode);
break;
diff --git a/android/hal-msg.h b/android/hal-msg.h
index 558e030..2206f47 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -366,3 +366,9 @@ struct hal_msg_ev_bt_av_connection_state {
uint8_t state;
uint8_t bdaddr[6];
} __attribute__((packed));
+
+#define HAL_MSG_EV_BT_AV_AUDIO_STATE 0x82
+struct hal_msg_ev_bt_av_audio_state {
+ uint8_t state;
+ uint8_t bdaddr[6];
+} __attribute__((packed));
--
1.8.4.1
^ permalink raw reply related
* [PATCH 3/6] android/hal: Add support for handling av connection state event
From: Grzegorz Kolodziejczyk @ 2013-10-25 15:52 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1382716327-25283-1-git-send-email-grzegorz.kolodziejczyk@tieto.com>
---
android/hal-av.c | 13 +++++++++++++
android/hal-msg.h | 6 ++++++
2 files changed, 19 insertions(+)
diff --git a/android/hal-av.c b/android/hal-av.c
index 051fc3e..8aa096d 100644
--- a/android/hal-av.c
+++ b/android/hal-av.c
@@ -20,6 +20,7 @@
#include "hal-log.h"
#include "hal.h"
+#include "hal-msg.h"
static const btav_callbacks_t *cbs = NULL;
@@ -28,6 +29,15 @@ static bool interface_ready(void)
return cbs != NULL;
}
+static void handle_connection_state(void *buf)
+{
+ struct hal_msg_ev_bt_av_connection_state *ev = buf;
+
+ if (cbs->connection_state_cb)
+ cbs->connection_state_cb(ev->state,
+ (bt_bdaddr_t *) (ev->bdaddr));
+}
+
/* will be called from notification thread context */
void bt_notify_av(uint16_t opcode, void *buf, uint16_t len)
{
@@ -35,6 +45,9 @@ void bt_notify_av(uint16_t opcode, void *buf, uint16_t len)
return;
switch (opcode) {
+ case HAL_MSG_EV_BT_AV_CONNECTION_STATE:
+ handle_connection_state(buf);
+ break;
default:
DBG("Unhandled callback opcode=0x%x", opcode);
break;
diff --git a/android/hal-msg.h b/android/hal-msg.h
index 5de8eb2..558e030 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -360,3 +360,9 @@ struct hal_ev_le_test_mode {
uint8_t status;
uint16_t num_packets;
} __attribute__((packed));
+
+#define HAL_MSG_EV_BT_AV_CONNECTION_STATE 0x81
+struct hal_msg_ev_bt_av_connection_state {
+ uint8_t state;
+ uint8_t bdaddr[6];
+} __attribute__((packed));
--
1.8.4.1
^ permalink raw reply related
* [PATCH 2/6] android/hal: Add skeleton for handling av notifications
From: Grzegorz Kolodziejczyk @ 2013-10-25 15:52 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1382716327-25283-1-git-send-email-grzegorz.kolodziejczyk@tieto.com>
Only default case is handled in skeleton
---
android/hal-av.c | 13 +++++++++++++
android/hal-ipc.c | 3 +++
android/hal.h | 1 +
3 files changed, 17 insertions(+)
diff --git a/android/hal-av.c b/android/hal-av.c
index 0fe1b74..051fc3e 100644
--- a/android/hal-av.c
+++ b/android/hal-av.c
@@ -28,6 +28,19 @@ static bool interface_ready(void)
return cbs != NULL;
}
+/* will be called from notification thread context */
+void bt_notify_av(uint16_t opcode, void *buf, uint16_t len)
+{
+ if (!interface_ready())
+ return;
+
+ switch (opcode) {
+ default:
+ DBG("Unhandled callback opcode=0x%x", opcode);
+ break;
+ }
+}
+
static bt_status_t av_connect(bt_bdaddr_t *bd_addr)
{
DBG("");
diff --git a/android/hal-ipc.c b/android/hal-ipc.c
index 5723841..f68e789 100644
--- a/android/hal-ipc.c
+++ b/android/hal-ipc.c
@@ -49,6 +49,9 @@ static void notification_dispatch(struct hal_hdr *msg, int fd)
case HAL_SERVICE_ID_BLUETOOTH:
bt_notify_adapter(msg->opcode, msg->payload, msg->len);
break;
+ case HAL_SERVICE_ID_A2DP:
+ bt_notify_av(msg->opcode, msg->payload, msg->len);
+ break;
default:
DBG("Unhandled notification service=%d opcode=0x%x",
msg->service_id, msg->opcode);
diff --git a/android/hal.h b/android/hal.h
index 5cd5cab..a377649 100644
--- a/android/hal.h
+++ b/android/hal.h
@@ -29,3 +29,4 @@ btav_interface_t *bt_get_av_interface(void);
void bt_notify_adapter(uint16_t opcode, void *buf, uint16_t len);
void bt_thread_associate(void);
void bt_thread_disassociate(void);
+void bt_notify_av(uint16_t opcode, void *buf, uint16_t len);
--
1.8.4.1
^ permalink raw reply related
* [PATCH 1/6] android/hal: Fix typo in A2DP HAL service name
From: Grzegorz Kolodziejczyk @ 2013-10-25 15:52 UTC (permalink / raw)
To: linux-bluetooth
A2DP was misspelled as AD2P
---
android/hal-ipc-api.txt | 2 +-
android/hal-msg.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
index 0c2fd25..dc0d067 100644
--- a/android/hal-ipc-api.txt
+++ b/android/hal-ipc-api.txt
@@ -1023,7 +1023,7 @@ Notifications:
Bluetooth Advanced Audio HAL (ID 6)
===================================
-Android HAL name: "ad2p" (BT_PROFILE_ADVANCED_AUDIO_ID)
+Android HAL name: "a2dp" (BT_PROFILE_ADVANCED_AUDIO_ID)
Commands and responses:
diff --git a/android/hal-msg.h b/android/hal-msg.h
index 172cecb..5de8eb2 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -40,7 +40,7 @@ struct hal_hdr {
#define HAL_SERVICE_ID_HIDHOST 3
#define HAL_SERVICE_ID_PAN 4
#define HAL_SERVICE_ID_HANDSFREE 5
-#define HAL_SERVICE_ID_AD2P 6
+#define HAL_SERVICE_ID_A2DP 6
#define HAL_SERVICE_ID_HEALTH 7
#define HAL_SERVICE_ID_AVRCP 8
#define HAL_SERVICE_ID_GATT 9
--
1.8.4.1
^ permalink raw reply related
* [PATCH 6/6] android: Add support for notifying HAL about scan mode change
From: Szymon Janc @ 2013-10-25 15:15 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1382714103-27689-1-git-send-email-szymon.janc@tieto.com>
If connectable or discoverable setting changes property change is send
to HAL.
---
android/adapter.c | 54 ++++++++++++++++++++++++++++++++++++++++--------------
1 file changed, 40 insertions(+), 14 deletions(-)
diff --git a/android/adapter.c b/android/adapter.c
index eebe45e..a6e5129 100644
--- a/android/adapter.c
+++ b/android/adapter.c
@@ -86,19 +86,52 @@ static void settings_changed_powered(void)
HAL_EV_ADAPTER_STATE_CHANGED, sizeof(ev), &ev, -1);
}
-static void settings_changed_connectable(void)
+static uint8_t settings2scan_mode(void)
{
- /* TODO */
+ bool connectable, discoverable;
+
+ connectable = adapter->current_settings & MGMT_SETTING_CONNECTABLE;
+ discoverable = adapter->current_settings & MGMT_SETTING_DISCOVERABLE;
+
+ if (connectable && discoverable)
+ return HAL_ADAPTER_SCAN_MODE_CONN_DISC;
+
+ if (connectable)
+ return HAL_ADAPTER_SCAN_MODE_CONN;
+
+ return HAL_ADAPTER_SCAN_MODE_NONE;
}
-static void settings_changed_discoverable(void)
+static void settings_changed_scan_mode(void)
{
- /* TODO */
+ struct hal_ev_adapter_props_changed *ev;
+ uint8_t *mode;
+ int len;
+ len = sizeof(*ev) + sizeof(struct hal_property) + 1;
+
+ ev = g_malloc(len);
+
+ ev->num_props = 1;
+ ev->status = HAL_STATUS_SUCCESS;
+
+ ev->props[0].type = HAL_PROP_ADAPTER_SCAN_MODE;
+ ev->props[0].len = 1;
+
+ mode = ev->props[0].val;
+ *mode = settings2scan_mode();
+
+ DBG("mode %u", *mode);
+
+ ipc_send(notification_io, HAL_SERVICE_ID_BLUETOOTH,
+ HAL_EV_ADAPTER_PROPS_CHANGED, len, ev, -1);
+
+ g_free(ev);
}
static void settings_changed(uint32_t settings)
{
uint32_t changed_mask;
+ uint32_t scan_mode_mask;
changed_mask = adapter->current_settings ^ settings;
@@ -109,17 +142,10 @@ static void settings_changed(uint32_t settings)
if (changed_mask & MGMT_SETTING_POWERED)
settings_changed_powered();
- if (changed_mask & MGMT_SETTING_CONNECTABLE) {
- DBG("Connectable");
-
- settings_changed_connectable();
- }
+ scan_mode_mask = MGMT_SETTING_CONNECTABLE | MGMT_SETTING_DISCOVERABLE;
- if (changed_mask & MGMT_SETTING_DISCOVERABLE) {
- DBG("Discoverable");
-
- settings_changed_discoverable();
- }
+ if (changed_mask & scan_mode_mask)
+ settings_changed_scan_mode();
}
static void new_settings_callback(uint16_t index, uint16_t length,
--
1.8.4.1
^ permalink raw reply related
* [PATCH 5/6] android: Always set adapter to pairable on init
From: Szymon Janc @ 2013-10-25 15:15 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1382714103-27689-1-git-send-email-szymon.janc@tieto.com>
There is no operation to enable/disable pairable mode in Android HAL.
---
android/adapter.c | 72 ++++++++++++++++++++++++++++---------------------------
1 file changed, 37 insertions(+), 35 deletions(-)
diff --git a/android/adapter.c b/android/adapter.c
index a6c5704..eebe45e 100644
--- a/android/adapter.c
+++ b/android/adapter.c
@@ -224,6 +224,41 @@ static void load_link_keys(GSList *keys)
g_free(cp);
}
+static void set_mode_complete(uint8_t status, uint16_t length,
+ const void *param, void *user_data)
+{
+ if (status != MGMT_STATUS_SUCCESS) {
+ error("Failed to set mode: %s (0x%02x)",
+ mgmt_errstr(status), status);
+ return;
+ }
+
+ /*
+ * The parameters are identical and also the task that is
+ * required in both cases. So it is safe to just call the
+ * event handling functions here.
+ */
+ new_settings_callback(adapter->index, length, param, NULL);
+}
+
+static bool set_mode(uint16_t opcode, uint8_t mode)
+{
+ struct mgmt_mode cp;
+
+ memset(&cp, 0, sizeof(cp));
+ cp.val = mode;
+
+ DBG("opcode=0x%x mode=0x%x", opcode, mode);
+
+ if (mgmt_send(adapter->mgmt, opcode, adapter->index, sizeof(cp), &cp,
+ set_mode_complete, NULL, NULL) > 0)
+ return true;
+
+ error("Failed to set mode");
+
+ return false;
+}
+
static void read_info_complete(uint8_t status, uint16_t length, const void *param,
void *user_data)
{
@@ -265,6 +300,8 @@ static void read_info_complete(uint8_t status, uint16_t length, const void *para
load_link_keys(NULL);
+ set_mode(MGMT_OP_SET_PAIRABLE, 0x01);
+
return;
failed:
@@ -287,41 +324,6 @@ void bt_adapter_init(uint16_t index, struct mgmt *mgmt, bt_adapter_ready cb)
adapter->ready(-EIO);
}
-static void set_mode_complete(uint8_t status, uint16_t length,
- const void *param, void *user_data)
-{
- if (status != MGMT_STATUS_SUCCESS) {
- error("Failed to set mode: %s (0x%02x)",
- mgmt_errstr(status), status);
- return;
- }
-
- /*
- * The parameters are identical and also the task that is
- * required in both cases. So it is safe to just call the
- * event handling functions here.
- */
- new_settings_callback(adapter->index, length, param, NULL);
-}
-
-static bool set_mode(uint16_t opcode, uint8_t mode)
-{
- struct mgmt_mode cp;
-
- memset(&cp, 0, sizeof(cp));
- cp.val = mode;
-
- DBG("opcode=0x%x mode=0x%x", opcode, mode);
-
- if (mgmt_send(adapter->mgmt, opcode, adapter->index, sizeof(cp), &cp,
- set_mode_complete, NULL, NULL) > 0)
- return true;
-
- error("Failed to set mode");
-
- return false;
-}
-
static bool set_discoverable(uint8_t mode, uint16_t timeout)
{
struct mgmt_cp_set_discoverable cp;
--
1.8.4.1
^ permalink raw reply related
* [PATCH 4/6] android: Add support for setting adapter scan mode
From: Szymon Janc @ 2013-10-25 15:15 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1382714103-27689-1-git-send-email-szymon.janc@tieto.com>
This allows to set all modes defined: none, connectable and
'connectable and discoverable'.
---
android/adapter.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 72 insertions(+), 1 deletion(-)
diff --git a/android/adapter.c b/android/adapter.c
index 13cce8f..a6c5704 100644
--- a/android/adapter.c
+++ b/android/adapter.c
@@ -322,6 +322,26 @@ static bool set_mode(uint16_t opcode, uint8_t mode)
return false;
}
+static bool set_discoverable(uint8_t mode, uint16_t timeout)
+{
+ struct mgmt_cp_set_discoverable cp;
+
+ memset(&cp, 0, sizeof(cp));
+ cp.val = mode;
+ cp.timeout = htobs(timeout);
+
+ DBG("mode %u timeout %u", mode, timeout);
+
+ if (mgmt_send(adapter->mgmt, MGMT_OP_SET_DISCOVERABLE,
+ adapter->index, sizeof(cp), &cp,
+ set_mode_complete, adapter, NULL) > 0)
+ return true;
+
+ error("Failed to set mode discoverable");
+
+ return false;
+}
+
static void send_adapter_name(void)
{
struct hal_ev_adapter_props_changed *ev;
@@ -365,13 +385,64 @@ static bool get_property(void *buf, uint16_t len)
}
}
+static uint8_t set_scan_mode(void *buf, uint16_t len)
+{
+ uint8_t *mode = buf;
+ bool conn, disc, cur_conn, cur_disc;
+
+ cur_conn = adapter->current_settings & MGMT_SETTING_CONNECTABLE;
+ cur_disc = adapter->current_settings & MGMT_SETTING_DISCOVERABLE;
+
+ DBG("connectable %u discoverable %d mode %u", cur_conn, cur_disc,
+ *mode);
+
+ switch (*mode) {
+ case HAL_ADAPTER_SCAN_MODE_NONE:
+ if (!cur_conn && !cur_disc)
+ return HAL_STATUS_DONE;
+
+ conn = false;
+ disc = false;
+ break;
+ case HAL_ADAPTER_SCAN_MODE_CONN:
+ if (cur_conn && !cur_disc)
+ return HAL_STATUS_DONE;
+
+ conn = true;
+ disc = false;
+ break;
+ case HAL_ADAPTER_SCAN_MODE_CONN_DISC:
+ if (cur_conn && cur_disc)
+ return HAL_STATUS_DONE;
+
+ conn = true;
+ disc = true;
+ break;
+ default:
+ return HAL_STATUS_FAILED;
+ }
+
+ if (cur_conn != conn) {
+ if (!set_mode(MGMT_OP_SET_CONNECTABLE, conn ? 0x01 : 0x00))
+ return HAL_STATUS_FAILED;
+ }
+
+ if (cur_disc != disc) {
+ if (!set_discoverable(disc ? 0x01 : 0x00, 0))
+ return HAL_STATUS_FAILED;
+ }
+
+ return HAL_STATUS_SUCCESS;
+}
+
static uint8_t set_property(void *buf, uint16_t len)
{
struct hal_cmd_set_adapter_prop *cmd = buf;
switch (cmd->type) {
- case HAL_PROP_ADAPTER_NAME:
case HAL_PROP_ADAPTER_SCAN_MODE:
+ return set_scan_mode(cmd->val, cmd->len);
+ case HAL_PROP_ADAPTER_NAME:
case HAL_PROP_ADAPTER_DISC_TIMEOUT:
default:
DBG("Unhandled property type 0x%x", cmd->type);
--
1.8.4.1
^ permalink raw reply related
* [PATCH 3/6] android: Add missing scan mode difinitions to IPC header
From: Szymon Janc @ 2013-10-25 15:15 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1382714103-27689-1-git-send-email-szymon.janc@tieto.com>
---
android/hal-msg.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/android/hal-msg.h b/android/hal-msg.h
index 172cecb..677b00b 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -113,6 +113,10 @@ struct hal_cmd_get_adapter_prop {
#define HAL_PROP_DEVICE_VERSION_INFO 0x0c
#define HAL_PROP_DEVICE_TIMESTAMP 0xFF
+#define HAL_ADAPTER_SCAN_MODE_NONE 0x00
+#define HAL_ADAPTER_SCAN_MODE_CONN 0x01
+#define HAL_ADAPTER_SCAN_MODE_CONN_DISC 0x02
+
#define HAL_OP_SET_ADAPTER_PROP 0x05
struct hal_cmd_set_adapter_prop {
uint8_t type;
--
1.8.4.1
^ permalink raw reply related
* [PATCH 2/6] android: Add initial code for handling adapter set property command
From: Szymon Janc @ 2013-10-25 15:14 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1382714103-27689-1-git-send-email-szymon.janc@tieto.com>
No commands are handled yet.
---
android/adapter.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/android/adapter.c b/android/adapter.c
index 685b00d..13cce8f 100644
--- a/android/adapter.c
+++ b/android/adapter.c
@@ -365,6 +365,20 @@ static bool get_property(void *buf, uint16_t len)
}
}
+static uint8_t set_property(void *buf, uint16_t len)
+{
+ struct hal_cmd_set_adapter_prop *cmd = buf;
+
+ switch (cmd->type) {
+ case HAL_PROP_ADAPTER_NAME:
+ case HAL_PROP_ADAPTER_SCAN_MODE:
+ case HAL_PROP_ADAPTER_DISC_TIMEOUT:
+ default:
+ DBG("Unhandled property type 0x%x", cmd->type);
+ return HAL_STATUS_FAILED;
+ }
+}
+
void bt_adapter_handle_cmd(GIOChannel *io, uint8_t opcode, void *buf,
uint16_t len)
{
@@ -396,6 +410,12 @@ void bt_adapter_handle_cmd(GIOChannel *io, uint8_t opcode, void *buf,
goto error;
break;
+ case HAL_OP_SET_ADAPTER_PROP:
+ status = set_property(buf, len);
+ if (status != HAL_STATUS_SUCCESS)
+ goto error;
+
+ break;
default:
DBG("Unhandled command, opcode 0x%x", opcode);
goto error;
--
1.8.4.1
^ permalink raw reply related
* [PATCH 1/6] android: Use common exit path for commands in bt_adapter_handle_cmd
From: Szymon Janc @ 2013-10-25 15:14 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
All adapter commands return no parameters so putting error and success
response on common exit path. This will make function easier to follow
when more commands support will be added.
---
android/adapter.c | 34 ++++++++++++++++------------------
1 file changed, 16 insertions(+), 18 deletions(-)
diff --git a/android/adapter.c b/android/adapter.c
index ec90cca..685b00d 100644
--- a/android/adapter.c
+++ b/android/adapter.c
@@ -374,39 +374,37 @@ void bt_adapter_handle_cmd(GIOChannel *io, uint8_t opcode, void *buf,
case HAL_OP_ENABLE:
if (adapter->current_settings & MGMT_SETTING_POWERED) {
status = HAL_STATUS_DONE;
- break;
+ goto error;
}
- if (set_mode(MGMT_OP_SET_POWERED, 0x01)) {
- ipc_send(io, HAL_SERVICE_ID_BLUETOOTH, opcode, 0, NULL,
- -1);
- return;
- }
+ if (!set_mode(MGMT_OP_SET_POWERED, 0x01))
+ goto error;
+
break;
case HAL_OP_DISABLE:
if (!(adapter->current_settings & MGMT_SETTING_POWERED)) {
status = HAL_STATUS_DONE;
- break;
+ goto error;
}
- if (set_mode(MGMT_OP_SET_POWERED, 0x00)) {
- ipc_send(io, HAL_SERVICE_ID_BLUETOOTH, opcode, 0, NULL,
- -1);
- return;
- }
+ if (!set_mode(MGMT_OP_SET_POWERED, 0x00))
+ goto error;
+
break;
case HAL_OP_GET_ADAPTER_PROP:
- if (get_property(buf, len)) {
- ipc_send(io, HAL_SERVICE_ID_BLUETOOTH, opcode, 0, NULL,
- -1);
- return;
- }
+ if (!get_property(buf, len))
+ goto error;
+
break;
default:
DBG("Unhandled command, opcode 0x%x", opcode);
- break;
+ goto error;
}
+ ipc_send(io, HAL_SERVICE_ID_BLUETOOTH, opcode, 0, NULL, -1);
+ return;
+
+error:
ipc_send_rsp(io, HAL_SERVICE_ID_BLUETOOTH, status);
}
--
1.8.4.1
^ permalink raw reply related
* [PATCH 2/2] android/hal: Use debug helpers from hal client
From: Andrei Emeltchenko @ 2013-10-25 13:28 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1382707726-20118-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Debug helpers really helps a lot when debugging on Android target. The
patch uses helper functions already defined for hal test tool so
we do not need to reimplement them.
---
android/Android.mk | 1 +
android/hal-bluetooth.c | 6 ++++--
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/android/Android.mk b/android/Android.mk
index 946e9cd..56c43cb 100644
--- a/android/Android.mk
+++ b/android/Android.mk
@@ -73,6 +73,7 @@ LOCAL_SRC_FILES := \
hal-hidhost.c \
hal-pan.c \
hal-av.c \
+ client/textconv.c \
LOCAL_C_INCLUDES += \
$(call include-path-for, system-core) \
diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
index 282a680..5929fff 100644
--- a/android/hal-bluetooth.c
+++ b/android/hal-bluetooth.c
@@ -25,6 +25,8 @@
#include "hal-msg.h"
#include "hal-ipc.h"
+#include "client/textconv.h"
+
static const bt_callbacks_t *bt_hal_cbacks = NULL;
static void handle_adapter_state_changed(void *buf)
@@ -192,7 +194,7 @@ static int get_adapter_property(bt_property_type_t type)
{
struct hal_cmd_get_adapter_prop cmd;
- DBG("");
+ DBG("prop: %s", bt_property_type_t2str(type));
if (!interface_ready())
return BT_STATUS_NOT_READY;
@@ -224,7 +226,7 @@ static int set_adapter_property(const bt_property_t *property)
char buf[sizeof(struct hal_cmd_set_adapter_prop) + property->len];
struct hal_cmd_set_adapter_prop *cmd = (void *) buf;
- DBG("");
+ DBG("prop: %s", bt_property_type_t2str(property->type));
if (!interface_ready())
return BT_STATUS_NOT_READY;
--
1.7.10.4
^ permalink raw reply related
* [PATCH 1/2] android/hal: Use defined function to check that interface is ready
From: Andrei Emeltchenko @ 2013-10-25 13:28 UTC (permalink / raw)
To: linux-bluetooth
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
android/hal-bluetooth.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
index 894f5b5..282a680 100644
--- a/android/hal-bluetooth.c
+++ b/android/hal-bluetooth.c
@@ -78,10 +78,15 @@ void bt_thread_disassociate(void)
bt_hal_cbacks->thread_evt_cb(DISASSOCIATE_JVM);
}
+static bool interface_ready(void)
+{
+ return bt_hal_cbacks != NULL;
+}
+
/* will be called from notification thread context */
void bt_notify_adapter(uint16_t opcode, void *buf, uint16_t len)
{
- if (!bt_hal_cbacks)
+ if (!interface_ready())
return;
switch (opcode) {
@@ -97,11 +102,6 @@ void bt_notify_adapter(uint16_t opcode, void *buf, uint16_t len)
}
}
-static bool interface_ready(void)
-{
- return bt_hal_cbacks != NULL;
-}
-
static int init(bt_callbacks_t *callbacks)
{
struct hal_cmd_register_module cmd;
--
1.7.10.4
^ permalink raw reply related
* Re: [PATCH] android/hal: Associate thread to Java
From: Luiz Augusto von Dentz @ 2013-10-25 13:11 UTC (permalink / raw)
To: Andrei Emeltchenko; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <1382700886-6289-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
Hi Andrei,
On Fri, Oct 25, 2013 at 2:34 PM, Andrei Emeltchenko
<Andrei.Emeltchenko.news@gmail.com> wrote:
> From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
>
> Without thread assiciation callbacks are not received by Java.
> They are blocked by JNI:
> E/BluetoothServiceJni( 2844): Callback env check fail: env: 0x0, callback: 0x0
> E/BluetoothServiceJni( 2844): Callback: 'adapter_state_change_callback' is not
> called on the correct thread
> ---
> android/hal-bluetooth.c | 12 ++++++++++++
> android/hal-ipc.c | 4 ++++
> android/hal.h | 2 ++
> 3 files changed, 18 insertions(+)
>
> diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
> index f8ecec5..26f4fd9 100644
> --- a/android/hal-bluetooth.c
> +++ b/android/hal-bluetooth.c
> @@ -40,6 +40,18 @@ static bool interface_ready(void)
> return bt_hal_cbacks != NULL;
> }
>
> +void bt_thread_associate(void)
> +{
> + if (bt_hal_cbacks->thread_evt_cb)
> + bt_hal_cbacks->thread_evt_cb(ASSOCIATE_JVM);
> +}
> +
> +void bt_thread_disassociate(void)
> +{
> + if (bt_hal_cbacks->thread_evt_cb)
> + bt_hal_cbacks->thread_evt_cb(DISASSOCIATE_JVM);
> +}
> +
> /* will be called from notification thread context */
> void bt_notify_adapter(uint16_t opcode, void *buf, uint16_t len)
> {
> diff --git a/android/hal-ipc.c b/android/hal-ipc.c
> index 20421db..240ac9d 100644
> --- a/android/hal-ipc.c
> +++ b/android/hal-ipc.c
> @@ -67,6 +67,8 @@ static void *notification_handler(void *data)
> ssize_t ret;
> int fd;
>
> + bt_thread_associate();
> +
> while (true) {
> memset(&msg, 0, sizeof(msg));
> memset(buf, 0, sizeof(buf));
> @@ -133,6 +135,8 @@ static void *notification_handler(void *data)
> close(notif_sk);
> notif_sk = -1;
>
> + bt_thread_disassociate();
> +
> DBG("exit");
>
> return NULL;
> diff --git a/android/hal.h b/android/hal.h
> index ef9a107..5cd5cab 100644
> --- a/android/hal.h
> +++ b/android/hal.h
> @@ -27,3 +27,5 @@ btpan_interface_t *bt_get_pan_interface(void);
> btav_interface_t *bt_get_av_interface(void);
>
> void bt_notify_adapter(uint16_t opcode, void *buf, uint16_t len);
> +void bt_thread_associate(void);
> +void bt_thread_disassociate(void);
> --
> 1.7.10.4
Pushed, thanks.
--
Luiz Augusto von Dentz
^ permalink raw reply
* Re: [PATCH v2 01/15] android: Remove not needed local variable in connect_hal
From: Luiz Augusto von Dentz @ 2013-10-25 12:29 UTC (permalink / raw)
To: Szymon Janc; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <1382698211-9123-1-git-send-email-szymon.janc@tieto.com>
Hi Szymon,
On Fri, Oct 25, 2013 at 1:49 PM, Szymon Janc <szymon.janc@tieto.com> wrote:
> err variable was set but never read.
> ---
> android/main.c | 10 ++++------
> 1 file changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/android/main.c b/android/main.c
> index 50b5901..18dc9f7 100644
> --- a/android/main.c
> +++ b/android/main.c
> @@ -239,12 +239,12 @@ static GIOChannel *connect_hal(GIOFunc connect_cb)
> struct sockaddr_un addr;
> GIOCondition cond;
> GIOChannel *io;
> - int err, sk;
> + int sk;
>
> sk = socket(PF_LOCAL, SOCK_SEQPACKET, 0);
> if (sk < 0) {
> - err = errno;
> - error("Failed to create socket: %d (%s)", err, strerror(err));
> + error("Failed to create socket: %d (%s)", errno,
> + strerror(errno));
> return NULL;
> }
>
> @@ -258,9 +258,7 @@ static GIOChannel *connect_hal(GIOFunc connect_cb)
>
> memcpy(addr.sun_path, BLUEZ_HAL_SK_PATH, sizeof(BLUEZ_HAL_SK_PATH));
>
> - err = connect(sk, (struct sockaddr *) &addr, sizeof(addr));
> - if (err < 0) {
> - err = -errno;
> + if (connect(sk, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
> error("Failed to connect HAL socket: %d (%s)", errno,
> strerror(errno));
> g_io_channel_unref(io);
> --
> 1.8.4.1
Applied, thanks.
--
Luiz Augusto von Dentz
^ permalink raw reply
* Re: [PATCH v2 0/2] Add basic scripting to haltest
From: Luiz Augusto von Dentz @ 2013-10-25 11:56 UTC (permalink / raw)
To: Jerzy Kasenberg; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <1382698306-30914-1-git-send-email-jerzy.kasenberg@tieto.com>
Hi Jerzy,
On Fri, Oct 25, 2013 at 1:51 PM, Jerzy Kasenberg
<jerzy.kasenberg@tieto.com> wrote:
> This patcheset adds command 'source' to interpret scripts
> and processing of .haltestrc to execute some commands automatically.
> v2:
> - small styl changed (fd == -1) changed to (fd < 0)
>
> Jerzy Kasenberg (2):
> android/client: Add source command to haltest
> android/client: Add processing of .haltestrc
>
> android/client/haltest.c | 55 +++++++++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 54 insertions(+), 1 deletion(-)
>
> --
> 1.7.9.5
Applied, thanks.
--
Luiz Augusto von Dentz
^ permalink raw reply
* [PATCH] android/hal: Associate thread to Java
From: Andrei Emeltchenko @ 2013-10-25 11:34 UTC (permalink / raw)
To: linux-bluetooth
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Without thread assiciation callbacks are not received by Java.
They are blocked by JNI:
E/BluetoothServiceJni( 2844): Callback env check fail: env: 0x0, callback: 0x0
E/BluetoothServiceJni( 2844): Callback: 'adapter_state_change_callback' is not
called on the correct thread
---
android/hal-bluetooth.c | 12 ++++++++++++
android/hal-ipc.c | 4 ++++
android/hal.h | 2 ++
3 files changed, 18 insertions(+)
diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
index f8ecec5..26f4fd9 100644
--- a/android/hal-bluetooth.c
+++ b/android/hal-bluetooth.c
@@ -40,6 +40,18 @@ static bool interface_ready(void)
return bt_hal_cbacks != NULL;
}
+void bt_thread_associate(void)
+{
+ if (bt_hal_cbacks->thread_evt_cb)
+ bt_hal_cbacks->thread_evt_cb(ASSOCIATE_JVM);
+}
+
+void bt_thread_disassociate(void)
+{
+ if (bt_hal_cbacks->thread_evt_cb)
+ bt_hal_cbacks->thread_evt_cb(DISASSOCIATE_JVM);
+}
+
/* will be called from notification thread context */
void bt_notify_adapter(uint16_t opcode, void *buf, uint16_t len)
{
diff --git a/android/hal-ipc.c b/android/hal-ipc.c
index 20421db..240ac9d 100644
--- a/android/hal-ipc.c
+++ b/android/hal-ipc.c
@@ -67,6 +67,8 @@ static void *notification_handler(void *data)
ssize_t ret;
int fd;
+ bt_thread_associate();
+
while (true) {
memset(&msg, 0, sizeof(msg));
memset(buf, 0, sizeof(buf));
@@ -133,6 +135,8 @@ static void *notification_handler(void *data)
close(notif_sk);
notif_sk = -1;
+ bt_thread_disassociate();
+
DBG("exit");
return NULL;
diff --git a/android/hal.h b/android/hal.h
index ef9a107..5cd5cab 100644
--- a/android/hal.h
+++ b/android/hal.h
@@ -27,3 +27,5 @@ btpan_interface_t *bt_get_pan_interface(void);
btav_interface_t *bt_get_av_interface(void);
void bt_notify_adapter(uint16_t opcode, void *buf, uint16_t len);
+void bt_thread_associate(void);
+void bt_thread_disassociate(void);
--
1.7.10.4
^ permalink raw reply related
* [PATCH v2 2/2] android/client: Add processing of .haltestrc
From: Jerzy Kasenberg @ 2013-10-25 10:51 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Jerzy Kasenberg
In-Reply-To: <1382698306-30914-1-git-send-email-jerzy.kasenberg@tieto.com>
This patch allows tool to read commands from .haltestrc.
So it is possible to call some functions that are typically used.
So user can have:
adapter init
adapter get_profile_interface socket
adapter get_profile_interface pan
adapter get_profile_interface hidhost
adapter get_profile_interface a2dp
pan init
av init
---
android/client/haltest.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/android/client/haltest.c b/android/client/haltest.c
index ac43afb..6b4030b 100644
--- a/android/client/haltest.c
+++ b/android/client/haltest.c
@@ -314,6 +314,8 @@ static void stdin_handler(struct pollfd *pollfd)
int main(int argc, char **argv)
{
+ struct stat rcstat;
+
terminal_setup();
history_restore(".haltest_history");
@@ -321,6 +323,9 @@ int main(int argc, char **argv)
/* Register command line handler */
poll_register_fd(0, POLLIN, stdin_handler);
+ if (stat(".haltestrc", &rcstat) == 0 && (rcstat.st_mode & S_IFREG) != 0)
+ process_file(".haltestrc");
+
poll_dispatch_loop();
return 0;
--
1.7.9.5
^ permalink raw reply related
* [PATCH v2 1/2] android/client: Add source command to haltest
From: Jerzy Kasenberg @ 2013-10-25 10:51 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Jerzy Kasenberg
In-Reply-To: <1382698306-30914-1-git-send-email-jerzy.kasenberg@tieto.com>
New command allows to read script file into tool and
execute its contents as if it was typed.
---
android/client/haltest.c | 50 +++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 49 insertions(+), 1 deletion(-)
diff --git a/android/client/haltest.c b/android/client/haltest.c
index 189af0b..ac43afb 100644
--- a/android/client/haltest.c
+++ b/android/client/haltest.c
@@ -157,11 +157,47 @@ static void quit_p(int argc, const char **argv)
exit(0);
}
+static int fd_stack[10];
+static int fd_stack_pointer = 0;
+
+static void stdin_handler(struct pollfd *pollfd);
+
+static void process_file(const char *name)
+{
+ int fd = open(name, O_RDONLY);
+
+ if (fd < 0) {
+ haltest_error("Can't open file: %s for reading\n", name);
+ return;
+ }
+
+ if (fd_stack_pointer >= 10) {
+ haltest_error("To many open files\n");
+ close(fd);
+ return;
+ }
+
+ fd_stack[fd_stack_pointer++] = fd;
+ poll_unregister_fd(fd_stack[fd_stack_pointer - 2], stdin_handler);
+ poll_register_fd(fd_stack[fd_stack_pointer - 1], POLLIN, stdin_handler);
+}
+
+static void source_p(int argc, const char **argv)
+{
+ if (argc < 2) {
+ haltest_error("No file specified");
+ return;
+ }
+
+ process_file(argv[1]);
+}
+
/* Commands available without interface */
static struct method commands[] = {
STD_METHODCH(help, "[<interface>]"),
STD_METHOD(quit),
METHOD("exit", quit_p, NULL, NULL),
+ STD_METHODH(source, "<file>"),
END_METHOD
};
@@ -254,15 +290,26 @@ static void stdin_handler(struct pollfd *pollfd)
char buf[10];
if (pollfd->revents & POLLIN) {
- int count = read(0, buf, 10);
+ int count = read(fd_stack[fd_stack_pointer - 1], buf, 10);
if (count > 0) {
int i;
for (i = 0; i < count; ++i)
terminal_process_char(buf[i], process_line);
+ return;
}
}
+
+ if (fd_stack_pointer > 1)
+ poll_register_fd(fd_stack[fd_stack_pointer - 2], POLLIN,
+ stdin_handler);
+ if (fd_stack_pointer > 0) {
+ poll_unregister_fd(fd_stack[--fd_stack_pointer], stdin_handler);
+
+ if (fd_stack[fd_stack_pointer])
+ close(fd_stack[fd_stack_pointer]);
+ }
}
int main(int argc, char **argv)
@@ -270,6 +317,7 @@ int main(int argc, char **argv)
terminal_setup();
history_restore(".haltest_history");
+ fd_stack[fd_stack_pointer++] = 0;
/* Register command line handler */
poll_register_fd(0, POLLIN, stdin_handler);
--
1.7.9.5
^ permalink raw reply related
* [PATCH v2 0/2] Add basic scripting to haltest
From: Jerzy Kasenberg @ 2013-10-25 10:51 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Jerzy Kasenberg
This patcheset adds command 'source' to interpret scripts
and processing of .haltestrc to execute some commands automatically.
v2:
- small styl changed (fd == -1) changed to (fd < 0)
Jerzy Kasenberg (2):
android/client: Add source command to haltest
android/client: Add processing of .haltestrc
android/client/haltest.c | 55 +++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 54 insertions(+), 1 deletion(-)
--
1.7.9.5
^ permalink raw reply
* [PATCH v2 15/15] android: Add initial support for handling adapter get property command
From: Szymon Janc @ 2013-10-25 10:50 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1382698211-9123-1-git-send-email-szymon.janc@tieto.com>
Support for HAL_BT_PROP_BDADDR property only.
---
android/adapter.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 50 insertions(+)
diff --git a/android/adapter.c b/android/adapter.c
index 5837e99..df90db6 100644
--- a/android/adapter.c
+++ b/android/adapter.c
@@ -322,6 +322,49 @@ static bool set_mode(uint16_t opcode, uint8_t mode)
return false;
}
+static void send_adapter_name(void)
+{
+ struct hal_ev_adapter_props_changed *ev;
+ int len;
+
+ len = sizeof(*ev) + sizeof(struct hal_property) + sizeof(bdaddr_t);
+
+ ev = g_malloc(len);
+
+ ev->num_props = 1;
+ ev->status = HAL_ERROR_SUCCESS;
+
+ ev->props[0].type = HAL_PROP_ADAPTER_ADDR;
+ ev->props[0].len = sizeof(bdaddr_t);
+ baswap((bdaddr_t *) ev->props[0].val, &adapter->bdaddr);
+
+ ipc_send(notification_io, HAL_SERVICE_ID_BLUETOOTH,
+ HAL_EV_ADAPTER_PROPS_CHANGED, len, ev, -1);
+
+ g_free(ev);
+}
+
+static bool get_property(void *buf, uint16_t len)
+{
+ struct hal_cmd_get_adapter_prop *cmd = buf;
+
+ switch (cmd->type) {
+ case HAL_PROP_ADAPTER_ADDR:
+ send_adapter_name();
+ return true;
+ case HAL_PROP_ADAPTER_NAME:
+ case HAL_PROP_ADAPTER_UUIDS:
+ case HAL_PROP_ADAPTER_CLASS:
+ case HAL_PROP_ADAPTER_TYPE:
+ case HAL_PROP_ADAPTER_SERVICE_REC:
+ case HAL_PROP_ADAPTER_SCAN_MODE:
+ case HAL_PROP_ADAPTER_BONDED_DEVICES:
+ case HAL_PROP_ADAPTER_DISC_TIMEOUT:
+ default:
+ return false;
+ }
+}
+
void bt_adapter_handle_cmd(GIOChannel *io, uint8_t opcode, void *buf,
uint16_t len)
{
@@ -352,6 +395,13 @@ void bt_adapter_handle_cmd(GIOChannel *io, uint8_t opcode, void *buf,
return;
}
break;
+ case HAL_OP_GET_ADAPTER_PROP:
+ if (get_property(buf, len)) {
+ ipc_send(io, HAL_SERVICE_ID_BLUETOOTH, opcode, 0, NULL,
+ -1);
+ return;
+ }
+ break;
default:
DBG("Unhandled command, opcode 0x%x", opcode);
break;
--
1.8.4.1
^ permalink raw reply related
* [PATCH v2 14/15] android: Add missing success status definition to IPC header
From: Szymon Janc @ 2013-10-25 10:50 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1382698211-9123-1-git-send-email-szymon.janc@tieto.com>
This is used in HAL callbacks to indicate success.
---
android/hal-msg.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/android/hal-msg.h b/android/hal-msg.h
index 2a0b670..3703d55 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -49,6 +49,7 @@ struct hal_hdr {
/* Core Service */
+#define HAL_ERROR_SUCCESS 0x00
#define HAL_ERROR_FAILED 0x01
#define HAL_ERROR_NOT_READY 0x02
#define HAL_ERROR_NOMEM 0x03
--
1.8.4.1
^ permalink raw reply related
* [PATCH v2 13/15] android/hal: Add support for handling adapter properties change event
From: Szymon Janc @ 2013-10-25 10:50 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1382698211-9123-1-git-send-email-szymon.janc@tieto.com>
---
android/hal-bluetooth.c | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
index eb400ee..9c7fbea 100644
--- a/android/hal-bluetooth.c
+++ b/android/hal-bluetooth.c
@@ -35,6 +35,37 @@ static void handle_adapter_state_changed(void *buf)
bt_hal_cbacks->adapter_state_changed_cb(ev->state);
}
+static void handle_adapter_props_changed(void *buf, uint16_t len)
+{
+ struct hal_ev_adapter_props_changed *ev = buf;
+ bt_property_t props[ev->num_props];
+ struct hal_property *hal_prop;
+ void *p;
+ int i;
+
+ if (!bt_hal_cbacks->adapter_properties_cb)
+ return;
+
+ hal_prop = ev->props;
+ p = ev->props;
+
+ for (i = 0; i < ev->num_props; i++) {
+ if (p + sizeof(*hal_prop) + hal_prop->len > buf + len) {
+ error("invalid adapter properties event, aborting");
+ exit(EXIT_FAILURE);
+ }
+
+ props[i].type = hal_prop->type;
+ props[i].len = hal_prop->len;
+ props[i].val = hal_prop->val;
+
+ p += sizeof(*hal_prop) + hal_prop->len;
+ hal_prop = p;
+ }
+
+ bt_hal_cbacks->adapter_properties_cb(ev->status, ev->num_props, props);
+}
+
/* will be called from notification thread context */
void bt_notify_adapter(uint16_t opcode, void *buf, uint16_t len)
{
@@ -45,6 +76,9 @@ void bt_notify_adapter(uint16_t opcode, void *buf, uint16_t len)
case HAL_EV_ADAPTER_STATE_CHANGED:
handle_adapter_state_changed(buf);
break;
+ case HAL_EV_ADAPTER_PROPS_CHANGED:
+ handle_adapter_props_changed(buf, len);
+ break;
default:
DBG("Unhandled callback opcode=0x%x", opcode);
break;
--
1.8.4.1
^ permalink raw reply related
* [PATCH v2 12/15] android/hal: Add support for sending adapter SSP reply command
From: Szymon Janc @ 2013-10-25 10:50 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1382698211-9123-1-git-send-email-szymon.janc@tieto.com>
This allows HAL to reply to SSP request.
---
android/hal-bluetooth.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
index 6835db3..eb400ee 100644
--- a/android/hal-bluetooth.c
+++ b/android/hal-bluetooth.c
@@ -340,15 +340,21 @@ static int pin_reply(const bt_bdaddr_t *bd_addr, uint8_t accept,
static int ssp_reply(const bt_bdaddr_t *bd_addr, bt_ssp_variant_t variant,
uint8_t accept, uint32_t passkey)
{
+ struct hal_cmd_ssp_reply cmd;
+
DBG("");
if (!interface_ready())
return BT_STATUS_NOT_READY;
- if (!bd_addr)
- return BT_STATUS_PARM_INVALID;
+ memcpy(cmd.bdaddr, bd_addr, sizeof(cmd.bdaddr));
+ /* type match IPC type */
+ cmd.ssp_variant = variant;
+ cmd.accept = accept;
+ cmd.passkey = passkey;
- return BT_STATUS_UNSUPPORTED;
+ return hal_ipc_cmd(HAL_SERVICE_ID_BLUETOOTH, HAL_OP_SSP_REPLY,
+ sizeof(cmd), &cmd, 0, NULL, NULL);
}
static const void *get_profile_interface(const char *profile_id)
--
1.8.4.1
^ permalink raw reply related
* [PATCH v2 11/15] android: Add missing SSP variant definitions to IPC header
From: Szymon Janc @ 2013-10-25 10:50 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1382698211-9123-1-git-send-email-szymon.janc@tieto.com>
---
android/hal-msg.h | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/android/hal-msg.h b/android/hal-msg.h
index 352a64c..2a0b670 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -176,6 +176,11 @@ struct hal_cmd_pin_reply {
uint8_t pin_code[16];
} __attribute__((packed));
+#define HAL_BT_SSP_VARIANT_CONFIRM 0x00
+#define HAL_BT_SSP_VARIANT_ENTRY 0x01
+#define HAL_BT_SSP_VARIANT_CONSENT 0x02
+#define HAL_BT_SSP_VARIANT_NOTIF 0x03
+
#define HAL_OP_SSP_REPLY 0x11
struct hal_cmd_ssp_reply {
uint8_t bdaddr[6];
--
1.8.4.1
^ permalink raw reply related
* [PATCH v2 10/15] android: Add missing SSP Variant definitions to IPC document
From: Szymon Janc @ 2013-10-25 10:50 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1382698211-9123-1-git-send-email-szymon.janc@tieto.com>
Those are used to specify SSP association model.
---
android/hal-ipc-api.txt | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
index a5437c1..0c2fd25 100644
--- a/android/hal-ipc-api.txt
+++ b/android/hal-ipc-api.txt
@@ -281,6 +281,11 @@ Commands and responses:
Passkey (4 octets)
Response parameters: <none>
+ Valid SSP variant values: 0x00 = Passkey Confirmation
+ 0x01 = Passkey Entry
+ 0x02 = Consent (for Just Works)
+ 0x03 = Passkey Notification
+
In case of an error, the error response will be returned.
Opcode 0x12 - DUT Mode Configure command/response
--
1.8.4.1
^ permalink raw reply related
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