Following patches adds HF Client commands skeleton
v2:
* Szymon comment from IRC handled
* Splited patch set to smaller sets on Luiz request.
v3:
* Changed name to handsfree-client
* Fix compilation issues with BLUEZ_EXTENSIONS flag
Lukasz Rymanowski (15):
android/handsfree-client: Add handsfree-client ID
android/hardware: Add HFP Client Interface ID.
android/handsfree-client: Add handsfree-client daemon skeleton
android/handsfree-client: Add handsfree-client HAL skeleton
android/readme: Add information about handsfree-client
android/handsfree-client: Add Connect/Disconnect commands
android/handsfree-client: Add Audio Connect/Disconnect commands
android/handsfree-client: Add Start/Stop Voice Recognition command
android/handsfree-client: Add Volume Control command
android/handsfree-client: Add Dial and Dial Memory command
android/handsfree-client: Add Call Action command
android/handsfree-client: Add Query Current Call and Operator Name cmd
android/handsfree-client: Add Retrieve Subscriber Info command
android/handsfree-client: Add Send DTMF command
android/handsfree-client: Add Get Last Voice Tag Number command
android/Android.mk | 9 ++
android/Makefile.am | 5 +-
android/README | 10 ++
android/hal-bluetooth.c | 5 +
android/hal-handsfree-client.c | 356 +++++++++++++++++++++++++++++++++++++++++
android/hal-msg.h | 78 ++++++++-
android/hal.h | 8 +
android/handsfree-client.c | 218 +++++++++++++++++++++++++
android/handsfree-client.h | 25 +++
android/hardware/bluetooth.h | 1 +
android/main.c | 11 ++
11 files changed, 724 insertions(+), 2 deletions(-)
create mode 100644 android/hal-handsfree-client.c
create mode 100644 android/handsfree-client.c
create mode 100644 android/handsfree-client.h
--
1.8.4
Hi Ćukasz,
On Monday 15 of September 2014 13:51:13 Lukasz Rymanowski wrote:
> Following patches adds HF Client commands skeleton
>
> v2:
> * Szymon comment from IRC handled
> * Splited patch set to smaller sets on Luiz request.
>
> v3:
> * Changed name to handsfree-client
> * Fix compilation issues with BLUEZ_EXTENSIONS flag
>
> Lukasz Rymanowski (15):
> android/handsfree-client: Add handsfree-client ID
> android/hardware: Add HFP Client Interface ID.
> android/handsfree-client: Add handsfree-client daemon skeleton
> android/handsfree-client: Add handsfree-client HAL skeleton
> android/readme: Add information about handsfree-client
> android/handsfree-client: Add Connect/Disconnect commands
> android/handsfree-client: Add Audio Connect/Disconnect commands
> android/handsfree-client: Add Start/Stop Voice Recognition command
> android/handsfree-client: Add Volume Control command
> android/handsfree-client: Add Dial and Dial Memory command
> android/handsfree-client: Add Call Action command
> android/handsfree-client: Add Query Current Call and Operator Name cmd
> android/handsfree-client: Add Retrieve Subscriber Info command
> android/handsfree-client: Add Send DTMF command
> android/handsfree-client: Add Get Last Voice Tag Number command
>
> android/Android.mk | 9 ++
> android/Makefile.am | 5 +-
> android/README | 10 ++
> android/hal-bluetooth.c | 5 +
> android/hal-handsfree-client.c | 356
> +++++++++++++++++++++++++++++++++++++++++ android/hal-msg.h |
> 78 ++++++++-
> android/hal.h | 8 +
> android/handsfree-client.c | 218 +++++++++++++++++++++++++
> android/handsfree-client.h | 25 +++
> android/hardware/bluetooth.h | 1 +
> android/main.c | 11 ++
> 11 files changed, 724 insertions(+), 2 deletions(-)
> create mode 100644 android/hal-handsfree-client.c
> create mode 100644 android/handsfree-client.c
> create mode 100644 android/handsfree-client.h
All patches are now applied, thanks.
--
BR
Szymon Janc
---
android/hal-handsfree-client.c | 26 ++++++++++++++++++++++++++
android/hal-msg.h | 3 +++
android/handsfree-client.c | 20 ++++++++++++++++++++
3 files changed, 49 insertions(+)
diff --git a/android/hal-handsfree-client.c b/android/hal-handsfree-client.c
index 35929c5..fbdc516 100644
--- a/android/hal-handsfree-client.c
+++ b/android/hal-handsfree-client.c
@@ -246,6 +246,30 @@ static bt_status_t call_action(bthf_client_call_action_t action, int index)
NULL, NULL, NULL);
}
+static bt_status_t query_current_calls(void)
+{
+ DBG("");
+
+ if (!interface_ready())
+ return BT_STATUS_NOT_READY;
+
+ return hal_ipc_cmd(HAL_SERVICE_ID_HANDSFREE_CLIENT,
+ HAL_OP_HF_CLIENT_QUERY_CURRENT_CALLS, 0, NULL,
+ NULL, NULL, NULL);
+}
+
+static bt_status_t query_operator_name(void)
+{
+ DBG("");
+
+ if (!interface_ready())
+ return BT_STATUS_NOT_READY;
+
+ return hal_ipc_cmd(HAL_SERVICE_ID_HANDSFREE_CLIENT,
+ HAL_OP_HF_CLIENT_QUERY_OPERATOR_NAME, 0, NULL,
+ NULL, NULL, NULL);
+}
+
static void cleanup(void)
{
struct hal_cmd_unregister_module cmd;
@@ -278,6 +302,8 @@ static bthf_client_interface_t iface = {
.dial = dial,
.dial_memory = dial_memory,
.handle_call_action = call_action,
+ .query_current_calls = query_current_calls,
+ .query_current_operator_name = query_operator_name,
.cleanup = cleanup
};
diff --git a/android/hal-msg.h b/android/hal-msg.h
index dc563e4..bedc598 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -1040,6 +1040,9 @@ struct hal_cmd_hf_client_call_action {
uint8_t index;
} __attribute__((packed));
+#define HAL_OP_HF_CLIENT_QUERY_CURRENT_CALLS 0x0b
+#define HAL_OP_HF_CLIENT_QUERY_OPERATOR_NAME 0x0c
+
/* Notifications and confirmations */
#define HAL_POWER_OFF 0x00
diff --git a/android/handsfree-client.c b/android/handsfree-client.c
index 6319b85..9bec019 100644
--- a/android/handsfree-client.c
+++ b/android/handsfree-client.c
@@ -116,6 +116,22 @@ static void handle_call_action(const void *buf, uint16_t len)
HAL_OP_HF_CLIENT_CALL_ACTION, HAL_STATUS_UNSUPPORTED);
}
+static void handle_query_current_calls(const void *buf, uint16_t len)
+{
+ DBG("Not Implemented");
+ ipc_send_rsp(hal_ipc, HAL_SERVICE_ID_HANDSFREE_CLIENT,
+ HAL_OP_HF_CLIENT_QUERY_CURRENT_CALLS,
+ HAL_STATUS_UNSUPPORTED);
+}
+
+static void handle_query_operator_name(const void *buf, uint16_t len)
+{
+ DBG("Not Implemented");
+ ipc_send_rsp(hal_ipc, HAL_SERVICE_ID_HANDSFREE_CLIENT,
+ HAL_OP_HF_CLIENT_QUERY_OPERATOR_NAME,
+ HAL_STATUS_UNSUPPORTED);
+}
+
static const struct ipc_handler cmd_handlers[] = {
/* HAL_OP_HF_CLIENT_CONNECT */
{ handle_connect, false,
@@ -144,6 +160,10 @@ static const struct ipc_handler cmd_handlers[] = {
/* HAL_OP_HF_CLIENT_CALL_ACTION */
{ handle_call_action, false,
sizeof(struct hal_cmd_hf_client_call_action) },
+ /* HAL_OP_HF_CLIENT_QUERY_CURRENT_CALLS */
+ { handle_query_current_calls, false, 0 },
+ /* HAL_OP_HF_CLIENT_QUERY_OPERATOR_NAME */
+ { handle_query_operator_name, false, 0 },
};
bool bt_hf_client_register(struct ipc *ipc, const bdaddr_t *addr)
--
1.8.4
---
android/hal-handsfree-client.c | 13 +++++++++++++
android/hal-msg.h | 1 +
android/handsfree-client.c | 10 ++++++++++
3 files changed, 24 insertions(+)
diff --git a/android/hal-handsfree-client.c b/android/hal-handsfree-client.c
index fbdc516..d5683d1 100644
--- a/android/hal-handsfree-client.c
+++ b/android/hal-handsfree-client.c
@@ -270,6 +270,18 @@ static bt_status_t query_operator_name(void)
NULL, NULL, NULL);
}
+static bt_status_t retrieve_subsr_info(void)
+{
+ DBG("");
+
+ if (!interface_ready())
+ return BT_STATUS_NOT_READY;
+
+ return hal_ipc_cmd(HAL_SERVICE_ID_HANDSFREE_CLIENT,
+ HAL_OP_HF_CLIENT_RETRIEVE_SUBSCR_INFO, 0, NULL,
+ NULL, NULL, NULL);
+}
+
static void cleanup(void)
{
struct hal_cmd_unregister_module cmd;
@@ -304,6 +316,7 @@ static bthf_client_interface_t iface = {
.handle_call_action = call_action,
.query_current_calls = query_current_calls,
.query_current_operator_name = query_operator_name,
+ .retrieve_subscriber_info = retrieve_subsr_info,
.cleanup = cleanup
};
diff --git a/android/hal-msg.h b/android/hal-msg.h
index bedc598..300465d 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -1042,6 +1042,7 @@ struct hal_cmd_hf_client_call_action {
#define HAL_OP_HF_CLIENT_QUERY_CURRENT_CALLS 0x0b
#define HAL_OP_HF_CLIENT_QUERY_OPERATOR_NAME 0x0c
+#define HAL_OP_HF_CLIENT_RETRIEVE_SUBSCR_INFO 0x0d
/* Notifications and confirmations */
diff --git a/android/handsfree-client.c b/android/handsfree-client.c
index 9bec019..8df93d9 100644
--- a/android/handsfree-client.c
+++ b/android/handsfree-client.c
@@ -132,6 +132,14 @@ static void handle_query_operator_name(const void *buf, uint16_t len)
HAL_STATUS_UNSUPPORTED);
}
+static void handle_retrieve_subscr_info(const void *buf, uint16_t len)
+{
+ DBG("Not Implemented");
+ ipc_send_rsp(hal_ipc, HAL_SERVICE_ID_HANDSFREE_CLIENT,
+ HAL_OP_HF_CLIENT_RETRIEVE_SUBSCR_INFO,
+ HAL_STATUS_UNSUPPORTED);
+}
+
static const struct ipc_handler cmd_handlers[] = {
/* HAL_OP_HF_CLIENT_CONNECT */
{ handle_connect, false,
@@ -164,6 +172,8 @@ static const struct ipc_handler cmd_handlers[] = {
{ handle_query_current_calls, false, 0 },
/* HAL_OP_HF_CLIENT_QUERY_OPERATOR_NAME */
{ handle_query_operator_name, false, 0 },
+ /* HAL_OP_HF_CLIENT_RETRIEVE_SUBSCR_INFO */
+ { handle_retrieve_subscr_info, false, 0 },
};
bool bt_hf_client_register(struct ipc *ipc, const bdaddr_t *addr)
--
1.8.4
---
android/hal-handsfree-client.c | 13 +++++++++++++
android/hal-msg.h | 2 ++
android/handsfree-client.c | 10 ++++++++++
3 files changed, 25 insertions(+)
diff --git a/android/hal-handsfree-client.c b/android/hal-handsfree-client.c
index 7c1cfea..98b6cb6 100644
--- a/android/hal-handsfree-client.c
+++ b/android/hal-handsfree-client.c
@@ -298,6 +298,18 @@ static bt_status_t send_dtmf(char tone)
NULL, NULL, NULL);
}
+static bt_status_t request_last_voice_tag_number(void)
+{
+ DBG("");
+
+ if (!interface_ready())
+ return BT_STATUS_NOT_READY;
+
+ return hal_ipc_cmd(HAL_SERVICE_ID_HANDSFREE_CLIENT,
+ HAL_OP_HF_CLIENT_GET_LAST_VOICE_TAG_NUM,
+ 0, NULL, NULL, NULL, NULL);
+}
+
static void cleanup(void)
{
struct hal_cmd_unregister_module cmd;
@@ -334,6 +346,7 @@ static bthf_client_interface_t iface = {
.query_current_operator_name = query_operator_name,
.retrieve_subscriber_info = retrieve_subsr_info,
.send_dtmf = send_dtmf,
+ .request_last_voice_tag_number = request_last_voice_tag_number,
.cleanup = cleanup
};
diff --git a/android/hal-msg.h b/android/hal-msg.h
index f9fcfb3..ba213b7 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -1049,6 +1049,8 @@ struct hal_cmd_hf_client_send_dtmf {
uint8_t tone;
} __attribute__((packed));
+#define HAL_OP_HF_CLIENT_GET_LAST_VOICE_TAG_NUM 0x0f
+
/* Notifications and confirmations */
#define HAL_POWER_OFF 0x00
diff --git a/android/handsfree-client.c b/android/handsfree-client.c
index 604ac08..be29952 100644
--- a/android/handsfree-client.c
+++ b/android/handsfree-client.c
@@ -147,6 +147,14 @@ static void handle_send_dtmf(const void *buf, uint16_t len)
HAL_OP_HF_CLIENT_SEND_DTMF, HAL_STATUS_UNSUPPORTED);
}
+static void handle_get_last_vc_tag_num(const void *buf, uint16_t len)
+{
+ DBG("Not Implemented");
+ ipc_send_rsp(hal_ipc, HAL_SERVICE_ID_HANDSFREE_CLIENT,
+ HAL_OP_HF_CLIENT_GET_LAST_VOICE_TAG_NUM,
+ HAL_STATUS_UNSUPPORTED);
+}
+
static const struct ipc_handler cmd_handlers[] = {
/* HAL_OP_HF_CLIENT_CONNECT */
{ handle_connect, false,
@@ -184,6 +192,8 @@ static const struct ipc_handler cmd_handlers[] = {
/* HAL_OP_HF_CLIENT_SEND_DTMF */
{ handle_send_dtmf, false,
sizeof(struct hal_cmd_hf_client_send_dtmf) },
+ /* HAL_OP_HF_CLIENT_GET_LAST_VOICE_TAG_NUM */
+ { handle_get_last_vc_tag_num, false, 0 },
};
bool bt_hf_client_register(struct ipc *ipc, const bdaddr_t *addr)
--
1.8.4
---
android/hal-handsfree-client.c | 18 ++++++++++++++++++
android/hal-msg.h | 19 +++++++++++++++++++
android/handsfree-client.c | 10 ++++++++++
3 files changed, 47 insertions(+)
diff --git a/android/hal-handsfree-client.c b/android/hal-handsfree-client.c
index 23cbd53..35929c5 100644
--- a/android/hal-handsfree-client.c
+++ b/android/hal-handsfree-client.c
@@ -229,6 +229,23 @@ static bt_status_t dial_memory(int location)
sizeof(cmd), &cmd, NULL, NULL, NULL);
}
+static bt_status_t call_action(bthf_client_call_action_t action, int index)
+{
+ struct hal_cmd_hf_client_call_action cmd;
+
+ DBG("");
+
+ if (!interface_ready())
+ return BT_STATUS_NOT_READY;
+
+ cmd.action = action;
+ cmd.index = index;
+
+ return hal_ipc_cmd(HAL_SERVICE_ID_HANDSFREE_CLIENT,
+ HAL_OP_HF_CLIENT_CALL_ACTION, sizeof(cmd), &cmd,
+ NULL, NULL, NULL);
+}
+
static void cleanup(void)
{
struct hal_cmd_unregister_module cmd;
@@ -260,6 +277,7 @@ static bthf_client_interface_t iface = {
.volume_control = volume_control,
.dial = dial,
.dial_memory = dial_memory,
+ .handle_call_action = call_action,
.cleanup = cleanup
};
diff --git a/android/hal-msg.h b/android/hal-msg.h
index 1c57657..dc563e4 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -1021,6 +1021,25 @@ struct hal_cmd_hf_client_dial_memory {
int32_t location;
} __attribute__((packed));
+#define HAL_HF_CLIENT_ACTION_CHLD_0 0x00
+#define HAL_HF_CLIENT_ACTION_CHLD_1 0x01
+#define HAL_HF_CLIENT_ACTION_CHLD_2 0x02
+#define HAL_HF_CLIENT_ACTION_CHLD_3 0x03
+#define HAL_HF_CLIENT_ACTION_CHLD_4 0x04
+#define HAL_HF_CLIENT_ACTION_CHLD_1x 0x05
+#define HAL_HF_CLIENT_ACTION_CHLD_2x 0x06
+#define HAL_HF_CLIENT_ACTION_ATA 0x07
+#define HAL_HF_CLIENT_ACTION_CHUP 0x08
+#define HAL_HF_CLIENT_ACTION_BRTH_0 0x09
+#define HAL_HF_CLIENT_ACTION_BRTH_1 0x10
+#define HAL_HF_CLIENT_ACTION_BRTH_02 0x11
+
+#define HAL_OP_HF_CLIENT_CALL_ACTION 0x0a
+struct hal_cmd_hf_client_call_action {
+ uint8_t action;
+ uint8_t index;
+} __attribute__((packed));
+
/* Notifications and confirmations */
#define HAL_POWER_OFF 0x00
diff --git a/android/handsfree-client.c b/android/handsfree-client.c
index d51ba86..6319b85 100644
--- a/android/handsfree-client.c
+++ b/android/handsfree-client.c
@@ -109,6 +109,13 @@ static void handle_dial_memory(const void *buf, uint16_t len)
HAL_OP_HF_CLIENT_DIAL_MEMORY, HAL_STATUS_UNSUPPORTED);
}
+static void handle_call_action(const void *buf, uint16_t len)
+{
+ DBG("Not Implemented");
+ ipc_send_rsp(hal_ipc, HAL_SERVICE_ID_HANDSFREE_CLIENT,
+ HAL_OP_HF_CLIENT_CALL_ACTION, HAL_STATUS_UNSUPPORTED);
+}
+
static const struct ipc_handler cmd_handlers[] = {
/* HAL_OP_HF_CLIENT_CONNECT */
{ handle_connect, false,
@@ -134,6 +141,9 @@ static const struct ipc_handler cmd_handlers[] = {
/* HAL_OP_HF_CLIENT_DIAL_MEMORY */
{ handle_dial_memory, false,
sizeof(struct hal_cmd_hf_client_dial_memory) },
+ /* HAL_OP_HF_CLIENT_CALL_ACTION */
+ { handle_call_action, false,
+ sizeof(struct hal_cmd_hf_client_call_action) },
};
bool bt_hf_client_register(struct ipc *ipc, const bdaddr_t *addr)
--
1.8.4
---
android/hal-handsfree-client.c | 17 +++++++++++++++++
android/hal-msg.h | 5 +++++
android/handsfree-client.c | 10 ++++++++++
3 files changed, 32 insertions(+)
diff --git a/android/hal-handsfree-client.c b/android/hal-handsfree-client.c
index d5683d1..7c1cfea 100644
--- a/android/hal-handsfree-client.c
+++ b/android/hal-handsfree-client.c
@@ -282,6 +282,22 @@ static bt_status_t retrieve_subsr_info(void)
NULL, NULL, NULL);
}
+static bt_status_t send_dtmf(char tone)
+{
+ struct hal_cmd_hf_client_send_dtmf cmd;
+
+ DBG("");
+
+ if (!interface_ready())
+ return BT_STATUS_NOT_READY;
+
+ cmd.tone = tone;
+
+ return hal_ipc_cmd(HAL_SERVICE_ID_HANDSFREE_CLIENT,
+ HAL_OP_HF_CLIENT_SEND_DTMF, sizeof(cmd), &cmd,
+ NULL, NULL, NULL);
+}
+
static void cleanup(void)
{
struct hal_cmd_unregister_module cmd;
@@ -317,6 +333,7 @@ static bthf_client_interface_t iface = {
.query_current_calls = query_current_calls,
.query_current_operator_name = query_operator_name,
.retrieve_subscriber_info = retrieve_subsr_info,
+ .send_dtmf = send_dtmf,
.cleanup = cleanup
};
diff --git a/android/hal-msg.h b/android/hal-msg.h
index 300465d..f9fcfb3 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -1044,6 +1044,11 @@ struct hal_cmd_hf_client_call_action {
#define HAL_OP_HF_CLIENT_QUERY_OPERATOR_NAME 0x0c
#define HAL_OP_HF_CLIENT_RETRIEVE_SUBSCR_INFO 0x0d
+#define HAL_OP_HF_CLIENT_SEND_DTMF 0x0e
+struct hal_cmd_hf_client_send_dtmf {
+ uint8_t tone;
+} __attribute__((packed));
+
/* Notifications and confirmations */
#define HAL_POWER_OFF 0x00
diff --git a/android/handsfree-client.c b/android/handsfree-client.c
index 8df93d9..604ac08 100644
--- a/android/handsfree-client.c
+++ b/android/handsfree-client.c
@@ -140,6 +140,13 @@ static void handle_retrieve_subscr_info(const void *buf, uint16_t len)
HAL_STATUS_UNSUPPORTED);
}
+static void handle_send_dtmf(const void *buf, uint16_t len)
+{
+ DBG("Not Implemented");
+ ipc_send_rsp(hal_ipc, HAL_SERVICE_ID_HANDSFREE_CLIENT,
+ HAL_OP_HF_CLIENT_SEND_DTMF, HAL_STATUS_UNSUPPORTED);
+}
+
static const struct ipc_handler cmd_handlers[] = {
/* HAL_OP_HF_CLIENT_CONNECT */
{ handle_connect, false,
@@ -174,6 +181,9 @@ static const struct ipc_handler cmd_handlers[] = {
{ handle_query_operator_name, false, 0 },
/* HAL_OP_HF_CLIENT_RETRIEVE_SUBSCR_INFO */
{ handle_retrieve_subscr_info, false, 0 },
+ /* HAL_OP_HF_CLIENT_SEND_DTMF */
+ { handle_send_dtmf, false,
+ sizeof(struct hal_cmd_hf_client_send_dtmf) },
};
bool bt_hf_client_register(struct ipc *ipc, const bdaddr_t *addr)
--
1.8.4
---
android/hal-handsfree-client.c | 26 ++++++++++++++++++++++++++
android/hal-msg.h | 3 +++
android/handsfree-client.c | 18 ++++++++++++++++++
3 files changed, 47 insertions(+)
diff --git a/android/hal-handsfree-client.c b/android/hal-handsfree-client.c
index 22a7fd6..c52d0c4 100644
--- a/android/hal-handsfree-client.c
+++ b/android/hal-handsfree-client.c
@@ -146,6 +146,30 @@ static bt_status_t disconnect_audio(bt_bdaddr_t *bd_addr)
&cmd, NULL, NULL, NULL);
}
+static bt_status_t start_voice_recognition(void)
+{
+ DBG("");
+
+ if (!interface_ready())
+ return BT_STATUS_NOT_READY;
+
+ return hal_ipc_cmd(HAL_SERVICE_ID_HANDSFREE_CLIENT,
+ HAL_OP_HF_CLIENT_START_VR, 0, NULL, NULL, NULL,
+ NULL);
+}
+
+static bt_status_t stop_voice_recognition(void)
+{
+ DBG("");
+
+ if (!interface_ready())
+ return BT_STATUS_NOT_READY;
+
+ return hal_ipc_cmd(HAL_SERVICE_ID_HANDSFREE_CLIENT,
+ HAL_OP_HF_CLIENT_STOP_VR, 0, NULL, NULL, NULL,
+ NULL);
+}
+
static void cleanup(void)
{
struct hal_cmd_unregister_module cmd;
@@ -172,6 +196,8 @@ static bthf_client_interface_t iface = {
.disconnect = disconnect,
.connect_audio = connect_audio,
.disconnect_audio = disconnect_audio,
+ .start_voice_recognition = start_voice_recognition,
+ .stop_voice_recognition = stop_voice_recognition,
.cleanup = cleanup
};
diff --git a/android/hal-msg.h b/android/hal-msg.h
index afb7836..a97759c 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -998,6 +998,9 @@ struct hal_cmd_hf_client_disconnect_audio {
uint8_t bdaddr[6];
} __attribute__((packed));
+#define HAL_OP_HF_CLIENT_START_VR 0x05
+#define HAL_OP_HF_CLIENT_STOP_VR 0x06
+
/* Notifications and confirmations */
#define HAL_POWER_OFF 0x00
diff --git a/android/handsfree-client.c b/android/handsfree-client.c
index a65868e..921272f 100644
--- a/android/handsfree-client.c
+++ b/android/handsfree-client.c
@@ -73,6 +73,20 @@ static void handle_disconnect_audio(const void *buf, uint16_t len)
HAL_STATUS_UNSUPPORTED);
}
+static void handle_start_vr(const void *buf, uint16_t len)
+{
+ DBG("Not Implemented");
+ ipc_send_rsp(hal_ipc, HAL_SERVICE_ID_HANDSFREE_CLIENT,
+ HAL_OP_HF_CLIENT_START_VR, HAL_STATUS_UNSUPPORTED);
+}
+
+static void handle_stop_vr(const void *buf, uint16_t len)
+{
+ DBG("Not Implemented");
+ ipc_send_rsp(hal_ipc, HAL_SERVICE_ID_HANDSFREE_CLIENT,
+ HAL_OP_HF_CLIENT_STOP_VR, HAL_STATUS_UNSUPPORTED);
+}
+
static const struct ipc_handler cmd_handlers[] = {
/* HAL_OP_HF_CLIENT_CONNECT */
{ handle_connect, false,
@@ -86,6 +100,10 @@ static const struct ipc_handler cmd_handlers[] = {
/* HAL_OP_HF_CLIENT_DISCONNECT_AUDIO */
{ handle_disconnect_audio, false,
sizeof(struct hal_cmd_hf_client_disconnect_audio) },
+ /* define HAL_OP_HF_CLIENT_START_VR */
+ { handle_start_vr, false, 0 },
+ /* define HAL_OP_HF_CLIENT_STOP_VR */
+ { handle_stop_vr, false, 0 },
};
bool bt_hf_client_register(struct ipc *ipc, const bdaddr_t *addr)
--
1.8.4
---
android/hal-handsfree-client.c | 43 ++++++++++++++++++++++++++++++++++++++++++
android/hal-msg.h | 11 +++++++++++
android/handsfree-client.c | 19 +++++++++++++++++++
3 files changed, 73 insertions(+)
diff --git a/android/hal-handsfree-client.c b/android/hal-handsfree-client.c
index 9a73931..23cbd53 100644
--- a/android/hal-handsfree-client.c
+++ b/android/hal-handsfree-client.c
@@ -188,6 +188,47 @@ static bt_status_t volume_control(bthf_client_volume_type_t type,
&cmd, NULL, NULL, NULL);
}
+static bt_status_t dial(const char *number)
+{
+ char buf[IPC_MTU];
+ struct hal_cmd_hf_client_dial *cmd = (void *) buf;
+ size_t len;
+
+ DBG("");
+
+ if (!interface_ready())
+ return BT_STATUS_NOT_READY;
+
+ if (number) {
+ cmd->number_len = strlen(number) + 1;
+ memcpy(cmd->number, number, cmd->number_len);
+ } else {
+ cmd->number_len = 0;
+ }
+
+ len = sizeof(*cmd) + cmd->number_len;
+
+ return hal_ipc_cmd(HAL_SERVICE_ID_HANDSFREE_CLIENT,
+ HAL_OP_HF_CLIENT_DIAL, len, cmd, NULL, NULL,
+ NULL);
+}
+
+static bt_status_t dial_memory(int location)
+{
+ struct hal_cmd_hf_client_dial_memory cmd;
+
+ DBG("");
+
+ if (!interface_ready())
+ return BT_STATUS_NOT_READY;
+
+ cmd.location = location;
+
+ return hal_ipc_cmd(HAL_SERVICE_ID_HANDSFREE_CLIENT,
+ HAL_OP_HF_CLIENT_DIAL_MEMORY,
+ sizeof(cmd), &cmd, NULL, NULL, NULL);
+}
+
static void cleanup(void)
{
struct hal_cmd_unregister_module cmd;
@@ -217,6 +258,8 @@ static bthf_client_interface_t iface = {
.start_voice_recognition = start_voice_recognition,
.stop_voice_recognition = stop_voice_recognition,
.volume_control = volume_control,
+ .dial = dial,
+ .dial_memory = dial_memory,
.cleanup = cleanup
};
diff --git a/android/hal-msg.h b/android/hal-msg.h
index 72e0def..1c57657 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -1010,6 +1010,17 @@ struct hal_cmd_hf_client_volume_control {
uint8_t volume;
} __attribute__((packed));
+#define HAL_OP_HF_CLIENT_DIAL 0x08
+struct hal_cmd_hf_client_dial {
+ uint16_t number_len;
+ uint8_t number[0];
+} __attribute__((packed));
+
+#define HAL_OP_HF_CLIENT_DIAL_MEMORY 0x09
+struct hal_cmd_hf_client_dial_memory {
+ int32_t location;
+} __attribute__((packed));
+
/* Notifications and confirmations */
#define HAL_POWER_OFF 0x00
diff --git a/android/handsfree-client.c b/android/handsfree-client.c
index f2394d0..d51ba86 100644
--- a/android/handsfree-client.c
+++ b/android/handsfree-client.c
@@ -95,6 +95,20 @@ static void handle_volume_control(const void *buf, uint16_t len)
HAL_STATUS_UNSUPPORTED);
}
+static void handle_dial(const void *buf, uint16_t len)
+{
+ DBG("Not Implemented");
+ ipc_send_rsp(hal_ipc, HAL_SERVICE_ID_HANDSFREE_CLIENT,
+ HAL_OP_HF_CLIENT_DIAL, HAL_STATUS_UNSUPPORTED);
+}
+
+static void handle_dial_memory(const void *buf, uint16_t len)
+{
+ DBG("Not Implemented");
+ ipc_send_rsp(hal_ipc, HAL_SERVICE_ID_HANDSFREE_CLIENT,
+ HAL_OP_HF_CLIENT_DIAL_MEMORY, HAL_STATUS_UNSUPPORTED);
+}
+
static const struct ipc_handler cmd_handlers[] = {
/* HAL_OP_HF_CLIENT_CONNECT */
{ handle_connect, false,
@@ -115,6 +129,11 @@ static const struct ipc_handler cmd_handlers[] = {
/* HAL_OP_HF_CLIENT_VOLUME_CONTROL */
{ handle_volume_control, false,
sizeof(struct hal_cmd_hf_client_volume_control) },
+ /* HAL_OP_HF_CLIENT_DIAL */
+ { handle_dial, true, sizeof(struct hal_cmd_hf_client_dial) },
+ /* HAL_OP_HF_CLIENT_DIAL_MEMORY */
+ { handle_dial_memory, false,
+ sizeof(struct hal_cmd_hf_client_dial_memory) },
};
bool bt_hf_client_register(struct ipc *ipc, const bdaddr_t *addr)
--
1.8.4
---
android/hal-handsfree-client.c | 19 +++++++++++++++++++
android/hal-msg.h | 9 +++++++++
android/handsfree-client.c | 11 +++++++++++
3 files changed, 39 insertions(+)
diff --git a/android/hal-handsfree-client.c b/android/hal-handsfree-client.c
index c52d0c4..9a73931 100644
--- a/android/hal-handsfree-client.c
+++ b/android/hal-handsfree-client.c
@@ -170,6 +170,24 @@ static bt_status_t stop_voice_recognition(void)
NULL);
}
+static bt_status_t volume_control(bthf_client_volume_type_t type,
+ int volume)
+{
+ struct hal_cmd_hf_client_volume_control cmd;
+
+ DBG("");
+
+ if (!interface_ready())
+ return BT_STATUS_NOT_READY;
+
+ cmd.type = type;
+ cmd.volume = volume;
+
+ return hal_ipc_cmd(HAL_SERVICE_ID_HANDSFREE_CLIENT,
+ HAL_OP_HF_CLIENT_VOLUME_CONTROL, sizeof(cmd),
+ &cmd, NULL, NULL, NULL);
+}
+
static void cleanup(void)
{
struct hal_cmd_unregister_module cmd;
@@ -198,6 +216,7 @@ static bthf_client_interface_t iface = {
.disconnect_audio = disconnect_audio,
.start_voice_recognition = start_voice_recognition,
.stop_voice_recognition = stop_voice_recognition,
+ .volume_control = volume_control,
.cleanup = cleanup
};
diff --git a/android/hal-msg.h b/android/hal-msg.h
index a97759c..72e0def 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -1001,6 +1001,15 @@ struct hal_cmd_hf_client_disconnect_audio {
#define HAL_OP_HF_CLIENT_START_VR 0x05
#define HAL_OP_HF_CLIENT_STOP_VR 0x06
+#define HF_CLIENT_VOLUME_TYPE_SPEAKER 0x00
+#define HF_CLIENT_VOLUME_TYPE_MIC 0x01
+
+#define HAL_OP_HF_CLIENT_VOLUME_CONTROL 0x07
+struct hal_cmd_hf_client_volume_control {
+ uint8_t type;
+ uint8_t volume;
+} __attribute__((packed));
+
/* Notifications and confirmations */
#define HAL_POWER_OFF 0x00
diff --git a/android/handsfree-client.c b/android/handsfree-client.c
index 921272f..f2394d0 100644
--- a/android/handsfree-client.c
+++ b/android/handsfree-client.c
@@ -87,6 +87,14 @@ static void handle_stop_vr(const void *buf, uint16_t len)
HAL_OP_HF_CLIENT_STOP_VR, HAL_STATUS_UNSUPPORTED);
}
+static void handle_volume_control(const void *buf, uint16_t len)
+{
+ DBG("Not Implemented");
+ ipc_send_rsp(hal_ipc, HAL_SERVICE_ID_HANDSFREE_CLIENT,
+ HAL_OP_HF_CLIENT_VOLUME_CONTROL,
+ HAL_STATUS_UNSUPPORTED);
+}
+
static const struct ipc_handler cmd_handlers[] = {
/* HAL_OP_HF_CLIENT_CONNECT */
{ handle_connect, false,
@@ -104,6 +112,9 @@ static const struct ipc_handler cmd_handlers[] = {
{ handle_start_vr, false, 0 },
/* define HAL_OP_HF_CLIENT_STOP_VR */
{ handle_stop_vr, false, 0 },
+ /* HAL_OP_HF_CLIENT_VOLUME_CONTROL */
+ { handle_volume_control, false,
+ sizeof(struct hal_cmd_hf_client_volume_control) },
};
bool bt_hf_client_register(struct ipc *ipc, const bdaddr_t *addr)
--
1.8.4
---
android/README | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/android/README b/android/README
index 20b61a6..6b6a62e 100644
--- a/android/README
+++ b/android/README
@@ -37,6 +37,9 @@ features (currently epoll_create1 and ppoll calls for Android 4.4). Sample
Bionic for Android 4.4 with all required features backported is available at
https://code.google.com/p/aosp-bluez.platform-bionic/
+- Some of the bluetooth HALs are available only when BLUEZ_EXTENSIONS flag is
+set in BoardConfig.mk or similar. Please read below for detail which HALs needs
+that.
Runtime requirements
--------------------
@@ -257,6 +260,7 @@ health bt_hl.h complete
pan bt_pan.h complete
avrcp bt_rc.h complete
socket bt_sock.h complete
+hf-client bt_hf_client.h initial
Implementation shortcomings
@@ -323,6 +327,12 @@ methods:
client->set_adv_data missing kernel support for vendor data
client->connect is_direct parameter is ignored
+HAL HF Client
+-------------
+
+Available on Android only when BLUEZ_EXTENSIONS flag set in BoardConfig.mk
+
+
Audio SCO HAL
=============
--
1.8.4
---
android/hal-handsfree-client.c | 40 ++++++++++++++++++++++++++++++++++++++++
android/hal-msg.h | 10 ++++++++++
android/handsfree-client.c | 21 +++++++++++++++++++++
3 files changed, 71 insertions(+)
diff --git a/android/hal-handsfree-client.c b/android/hal-handsfree-client.c
index 441d2b4..22a7fd6 100644
--- a/android/hal-handsfree-client.c
+++ b/android/hal-handsfree-client.c
@@ -108,6 +108,44 @@ static bt_status_t disconnect(bt_bdaddr_t *bd_addr)
NULL, NULL, NULL);
}
+static bt_status_t connect_audio(bt_bdaddr_t *bd_addr)
+{
+ struct hal_cmd_hf_client_connect_audio 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 hal_ipc_cmd(HAL_SERVICE_ID_HANDSFREE_CLIENT,
+ HAL_OP_HF_CLIENT_CONNECT_AUDIO, sizeof(cmd),
+ &cmd, NULL, NULL, NULL);
+}
+
+static bt_status_t disconnect_audio(bt_bdaddr_t *bd_addr)
+{
+ struct hal_cmd_hf_client_disconnect_audio 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 hal_ipc_cmd(HAL_SERVICE_ID_HANDSFREE_CLIENT,
+ HAL_OP_HF_CLIENT_DISCONNECT_AUDIO, sizeof(cmd),
+ &cmd, NULL, NULL, NULL);
+}
+
static void cleanup(void)
{
struct hal_cmd_unregister_module cmd;
@@ -132,6 +170,8 @@ static bthf_client_interface_t iface = {
.init = init,
.connect = hf_client_connect,
.disconnect = disconnect,
+ .connect_audio = connect_audio,
+ .disconnect_audio = disconnect_audio,
.cleanup = cleanup
};
diff --git a/android/hal-msg.h b/android/hal-msg.h
index 02cc798..afb7836 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -988,6 +988,16 @@ struct hal_cmd_hf_client_disconnect {
uint8_t bdaddr[6];
} __attribute__((packed));
+#define HAL_OP_HF_CLIENT_CONNECT_AUDIO 0x03
+struct hal_cmd_hf_client_connect_audio {
+ uint8_t bdaddr[6];
+} __attribute__((packed));
+
+#define HAL_OP_HF_CLIENT_DISCONNECT_AUDIO 0x04
+struct hal_cmd_hf_client_disconnect_audio {
+ uint8_t bdaddr[6];
+} __attribute__((packed));
+
/* Notifications and confirmations */
#define HAL_POWER_OFF 0x00
diff --git a/android/handsfree-client.c b/android/handsfree-client.c
index f43829a..a65868e 100644
--- a/android/handsfree-client.c
+++ b/android/handsfree-client.c
@@ -58,6 +58,21 @@ static void handle_disconnect(const void *buf, uint16_t len)
HAL_OP_HF_CLIENT_DISCONNECT, HAL_STATUS_UNSUPPORTED);
}
+static void handle_connect_audio(const void *buf, uint16_t len)
+{
+ DBG("Not Implemented");
+ ipc_send_rsp(hal_ipc, HAL_SERVICE_ID_HANDSFREE_CLIENT,
+ HAL_OP_HF_CLIENT_CONNECT_AUDIO, HAL_STATUS_UNSUPPORTED);
+}
+
+static void handle_disconnect_audio(const void *buf, uint16_t len)
+{
+ DBG("Not Implemented");
+ ipc_send_rsp(hal_ipc, HAL_SERVICE_ID_HANDSFREE_CLIENT,
+ HAL_OP_HF_CLIENT_DISCONNECT_AUDIO,
+ HAL_STATUS_UNSUPPORTED);
+}
+
static const struct ipc_handler cmd_handlers[] = {
/* HAL_OP_HF_CLIENT_CONNECT */
{ handle_connect, false,
@@ -65,6 +80,12 @@ static const struct ipc_handler cmd_handlers[] = {
/* HAL_OP_HF_CLIENT_DISCONNECT */
{ handle_disconnect, false,
sizeof(struct hal_cmd_hf_client_disconnect) },
+ /* HAL_OP_HF_CLIENT_CONNECT_AUDIO */
+ { handle_connect_audio, false,
+ sizeof(struct hal_cmd_hf_client_connect_audio) },
+ /* HAL_OP_HF_CLIENT_DISCONNECT_AUDIO */
+ { handle_disconnect_audio, false,
+ sizeof(struct hal_cmd_hf_client_disconnect_audio) },
};
bool bt_hf_client_register(struct ipc *ipc, const bdaddr_t *addr)
--
1.8.4
This patch also introduce BLUEZ_EXTENSIONS flag which is used for not
Android AOSP features like HF Client in this case.
Idea is that BfA for PC is always build with this flag and it is added
to Makefile.am
For Android there is need to set this flag as described in README
---
android/Android.mk | 8 ++++
android/Makefile.am | 4 +-
android/hal-bluetooth.c | 5 ++
android/hal-handsfree-client.c | 101 +++++++++++++++++++++++++++++++++++++++++
android/hal.h | 8 ++++
5 files changed, 125 insertions(+), 1 deletion(-)
create mode 100644 android/hal-handsfree-client.c
diff --git a/android/Android.mk b/android/Android.mk
index aae426d..4a14474 100644
--- a/android/Android.mk
+++ b/android/Android.mk
@@ -129,6 +129,10 @@ LOCAL_SRC_FILES := \
bluez/android/hal-utils.c \
bluez/android/hal-health.c \
+ifeq ($(BLUEZ_EXTENSIONS), true)
+LOCAL_SRC_FILES += bluez/android/hal-handsfree-client.c
+endif
+
LOCAL_C_INCLUDES += \
$(call include-path-for, system-core) \
$(call include-path-for, libhardware) \
@@ -138,6 +142,10 @@ LOCAL_SHARED_LIBRARIES := \
LOCAL_CFLAGS := $(BLUEZ_COMMON_CFLAGS)
+ifeq ($(BLUEZ_EXTENSIONS), true)
+LOCAL_CFLAGS += -DBLUEZ_EXTENSIONS
+endif
+
LOCAL_MODULE := bluetooth.default
LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw
LOCAL_MODULE_TAGS := optional
diff --git a/android/Makefile.am b/android/Makefile.am
index 70b9c3a..b576fda 100644
--- a/android/Makefile.am
+++ b/android/Makefile.am
@@ -75,6 +75,7 @@ android_bluetooth_default_la_SOURCES = android/hal.h android/hal-bluetooth.c \
android/hal-a2dp.c \
android/hal-avrcp.c \
android/hal-handsfree.c \
+ android/hal-handsfree-client.c \
android/hal-gatt.c \
android/hardware/bluetooth.h \
android/hardware/bt_av.h \
@@ -88,6 +89,7 @@ android_bluetooth_default_la_SOURCES = android/hal.h android/hal-bluetooth.c \
android/hardware/bt_pan.h \
android/hardware/bt_rc.h \
android/hardware/bt_sock.h \
+ android/hardware/bt_hf_client.h \
android/hardware/hardware.h \
android/cutils/properties.h \
android/ipc-common.h \
@@ -95,7 +97,7 @@ android_bluetooth_default_la_SOURCES = android/hal.h android/hal-bluetooth.c \
android/hal-ipc.h android/hal-ipc.c \
android/hal-utils.h android/hal-utils.c
-android_bluetooth_default_la_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/android
+android_bluetooth_default_la_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/android -DBLUEZ_EXTENSIONS
android_bluetooth_default_la_LDFLAGS = $(AM_LDFLAGS) -module -avoid-version \
-no-undefined
diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
index 44eddbd..7c8c2ee 100644
--- a/android/hal-bluetooth.c
+++ b/android/hal-bluetooth.c
@@ -783,6 +783,11 @@ static const void *get_profile_interface(const char *profile_id)
if (!strcmp(profile_id, BT_PROFILE_HEALTH_ID))
return bt_get_health_interface();
+#if BLUEZ_EXTENSIONS
+ if (!strcmp(profile_id, BT_PROFILE_HANDSFREE_CLIENT_ID))
+ return bt_get_hf_client_interface();
+#endif
+
return NULL;
}
diff --git a/android/hal-handsfree-client.c b/android/hal-handsfree-client.c
new file mode 100644
index 0000000..9422e0f
--- /dev/null
+++ b/android/hal-handsfree-client.c
@@ -0,0 +1,101 @@
+/*
+ * Copyright (C) 2014 Intel Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdbool.h>
+#include <stddef.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include <cutils/properties.h>
+
+#include "hal-log.h"
+#include "hal.h"
+#include "hal-msg.h"
+#include "ipc-common.h"
+#include "hal-ipc.h"
+
+static const bthf_client_callbacks_t *cbs = NULL;
+
+static bool interface_ready(void)
+{
+ return cbs != NULL;
+}
+
+/*
+ * handlers will be called from notification thread context,
+ * index in table equals to 'opcode - HAL_MINIMUM_EVENT'
+ */
+static const struct hal_ipc_handler ev_handlers[] = {
+};
+
+static bt_status_t init(bthf_client_callbacks_t *callbacks)
+{
+ struct hal_cmd_register_module cmd;
+ int ret;
+
+ DBG("");
+
+ if (interface_ready())
+ return BT_STATUS_DONE;
+
+ cbs = callbacks;
+
+ hal_ipc_register(HAL_SERVICE_ID_HANDSFREE_CLIENT, ev_handlers,
+ sizeof(ev_handlers)/sizeof(ev_handlers[0]));
+
+ cmd.service_id = HAL_SERVICE_ID_HANDSFREE_CLIENT;
+
+ ret = hal_ipc_cmd(HAL_SERVICE_ID_CORE, HAL_OP_REGISTER_MODULE,
+ sizeof(cmd), &cmd, NULL, NULL, NULL);
+
+ if (ret != BT_STATUS_SUCCESS) {
+ cbs = NULL;
+ hal_ipc_unregister(HAL_SERVICE_ID_HANDSFREE_CLIENT);
+ }
+
+ return ret;
+}
+
+static void cleanup(void)
+{
+ struct hal_cmd_unregister_module cmd;
+
+ DBG("");
+
+ if (!interface_ready())
+ return;
+
+ cbs = NULL;
+
+ cmd.service_id = HAL_SERVICE_ID_HANDSFREE_CLIENT;
+
+ hal_ipc_cmd(HAL_SERVICE_ID_CORE, HAL_OP_UNREGISTER_MODULE,
+ sizeof(cmd), &cmd, NULL, NULL, NULL);
+
+ hal_ipc_unregister(HAL_SERVICE_ID_HANDSFREE_CLIENT);
+}
+
+static bthf_client_interface_t iface = {
+ .size = sizeof(iface),
+ .init = init,
+ .cleanup = cleanup
+};
+
+bthf_client_interface_t *bt_get_hf_client_interface(void)
+{
+ return &iface;
+}
diff --git a/android/hal.h b/android/hal.h
index 6998e9a..c34022d 100644
--- a/android/hal.h
+++ b/android/hal.h
@@ -27,6 +27,10 @@
#include <hardware/bt_gatt_server.h>
#include <hardware/bt_hl.h>
+#ifdef BLUEZ_EXTENSIONS
+#include <hardware/bt_hf_client.h>
+#endif
+
btsock_interface_t *bt_get_socket_interface(void);
bthh_interface_t *bt_get_hidhost_interface(void);
btpan_interface_t *bt_get_pan_interface(void);
@@ -36,5 +40,9 @@ bthf_interface_t *bt_get_handsfree_interface(void);
btgatt_interface_t *bt_get_gatt_interface(void);
bthl_interface_t *bt_get_health_interface(void);
+#ifdef BLUEZ_EXTENSIONS
+bthf_client_interface_t *bt_get_hf_client_interface(void);
+#endif
+
void bt_thread_associate(void);
void bt_thread_disassociate(void);
--
1.8.4
---
android/hal-handsfree-client.c | 40 ++++++++++++++++++++++++++++++++++++++++
android/hal-msg.h | 12 ++++++++++++
android/handsfree-client.c | 20 ++++++++++++++++++++
3 files changed, 72 insertions(+)
diff --git a/android/hal-handsfree-client.c b/android/hal-handsfree-client.c
index 9422e0f..441d2b4 100644
--- a/android/hal-handsfree-client.c
+++ b/android/hal-handsfree-client.c
@@ -70,6 +70,44 @@ static bt_status_t init(bthf_client_callbacks_t *callbacks)
return ret;
}
+static bt_status_t hf_client_connect(bt_bdaddr_t *bd_addr)
+{
+ struct hal_cmd_hf_client_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 hal_ipc_cmd(HAL_SERVICE_ID_HANDSFREE_CLIENT,
+ HAL_OP_HF_CLIENT_CONNECT, sizeof(cmd), &cmd,
+ NULL, NULL, NULL);
+}
+
+static bt_status_t disconnect(bt_bdaddr_t *bd_addr)
+{
+ struct hal_cmd_hf_client_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 hal_ipc_cmd(HAL_SERVICE_ID_HANDSFREE_CLIENT,
+ HAL_OP_HF_CLIENT_DISCONNECT, sizeof(cmd), &cmd,
+ NULL, NULL, NULL);
+}
+
static void cleanup(void)
{
struct hal_cmd_unregister_module cmd;
@@ -92,6 +130,8 @@ static void cleanup(void)
static bthf_client_interface_t iface = {
.size = sizeof(iface),
.init = init,
+ .connect = hf_client_connect,
+ .disconnect = disconnect,
.cleanup = cleanup
};
diff --git a/android/hal-msg.h b/android/hal-msg.h
index 8b1e292..02cc798 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -976,6 +976,18 @@ struct hal_cmd_gatt_server_send_response {
uint8_t data[0];
} __attribute__((packed));
+/* Handsfree client HAL API */
+
+#define HAL_OP_HF_CLIENT_CONNECT 0x01
+struct hal_cmd_hf_client_connect {
+ uint8_t bdaddr[6];
+} __attribute__((packed));
+
+#define HAL_OP_HF_CLIENT_DISCONNECT 0x02
+struct hal_cmd_hf_client_disconnect {
+ uint8_t bdaddr[6];
+} __attribute__((packed));
+
/* Notifications and confirmations */
#define HAL_POWER_OFF 0x00
diff --git a/android/handsfree-client.c b/android/handsfree-client.c
index c3ff555..f43829a 100644
--- a/android/handsfree-client.c
+++ b/android/handsfree-client.c
@@ -44,7 +44,27 @@ static bdaddr_t adapter_addr;
static struct ipc *hal_ipc = NULL;
+static void handle_connect(const void *buf, uint16_t len)
+{
+ DBG("Not Implemented");
+ ipc_send_rsp(hal_ipc, HAL_SERVICE_ID_HANDSFREE_CLIENT,
+ HAL_OP_HF_CLIENT_CONNECT, HAL_STATUS_UNSUPPORTED);
+}
+
+static void handle_disconnect(const void *buf, uint16_t len)
+{
+ DBG("Not Implemented");
+ ipc_send_rsp(hal_ipc, HAL_SERVICE_ID_HANDSFREE_CLIENT,
+ HAL_OP_HF_CLIENT_DISCONNECT, HAL_STATUS_UNSUPPORTED);
+}
+
static const struct ipc_handler cmd_handlers[] = {
+ /* HAL_OP_HF_CLIENT_CONNECT */
+ { handle_connect, false,
+ sizeof(struct hal_cmd_hf_client_connect) },
+ /* HAL_OP_HF_CLIENT_DISCONNECT */
+ { handle_disconnect, false,
+ sizeof(struct hal_cmd_hf_client_disconnect) },
};
bool bt_hf_client_register(struct ipc *ipc, const bdaddr_t *addr)
--
1.8.4
---
android/Android.mk | 1 +
android/Makefile.am | 1 +
android/handsfree-client.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++
android/handsfree-client.h | 25 +++++++++++++++++
android/main.c | 11 ++++++++
5 files changed, 107 insertions(+)
create mode 100644 android/handsfree-client.c
create mode 100644 android/handsfree-client.h
diff --git a/android/Android.mk b/android/Android.mk
index b2b55f7..aae426d 100644
--- a/android/Android.mk
+++ b/android/Android.mk
@@ -49,6 +49,7 @@ LOCAL_SRC_FILES := \
bluez/android/avrcp-lib.c \
bluez/android/pan.c \
bluez/android/handsfree.c \
+ bluez/android/handsfree-client.c \
bluez/android/gatt.c \
bluez/android/health.c \
bluez/android/mcap-lib.c \
diff --git a/android/Makefile.am b/android/Makefile.am
index 49fbddc..70b9c3a 100644
--- a/android/Makefile.am
+++ b/android/Makefile.am
@@ -52,6 +52,7 @@ android_bluetoothd_SOURCES = android/main.c \
android/socket.h android/socket.c \
android/pan.h android/pan.c \
android/handsfree.h android/handsfree.c \
+ android/handsfree-client.c android/handsfree-client.h \
android/gatt.h android/gatt.c \
android/health.h android/health.c \
android/mcap-lib.h android/mcap-lib.c \
diff --git a/android/handsfree-client.c b/android/handsfree-client.c
new file mode 100644
index 0000000..c3ff555
--- /dev/null
+++ b/android/handsfree-client.c
@@ -0,0 +1,69 @@
+/*
+ *
+ * BlueZ - Bluetooth protocol stack for Linux
+ *
+ * Copyright (C) 2014 Intel Corporation. All rights reserved.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdlib.h>
+#include <stdbool.h>
+#include <errno.h>
+#include <unistd.h>
+#include <glib.h>
+
+#include "lib/bluetooth.h"
+#include "ipc.h"
+#include "ipc-common.h"
+#include "src/log.h"
+#include "utils.h"
+
+#include "hal-msg.h"
+#include "handsfree-client.h"
+
+static bdaddr_t adapter_addr;
+
+static struct ipc *hal_ipc = NULL;
+
+static const struct ipc_handler cmd_handlers[] = {
+};
+
+bool bt_hf_client_register(struct ipc *ipc, const bdaddr_t *addr)
+{
+ DBG("");
+
+ bacpy(&adapter_addr, addr);
+
+ hal_ipc = ipc;
+ ipc_register(hal_ipc, HAL_SERVICE_ID_HANDSFREE_CLIENT, cmd_handlers,
+ G_N_ELEMENTS(cmd_handlers));
+
+ return true;
+}
+
+void bt_hf_client_unregister(void)
+{
+ DBG("");
+
+ ipc_unregister(hal_ipc, HAL_SERVICE_ID_HANDSFREE);
+ hal_ipc = NULL;
+}
diff --git a/android/handsfree-client.h b/android/handsfree-client.h
new file mode 100644
index 0000000..1eb69ff
--- /dev/null
+++ b/android/handsfree-client.h
@@ -0,0 +1,25 @@
+/*
+ *
+ * BlueZ - Bluetooth protocol stack for Linux
+ *
+ * Copyright (C) 2014 Intel Corporation. All rights reserved.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+bool bt_hf_client_register(struct ipc *ipc, const bdaddr_t *addr);
+void bt_hf_client_unregister(void);
diff --git a/android/main.c b/android/main.c
index b03a2df..5652331 100644
--- a/android/main.c
+++ b/android/main.c
@@ -60,6 +60,7 @@
#include "handsfree.h"
#include "gatt.h"
#include "health.h"
+#include "handsfree-client.h"
#define STARTUP_GRACE_SECONDS 5
#define SHUTDOWN_GRACE_SECONDS 10
@@ -145,6 +146,13 @@ static void service_register(const void *buf, uint16_t len)
}
break;
+ case HAL_SERVICE_ID_HANDSFREE_CLIENT:
+ if (!bt_hf_client_register(hal_ipc, &adapter_bdaddr)) {
+ status = HAL_STATUS_FAILED;
+ goto failed;
+ }
+
+ break;
default:
DBG("service %u not supported", m->service_id);
status = HAL_STATUS_FAILED;
@@ -200,6 +208,9 @@ static void service_unregister(const void *buf, uint16_t len)
case HAL_SERVICE_ID_HEALTH:
bt_health_unregister();
break;
+ case HAL_SERVICE_ID_HANDSFREE_CLIENT:
+ bt_hf_client_unregister();
+ break;
default:
/*
* This would indicate bug in HAL, as unregister should not be
--
1.8.4
---
android/hardware/bluetooth.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/android/hardware/bluetooth.h b/android/hardware/bluetooth.h
index c00a8f7..0d3283b 100644
--- a/android/hardware/bluetooth.h
+++ b/android/hardware/bluetooth.h
@@ -37,6 +37,7 @@ __BEGIN_DECLS
/* Bluetooth profile interface IDs */
#define BT_PROFILE_HANDSFREE_ID "handsfree"
+#define BT_PROFILE_HANDSFREE_CLIENT_ID "handsfree_client"
#define BT_PROFILE_ADVANCED_AUDIO_ID "a2dp"
#define BT_PROFILE_HEALTH_ID "health"
#define BT_PROFILE_SOCKETS_ID "socket"
--
1.8.4
---
android/hal-msg.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/android/hal-msg.h b/android/hal-msg.h
index 3d95e10..8b1e292 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -35,8 +35,9 @@ static const char BLUEZ_HAL_SK_PATH[] = "\0bluez_hal_socket";
#define HAL_SERVICE_ID_HEALTH 7
#define HAL_SERVICE_ID_AVRCP 8
#define HAL_SERVICE_ID_GATT 9
+#define HAL_SERVICE_ID_HANDSFREE_CLIENT 10
-#define HAL_SERVICE_ID_MAX HAL_SERVICE_ID_GATT
+#define HAL_SERVICE_ID_MAX HAL_SERVICE_ID_HANDSFREE_CLIENT
/* Core Service */
--
1.8.4