Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCHv2 1/4] android/hal-ipc-api: Update HidHost with Android 5 API
@ 2014-11-20 11:18 Jakub Tyszkowski
  2014-11-20 11:18 ` [PATCHv2 2/4] android/hal: Update HidHost HAL for Android 5 Jakub Tyszkowski
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Jakub Tyszkowski @ 2014-11-20 11:18 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jakub Tyszkowski

---
 android/hal-ipc-api.txt | 38 ++++++++++++++++++++++++--------------
 1 file changed, 24 insertions(+), 14 deletions(-)

diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
index 67a6205..efcd3cf 100644
--- a/android/hal-ipc-api.txt
+++ b/android/hal-ipc-api.txt
@@ -599,6 +599,23 @@ Commands and responses:
 
 Notifications:
 
+	Status is common for many notifications and has fixed value range:
+
+		Status values: 0x00 = Ok
+		               0x01 = Handshake - Device not ready
+		               0x02 = Handshake - Invalid report ID
+		               0x03 = Handshake - Transaction not SPT
+		               0x04 = Handshake - Invalid parameter
+		               0x05 = Handshake - Generic error
+		               0x06 = General error
+		               0x07 = SDP error
+		               0x08 = Set protocol error
+		               0x09 = Device database full
+		               0x0a = Device type not supported
+		               0x0b = No resources
+		               0x0c = Authentication failed
+		               0x0d = HDL
+
 	Opcode 0x81 - Connection State notification
 
 		Notification parameters: Remote address (6 octets)
@@ -656,20 +673,13 @@ Notifications:
 		Notification parameters: Remote address (6 octets)
 		                         Status (1 octet)
 
-		Valid status values: 0x00 = Ok
-		                     0x01 = Handshake - Device not ready
-		                     0x02 = Handshake - Invalid report ID
-		                     0x03 = Handshake - Transaction not SPT
-		                     0x04 = Handshake - Invalid parameter
-		                     0x05 = Handshake - Generic error
-		                     0x06 = General error
-		                     0x07 = SDP error
-		                     0x08 = Set protocol error
-		                     0x09 = Device database full
-		                     0x0a = Device type not supported
-		                     0x0b = No resources
-		                     0x0c = Authentication failed
-		                     0x0d = HDL
+	Opcode 0x87 - Handshake notification
+
+		Notification parameters: Remote address (6 octets)
+		                         Status (1 octet)
+
+		Only status values from 0x00 to 0x05 are valid as handshake
+		status.
 
 
 Bluetooth PAN HAL (ID 4)
-- 
1.9.1


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

* [PATCHv2 2/4] android/hal: Update HidHost HAL for Android 5
  2014-11-20 11:18 [PATCHv2 1/4] android/hal-ipc-api: Update HidHost with Android 5 API Jakub Tyszkowski
@ 2014-11-20 11:18 ` Jakub Tyszkowski
  2014-11-20 11:18 ` [PATCHv2 3/4] android/hid: Support handshake message Jakub Tyszkowski
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Jakub Tyszkowski @ 2014-11-20 11:18 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jakub Tyszkowski

---
 android/hal-hidhost.c | 11 +++++++++++
 android/hal-msg.h     | 24 ++++++++++++++++++++++--
 2 files changed, 33 insertions(+), 2 deletions(-)

diff --git a/android/hal-hidhost.c b/android/hal-hidhost.c
index 58b0218..3cfc6b6 100644
--- a/android/hal-hidhost.c
+++ b/android/hal-hidhost.c
@@ -102,6 +102,16 @@ static void handle_virtual_unplug(void *buf, uint16_t len, int fd)
 								ev->status);
 }
 
+static void handle_handshake(void *buf, uint16_t len, int fd)
+{
+#if ANDROID_VERSION >= PLATFORM_VER(5, 0, 0)
+	struct hal_ev_hidhost_handshake *ev = buf;
+
+	if (cbacks->handshake_cb)
+		cbacks->handshake_cb((bt_bdaddr_t *) ev->bdaddr, ev->status);
+#endif
+}
+
 /*
  * handlers will be called from notification thread context,
  * index in table equals to 'opcode - HAL_MINIMUM_EVENT'
@@ -120,6 +130,7 @@ static const struct hal_ipc_handler ev_handlers[] = {
 	/* HAL_EV_HIDHOST_VIRTUAL_UNPLUG */
 	{ handle_virtual_unplug, false,
 				sizeof(struct hal_ev_hidhost_virtual_unplug) },
+	{ handle_handshake, false, sizeof(struct hal_ev_hidhost_handshake) },
 };
 
 static bt_status_t hidhost_connect(bt_bdaddr_t *bd_addr)
diff --git a/android/hal-msg.h b/android/hal-msg.h
index c575938..ca512d4 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -1353,8 +1353,22 @@ struct hal_ev_hidhost_conn_state {
 	uint8_t state;
 } __attribute__((packed));
 
-#define HAL_HIDHOST_STATUS_OK		0x00
-#define HAL_HIDHOST_GENERAL_ERROR	0x06
+#define HAL_HIDHOST_STATUS_OK			0x00
+
+#define HAL_HIDHOST_HS_NOT_READY		0x01
+#define HAL_HIDHOST_HS_INVALID_RAPORT_ID	0x02
+#define HAL_HIDHOST_HS_TRANS_NOT_SUPPORTED	0x03
+#define HAL_HIDHOST_HS_INVALID_PARAM		0x04
+#define HAL_HIDHOST_HS_ERROR			0x05
+
+#define HAL_HIDHOST_GENERAL_ERROR		0x06
+#define HAL_HIDHOST_SDP_ERROR			0x07
+#define HAL_HIDHOST_PROTOCOL_ERROR		0x08
+#define HAL_HIDHOST_DB_ERROR			0x09
+#define HAL_HIDHOST_TOD_UNSUPPORTED_ERROR	0x0a
+#define HAL_HIDHOST_NO_RESOURCES_ERROR		0x0b
+#define HAL_HIDHOST_AUTH_FAILED_ERROR		0x0c
+#define HAL_HIDHOST_HDL_ERROR			0x0d
 
 #define HAL_EV_HIDHOST_INFO			0x82
 struct hal_ev_hidhost_info {
@@ -1398,6 +1412,12 @@ struct hal_ev_hidhost_virtual_unplug {
 	uint8_t  status;
 } __attribute__((packed));
 
+#define HAL_EV_HIDHOST_HANDSHAKE		0x87
+struct hal_ev_hidhost_handshake {
+	uint8_t  bdaddr[6];
+	uint8_t  status;
+} __attribute__((packed));
+
 #define HAL_EV_PAN_CTRL_STATE			0x81
 struct hal_ev_pan_ctrl_state {
 	uint8_t  state;
-- 
1.9.1


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

* [PATCHv2 3/4] android/hid: Support handshake message
  2014-11-20 11:18 [PATCHv2 1/4] android/hal-ipc-api: Update HidHost with Android 5 API Jakub Tyszkowski
  2014-11-20 11:18 ` [PATCHv2 2/4] android/hal: Update HidHost HAL for Android 5 Jakub Tyszkowski
@ 2014-11-20 11:18 ` Jakub Tyszkowski
  2014-11-20 11:18 ` [PATCHv2 4/4] android/client: Add handshake callback Jakub Tyszkowski
  2014-11-20 15:23 ` [PATCHv2 1/4] android/hal-ipc-api: Update HidHost with Android 5 API Szymon Janc
  3 siblings, 0 replies; 5+ messages in thread
From: Jakub Tyszkowski @ 2014-11-20 11:18 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jakub Tyszkowski

---
 android/hidhost.c | 32 ++++++++++++++++++++++++++++++--
 1 file changed, 30 insertions(+), 2 deletions(-)

diff --git a/android/hidhost.c b/android/hidhost.c
index 657fa8f..75e895b 100644
--- a/android/hidhost.c
+++ b/android/hidhost.c
@@ -58,6 +58,7 @@
 #define L2CAP_PSM_HIDP_INTR	0x13
 
 /* HID message types */
+#define HID_MSG_HANDSHAKE	0x00
 #define HID_MSG_CONTROL		0x10
 #define HID_MSG_GET_REPORT	0x40
 #define HID_MSG_SET_REPORT	0x50
@@ -65,6 +66,8 @@
 #define HID_MSG_SET_PROTOCOL	0x70
 #define HID_MSG_DATA		0xa0
 
+#define HID_MSG_TYPE_MASK	0xf0
+
 /* HID data types */
 #define HID_DATA_TYPE_INPUT	0x01
 #define HID_DATA_TYPE_OUTPUT	0x02
@@ -391,6 +394,22 @@ send:
 	g_free(ev);
 }
 
+static void bt_hid_notify_handshake(struct hid_device *dev, uint8_t *buf,
+									int len)
+{
+	struct hal_ev_hidhost_handshake ev;
+
+	bdaddr2android(&dev->dst, ev.bdaddr);
+
+	/* crop result code to handshake status range from HAL */
+	ev.status = buf[0];
+	if (ev.status > HAL_HIDHOST_HS_ERROR)
+		ev.status = HAL_HIDHOST_HS_ERROR;
+
+	ipc_send_notif(hal_ipc, HAL_SERVICE_ID_HIDHOST,
+				HAL_EV_HIDHOST_HANDSHAKE, sizeof(ev), &ev);
+}
+
 static void bt_hid_notify_virtual_unplug(struct hid_device *dev,
 							uint8_t *buf, int len)
 {
@@ -441,8 +460,17 @@ static gboolean ctrl_io_watch_cb(GIOChannel *chan, gpointer data)
 		break;
 	}
 
-	if (buf[0] == (HID_MSG_CONTROL | HID_VIRTUAL_CABLE_UNPLUG))
-		bt_hid_notify_virtual_unplug(dev, buf, bread);
+	switch (buf[0] & HID_MSG_TYPE_MASK) {
+	case HID_MSG_HANDSHAKE:
+		bt_hid_notify_handshake(dev, buf, bread);
+		break;
+	case HID_MSG_CONTROL:
+		if ((buf[0] & !HID_MSG_TYPE_MASK) == HID_VIRTUAL_CABLE_UNPLUG)
+			bt_hid_notify_virtual_unplug(dev, buf, bread);
+		break;
+	default:
+		break;
+	}
 
 	/* reset msg type request */
 	dev->last_hid_msg = 0;
-- 
1.9.1


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

* [PATCHv2 4/4] android/client: Add handshake callback
  2014-11-20 11:18 [PATCHv2 1/4] android/hal-ipc-api: Update HidHost with Android 5 API Jakub Tyszkowski
  2014-11-20 11:18 ` [PATCHv2 2/4] android/hal: Update HidHost HAL for Android 5 Jakub Tyszkowski
  2014-11-20 11:18 ` [PATCHv2 3/4] android/hid: Support handshake message Jakub Tyszkowski
@ 2014-11-20 11:18 ` Jakub Tyszkowski
  2014-11-20 15:23 ` [PATCHv2 1/4] android/hal-ipc-api: Update HidHost with Android 5 API Szymon Janc
  3 siblings, 0 replies; 5+ messages in thread
From: Jakub Tyszkowski @ 2014-11-20 11:18 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jakub Tyszkowski

---
 android/client/if-hh.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/android/client/if-hh.c b/android/client/if-hh.c
index b2bf8ca..25519e5 100644
--- a/android/client/if-hh.c
+++ b/android/client/if-hh.c
@@ -100,6 +100,18 @@ static void virtual_unplug_cb(bt_bdaddr_t *bd_addr, bthh_status_t hh_status)
 						bthh_status_t2str(hh_status));
 }
 
+/* Callback for Android 5.0 handshake api. */
+#if ANDROID_VERSION >= PLATFORM_VER(5, 0, 0)
+static void handshake_cb(bt_bdaddr_t *bd_addr, bthh_status_t hh_status)
+{
+	char addr[MAX_ADDR_STR_LEN];
+
+	haltest_info("%s: bd_addr=%s hh_status=%s\n", __func__,
+						bt_bdaddr_t2str(bd_addr, addr),
+						bthh_status_t2str(hh_status));
+}
+#endif
+
 /*
  * Callback for get hid info
  * hid_info will contain attr_mask, sub_class, app_id, vendor_id, product_id,
@@ -163,7 +175,10 @@ static bthh_callbacks_t bthh_callbacks = {
 	.protocol_mode_cb = protocol_mode_cb,
 	.idle_time_cb = idle_time_cb,
 	.get_report_cb = get_report_cb,
-	.virtual_unplug_cb = virtual_unplug_cb
+	.virtual_unplug_cb = virtual_unplug_cb,
+#if ANDROID_VERSION >= PLATFORM_VER(5, 0, 0)
+	.handshake_cb = handshake_cb
+#endif
 };
 
 /* init */
-- 
1.9.1


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

* Re: [PATCHv2 1/4] android/hal-ipc-api: Update HidHost with Android 5 API
  2014-11-20 11:18 [PATCHv2 1/4] android/hal-ipc-api: Update HidHost with Android 5 API Jakub Tyszkowski
                   ` (2 preceding siblings ...)
  2014-11-20 11:18 ` [PATCHv2 4/4] android/client: Add handshake callback Jakub Tyszkowski
@ 2014-11-20 15:23 ` Szymon Janc
  3 siblings, 0 replies; 5+ messages in thread
From: Szymon Janc @ 2014-11-20 15:23 UTC (permalink / raw)
  To: Jakub Tyszkowski; +Cc: linux-bluetooth

Hi Jakub,

On Thursday 20 of November 2014 12:18:48 Jakub Tyszkowski wrote:
> ---
>  android/hal-ipc-api.txt | 38 ++++++++++++++++++++++++--------------
>  1 file changed, 24 insertions(+), 14 deletions(-)
> 
> diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
> index 67a6205..efcd3cf 100644
> --- a/android/hal-ipc-api.txt
> +++ b/android/hal-ipc-api.txt
> @@ -599,6 +599,23 @@ Commands and responses:
>  
>  Notifications:
>  
> +	Status is common for many notifications and has fixed value range:
> +
> +		Status values: 0x00 = Ok
> +		               0x01 = Handshake - Device not ready
> +		               0x02 = Handshake - Invalid report ID
> +		               0x03 = Handshake - Transaction not SPT
> +		               0x04 = Handshake - Invalid parameter
> +		               0x05 = Handshake - Generic error
> +		               0x06 = General error
> +		               0x07 = SDP error
> +		               0x08 = Set protocol error
> +		               0x09 = Device database full
> +		               0x0a = Device type not supported
> +		               0x0b = No resources
> +		               0x0c = Authentication failed
> +		               0x0d = HDL
> +
>  	Opcode 0x81 - Connection State notification
>  
>  		Notification parameters: Remote address (6 octets)
> @@ -656,20 +673,13 @@ Notifications:
>  		Notification parameters: Remote address (6 octets)
>  		                         Status (1 octet)
>  
> -		Valid status values: 0x00 = Ok
> -		                     0x01 = Handshake - Device not ready
> -		                     0x02 = Handshake - Invalid report ID
> -		                     0x03 = Handshake - Transaction not SPT
> -		                     0x04 = Handshake - Invalid parameter
> -		                     0x05 = Handshake - Generic error
> -		                     0x06 = General error
> -		                     0x07 = SDP error
> -		                     0x08 = Set protocol error
> -		                     0x09 = Device database full
> -		                     0x0a = Device type not supported
> -		                     0x0b = No resources
> -		                     0x0c = Authentication failed
> -		                     0x0d = HDL
> +	Opcode 0x87 - Handshake notification
> +
> +		Notification parameters: Remote address (6 octets)
> +		                         Status (1 octet)
> +
> +		Only status values from 0x00 to 0x05 are valid as handshake
> +		status.
>  
>  
>  Bluetooth PAN HAL (ID 4)

All patches applied, thanks. 

-- 
Best regards, 
Szymon Janc

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

end of thread, other threads:[~2014-11-20 15:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-20 11:18 [PATCHv2 1/4] android/hal-ipc-api: Update HidHost with Android 5 API Jakub Tyszkowski
2014-11-20 11:18 ` [PATCHv2 2/4] android/hal: Update HidHost HAL for Android 5 Jakub Tyszkowski
2014-11-20 11:18 ` [PATCHv2 3/4] android/hid: Support handshake message Jakub Tyszkowski
2014-11-20 11:18 ` [PATCHv2 4/4] android/client: Add handshake callback Jakub Tyszkowski
2014-11-20 15:23 ` [PATCHv2 1/4] android/hal-ipc-api: Update HidHost with Android 5 API Szymon Janc

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox