2013-11-08 15:48:28

by Lukasz Rymanowski

[permalink] [raw]
Subject: [PATCH 0/3] Fixes for incoming connection and bonding

With those patches it is possible to bond from remote device and in addition
you will see the name of remote device on Android pairing request pop up.

Lukasz Rymanowski (3):
android: Update bond state on incoming bonding
android: Update HAL with device info on incoming connection
android: Change TODO with explaining comment

android/adapter.c | 36 +++++++++++++++++++++++++++++-------
1 file changed, 29 insertions(+), 7 deletions(-)

--
1.8.4



2013-11-11 23:19:03

by Marcel Holtmann

[permalink] [raw]
Subject: Re: [PATCH 1/3] android: Update bond state on incoming bonding

Hi Lukasz,

>>> Before sending any ssp request or pin code request up to HAL library we
>>> need to send bond state change with bonding state. Otherwise incoming
>>> bonding is impossible.
>>> ---
>>> android/adapter.c | 21 ++++++++++++++++++---
>>> 1 file changed, 18 insertions(+), 3 deletions(-)
>>
>> Wont this cause HAL_BOND_STATE_BONDING to be sent twice if the pairing
>> was locally initiated through create_bond()?
>
> Well, of course we could try to keep track our local bond state and
> send HAL_BOND_STATE_BONDING in smarter way, but we don't need to. It
> is not a problem for Android to handle HAL_BOND_STATE_BONDING twice.
> Actually It works like this even now with current BT stack.
> And of course we need to send this event up as soon as we start
> bonding procedure, so it should stay in create_bond().

I think we should keep track of our bond state internally. I get the feeling we will need that eventually anyway. For example we already know that we need to keep a mapping of BD_ADDR to address types to make LE work.

Regards

Marcel


2013-11-11 22:23:27

by Lukasz Rymanowski

[permalink] [raw]
Subject: Re: [PATCH 1/3] android: Update bond state on incoming bonding

Hi Johan,

On Mon, Nov 11, 2013 at 9:37 AM, Johan Hedberg <[email protected]> wrote:
> Hi Lukasz,
>
> On Fri, Nov 08, 2013, Lukasz Rymanowski wrote:
>> Before sending any ssp request or pin code request up to HAL library we
>> need to send bond state change with bonding state. Otherwise incoming
>> bonding is impossible.
>> ---
>> android/adapter.c | 21 ++++++++++++++++++---
>> 1 file changed, 18 insertions(+), 3 deletions(-)
>
> Wont this cause HAL_BOND_STATE_BONDING to be sent twice if the pairing
> was locally initiated through create_bond()?

Well, of course we could try to keep track our local bond state and
send HAL_BOND_STATE_BONDING in smarter way, but we don't need to. It
is not a problem for Android to handle HAL_BOND_STATE_BONDING twice.
Actually It works like this even now with current BT stack.
And of course we need to send this event up as soon as we start
bonding procedure, so it should stay in create_bond().

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

\Ɓukasz

2013-11-11 08:37:35

by Johan Hedberg

[permalink] [raw]
Subject: Re: [PATCH 1/3] android: Update bond state on incoming bonding

Hi Lukasz,

On Fri, Nov 08, 2013, Lukasz Rymanowski wrote:
> Before sending any ssp request or pin code request up to HAL library we
> need to send bond state change with bonding state. Otherwise incoming
> bonding is impossible.
> ---
> android/adapter.c | 21 ++++++++++++++++++---
> 1 file changed, 18 insertions(+), 3 deletions(-)

Wont this cause HAL_BOND_STATE_BONDING to be sent twice if the pairing
was locally initiated through create_bond()?

Johan

2013-11-08 15:48:31

by Lukasz Rymanowski

[permalink] [raw]
Subject: [PATCH 3/3] android: Change TODO with explaining comment

---
android/adapter.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/android/adapter.c b/android/adapter.c
index cd820df..cb25954 100644
--- a/android/adapter.c
+++ b/android/adapter.c
@@ -509,7 +509,10 @@ static void pin_code_request_callback(uint16_t index, uint16_t length,

DBG("%s type %u secure %u", dst, ev->addr.type, ev->secure);

- /* TODO name and CoD of remote devices should probably be cached */
+ /* It is ok to have empty name and CoD of remote devices here since
+ * those information has been already provided on device_connected event
+ * or during device scaning. Android will use that instead.
+ */
memset(&hal_ev, 0, sizeof(hal_ev));
bdaddr2android(&ev->addr.bdaddr, hal_ev.bdaddr);

@@ -522,7 +525,10 @@ static void send_ssp_request(const bdaddr_t *addr, uint8_t variant,
{
struct hal_ev_ssp_request ev;

- /* TODO name and CoD of remote devices should probably be cached */
+ /* It is ok to have empty name and CoD of remote devices here since
+ * those information has been already provided on device_connected event
+ * or during device scaning. Android will use that instead.
+ */
memset(&ev, 0, sizeof(ev));
bdaddr2android(addr, ev.bdaddr);
ev.pairing_variant = variant;
--
1.8.4


2013-11-08 15:48:29

by Lukasz Rymanowski

[permalink] [raw]
Subject: [PATCH 1/3] android: Update bond state on incoming bonding

Before sending any ssp request or pin code request up to HAL library we
need to send bond state change with bonding state. Otherwise incoming
bonding is impossible.
---
android/adapter.c | 21 ++++++++++++++++++---
1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/android/adapter.c b/android/adapter.c
index 65b3170..d63352e 100644
--- a/android/adapter.c
+++ b/android/adapter.c
@@ -501,6 +501,10 @@ static void pin_code_request_callback(uint16_t index, uint16_t length,
return;
}

+ /* Update bonding state */
+ send_bond_state_change(&ev->addr.bdaddr, HAL_STATUS_SUCCESS,
+ HAL_BOND_STATE_BONDING);
+
ba2str(&ev->addr.bdaddr, dst);

DBG("%s type %u secure %u", dst, ev->addr.type, ev->secure);
@@ -542,6 +546,10 @@ static void user_confirm_request_callback(uint16_t index, uint16_t length,
ba2str(&ev->addr.bdaddr, dst);
DBG("%s confirm_hint %u", dst, ev->confirm_hint);

+ /* Update bonding state */
+ send_bond_state_change(&ev->addr.bdaddr, HAL_STATUS_SUCCESS,
+ HAL_BOND_STATE_BONDING);
+
if (ev->confirm_hint)
send_ssp_request(&ev->addr.bdaddr, HAL_SSP_VARIANT_CONSENT, 0);
else
@@ -563,6 +571,10 @@ static void user_passkey_request_callback(uint16_t index, uint16_t length,
ba2str(&ev->addr.bdaddr, dst);
DBG("%s", dst);

+ /* Update bonding state */
+ send_bond_state_change(&ev->addr.bdaddr, HAL_STATUS_SUCCESS,
+ HAL_BOND_STATE_BONDING);
+
send_ssp_request(&ev->addr.bdaddr, HAL_SSP_VARIANT_ENTRY, 0);
}

@@ -581,9 +593,14 @@ static void user_passkey_notify_callback(uint16_t index, uint16_t length,
DBG("%s entered %u", dst, ev->entered);

/* HAL seems to not support entered characters */
- if (!ev->entered)
+ if (!ev->entered) {
+ /* Update bonding state */
+ send_bond_state_change(&ev->addr.bdaddr, HAL_STATUS_SUCCESS,
+ HAL_BOND_STATE_BONDING);
+
send_ssp_request(&ev->addr.bdaddr, HAL_SSP_VARIANT_NOTIF,
ev->passkey);
+ }
}

static void mgmt_discovering_event(uint16_t index, uint16_t length,
@@ -827,8 +844,6 @@ static void mgmt_device_connected_event(uint16_t index, uint16_t length,

/* TODO: Update device */

- /* TODO: Check Set bonding state */
-
hal_ev.status = HAL_STATUS_SUCCESS;
hal_ev.state = HAL_ACL_STATE_CONNECTED;
bdaddr2android(&ev->addr.bdaddr, hal_ev.bdaddr);
--
1.8.4


2013-11-08 15:48:30

by Lukasz Rymanowski

[permalink] [raw]
Subject: [PATCH 2/3] android: Update HAL with device info on incoming connection

Make sure Android have information about connecting remote device. This
is needed for example to show device name on incoming bonding request.
---
android/adapter.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/android/adapter.c b/android/adapter.c
index d63352e..cd820df 100644
--- a/android/adapter.c
+++ b/android/adapter.c
@@ -842,8 +842,9 @@ static void mgmt_device_connected_event(uint16_t index, uint16_t length,
return;
}

- /* TODO: Update device */
-
+ /* Update HAL library with device info */
+ update_found_device(&ev->addr.bdaddr, ev->addr.type, 0, false,
+ &ev->eir[0], btohs(ev->eir_len));
hal_ev.status = HAL_STATUS_SUCCESS;
hal_ev.state = HAL_ACL_STATE_CONNECTED;
bdaddr2android(&ev->addr.bdaddr, hal_ev.bdaddr);
--
1.8.4