noble / bleno

A Node.js module for implementing BLE (Bluetooth Low Energy) peripherals
MIT License
2.12k stars 447 forks source link

Handle pairing request #379

Closed SpotIntern closed 6 years ago

SpotIntern commented 6 years ago

I've been trying to clone a physical smart lock with bleno running on a rpi 3, the app which control the lock require pairing through a pin. Where the "lock" pin should be written and where I should handle the pairing request? I read an answer talking about smp.js module but I can't find any doc. Someone could help?

I've tried the echo example, the pairing process with Android(nRf Connect) failed: that's the dump

evice: hci0 snap_len: 1500 filter: 0xffffffff 2018-04-27 14:20:53.174624 > ACL data: handle 64 flags 0x02 dlen 11 SMP: Pairing Request (0x01) capability 0x04 oob 0x00 auth req 0x0d max key size 0x10 init key dist 0x07 resp key dist 0x07 Capability: KeyboardDisplay (OOB data not present) Authentication: Bonding (MITM Protection) Initiator Key Distribution: LTK IRK CSRK Responder Key Distribution: LTK IRK CSRK 2018-04-27 14:20:53.177427 < ACL data: handle 64 flags 0x00 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
2018-04-27 14:20:53.321093 > ACL data: handle 64 flags 0x02 dlen 21 SMP: Pairing Confirm (0x03) key fb7ff723fc697f4278af98616637f830 2018-04-27 14:20:53.330959 < ACL data: handle 64 flags 0x00 dlen 21 SMP: Pairing Confirm (0x03) key e161ee0cff4cd399b62ff3dc65c05e38 2018-04-27 14:20:53.467381 > ACL data: handle 64 flags 0x02 dlen 21 SMP: Pairing Random (0x04) random 209d46e4d82c1469b1709465b0c67dc8 2018-04-27 14:20:53.467488 > HCI Event: Number of Completed Packets (0x13) plen 5 handle 64 packets 2 2018-04-27 14:20:53.474541 < ACL data: handle 64 flags 0x00 dlen 21 SMP: Pairing Random (0x04) random 076a62fea14ee00361099d40b8cab99f 2018-04-27 14:20:53.617539 > HCI Event: LE Meta Event (0x3e) plen 10 LE Connection Update Complete status 0x00 handle 64 interval 7.50ms, latency 0.00ms, superv. timeout 20000.00ms 2018-04-27 14:20:53.624994 > HCI Event: LE Meta Event (0x3e) plen 13 LE Long Term Key Request 40 00 00 00 00 00 00 00 00 00 00 00 2018-04-27 14:20:53.625050 < HCI Command: LE Long Term Key Request Negative Reply (0x08|0x001b) plen 2 40 00 2018-04-27 14:20:53.625560 > HCI Event: Command Complete (0x0e) plen 6 LE Long Term Key Request Negative Reply (0x08|0x001b) ncmd 1 00 40 00 2018-04-27 14:20:53.627391 < ACL data: handle 64 flags 0x00 dlen 6 SMP: Pairing Failed (0x05) reason 0x08 Reason Unspecified Reason 2018-04-27 14:20:53.684594 > HCI Event: Number of Completed Packets (0x13) plen 5 handle 64 packets 2 2018-04-27 14:20:53.747531 > HCI Event: LE Meta Event (0x3e) plen 10 LE Connection Update Complete status 0x00 handle 64 interval 48.75ms, latency 0.00ms, superv. timeout 20000.00ms