Re: How to add the Secure simple pairing to the btstack?

613 views
Skip to first unread message

Matthias Ringwald

unread,
Oct 25, 2012, 6:14:09 AM10/25/12
to btsta...@googlegroups.com
Hi Chris

In addition to sending the hci_write_simple_pairing_mode command, you also need to enable the special events associated with it.

So, please try sending hci_send_cmd(&hci_set_event_mask,0xffffffff, 0x1DFFFFFF), to enable the IO Capability Request event (and others).
You then have to answer that one.

I guess it would be very nice if BTstack on iOS would handle all the UI stuff...

Cheers
Matthias


On Oct 25, 2012, at 4:11 AM, cgha wrote:

> I want to add the ssp with io capacities no input no output, but when my android(with android version 2.3.7) phone try to pair with it, nothing happen.
> I have added the hci_cmd of write_simple_pairng_mode to the init of usb dongle.Can someone help me? My usb dongle is a BT2.1 dongle and can work with ssp in windows 7.
>
> Chris
>
>
> --
> You received this message because you are subscribed to the Google Groups "btstack-dev" group.
> To view this discussion on the web visit https://groups.google.com/d/msg/btstack-dev/-/7MZAjluBBIEJ.
> To post to this group, send email to btsta...@googlegroups.com.
> To unsubscribe from this group, send email to btstack-dev...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/btstack-dev?hl=en.

Rajesh Venkataraman

unread,
Jul 29, 2013, 3:48:08 PM7/29/13
to btsta...@googlegroups.com
I am trying to add Simple secure pairing feature to the BTStack running on an embedded system. I have enabled the SSP mode by using HCI command write_simple_pairing_mode. I am handling the io_capabilities_request event. I am responding with io capabilities 0x01 (DisplayYesNo) OOB 0x00 Authentication ) 0x03. I handle the user confirm request event. The Link Key notification event is generated. I store the Link key (16 bytes). The connection is established successfully.  Now if I disconnect the connection and try to connect again without unpairing from the external device. I get the Link Key Request event. This event is responded by the Link Key request response command with the link key stored earlier during the pairing. But the ACL connection is disconnected. I get a Disconnect event with the reason of 0x13. What is going wrong? Why I am not able to connect the second time without unpairing.

Matthias Ringwald

unread,
Jul 31, 2013, 11:30:24 AM7/31/13
to btsta...@googlegroups.com
Hi Rajesh

What's the other side? Do you have logs from the remote?

After you get a link key, this should be enough to setup an authenticated connection the next time, independent of the SSP.

Best
Matthias
> --
> You received this message because you are subscribed to the Google Groups "btstack-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to btstack-dev...@googlegroups.com.
> To post to this group, send email to btsta...@googlegroups.com.
> Visit this group at http://groups.google.com/group/btstack-dev.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Rajesh Venkataraman

unread,
Jul 31, 2013, 4:12:22 PM7/31/13
to btsta...@googlegroups.com
The remote device is an android tablet running android version 4.0.4 and I do not have access to capture the log on this device. The log on my development platform looks like this.

12:59:26.727 [681088.73] HCI:EVENT:04
12:59:26.741 [681088.74] Connection_incoming: 04:fe:31:13:0e:d0, type 1
12:59:26.752 [681088.75] sending hci_accept_connection_request
12:59:26.754 [681088.75] HCI:EVENT:0f
12:59:26.887 [681088.89] HCI:EVENT:03
12:59:26.901 [681088.90] Connection_complete (status=0) 04:fe:31:13:0e:d0
12:59:26.912 [681088.91] New connection: handle 1, 04:fe:31:13:0e:d0
12:59:26.923 [681088.92] BTSTACK_EVENT_NR_CONNECTIONS_CHANGED 1
12:59:26.959 [681088.96] HCI:EVENT:1b
12:59:27.009 [681089.01] HCI:EVENT:17
12:59:27.016 [681089.02] HCI_EVENT_LINK_KEY_REQUEST
12:59:27.042 [681089.04] Link key 4:b3:84:38:2e:b8:de:34:f6:7e:d3:83:8b:4b:60:70
12:59:27.046 [681089.05] HCI:EVENT:0e
12:59:27.053 [681089.05] Link Key status 0
12:59:27.068 [681089.07] HCI:EVENT:17
12:59:27.075 [681089.07] HCI_EVENT_LINK_KEY_REQUEST
12:59:27.086 [681089.09] responding to link key request
12:59:27.100 [681089.10] Link key 4:b3:84:38:2e:b8:de:34:f6:7e:d3:83:8b:4b:60:70
12:59:27.104 [681089.10] HCI:EVENT:0e
12:59:27.111 [681089.11] Link Key status 0:d0:e:13
12:59:27.190 [681089.19] HCI:EVENT:05
12:59:27.197 [681089.20] Disconnect reason 13
12:59:27.208 [681089.21] Connection closed: handle 1, 04:fe:31:13:0e:d0
12:59:27.220 [681089.22] BTSTACK_EVENT_NR_CONNECTIONS_CHANGED 0

Is there any issue with the byte order of either the Link key or the BD address while responding to the HCI_EVENT_LINK_KEY_REQUEST?



On Wednesday, July 31, 2013 8:30:24 AM UTC-7, Matthias Ringwald wrote:
Hi Rajesh

What's the other side? Do you have logs from the remote?

After you get a link key, this should be enough to setup an authenticated connection the next time, independent of the SSP.

Best
 Matthias

Matthias RIngwald

unread,
Aug 30, 2013, 6:42:14 AM8/30/13
to btsta...@googlegroups.com
Hello Rajesh

sorry for the late delay. What's weird in the log below is that you get the link key request twice.

On Jul 31, 2013, at 10:12 PM, Rajesh Venkataraman <rajesh_ve...@trimble.com> wrote:

The remote device is an android tablet running android version 4.0.4 and I do not have access to capture the log on this device. The log on my development platform looks like this.

..
12:59:27.016 [681089.02] HCI_EVENT_LINK_KEY_REQUEST
12:59:27.042 [681089.04] Link key 4:b3:84:38:2e:b8:de:34:f6:7e:d3:83:8b:4b:60:70
12:59:27.046 [681089.05] HCI:EVENT:0e
12:59:27.053 [681089.05] Link Key status 0
12:59:27.068 [681089.07] HCI:EVENT:17
12:59:27.075 [681089.07] HCI_EVENT_LINK_KEY_REQUEST
12:59:27.086 [681089.09] responding to link key request
12:59:27.100 [681089.10] Link key 4:b3:84:38:2e:b8:de:34:f6:7e:d3:83:8b:4b:60:70
12:59:27.104 [681089.10] HCI:EVENT:0e
12:59:27.111 [681089.11] Link Key status 0:d0:e:13
12:59:27.190 [681089.19] HCI:EVENT:05
12:59:27.197 [681089.20] Disconnect reason 13
12:59:27.208 [681089.21] Connection closed: handle 1, 04:fe:31:13:0e:d0
12:59:27.220 [681089.22] BTSTACK_EVENT_NR_CONNECTIONS_CHANGED 0

Is there any issue with the byte order of either the Link key or the BD address while responding to the HCI_EVENT_LINK_KEY_REQUEST?

Link key and BD_ADDR should go over the wire in the same order. BTstack usually flips the little endian BD_ADDR to big endian, as it did seem more logical to me. Maybe never flipping it would make life easier.

I'm about to add Secure Simple Pairing to BTstack now and keep you/all update on that.

Best
 Matthias


all the time, which might 

Matthias RIngwald

unread,
Sep 1, 2013, 4:15:56 PM9/1/13
to btsta...@googlegroups.com
Hi Rajesh

I've finished a first version of Secure Simple Pairing. If you add this

    // Secure Simple Pairing configuration -> just works
    hci_ssp_set_enable(1);
    hci_ssp_set_io_capability(SSP_IO_CAPABILITY_NO_INPUT_NO_OUTPUT);
    hci_ssp_set_auto_accept(1);


during the setup, BTstack will set up secure simple pairing and respond to IO Capability Request and User Confirmation Requests.

Could you try this to see if it helps you?

Best 
Matthias

On Jul 31, 2013, at 10:12 PM, Rajesh Venkataraman <rajesh_ve...@trimble.com> wrote:

Rajesh Venkataraman

unread,
Sep 6, 2013, 7:47:38 PM9/6/13
to btsta...@googlegroups.com
Hi,
   Tried the new SSP mode support but it did not work. Still having the same issue. The first connect succeeds and the link key is generated. The next connection using the
previously generated key fails to connect.

Rajesh

Matthias Ringwald

unread,
Sep 7, 2013, 10:28:32 AM9/7/13
to btsta...@googlegroups.com
Thanks for trying. I'll have a look at the second connect then. 

Sent from my iPhone

Matthias RIngwald

unread,
Sep 11, 2013, 3:49:02 PM9/11/13
to btsta...@googlegroups.com
Hi Rajesh

I've tried my test app again and had no problems connecting to it a second time. My setup: example/libusb/spp_counter_ssp with a Belkin dongle. I did connect from OS X 10.8. After the first setup and simple pairing, I could do a cat on the create serial port and got the BTstack counter.

Could you try to get this example running on Linux or OS X? It only requires libusb 1.0+ and you might need to fix the compile flags in the Makefile. The example writes a packet log to /tmp/hci_dump.pklg which is very interesting in case of an error.

I'd like to fix this, but I'm not sure where/how to look for problems. (hm… I do have an Nexus 7 tables, but I didn't bring that with for vacation. I can try that with my libusb example in 1.5 weeks, if you don't have anything until then)

Best
 Matthias
Reply all
Reply to author
Forward
0 new messages