All of lore.kernel.org
 help / color / mirror / Atom feed
From: Szymon Janc <szymon.janc@tieto.com>
To: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH 1/3] android/gatt: Add support for direct connect
Date: Thu, 05 Mar 2015 16:59:30 +0100	[thread overview]
Message-ID: <4194893.WTandXkbt4@leonov> (raw)
In-Reply-To: <1425556666-9868-1-git-send-email-szymon.janc@tieto.com>

On Thursday 05 of March 2015 12:57:44 Szymon Janc wrote:
> Don't use kernel auto connect if direct connect is requested by Android
> Framework. This is required to be able to connect to non-bonded devices
> that are using RPA.
> ---
>  android/gatt.c | 25 +++++++++++++------------
>  1 file changed, 13 insertions(+), 12 deletions(-)
> 
> diff --git a/android/gatt.c b/android/gatt.c
> index e6b0753..638786d 100644
> --- a/android/gatt.c
> +++ b/android/gatt.c
> @@ -1928,7 +1928,7 @@ static int connect_bredr(struct gatt_device *dev)
>  	return 0;
>  }
> 
> -static bool trigger_connection(struct app_connection *conn)
> +static bool trigger_connection(struct app_connection *conn, bool direct)
>  {
>  	bool ret;
> 
> @@ -1942,8 +1942,11 @@ static bool trigger_connection(struct app_connection
> *conn) BDADDR_BREDR)
>  			return connect_bredr(conn->device) == 0;
> 
> -		/* For LE use auto connect feature */
> -		ret = auto_connect_le(conn->device);
> +		if (direct)
> +			ret = connect_le(conn->device) == 0;
> +		else
> +			ret = auto_connect_le(conn->device);
> +
>  		if (ret)
>  			device_set_state(conn->device, DEVICE_CONNECT_INIT);
>  		break;
> @@ -2103,7 +2106,7 @@ reply:
>  					HAL_OP_GATT_CLIENT_UNREGISTER, status);
>  }
> 
> -static uint8_t handle_connect(int32_t app_id, const bdaddr_t *addr)
> +static uint8_t handle_connect(int32_t app_id, const bdaddr_t *addr, bool
> direct) {
>  	struct app_connection conn_match;
>  	struct app_connection *conn;
> @@ -2134,7 +2137,7 @@ static uint8_t handle_connect(int32_t app_id, const
> bdaddr_t *addr) return HAL_STATUS_NOMEM;
>  	}
> 
> -	if (!trigger_connection(conn))
> +	if (!trigger_connection(conn, direct))
>  		return HAL_STATUS_FAILED;
> 
>  	return HAL_STATUS_SUCCESS;
> @@ -2146,15 +2149,13 @@ static void handle_client_connect(const void *buf,
> uint16_t len) uint8_t status;
>  	bdaddr_t addr;
> 
> -	DBG("");
> +	DBG("is_direct:%u transport:%u", cmd->is_direct, cmd->transport);
> 
>  	android2bdaddr(&cmd->bdaddr, &addr);
> 
> -	/* TODO handle is_direct flag */
> -
>  	/* TODO handle transport flag */
> 
> -	status = handle_connect(cmd->client_if, &addr);
> +	status = handle_connect(cmd->client_if, &addr, cmd->is_direct);
> 
>  	ipc_send_rsp(hal_ipc, HAL_SERVICE_ID_GATT, HAL_OP_GATT_CLIENT_CONNECT,
>  								status);
> @@ -4211,7 +4212,7 @@ static void handle_client_test_command(const void
> *buf, uint16_t len) break;
>  	case GATT_CLIENT_TEST_CMD_CONNECT:
>  		/* TODO u1 holds device type, for now assume BLE */
> -		status = handle_connect(test_client_if, &bdaddr);
> +		status = handle_connect(test_client_if, &bdaddr, false);
>  		break;
>  	case GATT_CLIENT_TEST_CMD_DISCONNECT:
>  		app = queue_find(gatt_apps, match_app_by_id,
> @@ -4295,7 +4296,7 @@ static void handle_server_connect(const void *buf,
> uint16_t len)
> 
>  	/* TODO: Handle transport flag */
> 
> -	status = handle_connect(cmd->server_if, &addr);
> +	status = handle_connect(cmd->server_if, &addr, cmd->is_direct);
> 
>  	ipc_send_rsp(hal_ipc, HAL_SERVICE_ID_GATT, HAL_OP_GATT_SERVER_CONNECT,
>  								status);
> @@ -7350,7 +7351,7 @@ bool bt_gatt_connect_app(unsigned int id, const
> bdaddr_t *addr) {
>  	uint8_t status;
> 
> -	status = handle_connect(id, addr);
> +	status = handle_connect(id, addr, false);
> 
>  	return status != HAL_STATUS_FAILED;
>  }

Applied.

-- 
BR
Szymon Janc

      parent reply	other threads:[~2015-03-05 15:59 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-05 11:57 [PATCH 1/3] android/gatt: Add support for direct connect Szymon Janc
2015-03-05 11:57 ` [PATCH 2/3] android/bluetooth: Remove address type from BT callbacks Szymon Janc
2015-03-05 11:57 ` [PATCH 3/3] android/gatt: Handle device state in connect functions Szymon Janc
2015-03-05 15:59 ` Szymon Janc [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4194893.WTandXkbt4@leonov \
    --to=szymon.janc@tieto.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.