0

I'm trying to connect a bluetooth low energy Oximeter with my Ubuntu desktop but I'm running into some problems.

I can see the device just fine by using hcitool lescan but I cannot connect when I type

sudo gatttool -b 00:1C:05:FF:ED:A9 -I [ ][00:1C:05:FF:ED:A9][LE]> connect

These are the logs from hcidump -X:

HCI Event: Command Status (0x0f) plen 4 LE Create Connection (0x08|0x000d) status 0x00 ncmd 1 HCI Event: Command Status (0x0f) plen 4 LE Start Encryption (0x08|0x0019) status 0x00 ncmd 1 HCI Event: Encrypt Change (0x08) plen 4 status 0x06 handle 64 encrypt 0x00 Error: PIN or Key Missing HCI Event: Command Status (0x0f) plen 4 Disconnect (0x01|0x0006) status 0x00 ncmd 1 HCI Event: Disconn Complete (0x05) plen 4 status 0x00 handle 64 reason 0x16 Reason: Connection Terminated by Local Host

This looks like some kind of authentication failure. The problem is that the oximeter doesn't require any PINs or passkeys. It's just a simple agent that sends data to whoever its connected.

Thank you

user1378063
  • 263
  • 1
  • 6
  • 9

3 Answers3

0

Try using the hcitool lecc command:

sudo hcitool lecc 00:1C:05:FF:ED:A9
Jonathan Davies
  • 882
  • 3
  • 12
  • 27
0

I'm also facing the same problem with my oximeter. I haven't gotten to the bottom of it yet but I do have a workaround for my case. YMMV.

In my case, the connection works ok for the first few times and then stops working with the same PIN error you have shown. My workaround is to delete the pairing with the oximiter (which was created by the initially successful connects). I do this via "bt-device -r XX:XX:XX:XX:XX:XX". After that the connection succeeds. That is, need to delete any prior pairing before connecting again.

That's the short answer :-) Here's the research in more detail.

If you run hcidump as root (sudo hcidump -X) it will give you more verbose data. What you might see is this:

> ACL data: handle 69 flags 0x02 dlen 6
    SMP: Security Request (0x0b)
      auth req 0x00
< HCI Command: LE Start Encryption (0x08|0x0019) plen 28
  0000: 45 00 ec 8e 25 1b 09 46  b3 f7 7e ae 20 be 0c 63  E...%..F..~. ..c
  0010: fc cf ef e5 82 61 e0 eb  d4 bd 54 f6              .....a....T.
> HCI Event: Command Status (0x0f) plen 4
    LE Start Encryption (0x08|0x0019) status 0x00 ncmd 0
> HCI Event: Command Status (0x0f) plen 4
    Unknown (0x00|0x0000) status 0x00 ncmd 1
> HCI Event: Encrypt Change (0x08) plen 4
    status 0x06 handle 69 encrypt 0x00
    Error: PIN or Key Missing

Looks to me like the oximiter requests a pairing (the first ACL data dump) but bluez does not initiate one like it is supposed to. Compare this with the initial successful connect. The oximiter requests a pairing and at that point the local bluez does respond with a pair request:

> ACL data: handle 70 flags 0x02 dlen 6
    SMP: Security Request (0x0b)
      auth req 0x00
< ACL data: handle 70 flags 0x00 dlen 11
    SMP: Pairing Request (0x01)
      capability 0x03 oob 0x00 auth req 0x01
      max key size 0x10 init key dist 0x00 resp key dist 0x01
      Capability: NoInputNoOutput (OOB data not present)
      Authentication: Bonding (No MITM Protection)
      Initiator Key Distribution:    
      Responder Key Distribution:  LTK  
> HCI Event: Number of Completed Packets (0x13) plen 5
    handle 70 packets 1
> ACL data: handle 70 flags 0x02 dlen 11
    SMP: Pairing Response (0x02)
      capability 0x03 oob 0x00 auth req 0x01
      max key size 0x10 init key dist 0x00 resp key dist 0x01
      Capability: NoInputNoOutput (OOB data not present)
      Authentication: Bonding (No MITM Protection)
      Initiator Key Distribution:    
      Responder Key Distribution:  LTK

I'm still investigating to try and determine whether this is a bug in bluez or whether its user error on my part.

kaylum
  • 13,833
  • 2
  • 22
  • 31
  • Thank you very much for the detailed answer. Indeed it's the same problem I'm facing. It does connect once or twice and then fails until I reboot the machine. What bluez version are you using? I know that bluetoothctl from bluez 5.X works flawlessly with the oximeter, but due to compatibility issues, I really need to get this working with bluez 4.X. – user1378063 Dec 11 '14 at 17:22
  • The problem I have is reproducible with both bluez4 and bluez5. Does the workaround of removing the pairing (without reboot) and then connecting work for you? Just trying to determine whether your problem is the same. – kaylum Dec 11 '14 at 22:10
  • Thing is, I never been able to pair the device in the first place. Not with a bluetooth manager nor with any other console command. So when I run "bt-device -r" it just returns with a "doesn't exist" message. – user1378063 Dec 14 '14 at 14:44
0

Try:

sudo gatttool -t random -b 00:1C:05:FF:ED:A9 -I

then type connect