* [PATCH 2/5] android: Initial implementation of socket interface
From: Marcin Kraglak @ 2013-10-28 12:30 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Marcin Kraglak
In-Reply-To: <1382963409-1012-1-git-send-email-marcin.kraglak@tieto.com>
Add stub implementation of socket interace on daemon side.
---
android/main.c | 4 ++++
android/socket.c | 42 ++++++++++++++++++++++++++++++++++++++++++
android/socket.h | 3 +++
3 files changed, 49 insertions(+)
diff --git a/android/main.c b/android/main.c
index 6ff30a9..2b40621 100644
--- a/android/main.c
+++ b/android/main.c
@@ -213,6 +213,10 @@ static gboolean cmd_watch_cb(GIOChannel *io, GIOCondition cond,
bt_hid_handle_cmd(hal_cmd_io, msg->opcode, msg->payload,
msg->len);
break;
+ case HAL_SERVICE_ID_SOCK:
+ bt_sock_handle_cmd(hal_cmd_io, msg->opcode, msg->payload,
+ msg->len);
+ break;
default:
ipc_send_rsp(hal_cmd_io, msg->service_id, HAL_STATUS_FAILED);
break;
diff --git a/android/socket.c b/android/socket.c
index 22d2acb..39709cd 100644
--- a/android/socket.c
+++ b/android/socket.c
@@ -26,8 +26,50 @@
#include "lib/bluetooth.h"
#include "log.h"
+#include "hal-msg.h"
+#include "hal-ipc.h"
+#include "ipc.h"
#include "socket.h"
+
+static int handle_listen(void *buf)
+{
+ return -1;
+}
+
+static int handle_connect(void *buf)
+{
+ return -1;
+}
+
+void bt_sock_handle_cmd(GIOChannel *io, uint8_t opcode, void *buf,
+ uint16_t len)
+{
+ int fd;
+
+ switch (opcode) {
+ case HAL_OP_SOCK_LISTEN:
+ fd = handle_listen(buf);
+ if (fd < 0)
+ break;
+
+ ipc_send(io, HAL_SERVICE_ID_SOCK, opcode, 0, NULL, fd);
+ return;
+ case HAL_OP_SOCK_CONNECT:
+ fd = handle_connect(buf);
+ if (fd < 0)
+ break;
+
+ ipc_send(io, HAL_SERVICE_ID_SOCK, opcode, 0, NULL, fd);
+ return;
+ default:
+ DBG("Unhandled command, opcode 0x%x", opcode);
+ break;
+ }
+
+ ipc_send_rsp(io, HAL_SERVICE_ID_SOCK, HAL_STATUS_FAILED);
+}
+
bool bt_socket_register(GIOChannel *io, const bdaddr_t *addr)
{
DBG("");
diff --git a/android/socket.h b/android/socket.h
index b13e84c..2b3b940 100644
--- a/android/socket.h
+++ b/android/socket.h
@@ -21,5 +21,8 @@
*
*/
+void bt_sock_handle_cmd(GIOChannel *io, uint8_t opcode, void *buf,
+ uint16_t len);
+
bool bt_socket_register(GIOChannel *io, const bdaddr_t *addr);
void bt_socket_unregister(void);
--
1.8.2.2
^ permalink raw reply related
* [PATCH 1/5] android/hal: Add initial socket implementation
From: Marcin Kraglak @ 2013-10-28 12:30 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Marcin Kraglak
Added socket api opcodes and structures and its implementation
in hal-sock.c.
---
android/hal-msg.h | 20 ++++++++++++++++++++
android/hal-sock.c | 28 ++++++++++++++++++++++++++--
2 files changed, 46 insertions(+), 2 deletions(-)
diff --git a/android/hal-msg.h b/android/hal-msg.h
index 677b00b..ec7d181 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -213,6 +213,26 @@ struct hal_cmd_le_test_mode {
uint8_t data[0];
} __attribute__((packed));
+/* Bluetooth Socket HAL api */
+
+#define HAL_OP_SOCK_LISTEN 0x01
+struct hal_op_sock_listen {
+ uint8_t type;
+ uint8_t name[256];
+ uint8_t uuid[16];
+ uint16_t channel;
+ uint8_t flags;
+} __attribute__((packed));
+
+#define HAL_OP_SOCK_CONNECT 0x02
+struct hal_op_sock_connect {
+ uint8_t bdaddr[6];
+ uint8_t type;
+ uint8_t uuid[16];
+ uint16_t channel;
+ uint8_t flags;
+} __attribute__((packed));
+
#define HAL_OP_HID_CONNECT 0x01
struct hal_cmd_hid_connect {
uint8_t bdaddr[6];
diff --git a/android/hal-sock.c b/android/hal-sock.c
index 7642ee3..131877a 100644
--- a/android/hal-sock.c
+++ b/android/hal-sock.c
@@ -15,18 +15,33 @@
*
*/
+#include <stdbool.h>
+#include <stdint.h>
#include <stdlib.h>
+#include <string.h>
+#include "hal-ipc.h"
#include "hal-log.h"
+#include "hal-msg.h"
#include "hal.h"
static bt_status_t sock_listen_rfcomm(const char *service_name,
const uint8_t *uuid, int chan,
int *sock, int flags)
{
+ struct hal_op_sock_listen cmd;
+
DBG("");
- return BT_STATUS_UNSUPPORTED;
+ cmd.flags = flags;
+ cmd.type = BTSOCK_RFCOMM;
+ cmd.channel = chan;
+ memcpy(cmd.uuid, uuid, sizeof(cmd.uuid));
+ memset(cmd.name, 0, sizeof(cmd.name));
+ memcpy(cmd.name, service_name, strlen(service_name));
+
+ return hal_ipc_cmd(HAL_SERVICE_ID_SOCK, HAL_OP_SOCK_LISTEN,
+ sizeof(cmd), &cmd, NULL, NULL, sock);
}
static bt_status_t sock_listen(btsock_type_t type, const char *service_name,
@@ -58,6 +73,8 @@ static bt_status_t sock_connect(const bt_bdaddr_t *bdaddr, btsock_type_t type,
const uint8_t *uuid, int chan,
int *sock, int flags)
{
+ struct hal_op_sock_connect cmd;
+
if ((!uuid && chan <= 0) || !bdaddr || !sock) {
error("invalid params: bd_addr %p, uuid %p, chan %d, sock %p",
bdaddr, uuid, chan, sock);
@@ -66,7 +83,14 @@ static bt_status_t sock_connect(const bt_bdaddr_t *bdaddr, btsock_type_t type,
DBG("uuid %p chan %d sock %p type %d", uuid, chan, sock, type);
- return BT_STATUS_UNSUPPORTED;
+ cmd.flags = flags;
+ cmd.type = type;
+ cmd.channel = chan;
+ memcpy(cmd.uuid, uuid, sizeof(cmd.uuid));
+ memcpy(cmd.bdaddr, bdaddr, sizeof(cmd.bdaddr));
+
+ return hal_ipc_cmd(HAL_SERVICE_ID_SOCK, HAL_OP_SOCK_CONNECT,
+ sizeof(cmd), &cmd, NULL, NULL, sock);
}
static btsock_interface_t sock_if = {
--
1.8.2.2
^ permalink raw reply related
* [PATCH BlueZ 5/5] android/hal-pan: Add implementation of .disconnect
From: Luiz Augusto von Dentz @ 2013-10-28 12:09 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1382962146-19587-1-git-send-email-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
---
android/hal-msg.h | 5 +++++
android/hal-pan.c | 8 +++++---
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/android/hal-msg.h b/android/hal-msg.h
index 65f60dc..bba031c 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -309,6 +309,11 @@ struct hal_cmd_pan_connect {
uint8_t remote_role;
} __attribute__((packed));
+#define HAL_OP_PAN_DISCONNECT 0x04
+struct hal_cmd_pan_disconnect {
+ uint8_t bdaddr[6];
+} __attribute__((packed));
+
/* Notifications and confirmations */
diff --git a/android/hal-pan.c b/android/hal-pan.c
index 3e23eb5..cacc6c0 100644
--- a/android/hal-pan.c
+++ b/android/hal-pan.c
@@ -85,15 +85,17 @@ static bt_status_t pan_connect(const bt_bdaddr_t *bd_addr, int local_role,
static bt_status_t pan_disconnect(const bt_bdaddr_t *bd_addr)
{
+ struct hal_cmd_pan_disconnect cmd;
+
DBG("");
if (!interface_ready())
return BT_STATUS_NOT_READY;
- if (!bd_addr)
- return BT_STATUS_PARM_INVALID;
+ memcpy(cmd.bdaddr, bd_addr, sizeof(cmd.bdaddr));
- return BT_STATUS_UNSUPPORTED;
+ return hal_ipc_cmd(HAL_SERVICE_ID_PAN, HAL_OP_PAN_DISCONNECT,
+ sizeof(cmd), &cmd, 0, NULL, NULL);
}
static bt_status_t pan_init(const btpan_callbacks_t *callbacks)
--
1.8.3.1
^ permalink raw reply related
* [PATCH BlueZ 4/5] android/hal-pan: Add implementation of .connect
From: Luiz Augusto von Dentz @ 2013-10-28 12:09 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1382962146-19587-1-git-send-email-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
---
android/hal-msg.h | 7 +++++++
android/hal-pan.c | 11 ++++++++---
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/android/hal-msg.h b/android/hal-msg.h
index 350cec1..65f60dc 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -302,6 +302,13 @@ struct hal_rsp_pan_get_role {
uint8_t local_role;
} __attribute__((packed));
+#define HAL_OP_PAN_CONNECT 0x03
+struct hal_cmd_pan_connect {
+ uint8_t bdaddr[6];
+ uint8_t local_role;
+ uint8_t remote_role;
+} __attribute__((packed));
+
/* Notifications and confirmations */
diff --git a/android/hal-pan.c b/android/hal-pan.c
index c8dcdec..3e23eb5 100644
--- a/android/hal-pan.c
+++ b/android/hal-pan.c
@@ -17,6 +17,7 @@
#include <stdbool.h>
#include <stddef.h>
+#include <string.h>
#include "hal-log.h"
#include "hal.h"
@@ -67,15 +68,19 @@ static int pan_get_local_role(void)
static bt_status_t pan_connect(const bt_bdaddr_t *bd_addr, int local_role,
int remote_role)
{
+ struct hal_cmd_pan_connect 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));
+ cmd.local_role = local_role;
+ cmd.remote_role = remote_role;
- return BT_STATUS_UNSUPPORTED;
+ return hal_ipc_cmd(HAL_SERVICE_ID_PAN, HAL_OP_PAN_CONNECT,
+ sizeof(cmd), &cmd, 0, NULL, NULL);
}
static bt_status_t pan_disconnect(const bt_bdaddr_t *bd_addr)
--
1.8.3.1
^ permalink raw reply related
* [PATCH BlueZ 3/5] android/hal-pan: Add implementation of .get_local_role
From: Luiz Augusto von Dentz @ 2013-10-28 12:09 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1382962146-19587-1-git-send-email-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
---
android/hal-msg.h | 5 +++++
android/hal-pan.c | 11 ++++++++++-
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/android/hal-msg.h b/android/hal-msg.h
index 0987eec..350cec1 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -297,6 +297,11 @@ struct hal_cmd_pan_enable {
uint8_t local_role;
} __attribute__((packed));
+#define HAL_OP_PAN_GET_ROLE 0x02
+struct hal_rsp_pan_get_role {
+ uint8_t local_role;
+} __attribute__((packed));
+
/* Notifications and confirmations */
diff --git a/android/hal-pan.c b/android/hal-pan.c
index 8fb2563..c8dcdec 100644
--- a/android/hal-pan.c
+++ b/android/hal-pan.c
@@ -47,12 +47,21 @@ static bt_status_t pan_enable(int local_role)
static int pan_get_local_role(void)
{
+ struct hal_rsp_pan_get_role rsp;
+ size_t len = sizeof(rsp);
+ bt_status_t status;
+
DBG("");
if (!interface_ready())
return BTPAN_ROLE_NONE;
- return BTPAN_ROLE_NONE;
+ status = hal_ipc_cmd(HAL_SERVICE_ID_PAN, HAL_OP_PAN_GET_ROLE, 0, NULL,
+ &len, &rsp, NULL);
+ if (status != BT_STATUS_SUCCESS)
+ return BTPAN_ROLE_NONE;
+
+ return rsp.local_role;
}
static bt_status_t pan_connect(const bt_bdaddr_t *bd_addr, int local_role,
--
1.8.3.1
^ permalink raw reply related
* [PATCH BlueZ 2/5] android/hal-pan: Add implementation of .enable
From: Luiz Augusto von Dentz @ 2013-10-28 12:09 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1382962146-19587-1-git-send-email-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
---
android/hal-msg.h | 7 +++++++
android/hal-pan.c | 7 ++++++-
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/android/hal-msg.h b/android/hal-msg.h
index a0a8390..0987eec 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -290,6 +290,13 @@ struct hal_cmd_av_disconnect {
uint8_t bdaddr[6];
} __attribute__((packed));
+/* PAN HAL API */
+
+#define HAL_OP_PAN_ENABLE 0x01
+struct hal_cmd_pan_enable {
+ uint8_t local_role;
+} __attribute__((packed));
+
/* Notifications and confirmations */
diff --git a/android/hal-pan.c b/android/hal-pan.c
index 62fec00..8fb2563 100644
--- a/android/hal-pan.c
+++ b/android/hal-pan.c
@@ -32,12 +32,17 @@ static bool interface_ready(void)
static bt_status_t pan_enable(int local_role)
{
+ struct hal_cmd_pan_enable cmd;
+
DBG("");
if (!interface_ready())
return BT_STATUS_NOT_READY;
- return BT_STATUS_UNSUPPORTED;
+ cmd.local_role = local_role;
+
+ return hal_ipc_cmd(HAL_SERVICE_ID_PAN, HAL_OP_PAN_ENABLE,
+ sizeof(cmd), &cmd, 0, NULL, NULL);
}
static int pan_get_local_role(void)
--
1.8.3.1
^ permalink raw reply related
* [PATCH BlueZ 1/5] android/hal-pan: Add implementation of .init
From: Luiz Augusto von Dentz @ 2013-10-28 12:09 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
---
android/hal-pan.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/android/hal-pan.c b/android/hal-pan.c
index 609bc1c..62fec00 100644
--- a/android/hal-pan.c
+++ b/android/hal-pan.c
@@ -20,6 +20,8 @@
#include "hal-log.h"
#include "hal.h"
+#include "hal-msg.h"
+#include "hal-ipc.h"
static const btpan_callbacks_t *cbs = NULL;
@@ -77,15 +79,16 @@ static bt_status_t pan_disconnect(const bt_bdaddr_t *bd_addr)
static bt_status_t pan_init(const btpan_callbacks_t *callbacks)
{
+ struct hal_cmd_register_module cmd;
+
DBG("");
cbs = callbacks;
- /* TODO: start HID Host thread */
-
- /* TODO: enable service */
+ cmd.service_id = HAL_SERVICE_ID_PAN;
- return BT_STATUS_SUCCESS;
+ return hal_ipc_cmd(HAL_SERVICE_ID_CORE, HAL_OP_REGISTER_MODULE,
+ sizeof(cmd), &cmd, 0, NULL, NULL);
}
static void pan_cleanup()
--
1.8.3.1
^ permalink raw reply related
* [PATCH 4/4] android/client: Add completion for hf methods
From: Jerzy Kasenberg @ 2013-10-28 11:39 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Jerzy Kasenberg
In-Reply-To: <1382960343-10765-1-git-send-email-jerzy.kasenberg@tieto.com>
This patch adds completion functions to handsfree methods.
---
android/client/if-hf.c | 124 ++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 114 insertions(+), 10 deletions(-)
diff --git a/android/client/if-hf.c b/android/client/if-hf.c
index 585a569..c23fb13 100644
--- a/android/client/if-hf.c
+++ b/android/client/if-hf.c
@@ -269,6 +269,14 @@ static void init_p(int argc, const char **argv)
/* connect */
+static void connect_c(int argc, const char **argv, enum_func *enum_func,
+ void **user)
+{
+ if (argc == 3) {
+ *user = NULL;
+ *enum_func = enum_devices;
+ }
+}
static void connect_p(int argc, const char **argv)
{
@@ -282,6 +290,22 @@ static void connect_p(int argc, const char **argv)
/* disconnect */
+/*
+ * This completion function will be used for several methods
+ * returning recently connected address
+ */
+static void connected_addr_c(int argc, const char **argv, enum_func *enum_func,
+ void **user)
+{
+ if (argc == 3) {
+ *user = last_addr;
+ *enum_func = enum_one_string;
+ }
+}
+
+/* Map completion to connected_addr_c */
+#define disconnect_c connected_addr_c
+
static void disconnect_p(int argc, const char **argv)
{
bt_bdaddr_t addr;
@@ -294,6 +318,9 @@ static void disconnect_p(int argc, const char **argv)
/* create an audio connection */
+/* Map completion to connected_addr_c */
+#define connect_audio_c connected_addr_c
+
static void connect_audio_p(int argc, const char **argv)
{
bt_bdaddr_t addr;
@@ -306,6 +333,9 @@ static void connect_audio_p(int argc, const char **argv)
/* close the audio connection */
+/* Map completion to connected_addr_c */
+#define disconnect_audio_c connected_addr_c
+
static void disconnect_audio_p(int argc, const char **argv)
{
bt_bdaddr_t addr;
@@ -336,6 +366,15 @@ static void stop_voice_recognition_p(int argc, const char **argv)
/* volume control */
+static void volume_control_c(int argc, const char **argv, enum_func *enum_func,
+ void **user)
+{
+ if (argc == 3) {
+ *user = TYPE_ENUM(bthf_volume_type_t);
+ *enum_func = enum_defines;
+ }
+}
+
static void volume_control_p(int argc, const char **argv)
{
bthf_volume_type_t type;
@@ -362,6 +401,19 @@ static void volume_control_p(int argc, const char **argv)
/* Combined device status change notification */
+static void device_status_notification_c(int argc, const char **argv,
+ enum_func *enum_func,
+ void **user)
+{
+ if (argc == 3) {
+ *user = TYPE_ENUM(bthf_network_state_t);
+ *enum_func = enum_defines;
+ } else if (argc == 4) {
+ *user = TYPE_ENUM(bthf_service_type_t);
+ *enum_func = enum_defines;
+ }
+}
+
static void device_status_notification_p(int argc, const char **argv)
{
bthf_network_state_t ntk_state;
@@ -420,6 +472,15 @@ static void cops_response_p(int argc, const char **argv)
/* Response for CIND command */
+static void cind_response_c(int argc, const char **argv, enum_func *enum_func,
+ void **user)
+{
+ if (argc == 6) {
+ *user = TYPE_ENUM(bthf_call_state_t);
+ *enum_func = enum_defines;
+ }
+}
+
static void cind_response_p(int argc, const char **argv)
{
int svc;
@@ -502,6 +563,15 @@ static void formatted_at_response_p(int argc, const char **argv)
/* at_response */
+static void at_response_c(int argc, const char **argv, enum_func *enum_func,
+ void **user)
+{
+ if (argc == 3) {
+ *user = TYPE_ENUM(bthf_at_response_t);
+ *enum_func = enum_defines;
+ }
+}
+
static void at_response_p(int argc, const char **argv)
{
bthf_at_response_t response_code;
@@ -525,6 +595,27 @@ static void at_response_p(int argc, const char **argv)
/* response for CLCC command */
+static void clcc_response_c(int argc, const char **argv, enum_func *enum_func,
+ void **user)
+{
+ if (argc == 4) {
+ *user = TYPE_ENUM(bthf_call_direction_t);
+ *enum_func = enum_defines;
+ } else if (argc == 5) {
+ *user = TYPE_ENUM(bthf_call_state_t);
+ *enum_func = enum_defines;
+ } else if (argc == 6) {
+ *user = TYPE_ENUM(bthf_call_mode_t);
+ *enum_func = enum_defines;
+ } else if (argc == 7) {
+ *user = TYPE_ENUM(bthf_call_mpty_type_t);
+ *enum_func = enum_defines;
+ } else if (argc == 9) {
+ *user = TYPE_ENUM(bthf_call_addrtype_t);
+ *enum_func = enum_defines;
+ }
+}
+
static void clcc_response_p(int argc, const char **argv)
{
int index;
@@ -591,6 +682,19 @@ static void clcc_response_p(int argc, const char **argv)
}
/* phone state change */
+
+static void phone_state_change_c(int argc, const char **argv,
+ enum_func *enum_func, void **user)
+{
+ if (argc == 5) {
+ *user = TYPE_ENUM(bthf_call_state_t);
+ *enum_func = enum_defines;
+ } else if (argc == 7) {
+ *user = TYPE_ENUM(bthf_call_addrtype_t);
+ *enum_func = enum_defines;
+ }
+}
+
static void phone_state_change_p(int argc, const char **argv)
{
int num_active;
@@ -652,23 +756,23 @@ static void cleanup_p(int argc, const char **argv)
static struct method methods[] = {
STD_METHOD(init),
- STD_METHODH(connect, "<addr>"),
- STD_METHODH(disconnect, "<addr>"),
- STD_METHODH(connect_audio, "<addr>"),
- STD_METHODH(disconnect_audio, "<addr>"),
+ STD_METHODCH(connect, "<addr>"),
+ STD_METHODCH(disconnect, "<addr>"),
+ STD_METHODCH(connect_audio, "<addr>"),
+ STD_METHODCH(disconnect_audio, "<addr>"),
STD_METHOD(start_voice_recognition),
STD_METHOD(stop_voice_recognition),
- STD_METHODH(volume_control, "<vol_type> <volume>"),
- STD_METHODH(device_status_notification,
+ STD_METHODCH(volume_control, "<vol_type> <volume>"),
+ STD_METHODCH(device_status_notification,
"<ntk_state> <svt_type> <signal> <batt_chg>"),
STD_METHODH(cops_response, "<cops string>"),
- STD_METHODH(cind_response,
+ STD_METHODCH(cind_response,
"<svc> <num_active> <num_held> <setup_state> <signal> <roam> <batt_chg>"),
STD_METHODH(formatted_at_response, "<at_response>"),
- STD_METHODH(at_response, "<response_code> [<error_code>]"),
- STD_METHODH(clcc_response,
+ STD_METHODCH(at_response, "<response_code> [<error_code>]"),
+ STD_METHODCH(clcc_response,
"<index> <direction> <state> <mode> <mpty> <number> <type>"),
- STD_METHODH(phone_state_change,
+ STD_METHODCH(phone_state_change,
"<num_active> <num_held> <setup_state> <number> <type>"),
STD_METHOD(cleanup),
END_METHOD
--
1.7.9.5
^ permalink raw reply related
* [PATCH 3/4] android/client: Add code for handsfree methods
From: Jerzy Kasenberg @ 2013-10-28 11:39 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Jerzy Kasenberg
In-Reply-To: <1382960343-10765-1-git-send-email-jerzy.kasenberg@tieto.com>
This patch adds implementation of handsfree methods to haltest.
---
android/client/if-hf.c | 289 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 289 insertions(+)
diff --git a/android/client/if-hf.c b/android/client/if-hf.c
index 43c7f47..585a569 100644
--- a/android/client/if-hf.c
+++ b/android/client/if-hf.c
@@ -272,83 +272,372 @@ static void init_p(int argc, const char **argv)
static void connect_p(int argc, const char **argv)
{
+ bt_bdaddr_t addr;
+
+ RETURN_IF_NULL(if_hf);
+ VERIFY_ADDR_ARG(2, &addr);
+
+ EXEC(if_hf->connect, &addr);
}
/* disconnect */
static void disconnect_p(int argc, const char **argv)
{
+ bt_bdaddr_t addr;
+
+ RETURN_IF_NULL(if_hf);
+ VERIFY_ADDR_ARG(2, &addr);
+
+ EXEC(if_hf->disconnect, &addr);
}
/* create an audio connection */
static void connect_audio_p(int argc, const char **argv)
{
+ bt_bdaddr_t addr;
+
+ RETURN_IF_NULL(if_hf);
+ VERIFY_ADDR_ARG(2, &addr);
+
+ EXEC(if_hf->connect_audio, &addr);
}
/* close the audio connection */
static void disconnect_audio_p(int argc, const char **argv)
{
+ bt_bdaddr_t addr;
+
+ RETURN_IF_NULL(if_hf);
+ VERIFY_ADDR_ARG(2, &addr);
+
+ EXEC(if_hf->disconnect_audio, &addr);
}
/* start voice recognition */
static void start_voice_recognition_p(int argc, const char **argv)
{
+ RETURN_IF_NULL(if_hf);
+
+ EXEC(if_hf->start_voice_recognition);
}
/* stop voice recognition */
static void stop_voice_recognition_p(int argc, const char **argv)
{
+ RETURN_IF_NULL(if_hf);
+
+ EXEC(if_hf->stop_voice_recognition);
}
/* volume control */
static void volume_control_p(int argc, const char **argv)
{
+ bthf_volume_type_t type;
+ int volume;
+
+ RETURN_IF_NULL(if_hf);
+
+ /* volume type */
+ if (argc <= 2) {
+ haltest_error("No volume type specified\n");
+ return;
+ }
+ type = str2bthf_volume_type_t(argv[2]);
+
+ /* volume */
+ if (argc <= 3) {
+ haltest_error("No volume specified\n");
+ return;
+ }
+ volume = atoi(argv[3]);
+
+ EXEC(if_hf->volume_control, type, volume);
}
/* Combined device status change notification */
static void device_status_notification_p(int argc, const char **argv)
{
+ bthf_network_state_t ntk_state;
+ bthf_service_type_t svc_type;
+ int signal;
+ int batt_chg;
+
+ RETURN_IF_NULL(if_hf);
+
+ /* network state */
+ if (argc <= 2) {
+ haltest_error("No network state specified\n");
+ return;
+ }
+ ntk_state = str2bthf_network_state_t(argv[2]);
+
+ /* service type */
+ if (argc <= 3) {
+ haltest_error("No service type specified\n");
+ return;
+ }
+ svc_type = str2bthf_service_type_t(argv[3]);
+
+ /* signal */
+ if (argc <= 4) {
+ haltest_error("No signal specified\n");
+ return;
+ }
+ signal = atoi(argv[4]);
+
+ /* batt_chg */
+ if (argc <= 5) {
+ haltest_error("No batt_chg specified\n");
+ return;
+ }
+ batt_chg = atoi(argv[5]);
+
+ EXEC(if_hf->device_status_notification, ntk_state, svc_type, signal,
+ batt_chg);
}
/* Response for COPS command */
static void cops_response_p(int argc, const char **argv)
{
+ RETURN_IF_NULL(if_hf);
+
+ /* response */
+ if (argc <= 2) {
+ haltest_error("No cops specified\n");
+ return;
+ }
+
+ EXEC(if_hf->cops_response, argv[2]);
}
/* Response for CIND command */
static void cind_response_p(int argc, const char **argv)
{
+ int svc;
+ int num_active;
+ int num_held;
+ bthf_call_state_t call_setup_state;
+ int signal;
+ int roam;
+ int batt_chg;
+
+ RETURN_IF_NULL(if_hf);
+
+ /* svc */
+ if (argc <= 2) {
+ haltest_error("No service specified\n");
+ return;
+ }
+ svc = atoi(argv[2]);
+
+ /* num active */
+ if (argc <= 3) {
+ haltest_error("No num active specified\n");
+ return;
+ }
+ num_active = atoi(argv[3]);
+
+ /* num held */
+ if (argc <= 4) {
+ haltest_error("No num held specified\n");
+ return;
+ }
+ num_held = atoi(argv[4]);
+
+ /* call setup state */
+ if (argc <= 5) {
+ haltest_error("No call setup state specified\n");
+ return;
+ }
+ call_setup_state = str2bthf_call_state_t(argv[5]);
+
+ /* signal */
+ if (argc <= 6) {
+ haltest_error("No signal specified\n");
+ return;
+ }
+ signal = atoi(argv[6]);
+
+ /* roam */
+ if (argc <= 7) {
+ haltest_error("No roam specified\n");
+ return;
+ }
+ roam = atoi(argv[7]);
+
+ /* batt_chg */
+ if (argc <= 8) {
+ haltest_error("No batt_chg specified\n");
+ return;
+ }
+ batt_chg = atoi(argv[8]);
+
+ EXEC(if_hf->cind_response, svc, num_active, num_held, call_setup_state,
+ signal, roam, batt_chg);
}
/* Pre-formatted AT response, typically in response to unknown AT cmd */
static void formatted_at_response_p(int argc, const char **argv)
{
+ RETURN_IF_NULL(if_hf);
+
+ /* response */
+ if (argc <= 2) {
+ haltest_error("No response specified\n");
+ return;
+ }
+
+ EXEC(if_hf->formatted_at_response, argv[2]);
}
/* at_response */
static void at_response_p(int argc, const char **argv)
{
+ bthf_at_response_t response_code;
+ int error_code = 0;
+
+ RETURN_IF_NULL(if_hf);
+
+ /* response type */
+ if (argc <= 2) {
+ haltest_error("No response specified\n");
+ return;
+ }
+ response_code = str2bthf_at_response_t(argv[2]);
+
+ /* error code */
+ if (argc >= 3)
+ error_code = atoi(argv[3]);
+
+ EXEC(if_hf->at_response, response_code, error_code);
}
/* response for CLCC command */
static void clcc_response_p(int argc, const char **argv)
{
+ int index;
+ bthf_call_direction_t dir;
+ bthf_call_state_t state;
+ bthf_call_mode_t mode;
+ bthf_call_mpty_type_t mpty;
+ const char *number;
+ bthf_call_addrtype_t type;
+
+ RETURN_IF_NULL(if_hf);
+
+ /* index */
+ if (argc <= 2) {
+ haltest_error("No index specified\n");
+ return;
+ }
+ index = atoi(argv[2]);
+
+ /* direction */
+ if (argc <= 3) {
+ haltest_error("No direction specified\n");
+ return;
+ }
+ dir = str2bthf_call_direction_t(argv[3]);
+
+ /* call state */
+ if (argc <= 4) {
+ haltest_error("No call state specified\n");
+ return;
+ }
+ state = str2bthf_call_state_t(argv[4]);
+
+ /* call mode */
+ if (argc <= 5) {
+ haltest_error("No mode specified\n");
+ return;
+ }
+ mode = str2bthf_call_mode_t(argv[5]);
+
+ /* call mpty type */
+ if (argc <= 6) {
+ haltest_error("No mpty type specified\n");
+ return;
+ }
+ mpty = str2bthf_call_mpty_type_t(argv[6]);
+
+ /* number */
+ if (argc <= 7) {
+ haltest_error("No number specified\n");
+ return;
+ }
+ number = argv[7];
+
+ /* call mpty type */
+ if (argc <= 8) {
+ haltest_error("No address type specified\n");
+ return;
+ }
+ type = str2bthf_call_addrtype_t(argv[8]);
+
+ EXEC(if_hf->clcc_response, index, dir, state, mode, mpty, number,
+ type);
}
/* phone state change */
static void phone_state_change_p(int argc, const char **argv)
{
+ int num_active;
+ int num_held;
+ bthf_call_state_t call_setup_state;
+ const char *number;
+ bthf_call_addrtype_t type;
+
+ RETURN_IF_NULL(if_hf);
+
+ /* num_active */
+ if (argc <= 2) {
+ haltest_error("No num_active specified\n");
+ return;
+ }
+ num_active = atoi(argv[2]);
+
+ /* num_held */
+ if (argc <= 3) {
+ haltest_error("No num_held specified\n");
+ return;
+ }
+ num_held = atoi(argv[3]);
+
+ /* setup state */
+ if (argc <= 4) {
+ haltest_error("No call setup state specified\n");
+ return;
+ }
+ call_setup_state = str2bthf_call_state_t(argv[4]);
+
+ /* number */
+ if (argc <= 5) {
+ haltest_error("No number specified\n");
+ return;
+ }
+ number = argv[5];
+
+ /* call mpty type */
+ if (argc <= 6) {
+ haltest_error("No address type specified\n");
+ return;
+ }
+ type = str2bthf_call_addrtype_t(argv[6]);
+
+ EXEC(if_hf->phone_state_change, num_active, num_held, call_setup_state,
+ number, type);
}
/* cleanup */
--
1.7.9.5
^ permalink raw reply related
* [PATCH 2/4] android/client: Add code for handsfree callbacks
From: Jerzy Kasenberg @ 2013-10-28 11:39 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Jerzy Kasenberg
In-Reply-To: <1382960343-10765-1-git-send-email-jerzy.kasenberg@tieto.com>
This adds implementation for handsfree callbacks.
---
android/client/if-hf.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/android/client/if-hf.c b/android/client/if-hf.c
index e4065df..43c7f47 100644
--- a/android/client/if-hf.c
+++ b/android/client/if-hf.c
@@ -106,6 +106,8 @@ ENDMAP
/* Callbacks */
+static char last_addr[MAX_ADDR_STR_LEN];
+
/*
* Callback for connection state change.
* state will have one of the values from BtHfConnectionState
@@ -113,6 +115,9 @@ ENDMAP
static void connection_state_cb(bthf_connection_state_t state,
bt_bdaddr_t *bd_addr)
{
+ haltest_info("%s: state=%s bd_addr=%s\n", __func__,
+ bthf_connection_state_t2str(state),
+ bt_bdaddr_t2str(bd_addr, last_addr));
}
/*
@@ -121,6 +126,9 @@ static void connection_state_cb(bthf_connection_state_t state,
*/
static void audio_state_cb(bthf_audio_state_t state, bt_bdaddr_t *bd_addr)
{
+ haltest_info("%s: state=%s bd_addr=%s\n", __func__,
+ bthf_audio_state_t2str(state),
+ bt_bdaddr_t2str(bd_addr, last_addr));
}
/*
@@ -129,16 +137,19 @@ static void audio_state_cb(bthf_audio_state_t state, bt_bdaddr_t *bd_addr)
*/
static void vr_cmd_cb(bthf_vr_state_t state)
{
+ haltest_info("%s: state=%s\n", __func__, bthf_vr_state_t2str(state));
}
/* Callback for answer incoming call (ATA) */
static void answer_call_cmd_cb(void)
{
+ haltest_info("%s\n", __func__);
}
/* Callback for disconnect call (AT+CHUP) */
static void hangup_call_cmd_cb(void)
{
+ haltest_info("%s\n", __func__);
}
/*
@@ -147,6 +158,8 @@ static void hangup_call_cmd_cb(void)
*/
static void volume_cmd_cb(bthf_volume_type_t type, int volume)
{
+ haltest_info("%s: type=%s volume=%d\n", __func__,
+ bthf_volume_type_t2str(type), volume);
}
/*
@@ -155,6 +168,7 @@ static void volume_cmd_cb(bthf_volume_type_t type, int volume)
*/
static void dial_call_cmd_cb(char *number)
{
+ haltest_info("%s: number=%s\n", __func__, number);
}
/*
@@ -163,6 +177,7 @@ static void dial_call_cmd_cb(char *number)
*/
static void dtmf_cmd_cb(char tone)
{
+ haltest_info("%s: tone=%d\n", __func__, tone);
}
/*
@@ -171,6 +186,7 @@ static void dtmf_cmd_cb(char tone)
*/
static void nrec_cmd_cb(bthf_nrec_t nrec)
{
+ haltest_info("%s: nrec=%s\n", __func__, bthf_nrec_t2str(nrec));
}
/*
@@ -179,26 +195,31 @@ static void nrec_cmd_cb(bthf_nrec_t nrec)
*/
static void chld_cmd_cb(bthf_chld_type_t chld)
{
+ haltest_info("%s: chld=%s\n", __func__, bthf_chld_type_t2str(chld));
}
/* Callback for CNUM (subscriber number) */
static void cnum_cmd_cb(void)
{
+ haltest_info("%s\n", __func__);
}
/* Callback for indicators (CIND) */
static void cind_cmd_cb(void)
{
+ haltest_info("%s\n", __func__);
}
/* Callback for operator selection (COPS) */
static void cops_cmd_cb(void)
{
+ haltest_info("%s\n", __func__);
}
/* Callback for call list (AT+CLCC) */
static void clcc_cmd_cb(void)
{
+ haltest_info("%s\n", __func__);
}
/*
@@ -207,11 +228,13 @@ static void clcc_cmd_cb(void)
*/
static void unknown_at_cmd_cb(char *at_string)
{
+ haltest_info("%s: at_string=%s\n", __func__, at_string);
}
/* Callback for keypressed (HSP) event. */
static void key_pressed_cmd_cb(void)
{
+ haltest_info("%s\n", __func__);
}
static bthf_callbacks_t hf_cbacks = {
--
1.7.9.5
^ permalink raw reply related
* [PATCH 1/4] android/client: Add skeleton for handsfree calls
From: Jerzy Kasenberg @ 2013-10-28 11:39 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Jerzy Kasenberg
In-Reply-To: <1382960343-10765-1-git-send-email-jerzy.kasenberg@tieto.com>
This patch adds skeleton for all methods of handsfree along with
all callbacks.
---
Makefile.android | 2 +
android/Android.mk | 1 +
android/client/haltest.c | 1 +
android/client/if-bt.c | 2 +-
android/client/if-hf.c | 368 ++++++++++++++++++++++++++++++++++++++++++++++
android/client/if-main.h | 2 +
6 files changed, 375 insertions(+), 1 deletion(-)
create mode 100644 android/client/if-hf.c
diff --git a/Makefile.android b/Makefile.android
index 01b3cea..fd8043c 100644
--- a/Makefile.android
+++ b/Makefile.android
@@ -51,6 +51,7 @@ android_haltest_SOURCES = android/client/haltest.c \
android/client/tabcompletion.c \
android/client/if-av.c \
android/client/if-bt.c \
+ android/client/if-hf.c \
android/client/if-hh.c \
android/client/if-pan.c \
android/client/if-sock.c \
@@ -81,6 +82,7 @@ EXTRA_DIST += android/client/terminal.c \
android/client/history.c \
android/client/if-av.c \
android/client/if-bt.c \
+ android/client/if-hf.c \
android/client/if-hh.c \
android/client/if-pan.c \
android/client/if-sock.c \
diff --git a/android/Android.mk b/android/Android.mk
index 56c43cb..22208e0 100644
--- a/android/Android.mk
+++ b/android/Android.mk
@@ -104,6 +104,7 @@ LOCAL_SRC_FILES := \
client/tabcompletion.c \
client/if-av.c \
client/if-bt.c \
+ client/if-hf.c \
client/if-hh.c \
client/if-pan.c \
client/if-sock.c \
diff --git a/android/client/haltest.c b/android/client/haltest.c
index 6b4030b..7fe0436 100644
--- a/android/client/haltest.c
+++ b/android/client/haltest.c
@@ -32,6 +32,7 @@
const struct interface *interfaces[] = {
&bluetooth_if,
&av_if,
+ &hf_if,
&hh_if,
&pan_if,
&sock_if,
diff --git a/android/client/if-bt.c b/android/client/if-bt.c
index dd5d12e..a20a7c6 100644
--- a/android/client/if-bt.c
+++ b/android/client/if-bt.c
@@ -811,7 +811,7 @@ static void get_profile_interface_p(int argc, const char **argv)
RETURN_IF_NULL(if_bluetooth);
if (strcmp(BT_PROFILE_HANDSFREE_ID, id) == 0)
- pif = &dummy; /* TODO: change when if_hf is there */
+ pif = (const void **) &if_hf;
else if (strcmp(BT_PROFILE_ADVANCED_AUDIO_ID, id) == 0)
pif = (const void **) &if_av;
else if (strcmp(BT_PROFILE_HEALTH_ID, id) == 0)
diff --git a/android/client/if-hf.c b/android/client/if-hf.c
new file mode 100644
index 0000000..e4065df
--- /dev/null
+++ b/android/client/if-hf.c
@@ -0,0 +1,368 @@
+/*
+ * Copyright (C) 2013 Intel Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "if-main.h"
+
+const bthf_interface_t *if_hf = NULL;
+
+SINTMAP(bthf_at_response_t, -1, "(unknown)")
+ DELEMENT(BTHF_AT_RESPONSE_ERROR),
+ DELEMENT(BTHF_AT_RESPONSE_OK),
+ENDMAP
+
+SINTMAP(bthf_connection_state_t, -1, "(unknown)")
+ DELEMENT(BTHF_CONNECTION_STATE_DISCONNECTED),
+ DELEMENT(BTHF_CONNECTION_STATE_CONNECTING),
+ DELEMENT(BTHF_CONNECTION_STATE_CONNECTED),
+ DELEMENT(BTHF_CONNECTION_STATE_SLC_CONNECTED),
+ DELEMENT(BTHF_CONNECTION_STATE_DISCONNECTING),
+ENDMAP
+
+SINTMAP(bthf_audio_state_t, -1, "(unknown)")
+ DELEMENT(BTHF_AUDIO_STATE_DISCONNECTED),
+ DELEMENT(BTHF_AUDIO_STATE_CONNECTING),
+ DELEMENT(BTHF_AUDIO_STATE_CONNECTED),
+ DELEMENT(BTHF_AUDIO_STATE_DISCONNECTING),
+ENDMAP
+
+SINTMAP(bthf_vr_state_t, -1, "(unknown)")
+ DELEMENT(BTHF_VR_STATE_STOPPED),
+ DELEMENT(BTHF_VR_STATE_STARTED),
+ENDMAP
+
+SINTMAP(bthf_volume_type_t, -1, "(unknown)")
+ DELEMENT(BTHF_VOLUME_TYPE_SPK),
+ DELEMENT(BTHF_VOLUME_TYPE_MIC),
+ENDMAP
+
+SINTMAP(bthf_nrec_t, -1, "(unknown)")
+ DELEMENT(BTHF_NREC_STOP),
+ DELEMENT(BTHF_NREC_START),
+ENDMAP
+
+SINTMAP(bthf_chld_type_t, -1, "(unknown)")
+ DELEMENT(BTHF_CHLD_TYPE_RELEASEHELD),
+ DELEMENT(BTHF_CHLD_TYPE_RELEASEACTIVE_ACCEPTHELD),
+ DELEMENT(BTHF_CHLD_TYPE_HOLDACTIVE_ACCEPTHELD),
+ DELEMENT(BTHF_CHLD_TYPE_ADDHELDTOCONF),
+ENDMAP
+
+/* Network Status */
+SINTMAP(bthf_network_state_t, -1, "(unknown)")
+ DELEMENT(BTHF_NETWORK_STATE_NOT_AVAILABLE),
+ DELEMENT(BTHF_NETWORK_STATE_AVAILABLE),
+ENDMAP
+
+/* Service type */
+SINTMAP(bthf_service_type_t, -1, "(unknown)")
+ DELEMENT(BTHF_SERVICE_TYPE_HOME),
+ DELEMENT(BTHF_SERVICE_TYPE_ROAMING),
+ENDMAP
+
+SINTMAP(bthf_call_state_t, -1, "(unknown)")
+ DELEMENT(BTHF_CALL_STATE_ACTIVE),
+ DELEMENT(BTHF_CALL_STATE_HELD),
+ DELEMENT(BTHF_CALL_STATE_DIALING),
+ DELEMENT(BTHF_CALL_STATE_ALERTING),
+ DELEMENT(BTHF_CALL_STATE_INCOMING),
+ DELEMENT(BTHF_CALL_STATE_WAITING),
+ DELEMENT(BTHF_CALL_STATE_IDLE),
+ENDMAP
+
+SINTMAP(bthf_call_direction_t, -1, "(unknown)")
+ DELEMENT(BTHF_CALL_DIRECTION_OUTGOING),
+ DELEMENT(BTHF_CALL_DIRECTION_INCOMING),
+ENDMAP
+
+SINTMAP(bthf_call_mode_t, -1, "(unknown)")
+ DELEMENT(BTHF_CALL_TYPE_VOICE),
+ DELEMENT(BTHF_CALL_TYPE_DATA),
+ DELEMENT(BTHF_CALL_TYPE_FAX),
+ENDMAP
+
+SINTMAP(bthf_call_mpty_type_t, -1, "(unknown)")
+ DELEMENT(BTHF_CALL_MPTY_TYPE_SINGLE),
+ DELEMENT(BTHF_CALL_MPTY_TYPE_MULTI),
+ENDMAP
+
+SINTMAP(bthf_call_addrtype_t, -1, "(unknown)")
+ DELEMENT(BTHF_CALL_ADDRTYPE_UNKNOWN),
+ DELEMENT(BTHF_CALL_ADDRTYPE_INTERNATIONAL),
+ENDMAP
+
+/* Callbacks */
+
+/*
+ * Callback for connection state change.
+ * state will have one of the values from BtHfConnectionState
+ */
+static void connection_state_cb(bthf_connection_state_t state,
+ bt_bdaddr_t *bd_addr)
+{
+}
+
+/*
+ * Callback for audio connection state change.
+ * state will have one of the values from BtHfAudioState
+ */
+static void audio_state_cb(bthf_audio_state_t state, bt_bdaddr_t *bd_addr)
+{
+}
+
+/*
+ * Callback for VR connection state change.
+ * state will have one of the values from BtHfVRState
+ */
+static void vr_cmd_cb(bthf_vr_state_t state)
+{
+}
+
+/* Callback for answer incoming call (ATA) */
+static void answer_call_cmd_cb(void)
+{
+}
+
+/* Callback for disconnect call (AT+CHUP) */
+static void hangup_call_cmd_cb(void)
+{
+}
+
+/*
+ * Callback for disconnect call (AT+CHUP)
+ * type will denote Speaker/Mic gain (BtHfVolumeControl).
+ */
+static void volume_cmd_cb(bthf_volume_type_t type, int volume)
+{
+}
+
+/*
+ * Callback for dialing an outgoing call
+ * If number is NULL, redial
+ */
+static void dial_call_cmd_cb(char *number)
+{
+}
+
+/*
+ * Callback for sending DTMF tones
+ * tone contains the dtmf character to be sent
+ */
+static void dtmf_cmd_cb(char tone)
+{
+}
+
+/*
+ * Callback for enabling/disabling noise reduction/echo cancellation
+ * value will be 1 to enable, 0 to disable
+ */
+static void nrec_cmd_cb(bthf_nrec_t nrec)
+{
+}
+
+/*
+ * Callback for call hold handling (AT+CHLD)
+ * value will contain the call hold command (0, 1, 2, 3)
+ */
+static void chld_cmd_cb(bthf_chld_type_t chld)
+{
+}
+
+/* Callback for CNUM (subscriber number) */
+static void cnum_cmd_cb(void)
+{
+}
+
+/* Callback for indicators (CIND) */
+static void cind_cmd_cb(void)
+{
+}
+
+/* Callback for operator selection (COPS) */
+static void cops_cmd_cb(void)
+{
+}
+
+/* Callback for call list (AT+CLCC) */
+static void clcc_cmd_cb(void)
+{
+}
+
+/*
+ * Callback for unknown AT command recd from HF
+ * at_string will contain the unparsed AT string
+ */
+static void unknown_at_cmd_cb(char *at_string)
+{
+}
+
+/* Callback for keypressed (HSP) event. */
+static void key_pressed_cmd_cb(void)
+{
+}
+
+static bthf_callbacks_t hf_cbacks = {
+
+ .size = sizeof(hf_cbacks),
+ .connection_state_cb = connection_state_cb,
+ .audio_state_cb = audio_state_cb,
+ .vr_cmd_cb = vr_cmd_cb,
+ .answer_call_cmd_cb = answer_call_cmd_cb,
+ .hangup_call_cmd_cb = hangup_call_cmd_cb,
+ .volume_cmd_cb = volume_cmd_cb,
+ .dial_call_cmd_cb = dial_call_cmd_cb,
+ .dtmf_cmd_cb = dtmf_cmd_cb,
+ .nrec_cmd_cb = nrec_cmd_cb,
+ .chld_cmd_cb = chld_cmd_cb,
+ .cnum_cmd_cb = cnum_cmd_cb,
+ .cind_cmd_cb = cind_cmd_cb,
+ .cops_cmd_cb = cops_cmd_cb,
+ .clcc_cmd_cb = clcc_cmd_cb,
+ .unknown_at_cmd_cb = unknown_at_cmd_cb,
+ .key_pressed_cmd_cb = key_pressed_cmd_cb,
+};
+
+/* init */
+
+static void init_p(int argc, const char **argv)
+{
+ RETURN_IF_NULL(if_hf);
+
+ EXEC(if_hf->init, &hf_cbacks);
+}
+
+/* connect */
+
+
+static void connect_p(int argc, const char **argv)
+{
+}
+
+/* disconnect */
+
+static void disconnect_p(int argc, const char **argv)
+{
+}
+
+/* create an audio connection */
+
+static void connect_audio_p(int argc, const char **argv)
+{
+}
+
+/* close the audio connection */
+
+static void disconnect_audio_p(int argc, const char **argv)
+{
+}
+
+/* start voice recognition */
+
+static void start_voice_recognition_p(int argc, const char **argv)
+{
+}
+
+/* stop voice recognition */
+
+static void stop_voice_recognition_p(int argc, const char **argv)
+{
+}
+
+/* volume control */
+
+static void volume_control_p(int argc, const char **argv)
+{
+}
+
+/* Combined device status change notification */
+
+static void device_status_notification_p(int argc, const char **argv)
+{
+}
+
+/* Response for COPS command */
+
+static void cops_response_p(int argc, const char **argv)
+{
+}
+
+/* Response for CIND command */
+
+static void cind_response_p(int argc, const char **argv)
+{
+}
+
+/* Pre-formatted AT response, typically in response to unknown AT cmd */
+
+static void formatted_at_response_p(int argc, const char **argv)
+{
+}
+
+/* at_response */
+
+static void at_response_p(int argc, const char **argv)
+{
+}
+
+/* response for CLCC command */
+
+static void clcc_response_p(int argc, const char **argv)
+{
+}
+
+/* phone state change */
+static void phone_state_change_p(int argc, const char **argv)
+{
+}
+
+/* cleanup */
+
+static void cleanup_p(int argc, const char **argv)
+{
+ RETURN_IF_NULL(if_hf);
+
+ EXECV(if_hf->cleanup);
+ if_hf = NULL;
+}
+
+static struct method methods[] = {
+ STD_METHOD(init),
+ STD_METHODH(connect, "<addr>"),
+ STD_METHODH(disconnect, "<addr>"),
+ STD_METHODH(connect_audio, "<addr>"),
+ STD_METHODH(disconnect_audio, "<addr>"),
+ STD_METHOD(start_voice_recognition),
+ STD_METHOD(stop_voice_recognition),
+ STD_METHODH(volume_control, "<vol_type> <volume>"),
+ STD_METHODH(device_status_notification,
+ "<ntk_state> <svt_type> <signal> <batt_chg>"),
+ STD_METHODH(cops_response, "<cops string>"),
+ STD_METHODH(cind_response,
+ "<svc> <num_active> <num_held> <setup_state> <signal> <roam> <batt_chg>"),
+ STD_METHODH(formatted_at_response, "<at_response>"),
+ STD_METHODH(at_response, "<response_code> [<error_code>]"),
+ STD_METHODH(clcc_response,
+ "<index> <direction> <state> <mode> <mpty> <number> <type>"),
+ STD_METHODH(phone_state_change,
+ "<num_active> <num_held> <setup_state> <number> <type>"),
+ STD_METHOD(cleanup),
+ END_METHOD
+};
+
+const struct interface hf_if = {
+ .name = "handsfree",
+ .methods = methods
+};
diff --git a/android/client/if-main.h b/android/client/if-main.h
index eaee914..37086dd 100644
--- a/android/client/if-main.h
+++ b/android/client/if-main.h
@@ -45,6 +45,7 @@
/* Interfaces from hal that can be populated during application lifetime */
extern const bt_interface_t *if_bluetooth;
extern const btav_interface_t *if_av;
+extern const bthf_interface_t *if_hf;
extern const bthh_interface_t *if_hh;
extern const btpan_interface_t *if_pan;
extern const btsock_interface_t *if_sock;
@@ -62,6 +63,7 @@ extern const struct interface bluetooth_if;
extern const struct interface av_if;
extern const struct interface pan_if;
extern const struct interface sock_if;
+extern const struct interface hf_if;
extern const struct interface hh_if;
/* Interfaces that will show up in tool (first part of command line) */
--
1.7.9.5
^ permalink raw reply related
* [PATCH 0/4] Add handsfree interface methods to haltest
From: Jerzy Kasenberg @ 2013-10-28 11:38 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Jerzy Kasenberg
With this patchset handsfree interface is available in haltest.
Jerzy Kasenberg (4):
android/client: Add skeleton for handsfree calls
android/client: Add code for handsfree callbacks
android/client: Add code for handsfree methods
android/client: Add completion for hf methods
Makefile.android | 2 +
android/Android.mk | 1 +
android/client/haltest.c | 1 +
android/client/if-bt.c | 2 +-
android/client/if-hf.c | 784 ++++++++++++++++++++++++++++++++++++++++++++++
android/client/if-main.h | 2 +
6 files changed, 791 insertions(+), 1 deletion(-)
create mode 100644 android/client/if-hf.c
--
1.7.9.5
^ permalink raw reply
* [PATCHv1 4/4] android/hal: Add extra logs
From: Andrei Emeltchenko @ 2013-10-28 10:44 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1382957047-31775-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Add extra log prints for printing properties and bluetooth addresses.
---
android/hal-bluetooth.c | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)
diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
index da96202..81e23cb 100644
--- a/android/hal-bluetooth.c
+++ b/android/hal-bluetooth.c
@@ -251,7 +251,7 @@ static int set_adapter_property(const bt_property_t *property)
static int get_remote_device_properties(bt_bdaddr_t *remote_addr)
{
- DBG("");
+ DBG("bdaddr: %s", bdaddr2str(remote_addr));
if (!interface_ready())
return BT_STATUS_NOT_READY;
@@ -262,7 +262,8 @@ static int get_remote_device_properties(bt_bdaddr_t *remote_addr)
static int get_remote_device_property(bt_bdaddr_t *remote_addr,
bt_property_type_t type)
{
- DBG("");
+ DBG("bdaddr: %s prop: %s", bdaddr2str(remote_addr),
+ bt_property_type_t2str(type));
if (!interface_ready())
return BT_STATUS_NOT_READY;
@@ -273,7 +274,8 @@ 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)
{
- DBG("");
+ DBG("bdaddr: %s prop: %s", bdaddr2str(remote_addr),
+ btproperty2str(property));
if (!interface_ready())
return BT_STATUS_NOT_READY;
@@ -283,7 +285,7 @@ static int set_remote_device_property(bt_bdaddr_t *remote_addr,
static int get_remote_service_record(bt_bdaddr_t *remote_addr, bt_uuid_t *uuid)
{
- DBG("");
+ DBG("bdaddr: %s", bdaddr2str(remote_addr));
if (!interface_ready())
return BT_STATUS_NOT_READY;
@@ -293,7 +295,7 @@ static int get_remote_service_record(bt_bdaddr_t *remote_addr, bt_uuid_t *uuid)
static int get_remote_services(bt_bdaddr_t *remote_addr)
{
- DBG("");
+ DBG("bdaddr: %s", bdaddr2str(remote_addr));
if (!interface_ready())
return BT_STATUS_NOT_READY;
@@ -325,7 +327,7 @@ static int create_bond(const bt_bdaddr_t *bd_addr)
{
struct hal_cmd_create_bond cmd;
- DBG("");
+ DBG("bdaddr: %s", bdaddr2str(bd_addr));
if (!interface_ready())
return BT_STATUS_NOT_READY;
@@ -340,7 +342,7 @@ static int cancel_bond(const bt_bdaddr_t *bd_addr)
{
struct hal_cmd_cancel_bond cmd;
- DBG("");
+ DBG("bdaddr: %s", bdaddr2str(bd_addr));
if (!interface_ready())
return BT_STATUS_NOT_READY;
@@ -355,7 +357,7 @@ static int remove_bond(const bt_bdaddr_t *bd_addr)
{
struct hal_cmd_remove_bond cmd;
- DBG("");
+ DBG("bdaddr: %s", bdaddr2str(bd_addr));
if (!interface_ready())
return BT_STATUS_NOT_READY;
@@ -371,7 +373,7 @@ static int pin_reply(const bt_bdaddr_t *bd_addr, uint8_t accept,
{
struct hal_cmd_pin_reply cmd;
- DBG("");
+ DBG("bdaddr: %s", bdaddr2str(bd_addr));
if (!interface_ready())
return BT_STATUS_NOT_READY;
@@ -390,7 +392,7 @@ static int ssp_reply(const bt_bdaddr_t *bd_addr, bt_ssp_variant_t variant,
{
struct hal_cmd_ssp_reply cmd;
- DBG("");
+ DBG("bdaddr: %s", bdaddr2str(bd_addr));
if (!interface_ready())
return BT_STATUS_NOT_READY;
--
1.7.10.4
^ permalink raw reply related
* [PATCHv1 3/4] android/hal: Print full property in debug
From: Andrei Emeltchenko @ 2013-10-28 10:44 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1382957047-31775-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Instead of printing property type print type and value. Use exported
function from hal test tool.
---
android/hal-bluetooth.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
index 5929fff..da96202 100644
--- a/android/hal-bluetooth.c
+++ b/android/hal-bluetooth.c
@@ -226,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("prop: %s", bt_property_type_t2str(property->type));
+ DBG("prop: %s", btproperty2str(property));
if (!interface_ready())
return BT_STATUS_NOT_READY;
--
1.7.10.4
^ permalink raw reply related
* [PATCHv1 2/4] android/haltest: Use pointer as parameter for debug
From: Andrei Emeltchenko @ 2013-10-28 10:44 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1382957047-31775-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Pass structure as pointer. This makes it consistent with the rest of
the code and helps to reuse this function in other parts.
---
android/client/if-bt.c | 2 +-
android/client/textconv.c | 36 ++++++++++++++++++------------------
android/client/textconv.h | 2 +-
3 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/android/client/if-bt.c b/android/client/if-bt.c
index 304ab28..d20feb3 100644
--- a/android/client/if-bt.c
+++ b/android/client/if-bt.c
@@ -74,7 +74,7 @@ static void dump_properties(int num_properties, bt_property_t *properties)
bt_property_t prop;
memcpy(&prop, properties + i, sizeof(prop));
- haltest_info("prop: %s\n", btproperty2str(prop));
+ haltest_info("prop: %s\n", btproperty2str(&prop));
}
}
diff --git a/android/client/textconv.c b/android/client/textconv.c
index a3e10ee..16392c2 100644
--- a/android/client/textconv.c
+++ b/android/client/textconv.c
@@ -241,52 +241,52 @@ char *btuuid2str(const bt_uuid_t *uuid)
return bt_uuid_t2str(uuid, buf);
}
-char *btproperty2str(bt_property_t property)
+char *btproperty2str(const bt_property_t *property)
{
static char buf[4096];
char *p;
p = buf + sprintf(buf, "type=%s len=%d val=",
- bt_property_type_t2str(property.type),
- property.len);
+ bt_property_type_t2str(property->type),
+ property->len);
- switch (property.type) {
+ switch (property->type) {
case BT_PROPERTY_BDNAME:
case BT_PROPERTY_REMOTE_FRIENDLY_NAME:
- sprintf(p, "%*s", property.len,
- ((bt_bdname_t *) property.val)->name);
+ sprintf(p, "%*s", property->len,
+ ((bt_bdname_t *) property->val)->name);
break;
case BT_PROPERTY_BDADDR:
- sprintf(p, "%s", bdaddr2str((bt_bdaddr_t *) property.val));
+ sprintf(p, "%s", bdaddr2str((bt_bdaddr_t *) property->val));
break;
case BT_PROPERTY_CLASS_OF_DEVICE:
- sprintf(p, "%06x", *((int *) property.val));
+ sprintf(p, "%06x", *((int *) property->val));
break;
case BT_PROPERTY_TYPE_OF_DEVICE:
sprintf(p, "%s", bt_device_type_t2str(
- *((bt_device_type_t *) property.val)));
+ *((bt_device_type_t *) property->val)));
break;
case BT_PROPERTY_REMOTE_RSSI:
- sprintf(p, "%d", *((char *) property.val));
+ sprintf(p, "%d", *((char *) property->val));
break;
case BT_PROPERTY_ADAPTER_SCAN_MODE:
sprintf(p, "%s",
- bt_scan_mode_t2str(*((bt_scan_mode_t *) property.val)));
+ bt_scan_mode_t2str(*((bt_scan_mode_t *) property->val)));
break;
case BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT:
- sprintf(p, "%d", *((int *) property.val));
+ sprintf(p, "%d", *((int *) property->val));
break;
case BT_PROPERTY_ADAPTER_BONDED_DEVICES:
{
- int count = property.len / sizeof(bt_bdaddr_t);
- char *ptr = property.val;
+ int count = property->len / sizeof(bt_bdaddr_t);
+ char *ptr = property->val;
strcat(p, "{");
@@ -304,8 +304,8 @@ char *btproperty2str(bt_property_t property)
case BT_PROPERTY_UUIDS:
{
- int count = property.len / sizeof(bt_uuid_t);
- char *ptr = property.val;
+ int count = property->len / sizeof(bt_uuid_t);
+ char *ptr = property->val;
strcat(p, "{");
@@ -323,7 +323,7 @@ char *btproperty2str(bt_property_t property)
case BT_PROPERTY_SERVICE_RECORD:
{
- bt_service_record_t *rec = property.val;
+ bt_service_record_t *rec = property->val;
sprintf(p, "{%s, %d, %s}", btuuid2str(&rec->uuid),
rec->channel, rec->name);
@@ -331,7 +331,7 @@ char *btproperty2str(bt_property_t property)
break;
default:
- sprintf(p, "%p", property.val);
+ sprintf(p, "%p", property->val);
}
return buf;
diff --git a/android/client/textconv.h b/android/client/textconv.h
index 89b29c6..1c848ef 100644
--- a/android/client/textconv.h
+++ b/android/client/textconv.h
@@ -107,7 +107,7 @@ void str2bt_bdaddr_t(const char *str, bt_bdaddr_t *bd_addr);
char *bt_uuid_t2str(const bt_uuid_t *uuid, char *buf);
void str2bt_uuid_t(const char *str, bt_uuid_t *uuid);
-char *btproperty2str(bt_property_t property);
+char *btproperty2str(const bt_property_t *property);
char *bdaddr2str(const bt_bdaddr_t *bd_addr);
DECINTMAP(bt_status_t);
--
1.7.10.4
^ permalink raw reply related
* [PATCHv1 1/4] android/haltest: Export print property
From: Andrei Emeltchenko @ 2013-10-28 10:44 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1382957047-31775-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Export property printing debug function.
---
android/client/if-bt.c | 110 ---------------------------------------------
android/client/textconv.c | 110 +++++++++++++++++++++++++++++++++++++++++++++
android/client/textconv.h | 3 ++
3 files changed, 113 insertions(+), 110 deletions(-)
diff --git a/android/client/if-bt.c b/android/client/if-bt.c
index dd5d12e..304ab28 100644
--- a/android/client/if-bt.c
+++ b/android/client/if-bt.c
@@ -29,20 +29,6 @@ const bt_interface_t *if_bluetooth;
} \
} while (0)
-static char *bdaddr2str(const bt_bdaddr_t *bd_addr)
-{
- static char buf[MAX_ADDR_STR_LEN];
-
- return bt_bdaddr_t2str(bd_addr, buf);
-}
-
-static char *btuuid2str(const bt_uuid_t *uuid)
-{
- static char buf[MAX_UUID_STR_LEN];
-
- return bt_uuid_t2str(uuid, buf);
-}
-
static bt_scan_mode_t str2btscanmode(const char *str)
{
bt_scan_mode_t v = str2bt_scan_mode_t(str);
@@ -76,102 +62,6 @@ static bt_property_type_t str2btpropertytype(const char *str)
return (bt_property_type_t) atoi(str);
}
-static char *btproperty2str(bt_property_t property)
-{
- static char buf[4096];
- char *p;
-
- p = buf + sprintf(buf, "type=%s len=%d val=",
- bt_property_type_t2str(property.type),
- property.len);
-
- switch (property.type) {
- case BT_PROPERTY_BDNAME:
- case BT_PROPERTY_REMOTE_FRIENDLY_NAME:
- sprintf(p, "%*s", property.len,
- ((bt_bdname_t *) property.val)->name);
- break;
-
- case BT_PROPERTY_BDADDR:
- sprintf(p, "%s", bdaddr2str((bt_bdaddr_t *) property.val));
- break;
-
- case BT_PROPERTY_CLASS_OF_DEVICE:
- sprintf(p, "%06x", *((int *) property.val));
- break;
-
- case BT_PROPERTY_TYPE_OF_DEVICE:
- sprintf(p, "%s", bt_device_type_t2str(
- *((bt_device_type_t *) property.val)));
- break;
-
- case BT_PROPERTY_REMOTE_RSSI:
- sprintf(p, "%d", *((char *) property.val));
- break;
-
- case BT_PROPERTY_ADAPTER_SCAN_MODE:
- sprintf(p, "%s",
- bt_scan_mode_t2str(*((bt_scan_mode_t *) property.val)));
- break;
-
- case BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT:
- sprintf(p, "%d", *((int *) property.val));
- break;
-
- case BT_PROPERTY_ADAPTER_BONDED_DEVICES:
- {
- int count = property.len / sizeof(bt_bdaddr_t);
- char *ptr = property.val;
-
- strcat(p, "{");
-
- while (count--) {
- strcat(p, bdaddr2str((bt_bdaddr_t *) ptr));
- if (count)
- strcat(p, ", ");
- ptr += sizeof(bt_bdaddr_t);
- }
-
- strcat(p, "}");
-
- }
- break;
-
- case BT_PROPERTY_UUIDS:
- {
- int count = property.len / sizeof(bt_uuid_t);
- char *ptr = property.val;
-
- strcat(p, "{");
-
- while (count--) {
- strcat(p, btuuid2str((bt_uuid_t *) ptr));
- if (count)
- strcat(p, ", ");
- ptr += sizeof(bt_uuid_t);
- }
-
- strcat(p, "}");
-
- }
- break;
-
- case BT_PROPERTY_SERVICE_RECORD:
- {
- bt_service_record_t *rec = property.val;
-
- sprintf(p, "{%s, %d, %s}", btuuid2str(&rec->uuid),
- rec->channel, rec->name);
- }
- break;
-
- default:
- sprintf(p, "%p", property.val);
- }
-
- return buf;
-}
-
static void dump_properties(int num_properties, bt_property_t *properties)
{
int i;
diff --git a/android/client/textconv.c b/android/client/textconv.c
index 32b1cab..a3e10ee 100644
--- a/android/client/textconv.c
+++ b/android/client/textconv.c
@@ -226,3 +226,113 @@ const char *enum_one_string(void *v, int i)
return (i == 0) && (m[0] != 0) ? m : NULL;
}
+
+char *bdaddr2str(const bt_bdaddr_t *bd_addr)
+{
+ static char buf[MAX_ADDR_STR_LEN];
+
+ return bt_bdaddr_t2str(bd_addr, buf);
+}
+
+char *btuuid2str(const bt_uuid_t *uuid)
+{
+ static char buf[MAX_UUID_STR_LEN];
+
+ return bt_uuid_t2str(uuid, buf);
+}
+
+char *btproperty2str(bt_property_t property)
+{
+ static char buf[4096];
+ char *p;
+
+ p = buf + sprintf(buf, "type=%s len=%d val=",
+ bt_property_type_t2str(property.type),
+ property.len);
+
+ switch (property.type) {
+ case BT_PROPERTY_BDNAME:
+ case BT_PROPERTY_REMOTE_FRIENDLY_NAME:
+ sprintf(p, "%*s", property.len,
+ ((bt_bdname_t *) property.val)->name);
+ break;
+
+ case BT_PROPERTY_BDADDR:
+ sprintf(p, "%s", bdaddr2str((bt_bdaddr_t *) property.val));
+ break;
+
+ case BT_PROPERTY_CLASS_OF_DEVICE:
+ sprintf(p, "%06x", *((int *) property.val));
+ break;
+
+ case BT_PROPERTY_TYPE_OF_DEVICE:
+ sprintf(p, "%s", bt_device_type_t2str(
+ *((bt_device_type_t *) property.val)));
+ break;
+
+ case BT_PROPERTY_REMOTE_RSSI:
+ sprintf(p, "%d", *((char *) property.val));
+ break;
+
+ case BT_PROPERTY_ADAPTER_SCAN_MODE:
+ sprintf(p, "%s",
+ bt_scan_mode_t2str(*((bt_scan_mode_t *) property.val)));
+ break;
+
+ case BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT:
+ sprintf(p, "%d", *((int *) property.val));
+ break;
+
+ case BT_PROPERTY_ADAPTER_BONDED_DEVICES:
+ {
+ int count = property.len / sizeof(bt_bdaddr_t);
+ char *ptr = property.val;
+
+ strcat(p, "{");
+
+ while (count--) {
+ strcat(p, bdaddr2str((bt_bdaddr_t *) ptr));
+ if (count)
+ strcat(p, ", ");
+ ptr += sizeof(bt_bdaddr_t);
+ }
+
+ strcat(p, "}");
+
+ }
+ break;
+
+ case BT_PROPERTY_UUIDS:
+ {
+ int count = property.len / sizeof(bt_uuid_t);
+ char *ptr = property.val;
+
+ strcat(p, "{");
+
+ while (count--) {
+ strcat(p, btuuid2str((bt_uuid_t *) ptr));
+ if (count)
+ strcat(p, ", ");
+ ptr += sizeof(bt_uuid_t);
+ }
+
+ strcat(p, "}");
+
+ }
+ break;
+
+ case BT_PROPERTY_SERVICE_RECORD:
+ {
+ bt_service_record_t *rec = property.val;
+
+ sprintf(p, "{%s, %d, %s}", btuuid2str(&rec->uuid),
+ rec->channel, rec->name);
+ }
+ break;
+
+ default:
+ sprintf(p, "%p", property.val);
+ }
+
+ return buf;
+}
diff --git a/android/client/textconv.h b/android/client/textconv.h
index 085b141..89b29c6 100644
--- a/android/client/textconv.h
+++ b/android/client/textconv.h
@@ -107,6 +107,9 @@ void str2bt_bdaddr_t(const char *str, bt_bdaddr_t *bd_addr);
char *bt_uuid_t2str(const bt_uuid_t *uuid, char *buf);
void str2bt_uuid_t(const char *str, bt_uuid_t *uuid);
+char *btproperty2str(bt_property_t property);
+char *bdaddr2str(const bt_bdaddr_t *bd_addr);
+
DECINTMAP(bt_status_t);
DECINTMAP(bt_state_t);
DECINTMAP(bt_device_type_t);
--
1.7.10.4
^ permalink raw reply related
* [PATCHv1 0/4] Improve logging for Android
From: Andrei Emeltchenko @ 2013-10-28 10:44 UTC (permalink / raw)
To: linux-bluetooth
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
This patch series uses debug functions defined already for haltest and
allows to print very helpful logs on Android target like shown below:
...
hal-bluetooth.c:set_adapter_property() prop: type=BT_PROPERTY_ADAPTER_SCAN_MODE len=4 val=BT_SCAN_MODE_NONE
...
Andrei Emeltchenko (4):
android/haltest: Export print property
android/haltest: Use pointer as parameter for debug
android/hal: Print full property in debug
android/hal: Add extra logs
android/client/if-bt.c | 112 +--------------------------------------------
android/client/textconv.c | 110 ++++++++++++++++++++++++++++++++++++++++++++
android/client/textconv.h | 3 ++
android/hal-bluetooth.c | 24 +++++-----
4 files changed, 127 insertions(+), 122 deletions(-)
--
1.7.10.4
^ permalink raw reply
* Re: [PATCH 1/6] android/hal: Fix typo in A2DP HAL service name
From: Luiz Augusto von Dentz @ 2013-10-28 9:53 UTC (permalink / raw)
To: Grzegorz Kolodziejczyk; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <1382716327-25283-1-git-send-email-grzegorz.kolodziejczyk@tieto.com>
Hi Grzegorz,
On Fri, Oct 25, 2013 at 6:52 PM, Grzegorz Kolodziejczyk
<grzegorz.kolodziejczyk@tieto.com> wrote:
> 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
Applied, thanks.
--
Luiz Augusto von Dentz
^ permalink raw reply
* Re: [PATCH 1/6] android: Use common exit path for commands in bt_adapter_handle_cmd
From: Luiz Augusto von Dentz @ 2013-10-27 12:03 UTC (permalink / raw)
To: Szymon Janc; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <1382714103-27689-1-git-send-email-szymon.janc@tieto.com>
Hi Szymon,
On Fri, Oct 25, 2013 at 6:14 PM, Szymon Janc <szymon.janc@tieto.com> wrote:
> 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
Pushed, thanks.
--
Luiz Augusto von Dentz
^ permalink raw reply
* Re: [PATCH 1/2] android/hal: Use defined function to check that interface is ready
From: Luiz Augusto von Dentz @ 2013-10-27 11:21 UTC (permalink / raw)
To: Andrei Emeltchenko; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <1382707726-20118-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
Hi Andrei,
On Fri, Oct 25, 2013 at 4:28 PM, Andrei Emeltchenko
<Andrei.Emeltchenko.news@gmail.com> wrote:
> 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
>
> --
Pushed, thanks.
--
Luiz Augusto von Dentz
^ permalink raw reply
* Re: [PATCH] Bluetooth: Add hci_h4p driver
From: Pali Rohár @ 2013-10-26 19:28 UTC (permalink / raw)
To: Joe Perches
Cc: Marcel Holtmann, Gustavo Padovan, Johan Hedberg, Pavel Machek,
linux-kernel, linux-bluetooth,
Ивайло Димитров,
Joni Lapilainen, Sebastian Reichel, Aaro Koskinen
In-Reply-To: <1382640113.22433.69.camel@joe-AO722>
[-- Attachment #1: Type: Text/Plain, Size: 3175 bytes --]
On Thursday 24 October 2013 20:41:53 Joe Perches wrote:
> On Fri, 2013-10-18 at 12:30 +0200, Pali Rohár wrote:
> > I rebased patch on top of
> > https://git.kernel.org/cgit/linux/kernel/git/bluetooth/blue
> > tooth-next.git branch master
>
> Hi Pali, just some trivial notes:
>
> []
>
> +static ssize_t hci_h4p_show_bdaddr(struct device *dev,
>
> > + struct device_attribute
> > *attr, char *buf) +{
> > + struct hci_h4p_info *info = dev_get_drvdata(dev);
> > +
> > + return sprintf(buf,
> > "%.2x:%.2x:%.2x:%.2x:%.2x:%.2x\n", +
> > info->bd_addr[0], info->bd_addr[1], info->bd_addr[2], +
> > info->bd_addr[3], info->bd_addr[4],
> > info->bd_addr[5]);
>
> sprintf(buf, "%pM", info->bd_addr)
>
"%pM" modifier printing mac address?
> and if this is really bluetooth, does the output need to
> be emitted in reverse order? ie: %pMR
>
I'm sure that actual order of above code is correct.
So what to use? "%pM" or "%pMR"?
> []
>
> > +#define NBT_DBG(fmt, arg...) \
> > + pr_debug("%s: " fmt "" , __func__ , ## arg)
> > +
> > +#define NBT_DBG_FW(fmt, arg...) \
> > + pr_debug("%s: " fmt "" , __func__ , ## arg)
> > +
> > +#define NBT_DBG_POWER(fmt, arg...) \
> > + pr_debug("%s: " fmt "" , __func__ , ## arg)
> > +
> > +#define NBT_DBG_TRANSFER(fmt, arg...) \
> > + pr_debug("%s: " fmt "" , __func__ , ## arg)
> > +
> > +#define NBT_DBG_TRANSFER_NF(fmt, arg...) \
> > + pr_debug(fmt "" , ## arg)
> > +
> > +#define NBT_DBG_DMA(fmt, arg...) \
> > + pr_debug("%s: " fmt "" , __func__ , ## arg)
>
> The "" isn't useful.
>
> dynamic_debugging can add __func__ to each message output
> with +f.
>
> I think all of these should be converted to pr_debug
> where used or consolidated into a single
> #define nbt_dbg(mask, fmt, ...) \
> do { \
> if (mask & debug) \
> pr_debug(fmt, ##__VA_ARGS__);
> } while (0)
>
> and used like:
> nbt_dbg(TRANSFER, fmt, etc...);
> where debug is some static.
>
> Also there are many uses missing "\n" which can
> cause interleaving problems with other printks.
>
> []
>
> > +int hci_h4p_wait_for_cts(struct hci_h4p_info *info, int
> > active, + int timeout_ms)
> > +{
> > + unsigned long timeout;
> > + int state;
> > +
> > + timeout = jiffies + msecs_to_jiffies(timeout_ms);
> > + for (;;) {
>
> while (time_before(jiffies, timeout)) {
>
> > + state = hci_h4p_inb(info, UART_MSR) &
> > UART_MSR_CTS; + if (active) {
> > + if (state)
> > + return 0;
> > + } else {
> > + if (!state)
> > + return 0;
> > + }
> > + if (time_after(jiffies, timeout))
> > + return -ETIMEDOUT;
> >
> > + msleep(1);
> > + }
>
> return -ETIMEDOUT;
>
> > +}
--
Pali Rohár
pali.rohar@gmail.com
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply
* Bluetooth tools
From: Kevin Wilson @ 2013-10-26 6:40 UTC (permalink / raw)
To: linux-bluetooth
Hello,
I saw that bluetoothctl and btmon are the newer tool of Bluetooth.
What are the advantages of bluetoothctl over hciconfig/hcitool?
What are the advantages of btmon over hcidump ?
Regards,
Kevin
^ permalink raw reply
* [PATCH 6/6] android/hal: Add support for send av disconnect command
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>
This allows HAL to send av disconnect command
---
android/hal-av.c | 8 +++++---
android/hal-msg.h | 5 +++++
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/android/hal-av.c b/android/hal-av.c
index 239088f..483dcf1 100644
--- a/android/hal-av.c
+++ b/android/hal-av.c
@@ -84,15 +84,17 @@ static bt_status_t av_connect(bt_bdaddr_t *bd_addr)
static bt_status_t av_disconnect(bt_bdaddr_t *bd_addr)
{
+ struct hal_msg_op_bt_av_disconnect cmd;
+
DBG("");
if (!interface_ready())
return BT_STATUS_NOT_READY;
- if (!bd_addr)
- return BT_STATUS_PARM_INVALID;
+ memcpy(cmd.bdaddr, bd_addr, sizeof(cmd.bdaddr));
- return BT_STATUS_UNSUPPORTED;
+ return hal_ipc_cmd(HAL_SERVICE_ID_A2DP, HAL_MSG_OP_BT_AV_DISCONNECT,
+ sizeof(cmd), &cmd, NULL, NULL, NULL);
}
static bt_status_t av_init(btav_callbacks_t *callbacks)
diff --git a/android/hal-msg.h b/android/hal-msg.h
index 66486f1..193ecae 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -281,6 +281,11 @@ struct hal_msg_op_bt_av_connect {
uint8_t bdaddr[6];
} __attribute__((packed));
+#define HAL_MSG_OP_BT_AV_DISCONNECT 0x02
+struct hal_msg_op_bt_av_disconnect {
+ uint8_t bdaddr[6];
+} __attribute__((packed));
+
/* Notifications and confirmations */
--
1.8.4.1
^ permalink raw reply related
* [PATCH 5/6] android/hal: Add support for send av connect command
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>
This allows HAL to send av connect command
---
android/hal-av.c | 10 +++++++---
android/hal-msg.h | 5 +++++
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/android/hal-av.c b/android/hal-av.c
index d537e84..239088f 100644
--- a/android/hal-av.c
+++ b/android/hal-av.c
@@ -17,10 +17,12 @@
#include <stdbool.h>
#include <stddef.h>
+#include <string.h>
#include "hal-log.h"
#include "hal.h"
#include "hal-msg.h"
+#include "hal-ipc.h"
static const btav_callbacks_t *cbs = NULL;
@@ -67,15 +69,17 @@ void bt_notify_av(uint16_t opcode, void *buf, uint16_t len)
static bt_status_t av_connect(bt_bdaddr_t *bd_addr)
{
+ struct hal_msg_op_bt_av_connect cmd;
+
DBG("");
if (!interface_ready())
return BT_STATUS_NOT_READY;
- if (!bd_addr)
- return BT_STATUS_PARM_INVALID;
+ memcpy(cmd.bdaddr, bd_addr, sizeof(cmd.bdaddr));
- return BT_STATUS_UNSUPPORTED;
+ return hal_ipc_cmd(HAL_SERVICE_ID_A2DP, HAL_MSG_OP_BT_AV_CONNECT,
+ sizeof(cmd), &cmd, NULL, NULL, NULL);
}
static bt_status_t av_disconnect(bt_bdaddr_t *bd_addr)
diff --git a/android/hal-msg.h b/android/hal-msg.h
index 2206f47..66486f1 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -276,6 +276,11 @@ struct hal_cmd_hid_send_data {
uint8_t bdaddr[6];
} __attribute__((packed));
+#define HAL_MSG_OP_BT_AV_CONNECT 0x01
+struct hal_msg_op_bt_av_connect {
+ uint8_t bdaddr[6];
+} __attribute__((packed));
+
/* Notifications and confirmations */
--
1.8.4.1
^ permalink raw reply related
* [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
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