All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/6] android/hal-ipc-api: Add MCE HAL
@ 2014-09-22 11:01 Grzegorz Kolodziejczyk
  2014-09-22 11:01 ` [PATCH 2/6] android/hal-mce-api: Add get remote MAS instance command and event Grzegorz Kolodziejczyk
                   ` (7 more replies)
  0 siblings, 8 replies; 12+ messages in thread
From: Grzegorz Kolodziejczyk @ 2014-09-22 11:01 UTC (permalink / raw)
  To: linux-bluetooth

---
 android/hal-ipc-api.txt | 51 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)

diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
index f6e1680..38f75e6 100644
--- a/android/hal-ipc-api.txt
+++ b/android/hal-ipc-api.txt
@@ -2396,3 +2396,54 @@ Notifications:
 	Opcode 0x95 - Ring Indication notification
 
 		Notification parameters: <none>
+
+
+Bluetooth MCE HAL (ID 11)
+=========================
+
+Android HAL name: "map_client" (BT_PROFILE_MAP_CLIENT_ID)
+
+Structures:
+
+	MAS instance: Instance ID (1 octet)
+	              Channel (1 octet)
+	              Message type (1 octet)
+	              Name (string)
+
+	Valid Message type: 0x01 = EMAIL
+	                    0x02 = SMS_GSM
+	                    0x04 = SMS_CDMA
+	                    0x08 = MMS
+
+Commands and responses:
+
+	Opcode 0x00 - Error response
+
+		Response parameters: Status (1 octet)
+
+		Valid status values: 0x01 = Fail
+		                     0x02 = Not ready
+		                     0x03 = No memory
+		                     0x04 = Busy
+		                     0x05 = Done (already completed)
+		                     0x06 = Unsupported
+		                     0x07 = Parameter invalid
+		                     0x08 = Unhandled
+		                     0x09 = Authentication failure
+		                     0x0a = Remote device down
+
+	Opcode 0x01 - Get Remote MAS Instances
+
+		Command parameters: Remote address (6 octets)
+		Response parameters: <none>
+
+		In case of an error, the error response will be returned.
+
+Notifications:
+
+	Opcode 0x81 - Remote MAS Instances notification
+
+		Notification parameters: Status (1 octet)
+		                         Remote address (6 octets)
+		                         Number of instances (1 octet)
+		                         MAS instance (variable)
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 2/6] android/hal-mce-api: Add get remote MAS instance command and event
  2014-09-22 11:01 [PATCH 1/6] android/hal-ipc-api: Add MCE HAL Grzegorz Kolodziejczyk
@ 2014-09-22 11:01 ` Grzegorz Kolodziejczyk
  2014-09-22 11:01 ` [PATCH 3/6] android/mce: Add Android MCE header Grzegorz Kolodziejczyk
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 12+ messages in thread
From: Grzegorz Kolodziejczyk @ 2014-09-22 11:01 UTC (permalink / raw)
  To: linux-bluetooth

---
 android/hal-msg.h | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/android/hal-msg.h b/android/hal-msg.h
index ba213b7..ca5f5a1 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -1051,6 +1051,13 @@ struct hal_cmd_hf_client_send_dtmf {
 
 #define HAL_OP_HF_CLIENT_GET_LAST_VOICE_TAG_NUM	0x0f
 
+/* MAP CLIENT HAL API */
+
+#define HAL_OP_MAP_CLIENT_GET_INSTANCES	0x01
+struct hal_cmd_map_client_get_instances {
+	uint8_t bdaddr[6];
+} __attribute__((packed));
+
 /* Notifications and confirmations */
 
 #define HAL_POWER_OFF			0x00
@@ -1695,3 +1702,19 @@ struct hal_ev_gatt_server_rsp_confirmation {
 #define HAL_GATT_AUTHENTICATION_NONE		0
 #define HAL_GATT_AUTHENTICATION_NO_MITM		1
 #define HAL_GATT_AUTHENTICATION_MITM		2
+
+#define HAL_EV_MAP_CLIENT_REMOTE_MAS_INSTANCES	0x81
+struct hal_map_client_mas_instance {
+	uint8_t  id;
+	uint8_t  scn;
+	uint8_t  msg_types;
+	uint16_t name_len;
+	uint8_t  name[0];
+} __attribute__((packed));
+
+struct hal_ev_map_client_remote_mas_instances {
+	int32_t status;
+	uint8_t bdaddr[6];
+	int32_t num_instances;
+	struct hal_map_client_mas_instance instances[0];
+} __attribute__((packed));
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 3/6] android/mce: Add Android MCE header
  2014-09-22 11:01 [PATCH 1/6] android/hal-ipc-api: Add MCE HAL Grzegorz Kolodziejczyk
  2014-09-22 11:01 ` [PATCH 2/6] android/hal-mce-api: Add get remote MAS instance command and event Grzegorz Kolodziejczyk
@ 2014-09-22 11:01 ` Grzegorz Kolodziejczyk
  2014-09-22 11:01 ` [PATCH 4/6] android/hal-mce: Add skeleton for MCE HAL Grzegorz Kolodziejczyk
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 12+ messages in thread
From: Grzegorz Kolodziejczyk @ 2014-09-22 11:01 UTC (permalink / raw)
  To: linux-bluetooth

This header file has been taken from Codeaurora forum.
---
 android/Makefile.am       |  1 +
 android/hardware/bt_mce.h | 57 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 58 insertions(+)
 create mode 100644 android/hardware/bt_mce.h

diff --git a/android/Makefile.am b/android/Makefile.am
index b576fda..9980c4c 100644
--- a/android/Makefile.am
+++ b/android/Makefile.am
@@ -90,6 +90,7 @@ android_bluetooth_default_la_SOURCES = android/hal.h android/hal-bluetooth.c \
 					android/hardware/bt_rc.h \
 					android/hardware/bt_sock.h \
 					android/hardware/bt_hf_client.h \
+					android/hardware/bt_mce.h \
 					android/hardware/hardware.h \
 					android/cutils/properties.h \
 					android/ipc-common.h \
diff --git a/android/hardware/bt_mce.h b/android/hardware/bt_mce.h
new file mode 100644
index 0000000..c87f64e
--- /dev/null
+++ b/android/hardware/bt_mce.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2013, The Linux Foundation. All rights reserved.
+ * Not a Contribution
+ *
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * 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.
+ */
+
+#ifndef ANDROID_INCLUDE_BT_MCE_H
+#define ANDROID_INCLUDE_BT_MCE_H
+
+__BEGIN_DECLS
+
+/** MAS instance description */
+typedef struct
+{
+    int  id;
+    int  scn;
+    int  msg_types;
+    char *p_name;
+} btmce_mas_instance_t;
+
+/** callback for get_remote_mas_instances */
+typedef void (*btmce_remote_mas_instances_callback)(bt_status_t status, bt_bdaddr_t *bd_addr,
+                                                    int num_instances, btmce_mas_instance_t *instances);
+
+typedef struct {
+    /** set to sizeof(btmce_callbacks_t) */
+    size_t      size;
+    btmce_remote_mas_instances_callback  remote_mas_instances_cb;
+} btmce_callbacks_t;
+
+typedef struct {
+    /** set to size of this struct */
+    size_t size;
+
+    /** register BT MCE callbacks */
+    bt_status_t (*init)(btmce_callbacks_t *callbacks);
+
+    /** search for MAS instances on remote device */
+    bt_status_t (*get_remote_mas_instances)(bt_bdaddr_t *bd_addr);
+} btmce_interface_t;
+
+__END_DECLS
+
+#endif /* ANDROID_INCLUDE_BT_MCE_H */
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 4/6] android/hal-mce: Add skeleton for MCE HAL
  2014-09-22 11:01 [PATCH 1/6] android/hal-ipc-api: Add MCE HAL Grzegorz Kolodziejczyk
  2014-09-22 11:01 ` [PATCH 2/6] android/hal-mce-api: Add get remote MAS instance command and event Grzegorz Kolodziejczyk
  2014-09-22 11:01 ` [PATCH 3/6] android/mce: Add Android MCE header Grzegorz Kolodziejczyk
@ 2014-09-22 11:01 ` Grzegorz Kolodziejczyk
  2014-10-03 11:26   ` Szymon Janc
  2014-09-22 11:01 ` [PATCH 5/6] android/hal-mce: Add event handler Grzegorz Kolodziejczyk
                   ` (4 subsequent siblings)
  7 siblings, 1 reply; 12+ messages in thread
From: Grzegorz Kolodziejczyk @ 2014-09-22 11:01 UTC (permalink / raw)
  To: linux-bluetooth

This adds skeleton with stubs and proper build system entries.
---
 android/Android.mk           |  1 +
 android/Makefile.am          |  1 +
 android/hal-bluetooth.c      |  3 ++
 android/hal-map-client.c     | 92 ++++++++++++++++++++++++++++++++++++++++++++
 android/hal-msg.h            |  3 +-
 android/hal.h                |  2 +
 android/hardware/bluetooth.h |  1 +
 7 files changed, 102 insertions(+), 1 deletion(-)
 create mode 100644 android/hal-map-client.c

diff --git a/android/Android.mk b/android/Android.mk
index 4a14474..6dfd801 100644
--- a/android/Android.mk
+++ b/android/Android.mk
@@ -128,6 +128,7 @@ LOCAL_SRC_FILES := \
 	bluez/android/hal-gatt.c \
 	bluez/android/hal-utils.c \
 	bluez/android/hal-health.c \
+	bluez/android/hal-map-client.c \
 
 ifeq ($(BLUEZ_EXTENSIONS), true)
 LOCAL_SRC_FILES += bluez/android/hal-handsfree-client.c
diff --git a/android/Makefile.am b/android/Makefile.am
index 9980c4c..92f3df1 100644
--- a/android/Makefile.am
+++ b/android/Makefile.am
@@ -77,6 +77,7 @@ android_bluetooth_default_la_SOURCES = android/hal.h android/hal-bluetooth.c \
 					android/hal-handsfree.c \
 					android/hal-handsfree-client.c \
 					android/hal-gatt.c \
+					android/hal-map-client.c \
 					android/hardware/bluetooth.h \
 					android/hardware/bt_av.h \
 					android/hardware/bt_gatt.h \
diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
index 7c8c2ee..2706773 100644
--- a/android/hal-bluetooth.c
+++ b/android/hal-bluetooth.c
@@ -786,6 +786,9 @@ static const void *get_profile_interface(const char *profile_id)
 #if BLUEZ_EXTENSIONS
 	if (!strcmp(profile_id, BT_PROFILE_HANDSFREE_CLIENT_ID))
 		return bt_get_hf_client_interface();
+
+	if (!strcmp(profile_id, BT_PROFILE_MAP_CLIENT_ID))
+		return bt_get_map_client_interface();
 #endif
 
 	return NULL;
diff --git a/android/hal-map-client.c b/android/hal-map-client.c
new file mode 100644
index 0000000..7fb3011
--- /dev/null
+++ b/android/hal-map-client.c
@@ -0,0 +1,92 @@
+/*
+ * 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 "hal-log.h"
+#include "hal.h"
+#include "hal-msg.h"
+#include "hal-ipc.h"
+
+static const btmce_callbacks_t *cbs = NULL;
+
+static bool interface_ready(void)
+{
+	return cbs != NULL;
+}
+
+/* Event Handlers */
+
+static void handle_remote_mas_instances(void *buf, uint16_t len, int fd)
+{
+
+}
+
+/* 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[] = {
+	/* HAL_EV_MCE_REMOTE_MAS_INSTANCES */
+	{ handle_remote_mas_instances, true,
+			sizeof(struct hal_ev_map_client_remote_mas_instances) }
+};
+
+/* API */
+
+static bt_status_t get_remote_mas_instances(bt_bdaddr_t *bd_addr)
+{
+	return BT_STATUS_UNSUPPORTED;
+}
+
+static bt_status_t init(btmce_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_MAP_CLIENT, ev_handlers,
+				sizeof(ev_handlers)/sizeof(ev_handlers[0]));
+
+	cmd.service_id = HAL_SERVICE_ID_MAP_CLIENT;
+
+	ret = hal_ipc_cmd(HAL_SERVICE_ID_CORE, HAL_OP_REGISTER_MODULE,
+					sizeof(cmd), &cmd, 0, NULL, NULL);
+
+	if (ret != BT_STATUS_SUCCESS) {
+		cbs = NULL;
+		hal_ipc_unregister(HAL_SERVICE_ID_MAP_CLIENT);
+	}
+
+	return ret;
+}
+
+static btmce_interface_t iface = {
+	.size = sizeof(iface),
+	.init = init,
+	.get_remote_mas_instances = get_remote_mas_instances
+};
+
+btmce_interface_t *bt_get_map_client_interface(void)
+{
+	return &iface;
+}
diff --git a/android/hal-msg.h b/android/hal-msg.h
index ca5f5a1..d13b6ce 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -36,8 +36,9 @@ static const char BLUEZ_HAL_SK_PATH[] = "\0bluez_hal_socket";
 #define HAL_SERVICE_ID_AVRCP		8
 #define HAL_SERVICE_ID_GATT		9
 #define HAL_SERVICE_ID_HANDSFREE_CLIENT	10
+#define HAL_SERVICE_ID_MAP_CLIENT	11
 
-#define HAL_SERVICE_ID_MAX HAL_SERVICE_ID_HANDSFREE_CLIENT
+#define HAL_SERVICE_ID_MAX HAL_SERVICE_ID_MAP_CLIENT
 
 /* Core Service */
 
diff --git a/android/hal.h b/android/hal.h
index c34022d..cff1b35 100644
--- a/android/hal.h
+++ b/android/hal.h
@@ -26,6 +26,7 @@
 #include <hardware/bt_gatt_client.h>
 #include <hardware/bt_gatt_server.h>
 #include <hardware/bt_hl.h>
+#include <hardware/bt_mce.h>
 
 #ifdef BLUEZ_EXTENSIONS
 #include <hardware/bt_hf_client.h>
@@ -39,6 +40,7 @@ btrc_interface_t *bt_get_avrcp_interface(void);
 bthf_interface_t *bt_get_handsfree_interface(void);
 btgatt_interface_t *bt_get_gatt_interface(void);
 bthl_interface_t *bt_get_health_interface(void);
+btmce_interface_t *bt_get_map_client_interface(void);
 
 #ifdef BLUEZ_EXTENSIONS
 bthf_client_interface_t *bt_get_hf_client_interface(void);
diff --git a/android/hardware/bluetooth.h b/android/hardware/bluetooth.h
index 0d3283b..b957c6f 100644
--- a/android/hardware/bluetooth.h
+++ b/android/hardware/bluetooth.h
@@ -43,6 +43,7 @@ __BEGIN_DECLS
 #define BT_PROFILE_SOCKETS_ID "socket"
 #define BT_PROFILE_HIDHOST_ID "hidhost"
 #define BT_PROFILE_PAN_ID "pan"
+#define BT_PROFILE_MAP_CLIENT_ID "map_client"
 
 #define BT_PROFILE_GATT_ID "gatt"
 #define BT_PROFILE_AV_RC_ID "avrcp"
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 5/6] android/hal-mce: Add event handler
  2014-09-22 11:01 [PATCH 1/6] android/hal-ipc-api: Add MCE HAL Grzegorz Kolodziejczyk
                   ` (2 preceding siblings ...)
  2014-09-22 11:01 ` [PATCH 4/6] android/hal-mce: Add skeleton for MCE HAL Grzegorz Kolodziejczyk
@ 2014-09-22 11:01 ` Grzegorz Kolodziejczyk
  2014-10-03 11:34   ` Szymon Janc
  2014-09-22 11:01 ` [PATCH 6/6] android/hal-mce: Add API calls Grzegorz Kolodziejczyk
                   ` (3 subsequent siblings)
  7 siblings, 1 reply; 12+ messages in thread
From: Grzegorz Kolodziejczyk @ 2014-09-22 11:01 UTC (permalink / raw)
  To: linux-bluetooth

---
 android/hal-map-client.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)

diff --git a/android/hal-map-client.c b/android/hal-map-client.c
index 7fb3011..7538958 100644
--- a/android/hal-map-client.c
+++ b/android/hal-map-client.c
@@ -15,6 +15,7 @@
  *
  */
 
+#include <stdlib.h>
 #include <stdbool.h>
 
 #include "hal-log.h"
@@ -31,9 +32,55 @@ static bool interface_ready(void)
 
 /* Event Handlers */
 
+static void remote_mas_instances_to_hal(btmce_mas_instance_t *send_instance,
+				struct hal_map_client_mas_instance *instance,
+				uint8_t num_instances, uint16_t len)
+{
+	void *buf = instance;
+	uint8_t i;
+
+	DBG("");
+
+	for (i = 0; i < num_instances; i++) {
+		if (sizeof(*instance) + instance->name_len > len) {
+			error("invalid remote mas instances (%zu > %u),"
+				"aborting",
+				sizeof(*instance) + instance->name_len, len);
+			exit(EXIT_FAILURE);
+		}
+
+		send_instance[i].id = instance->id;
+		send_instance[i].msg_types = instance->msg_types;
+		send_instance[i].scn = instance->scn;
+		send_instance[i].p_name = (char *) instance->name;
+
+		len -= sizeof(*instance) + instance->name_len;
+		buf += sizeof(*instance) + instance->name_len;
+		instance = buf;
+	}
+
+	if (!len)
+		return;
+
+	error("invalid remote mas instances (%u bytes left), aborting", len);
+	exit(EXIT_FAILURE);
+}
+
 static void handle_remote_mas_instances(void *buf, uint16_t len, int fd)
 {
+	struct hal_ev_map_client_remote_mas_instances *ev = buf;
+	btmce_mas_instance_t instances[ev->num_instances];
+
+	DBG("");
+
+	len -= sizeof(*ev);
+	remote_mas_instances_to_hal(instances, ev->instances, ev->num_instances,
+									len);
 
+	if (cbs->remote_mas_instances_cb)
+		cbs->remote_mas_instances_cb(ev->status,
+						(bt_bdaddr_t *) ev->bdaddr,
+						ev->num_instances, instances);
 }
 
 /* handlers will be called from notification thread context,
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 6/6] android/hal-mce: Add API calls
  2014-09-22 11:01 [PATCH 1/6] android/hal-ipc-api: Add MCE HAL Grzegorz Kolodziejczyk
                   ` (3 preceding siblings ...)
  2014-09-22 11:01 ` [PATCH 5/6] android/hal-mce: Add event handler Grzegorz Kolodziejczyk
@ 2014-09-22 11:01 ` Grzegorz Kolodziejczyk
  2014-10-02 20:49 ` [PATCH 1/6] android/hal-ipc-api: Add MCE HAL Lukasz Rymanowski
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 12+ messages in thread
From: Grzegorz Kolodziejczyk @ 2014-09-22 11:01 UTC (permalink / raw)
  To: linux-bluetooth

Send API calls data using IPC.
---
 android/hal-map-client.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/android/hal-map-client.c b/android/hal-map-client.c
index 7538958..ccc2764 100644
--- a/android/hal-map-client.c
+++ b/android/hal-map-client.c
@@ -17,6 +17,7 @@
 
 #include <stdlib.h>
 #include <stdbool.h>
+#include <string.h>
 
 #include "hal-log.h"
 #include "hal.h"
@@ -96,7 +97,16 @@ static const struct hal_ipc_handler ev_handlers[] = {
 
 static bt_status_t get_remote_mas_instances(bt_bdaddr_t *bd_addr)
 {
-	return BT_STATUS_UNSUPPORTED;
+	struct hal_cmd_map_client_get_instances cmd;
+
+	if (!interface_ready())
+		return BT_STATUS_NOT_READY;
+
+	memcpy(cmd.bdaddr, bd_addr, sizeof(*bd_addr));
+
+	return hal_ipc_cmd(HAL_SERVICE_ID_MAP_CLIENT,
+				HAL_OP_MAP_CLIENT_GET_INSTANCES, sizeof(cmd),
+				&cmd, NULL, NULL, NULL);
 }
 
 static bt_status_t init(btmce_callbacks_t *callbacks)
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/6] android/hal-ipc-api: Add MCE HAL
  2014-09-22 11:01 [PATCH 1/6] android/hal-ipc-api: Add MCE HAL Grzegorz Kolodziejczyk
                   ` (4 preceding siblings ...)
  2014-09-22 11:01 ` [PATCH 6/6] android/hal-mce: Add API calls Grzegorz Kolodziejczyk
@ 2014-10-02 20:49 ` Lukasz Rymanowski
  2014-10-03 11:17 ` Szymon Janc
  2014-10-03 11:38 ` Szymon Janc
  7 siblings, 0 replies; 12+ messages in thread
From: Lukasz Rymanowski @ 2014-10-02 20:49 UTC (permalink / raw)
  To: Grzegorz Kolodziejczyk, Szymon Janc; +Cc: linux-bluetooth

Hi Grzegorz, Szymon

On Mon, Sep 22, 2014 at 1:01 PM, Grzegorz Kolodziejczyk
<grzegorz.kolodziejczyk@tieto.com> wrote:
> ---
>  android/hal-ipc-api.txt | 51 +++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 51 insertions(+)
>
> diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
> index f6e1680..38f75e6 100644
> --- a/android/hal-ipc-api.txt
> +++ b/android/hal-ipc-api.txt
> @@ -2396,3 +2396,54 @@ Notifications:
>         Opcode 0x95 - Ring Indication notification
>
>                 Notification parameters: <none>
> +
> +
> +Bluetooth MCE HAL (ID 11)
> +=========================
> +
> +Android HAL name: "map_client" (BT_PROFILE_MAP_CLIENT_ID)
> +
> +Structures:
> +
> +       MAS instance: Instance ID (1 octet)
> +                     Channel (1 octet)
> +                     Message type (1 octet)
> +                     Name (string)
> +
> +       Valid Message type: 0x01 = EMAIL
> +                           0x02 = SMS_GSM
> +                           0x04 = SMS_CDMA
> +                           0x08 = MMS
> +
> +Commands and responses:
> +
> +       Opcode 0x00 - Error response
> +
> +               Response parameters: Status (1 octet)
> +
> +               Valid status values: 0x01 = Fail
> +                                    0x02 = Not ready
> +                                    0x03 = No memory
> +                                    0x04 = Busy
> +                                    0x05 = Done (already completed)
> +                                    0x06 = Unsupported
> +                                    0x07 = Parameter invalid
> +                                    0x08 = Unhandled
> +                                    0x09 = Authentication failure
> +                                    0x0a = Remote device down
> +
> +       Opcode 0x01 - Get Remote MAS Instances
> +
> +               Command parameters: Remote address (6 octets)
> +               Response parameters: <none>
> +
> +               In case of an error, the error response will be returned.
> +
> +Notifications:
> +
> +       Opcode 0x81 - Remote MAS Instances notification
> +
> +               Notification parameters: Status (1 octet)
> +                                        Remote address (6 octets)
> +                                        Number of instances (1 octet)
> +                                        MAS instance (variable)
> --
> 1.9.3
>
> --

Looks like we forgot about this set, or ? :)

BR
\Łukasz

> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/6] android/hal-ipc-api: Add MCE HAL
  2014-09-22 11:01 [PATCH 1/6] android/hal-ipc-api: Add MCE HAL Grzegorz Kolodziejczyk
                   ` (5 preceding siblings ...)
  2014-10-02 20:49 ` [PATCH 1/6] android/hal-ipc-api: Add MCE HAL Lukasz Rymanowski
@ 2014-10-03 11:17 ` Szymon Janc
  2014-10-03 11:38 ` Szymon Janc
  7 siblings, 0 replies; 12+ messages in thread
From: Szymon Janc @ 2014-10-03 11:17 UTC (permalink / raw)
  To: Grzegorz Kolodziejczyk; +Cc: linux-bluetooth

Hi Grzegorz,

On Monday 22 of September 2014 13:01:43 Grzegorz Kolodziejczyk wrote:
> ---
>  android/hal-ipc-api.txt | 51 +++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 51 insertions(+)
> 
> diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
> index f6e1680..38f75e6 100644
> --- a/android/hal-ipc-api.txt
> +++ b/android/hal-ipc-api.txt
> @@ -2396,3 +2396,54 @@ Notifications:
>  	Opcode 0x95 - Ring Indication notification
>  
>  		Notification parameters: <none>
> +
> +
> +Bluetooth MCE HAL (ID 11)
> +=========================

I'd prefer if we stick to term 'map client' instead of MCE.

> +
> +Android HAL name: "map_client" (BT_PROFILE_MAP_CLIENT_ID)
> +
> +Structures:

Since this is used only in one place I'd defined it there (see below).

> +
> +	MAS instance: Instance ID (1 octet)
> +	              Channel (1 octet)
> +	              Message type (1 octet)

This should be named 'Message types'.

> +	              Name (string)
> +
> +	Valid Message type: 0x01 = EMAIL
> +	                    0x02 = SMS_GSM
> +	                    0x04 = SMS_CDMA
> +	                    0x08 = MMS

I think we should not define that in IPC since this is not defined in HAL.
Especially that this should be bitmask, not values. Just pass whatever we
get from remote SDP.

> +
> +Commands and responses:
> +
> +	Opcode 0x00 - Error response
> +
> +		Response parameters: Status (1 octet)
> +
> +		Valid status values: 0x01 = Fail
> +		                     0x02 = Not ready
> +		                     0x03 = No memory
> +		                     0x04 = Busy
> +		                     0x05 = Done (already completed)
> +		                     0x06 = Unsupported
> +		                     0x07 = Parameter invalid
> +		                     0x08 = Unhandled
> +		                     0x09 = Authentication failure
> +		                     0x0a = Remote device down
> +
> +	Opcode 0x01 - Get Remote MAS Instances
> +
> +		Command parameters: Remote address (6 octets)
> +		Response parameters: <none>
> +
> +		In case of an error, the error response will be returned.
> +
> +Notifications:
> +
> +	Opcode 0x81 - Remote MAS Instances notification
> +
> +		Notification parameters: Status (1 octet)
> +		                         Remote address (6 octets)
> +		                         Number of instances (1 octet)
> +		                         MAS instance (variable)

Number of instances (1 octet)
Instance ID #(1 octet)
Channel #(1 octet)
Message type #(1 octet)
Name # (string)

-- 
Best regards, 
Szymon Janc

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 4/6] android/hal-mce: Add skeleton for MCE HAL
  2014-09-22 11:01 ` [PATCH 4/6] android/hal-mce: Add skeleton for MCE HAL Grzegorz Kolodziejczyk
@ 2014-10-03 11:26   ` Szymon Janc
  2014-10-03 11:30     ` Grzegorz Kolodziejczyk
  0 siblings, 1 reply; 12+ messages in thread
From: Szymon Janc @ 2014-10-03 11:26 UTC (permalink / raw)
  To: Grzegorz Kolodziejczyk; +Cc: linux-bluetooth

Hi Grzegorz,

On Monday 22 of September 2014 13:01:46 Grzegorz Kolodziejczyk wrote:
> This adds skeleton with stubs and proper build system entries.
> ---
>  android/Android.mk           |  1 +
>  android/Makefile.am          |  1 +
>  android/hal-bluetooth.c      |  3 ++
>  android/hal-map-client.c     | 92 ++++++++++++++++++++++++++++++++++++++++++++
>  android/hal-msg.h            |  3 +-
>  android/hal.h                |  2 +
>  android/hardware/bluetooth.h |  1 +
>  7 files changed, 102 insertions(+), 1 deletion(-)
>  create mode 100644 android/hal-map-client.c
> 
> diff --git a/android/Android.mk b/android/Android.mk
> index 4a14474..6dfd801 100644
> --- a/android/Android.mk
> +++ b/android/Android.mk
> @@ -128,6 +128,7 @@ LOCAL_SRC_FILES := \
>  	bluez/android/hal-gatt.c \
>  	bluez/android/hal-utils.c \
>  	bluez/android/hal-health.c \
> +	bluez/android/hal-map-client.c \
>  
>  ifeq ($(BLUEZ_EXTENSIONS), true)
>  LOCAL_SRC_FILES += bluez/android/hal-handsfree-client.c
> diff --git a/android/Makefile.am b/android/Makefile.am
> index 9980c4c..92f3df1 100644
> --- a/android/Makefile.am
> +++ b/android/Makefile.am
> @@ -77,6 +77,7 @@ android_bluetooth_default_la_SOURCES = android/hal.h android/hal-bluetooth.c \
>  					android/hal-handsfree.c \
>  					android/hal-handsfree-client.c \
>  					android/hal-gatt.c \
> +					android/hal-map-client.c \
>  					android/hardware/bluetooth.h \
>  					android/hardware/bt_av.h \
>  					android/hardware/bt_gatt.h \
> diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
> index 7c8c2ee..2706773 100644
> --- a/android/hal-bluetooth.c
> +++ b/android/hal-bluetooth.c
> @@ -786,6 +786,9 @@ static const void *get_profile_interface(const char *profile_id)
>  #if BLUEZ_EXTENSIONS
>  	if (!strcmp(profile_id, BT_PROFILE_HANDSFREE_CLIENT_ID))
>  		return bt_get_hf_client_interface();
> +
> +	if (!strcmp(profile_id, BT_PROFILE_MAP_CLIENT_ID))
> +		return bt_get_map_client_interface();
>  #endif
>  
>  	return NULL;
> diff --git a/android/hal-map-client.c b/android/hal-map-client.c
> new file mode 100644
> index 0000000..7fb3011
> --- /dev/null
> +++ b/android/hal-map-client.c
> @@ -0,0 +1,92 @@
> +/*
> + * 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 "hal-log.h"
> +#include "hal.h"
> +#include "hal-msg.h"
> +#include "hal-ipc.h"
> +
> +static const btmce_callbacks_t *cbs = NULL;
> +
> +static bool interface_ready(void)
> +{
> +	return cbs != NULL;
> +}
> +
> +/* Event Handlers */
> +
> +static void handle_remote_mas_instances(void *buf, uint16_t len, int fd)
> +{
> +
> +}
> +
> +/* handlers will be called from notification thread context,
> + * index in table equals to 'opcode - HAL_MINIMUM_EVENT'
> + */

Multiline comment should be like
/*
 * foo
 * bar
 */

> +static const struct hal_ipc_handler ev_handlers[] = {
> +	/* HAL_EV_MCE_REMOTE_MAS_INSTANCES */
> +	{ handle_remote_mas_instances, true,
> +			sizeof(struct hal_ev_map_client_remote_mas_instances) }
> +};
> +
> +/* API */
> +
> +static bt_status_t get_remote_mas_instances(bt_bdaddr_t *bd_addr)
> +{
> +	return BT_STATUS_UNSUPPORTED;
> +}
> +
> +static bt_status_t init(btmce_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_MAP_CLIENT, ev_handlers,
> +				sizeof(ev_handlers)/sizeof(ev_handlers[0]));
> +
> +	cmd.service_id = HAL_SERVICE_ID_MAP_CLIENT;
> +
> +	ret = hal_ipc_cmd(HAL_SERVICE_ID_CORE, HAL_OP_REGISTER_MODULE,
> +					sizeof(cmd), &cmd, 0, NULL, NULL);
> +
> +	if (ret != BT_STATUS_SUCCESS) {
> +		cbs = NULL;
> +		hal_ipc_unregister(HAL_SERVICE_ID_MAP_CLIENT);
> +	}
> +
> +	return ret;
> +}
> +
> +static btmce_interface_t iface = {
> +	.size = sizeof(iface),
> +	.init = init,
> +	.get_remote_mas_instances = get_remote_mas_instances
> +};
> +
> +btmce_interface_t *bt_get_map_client_interface(void)
> +{
> +	return &iface;
> +}
> diff --git a/android/hal-msg.h b/android/hal-msg.h
> index ca5f5a1..d13b6ce 100644
> --- a/android/hal-msg.h
> +++ b/android/hal-msg.h
> @@ -36,8 +36,9 @@ static const char BLUEZ_HAL_SK_PATH[] = "\0bluez_hal_socket";
>  #define HAL_SERVICE_ID_AVRCP		8
>  #define HAL_SERVICE_ID_GATT		9
>  #define HAL_SERVICE_ID_HANDSFREE_CLIENT	10
> +#define HAL_SERVICE_ID_MAP_CLIENT	11
>  
> -#define HAL_SERVICE_ID_MAX HAL_SERVICE_ID_HANDSFREE_CLIENT
> +#define HAL_SERVICE_ID_MAX HAL_SERVICE_ID_MAP_CLIENT
>  
>  /* Core Service */
>  
> diff --git a/android/hal.h b/android/hal.h
> index c34022d..cff1b35 100644
> --- a/android/hal.h
> +++ b/android/hal.h
> @@ -26,6 +26,7 @@
>  #include <hardware/bt_gatt_client.h>
>  #include <hardware/bt_gatt_server.h>
>  #include <hardware/bt_hl.h>
> +#include <hardware/bt_mce.h>
>  
>  #ifdef BLUEZ_EXTENSIONS
>  #include <hardware/bt_hf_client.h>
> @@ -39,6 +40,7 @@ btrc_interface_t *bt_get_avrcp_interface(void);
>  bthf_interface_t *bt_get_handsfree_interface(void);
>  btgatt_interface_t *bt_get_gatt_interface(void);
>  bthl_interface_t *bt_get_health_interface(void);
> +btmce_interface_t *bt_get_map_client_interface(void);
>  
>  #ifdef BLUEZ_EXTENSIONS
>  bthf_client_interface_t *bt_get_hf_client_interface(void);
> diff --git a/android/hardware/bluetooth.h b/android/hardware/bluetooth.h
> index 0d3283b..b957c6f 100644
> --- a/android/hardware/bluetooth.h
> +++ b/android/hardware/bluetooth.h
> @@ -43,6 +43,7 @@ __BEGIN_DECLS
>  #define BT_PROFILE_SOCKETS_ID "socket"
>  #define BT_PROFILE_HIDHOST_ID "hidhost"
>  #define BT_PROFILE_PAN_ID "pan"
> +#define BT_PROFILE_MAP_CLIENT_ID "map_client"
>  
>  #define BT_PROFILE_GATT_ID "gatt"
>  #define BT_PROFILE_AV_RC_ID "avrcp"
> 

-- 
Best regards, 
Szymon Janc

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 4/6] android/hal-mce: Add skeleton for MCE HAL
  2014-10-03 11:26   ` Szymon Janc
@ 2014-10-03 11:30     ` Grzegorz Kolodziejczyk
  0 siblings, 0 replies; 12+ messages in thread
From: Grzegorz Kolodziejczyk @ 2014-10-03 11:30 UTC (permalink / raw)
  To: Szymon Janc; +Cc: linux-bluetooth

Hi Szymon,

On 3 October 2014 13:26, Szymon Janc <szymon.janc@tieto.com> wrote:
> Hi Grzegorz,
>
> On Monday 22 of September 2014 13:01:46 Grzegorz Kolodziejczyk wrote:
>> This adds skeleton with stubs and proper build system entries.
>> ---
>>  android/Android.mk           |  1 +
>>  android/Makefile.am          |  1 +
>>  android/hal-bluetooth.c      |  3 ++
>>  android/hal-map-client.c     | 92 ++++++++++++++++++++++++++++++++++++++++++++
>>  android/hal-msg.h            |  3 +-
>>  android/hal.h                |  2 +
>>  android/hardware/bluetooth.h |  1 +
>>  7 files changed, 102 insertions(+), 1 deletion(-)
>>  create mode 100644 android/hal-map-client.c
>>
>> diff --git a/android/Android.mk b/android/Android.mk
>> index 4a14474..6dfd801 100644
>> --- a/android/Android.mk
>> +++ b/android/Android.mk
>> @@ -128,6 +128,7 @@ LOCAL_SRC_FILES := \
>>       bluez/android/hal-gatt.c \
>>       bluez/android/hal-utils.c \
>>       bluez/android/hal-health.c \
>> +     bluez/android/hal-map-client.c \
>>
>>  ifeq ($(BLUEZ_EXTENSIONS), true)
>>  LOCAL_SRC_FILES += bluez/android/hal-handsfree-client.c
>> diff --git a/android/Makefile.am b/android/Makefile.am
>> index 9980c4c..92f3df1 100644
>> --- a/android/Makefile.am
>> +++ b/android/Makefile.am
>> @@ -77,6 +77,7 @@ android_bluetooth_default_la_SOURCES = android/hal.h android/hal-bluetooth.c \
>>                                       android/hal-handsfree.c \
>>                                       android/hal-handsfree-client.c \
>>                                       android/hal-gatt.c \
>> +                                     android/hal-map-client.c \
>>                                       android/hardware/bluetooth.h \
>>                                       android/hardware/bt_av.h \
>>                                       android/hardware/bt_gatt.h \
>> diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
>> index 7c8c2ee..2706773 100644
>> --- a/android/hal-bluetooth.c
>> +++ b/android/hal-bluetooth.c
>> @@ -786,6 +786,9 @@ static const void *get_profile_interface(const char *profile_id)
>>  #if BLUEZ_EXTENSIONS
>>       if (!strcmp(profile_id, BT_PROFILE_HANDSFREE_CLIENT_ID))
>>               return bt_get_hf_client_interface();
>> +
>> +     if (!strcmp(profile_id, BT_PROFILE_MAP_CLIENT_ID))
>> +             return bt_get_map_client_interface();
>>  #endif
>>
>>       return NULL;
>> diff --git a/android/hal-map-client.c b/android/hal-map-client.c
>> new file mode 100644
>> index 0000000..7fb3011
>> --- /dev/null
>> +++ b/android/hal-map-client.c
>> @@ -0,0 +1,92 @@
>> +/*
>> + * 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 "hal-log.h"
>> +#include "hal.h"
>> +#include "hal-msg.h"
>> +#include "hal-ipc.h"
>> +
>> +static const btmce_callbacks_t *cbs = NULL;
>> +
>> +static bool interface_ready(void)
>> +{
>> +     return cbs != NULL;
>> +}
>> +
>> +/* Event Handlers */
>> +
>> +static void handle_remote_mas_instances(void *buf, uint16_t len, int fd)
>> +{
>> +
>> +}
>> +
>> +/* handlers will be called from notification thread context,
>> + * index in table equals to 'opcode - HAL_MINIMUM_EVENT'
>> + */
>
> Multiline comment should be like
> /*
>  * foo
>  * bar
>  */
>

Ok, I'll fix it in v2
>> +static const struct hal_ipc_handler ev_handlers[] = {
>> +     /* HAL_EV_MCE_REMOTE_MAS_INSTANCES */
>> +     { handle_remote_mas_instances, true,
>> +                     sizeof(struct hal_ev_map_client_remote_mas_instances) }
>> +};
>> +
>> +/* API */
>> +
>> +static bt_status_t get_remote_mas_instances(bt_bdaddr_t *bd_addr)
>> +{
>> +     return BT_STATUS_UNSUPPORTED;
>> +}
>> +
>> +static bt_status_t init(btmce_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_MAP_CLIENT, ev_handlers,
>> +                             sizeof(ev_handlers)/sizeof(ev_handlers[0]));
>> +
>> +     cmd.service_id = HAL_SERVICE_ID_MAP_CLIENT;
>> +
>> +     ret = hal_ipc_cmd(HAL_SERVICE_ID_CORE, HAL_OP_REGISTER_MODULE,
>> +                                     sizeof(cmd), &cmd, 0, NULL, NULL);
>> +
>> +     if (ret != BT_STATUS_SUCCESS) {
>> +             cbs = NULL;
>> +             hal_ipc_unregister(HAL_SERVICE_ID_MAP_CLIENT);
>> +     }
>> +
>> +     return ret;
>> +}
>> +
>> +static btmce_interface_t iface = {
>> +     .size = sizeof(iface),
>> +     .init = init,
>> +     .get_remote_mas_instances = get_remote_mas_instances
>> +};
>> +
>> +btmce_interface_t *bt_get_map_client_interface(void)
>> +{
>> +     return &iface;
>> +}
>> diff --git a/android/hal-msg.h b/android/hal-msg.h
>> index ca5f5a1..d13b6ce 100644
>> --- a/android/hal-msg.h
>> +++ b/android/hal-msg.h
>> @@ -36,8 +36,9 @@ static const char BLUEZ_HAL_SK_PATH[] = "\0bluez_hal_socket";
>>  #define HAL_SERVICE_ID_AVRCP         8
>>  #define HAL_SERVICE_ID_GATT          9
>>  #define HAL_SERVICE_ID_HANDSFREE_CLIENT      10
>> +#define HAL_SERVICE_ID_MAP_CLIENT    11
>>
>> -#define HAL_SERVICE_ID_MAX HAL_SERVICE_ID_HANDSFREE_CLIENT
>> +#define HAL_SERVICE_ID_MAX HAL_SERVICE_ID_MAP_CLIENT
>>
>>  /* Core Service */
>>
>> diff --git a/android/hal.h b/android/hal.h
>> index c34022d..cff1b35 100644
>> --- a/android/hal.h
>> +++ b/android/hal.h
>> @@ -26,6 +26,7 @@
>>  #include <hardware/bt_gatt_client.h>
>>  #include <hardware/bt_gatt_server.h>
>>  #include <hardware/bt_hl.h>
>> +#include <hardware/bt_mce.h>
>>
>>  #ifdef BLUEZ_EXTENSIONS
>>  #include <hardware/bt_hf_client.h>
>> @@ -39,6 +40,7 @@ btrc_interface_t *bt_get_avrcp_interface(void);
>>  bthf_interface_t *bt_get_handsfree_interface(void);
>>  btgatt_interface_t *bt_get_gatt_interface(void);
>>  bthl_interface_t *bt_get_health_interface(void);
>> +btmce_interface_t *bt_get_map_client_interface(void);
>>
>>  #ifdef BLUEZ_EXTENSIONS
>>  bthf_client_interface_t *bt_get_hf_client_interface(void);
>> diff --git a/android/hardware/bluetooth.h b/android/hardware/bluetooth.h
>> index 0d3283b..b957c6f 100644
>> --- a/android/hardware/bluetooth.h
>> +++ b/android/hardware/bluetooth.h
>> @@ -43,6 +43,7 @@ __BEGIN_DECLS
>>  #define BT_PROFILE_SOCKETS_ID "socket"
>>  #define BT_PROFILE_HIDHOST_ID "hidhost"
>>  #define BT_PROFILE_PAN_ID "pan"
>> +#define BT_PROFILE_MAP_CLIENT_ID "map_client"
>>
>>  #define BT_PROFILE_GATT_ID "gatt"
>>  #define BT_PROFILE_AV_RC_ID "avrcp"
>>
>
> --
> Best regards,
> Szymon Janc


Best regards,
Grzegorz Kolodziejczyk

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 5/6] android/hal-mce: Add event handler
  2014-09-22 11:01 ` [PATCH 5/6] android/hal-mce: Add event handler Grzegorz Kolodziejczyk
@ 2014-10-03 11:34   ` Szymon Janc
  0 siblings, 0 replies; 12+ messages in thread
From: Szymon Janc @ 2014-10-03 11:34 UTC (permalink / raw)
  To: Grzegorz Kolodziejczyk; +Cc: linux-bluetooth

Hi Grzegorz,

On Monday 22 of September 2014 13:01:47 Grzegorz Kolodziejczyk wrote:
> ---
>  android/hal-map-client.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 47 insertions(+)
> 
> diff --git a/android/hal-map-client.c b/android/hal-map-client.c
> index 7fb3011..7538958 100644
> --- a/android/hal-map-client.c
> +++ b/android/hal-map-client.c
> @@ -15,6 +15,7 @@
>   *
>   */
>  
> +#include <stdlib.h>
>  #include <stdbool.h>
>  
>  #include "hal-log.h"
> @@ -31,9 +32,55 @@ static bool interface_ready(void)
>  
>  /* Event Handlers */
>  
> +static void remote_mas_instances_to_hal(btmce_mas_instance_t *send_instance,
> +				struct hal_map_client_mas_instance *instance,
> +				uint8_t num_instances, uint16_t len)
> +{
> +	void *buf = instance;
> +	uint8_t i;
> +
> +	DBG("");
> +
> +	for (i = 0; i < num_instances; i++) {
> +		if (sizeof(*instance) + instance->name_len > len) {
> +			error("invalid remote mas instances (%zu > %u),"
> +				"aborting",

Try not to break strings ie. make this shorter by removing 'remote'.

> +				sizeof(*instance) + instance->name_len, len);
> +			exit(EXIT_FAILURE);
> +		}
> +
> +		send_instance[i].id = instance->id;
> +		send_instance[i].msg_types = instance->msg_types;
> +		send_instance[i].scn = instance->scn;
> +		send_instance[i].p_name = (char *) instance->name;

You should check if name is NULL terminated and abort if not.
Check handle_dial() in hal-handsfree for reference.

> +
> +		len -= sizeof(*instance) + instance->name_len;
> +		buf += sizeof(*instance) + instance->name_len;
> +		instance = buf;
> +	}
> +
> +	if (!len)
> +		return;
> +
> +	error("invalid remote mas instances (%u bytes left), aborting", len);
> +	exit(EXIT_FAILURE);
> +}
> +
>  static void handle_remote_mas_instances(void *buf, uint16_t len, int fd)
>  {
> +	struct hal_ev_map_client_remote_mas_instances *ev = buf;
> +	btmce_mas_instance_t instances[ev->num_instances];
> +
> +	DBG("");
> +
> +	len -= sizeof(*ev);
> +	remote_mas_instances_to_hal(instances, ev->instances, ev->num_instances,
> +									len);
>  
> +	if (cbs->remote_mas_instances_cb)
> +		cbs->remote_mas_instances_cb(ev->status,
> +						(bt_bdaddr_t *) ev->bdaddr,
> +						ev->num_instances, instances);
>  }
>  
>  /* handlers will be called from notification thread context,
> 

-- 
Best regards, 
Szymon Janc

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/6] android/hal-ipc-api: Add MCE HAL
  2014-09-22 11:01 [PATCH 1/6] android/hal-ipc-api: Add MCE HAL Grzegorz Kolodziejczyk
                   ` (6 preceding siblings ...)
  2014-10-03 11:17 ` Szymon Janc
@ 2014-10-03 11:38 ` Szymon Janc
  7 siblings, 0 replies; 12+ messages in thread
From: Szymon Janc @ 2014-10-03 11:38 UTC (permalink / raw)
  To: Grzegorz Kolodziejczyk; +Cc: linux-bluetooth

Hi Grzegorz,

On Monday 22 of September 2014 13:01:43 Grzegorz Kolodziejczyk wrote:
> ---
>  android/hal-ipc-api.txt | 51 +++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 51 insertions(+)
> 
> diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
> index f6e1680..38f75e6 100644
> --- a/android/hal-ipc-api.txt
> +++ b/android/hal-ipc-api.txt
> @@ -2396,3 +2396,54 @@ Notifications:
>  	Opcode 0x95 - Ring Indication notification
>  
>  		Notification parameters: <none>
> +
> +
> +Bluetooth MCE HAL (ID 11)
> +=========================
> +
> +Android HAL name: "map_client" (BT_PROFILE_MAP_CLIENT_ID)
> +
> +Structures:
> +
> +	MAS instance: Instance ID (1 octet)
> +	              Channel (1 octet)
> +	              Message type (1 octet)

One more note: those are defined as int in HAL so should be same in IPC.

> +	              Name (string)
> +
> +	Valid Message type: 0x01 = EMAIL
> +	                    0x02 = SMS_GSM
> +	                    0x04 = SMS_CDMA
> +	                    0x08 = MMS
> +
> +Commands and responses:
> +
> +	Opcode 0x00 - Error response
> +
> +		Response parameters: Status (1 octet)
> +
> +		Valid status values: 0x01 = Fail
> +		                     0x02 = Not ready
> +		                     0x03 = No memory
> +		                     0x04 = Busy
> +		                     0x05 = Done (already completed)
> +		                     0x06 = Unsupported
> +		                     0x07 = Parameter invalid
> +		                     0x08 = Unhandled
> +		                     0x09 = Authentication failure
> +		                     0x0a = Remote device down
> +
> +	Opcode 0x01 - Get Remote MAS Instances
> +
> +		Command parameters: Remote address (6 octets)
> +		Response parameters: <none>
> +
> +		In case of an error, the error response will be returned.
> +
> +Notifications:
> +
> +	Opcode 0x81 - Remote MAS Instances notification
> +
> +		Notification parameters: Status (1 octet)
> +		                         Remote address (6 octets)
> +		                         Number of instances (1 octet)
> +		                         MAS instance (variable)
> 

-- 
Best regards, 
Szymon Janc

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2014-10-03 11:38 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-22 11:01 [PATCH 1/6] android/hal-ipc-api: Add MCE HAL Grzegorz Kolodziejczyk
2014-09-22 11:01 ` [PATCH 2/6] android/hal-mce-api: Add get remote MAS instance command and event Grzegorz Kolodziejczyk
2014-09-22 11:01 ` [PATCH 3/6] android/mce: Add Android MCE header Grzegorz Kolodziejczyk
2014-09-22 11:01 ` [PATCH 4/6] android/hal-mce: Add skeleton for MCE HAL Grzegorz Kolodziejczyk
2014-10-03 11:26   ` Szymon Janc
2014-10-03 11:30     ` Grzegorz Kolodziejczyk
2014-09-22 11:01 ` [PATCH 5/6] android/hal-mce: Add event handler Grzegorz Kolodziejczyk
2014-10-03 11:34   ` Szymon Janc
2014-09-22 11:01 ` [PATCH 6/6] android/hal-mce: Add API calls Grzegorz Kolodziejczyk
2014-10-02 20:49 ` [PATCH 1/6] android/hal-ipc-api: Add MCE HAL Lukasz Rymanowski
2014-10-03 11:17 ` Szymon Janc
2014-10-03 11:38 ` Szymon Janc

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.