linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] android/gatt: Add support for new API
@ 2014-11-05  9:53 Andrei Emeltchenko
  2014-11-05  9:53 ` [PATCH 2/3] android/gatt: Add support for new parameter for connect Andrei Emeltchenko
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Andrei Emeltchenko @ 2014-11-05  9:53 UTC (permalink / raw)
  To: linux-bluetooth

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

In new Android API client_if parameter is removed.
---
 android/gatt.c     | 14 ++++++++------
 android/hal-gatt.c | 14 +++++++++++++-
 2 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/android/gatt.c b/android/gatt.c
index b3dd6d3..5a531d9 100644
--- a/android/gatt.c
+++ b/android/gatt.c
@@ -1730,15 +1730,17 @@ static void handle_client_scan(const void *buf, uint16_t len)
 {
 	const struct hal_cmd_gatt_client_scan *cmd = buf;
 	uint8_t status;
-	void *registered;
 
 	DBG("new state %d", cmd->start);
 
-	registered = find_app_by_id(cmd->client_if);
-	if (!registered) {
-		error("gatt: Client not registered");
-		status = HAL_STATUS_FAILED;
-		goto reply;
+	if (cmd->client_if != 0) {
+		void *registered = find_app_by_id(cmd->client_if);
+
+		if (!registered) {
+			error("gatt: Client not registered");
+			status = HAL_STATUS_FAILED;
+			goto reply;
+		}
 	}
 
 	/* Turn off scan */
diff --git a/android/hal-gatt.c b/android/hal-gatt.c
index c563fe9..080852a 100644
--- a/android/hal-gatt.c
+++ b/android/hal-gatt.c
@@ -595,7 +595,7 @@ static bt_status_t unregister_client(int client_if)
 					sizeof(cmd), &cmd, NULL, NULL, NULL);
 }
 
-static bt_status_t scan(int client_if, bool start)
+static bt_status_t scan_real(int client_if, bool start)
 {
 	struct hal_cmd_gatt_client_scan cmd;
 
@@ -609,6 +609,18 @@ static bt_status_t scan(int client_if, bool start)
 					sizeof(cmd), &cmd, NULL, NULL, NULL);
 }
 
+#if ANDROID_VERSION >= PLATFORM_VER(5, 0, 0)
+static bt_status_t scan(bool start)
+{
+	return scan_real(0, start);
+}
+#else
+static bt_status_t scan(int client_if, bool start)
+{
+	return scan_real(client_if, start);
+}
+#endif
+
 static bt_status_t connect(int client_if, const bt_bdaddr_t *bd_addr,
 								bool is_direct)
 {
-- 
1.9.1


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

* [PATCH 2/3] android/gatt: Add support for new parameter for connect
  2014-11-05  9:53 [PATCH 1/3] android/gatt: Add support for new API Andrei Emeltchenko
@ 2014-11-05  9:53 ` Andrei Emeltchenko
  2014-11-05  9:53 ` [PATCH 3/3] android/gatt: Add support for new parameter in srv connect() Andrei Emeltchenko
  2014-11-05 20:51 ` [PATCH 1/3] android/gatt: Add support for new API Szymon Janc
  2 siblings, 0 replies; 4+ messages in thread
From: Andrei Emeltchenko @ 2014-11-05  9:53 UTC (permalink / raw)
  To: linux-bluetooth

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

Add support for new parameter in gatt client connect() for new Android
API.
---
 android/gatt.c          |  2 ++
 android/hal-gatt.c      | 20 ++++++++++++++++++--
 android/hal-ipc-api.txt |  1 +
 android/hal-msg.h       |  1 +
 4 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/android/gatt.c b/android/gatt.c
index 5a531d9..e930b5a 100644
--- a/android/gatt.c
+++ b/android/gatt.c
@@ -2066,6 +2066,8 @@ static void handle_client_connect(const void *buf, uint16_t len)
 
 	/* TODO handle is_direct flag */
 
+	/* TODO handle transport flag */
+
 	status = handle_connect(cmd->client_if, &addr);
 
 	ipc_send_rsp(hal_ipc, HAL_SERVICE_ID_GATT, HAL_OP_GATT_CLIENT_CONNECT,
diff --git a/android/hal-gatt.c b/android/hal-gatt.c
index 080852a..82093fa 100644
--- a/android/hal-gatt.c
+++ b/android/hal-gatt.c
@@ -621,8 +621,8 @@ static bt_status_t scan(int client_if, bool start)
 }
 #endif
 
-static bt_status_t connect(int client_if, const bt_bdaddr_t *bd_addr,
-								bool is_direct)
+static bt_status_t connect_real(int client_if, const bt_bdaddr_t *bd_addr,
+						bool is_direct, int transport)
 {
 	struct hal_cmd_gatt_client_connect cmd;
 
@@ -631,6 +631,7 @@ static bt_status_t connect(int client_if, const bt_bdaddr_t *bd_addr,
 
 	cmd.client_if = client_if;
 	cmd.is_direct = is_direct;
+	cmd.transport = transport;
 
 	memcpy(cmd.bdaddr, bd_addr, sizeof(*bd_addr));
 
@@ -638,6 +639,21 @@ static bt_status_t connect(int client_if, const bt_bdaddr_t *bd_addr,
 					sizeof(cmd), &cmd, NULL, NULL, NULL);
 }
 
+#if ANDROID_VERSION >= PLATFORM_VER(5, 0, 0)
+static bt_status_t connect(int client_if, const bt_bdaddr_t *bd_addr,
+						bool is_direct, int transport)
+{
+	return connect_real(client_if, bd_addr, is_direct, transport);
+}
+#else
+static bt_status_t connect(int client_if, const bt_bdaddr_t *bd_addr,
+								bool is_direct)
+{
+	return connect_real(client_if, bd_addr, is_direct,
+							BT_TRANSPORT_UNKNOWN);
+}
+#endif
+
 static bt_status_t disconnect(int client_if, const bt_bdaddr_t *bd_addr,
 								int conn_id)
 {
diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
index 3a3ae92..d6e68f1 100644
--- a/android/hal-ipc-api.txt
+++ b/android/hal-ipc-api.txt
@@ -1522,6 +1522,7 @@ Commands and responses:
 		Command parameters: Client Interface (4 octets)
 		                    Remote address (6 octets)
 		                    Is Direct (1 octet)
+		                    Transport (4 octets)
 		Response parameters: <none>
 
 		In case of an error, the error response will be returned.
diff --git a/android/hal-msg.h b/android/hal-msg.h
index bcb73b2..8dd00a0 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -721,6 +721,7 @@ struct hal_cmd_gatt_client_connect {
 	int32_t client_if;
 	uint8_t bdaddr[6];
 	uint8_t is_direct;
+	int32_t transport;
 } __attribute__((packed));
 
 #define HAL_OP_GATT_CLIENT_DISCONNECT		0x05
-- 
1.9.1


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

* [PATCH 3/3] android/gatt: Add support for new parameter in srv connect()
  2014-11-05  9:53 [PATCH 1/3] android/gatt: Add support for new API Andrei Emeltchenko
  2014-11-05  9:53 ` [PATCH 2/3] android/gatt: Add support for new parameter for connect Andrei Emeltchenko
@ 2014-11-05  9:53 ` Andrei Emeltchenko
  2014-11-05 20:51 ` [PATCH 1/3] android/gatt: Add support for new API Szymon Janc
  2 siblings, 0 replies; 4+ messages in thread
From: Andrei Emeltchenko @ 2014-11-05  9:53 UTC (permalink / raw)
  To: linux-bluetooth

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

Support transport parameter in new Android API.
---
 android/gatt.c          |  2 ++
 android/hal-gatt.c      | 21 +++++++++++++++++++--
 android/hal-ipc-api.txt |  1 +
 android/hal-msg.h       |  1 +
 4 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/android/gatt.c b/android/gatt.c
index e930b5a..7cf612f 100644
--- a/android/gatt.c
+++ b/android/gatt.c
@@ -4184,6 +4184,8 @@ static void handle_server_connect(const void *buf, uint16_t len)
 
 	android2bdaddr(&cmd->bdaddr, &addr);
 
+	/* TODO: Handle transport flag */
+
 	status = handle_connect(cmd->server_if, &addr);
 
 	ipc_send_rsp(hal_ipc, HAL_SERVICE_ID_GATT, HAL_OP_GATT_SERVER_CONNECT,
diff --git a/android/hal-gatt.c b/android/hal-gatt.c
index 82093fa..a324009 100644
--- a/android/hal-gatt.c
+++ b/android/hal-gatt.c
@@ -1136,8 +1136,9 @@ static bt_status_t unregister_server(int server_if)
 					sizeof(cmd), &cmd, NULL, NULL, NULL);
 }
 
-static bt_status_t server_connect(int server_if, const bt_bdaddr_t *bd_addr,
-								bool is_direct)
+static bt_status_t server_connect_real(int server_if,
+						const bt_bdaddr_t *bd_addr,
+						bool is_direct, int transport)
 {
 	struct hal_cmd_gatt_server_connect cmd;
 
@@ -1146,6 +1147,7 @@ static bt_status_t server_connect(int server_if, const bt_bdaddr_t *bd_addr,
 
 	cmd.server_if = server_if;
 	cmd.is_direct = is_direct;
+	cmd.transport = transport;
 
 	memcpy(cmd.bdaddr, bd_addr, sizeof(*bd_addr));
 
@@ -1153,6 +1155,21 @@ static bt_status_t server_connect(int server_if, const bt_bdaddr_t *bd_addr,
 					sizeof(cmd), &cmd, NULL, NULL, NULL);
 }
 
+#if ANDROID_VERSION >= PLATFORM_VER(5, 0, 0)
+static bt_status_t server_connect(int server_if, const bt_bdaddr_t *bd_addr,
+						bool is_direct, int transport)
+{
+	return server_connect_real(server_if, bd_addr, is_direct, transport);
+}
+#else
+static bt_status_t server_connect(int server_if, const bt_bdaddr_t *bd_addr,
+								bool is_direct)
+{
+	return server_connect_real(server_if, bd_addr, is_direct,
+							BT_TRANSPORT_UNKNOWN);
+}
+#endif
+
 static bt_status_t server_disconnect(int server_if, const bt_bdaddr_t *bd_addr,
 								int conn_id)
 {
diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
index d6e68f1..1bb591a 100644
--- a/android/hal-ipc-api.txt
+++ b/android/hal-ipc-api.txt
@@ -1756,6 +1756,7 @@ Commands and responses:
 		Command parameters: Server (4 octets)
 		                    Remote address (6 octes)
 		                    Is Direct (1 octet)
+		                    Transport (4 octets)
 		Response parameters: <none>
 
 		In case of an error, the error response will be returned.
diff --git a/android/hal-msg.h b/android/hal-msg.h
index 8dd00a0..1876d6b 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -919,6 +919,7 @@ struct hal_cmd_gatt_server_connect {
 	int32_t server_if;
 	uint8_t bdaddr[6];
 	uint8_t is_direct;
+	int32_t transport;
 } __attribute__((packed));
 
 #define HAL_OP_GATT_SERVER_DISCONNECT		0x1a
-- 
1.9.1


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

* Re: [PATCH 1/3] android/gatt: Add support for new API
  2014-11-05  9:53 [PATCH 1/3] android/gatt: Add support for new API Andrei Emeltchenko
  2014-11-05  9:53 ` [PATCH 2/3] android/gatt: Add support for new parameter for connect Andrei Emeltchenko
  2014-11-05  9:53 ` [PATCH 3/3] android/gatt: Add support for new parameter in srv connect() Andrei Emeltchenko
@ 2014-11-05 20:51 ` Szymon Janc
  2 siblings, 0 replies; 4+ messages in thread
From: Szymon Janc @ 2014-11-05 20:51 UTC (permalink / raw)
  To: Andrei Emeltchenko; +Cc: linux-bluetooth

Hi Andrei,

On Wednesday 05 of November 2014 11:53:35 Andrei Emeltchenko wrote:
> From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> 
> In new Android API client_if parameter is removed.
> ---
>  android/gatt.c     | 14 ++++++++------
>  android/hal-gatt.c | 14 +++++++++++++-
>  2 files changed, 21 insertions(+), 7 deletions(-)
> 
> diff --git a/android/gatt.c b/android/gatt.c
> index b3dd6d3..5a531d9 100644
> --- a/android/gatt.c
> +++ b/android/gatt.c
> @@ -1730,15 +1730,17 @@ static void handle_client_scan(const void *buf,
> uint16_t len) {
>  	const struct hal_cmd_gatt_client_scan *cmd = buf;
>  	uint8_t status;
> -	void *registered;
> 
>  	DBG("new state %d", cmd->start);
> 
> -	registered = find_app_by_id(cmd->client_if);
> -	if (!registered) {
> -		error("gatt: Client not registered");
> -		status = HAL_STATUS_FAILED;
> -		goto reply;
> +	if (cmd->client_if != 0) {
> +		void *registered = find_app_by_id(cmd->client_if);
> +
> +		if (!registered) {
> +			error("gatt: Client not registered");
> +			status = HAL_STATUS_FAILED;
> +			goto reply;
> +		}
>  	}
> 
>  	/* Turn off scan */
> diff --git a/android/hal-gatt.c b/android/hal-gatt.c
> index c563fe9..080852a 100644
> --- a/android/hal-gatt.c
> +++ b/android/hal-gatt.c
> @@ -595,7 +595,7 @@ static bt_status_t unregister_client(int client_if)
>  					sizeof(cmd), &cmd, NULL, NULL, NULL);
>  }
> 
> -static bt_status_t scan(int client_if, bool start)
> +static bt_status_t scan_real(int client_if, bool start)
>  {
>  	struct hal_cmd_gatt_client_scan cmd;
> 
> @@ -609,6 +609,18 @@ static bt_status_t scan(int client_if, bool start)
>  					sizeof(cmd), &cmd, NULL, NULL, NULL);
>  }
> 
> +#if ANDROID_VERSION >= PLATFORM_VER(5, 0, 0)
> +static bt_status_t scan(bool start)
> +{
> +	return scan_real(0, start);
> +}
> +#else
> +static bt_status_t scan(int client_if, bool start)
> +{
> +	return scan_real(client_if, start);
> +}
> +#endif
> +
>  static bt_status_t connect(int client_if, const bt_bdaddr_t *bd_addr,
>  								bool is_direct)
>  {

All patches applied, thanks.

-- 
BR
Szymon Janc

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

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

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-05  9:53 [PATCH 1/3] android/gatt: Add support for new API Andrei Emeltchenko
2014-11-05  9:53 ` [PATCH 2/3] android/gatt: Add support for new parameter for connect Andrei Emeltchenko
2014-11-05  9:53 ` [PATCH 3/3] android/gatt: Add support for new parameter in srv connect() Andrei Emeltchenko
2014-11-05 20:51 ` [PATCH 1/3] android/gatt: Add support for new 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;
as well as URLs for NNTP newsgroup(s).