We have tried this on multiple Android devices. We are trying to upgrade our system to work with BLE instead of BT in order to support iOS.
Here is the scenario:
- Run bleno on Raspberry Pi
- Connect with Android Phone to BLE -> success
- Reboot (hard) Raspberry PI and enable bluetooth service
- Connect and Pair with Android Phone to BT
- Unpair device in Android Phone
- Reboot (hard) Raspberry PI, disable bluetooth service and run bleno
- Connect with Android Phone to BLE -> connection fails (BluetoothGatt status=19)
We tried resetting bluetooth cache (App Manager Storage), and also programmatically (How to Programmatically Clear Bluetooth Cache using GattServer) Reboot of Phone also didn't work, HOWEVER, after factory reset of the phone WE WERE ABLE to connect again.
Here is the output of sudo btmon
on the Raspberry PI during BLE connection before and after:
Before (success):
> HCI Event: LE Meta Event (0x3e) plen 19 [hci0] 7.416417
LE Connection Complete (0x01)
Status: Success (0x00)
Handle: 64
Role: Slave (0x01)
Peer address type: Random (0x01)
Peer address: 6D:B3:5A:EA:CB:50 (Resolvable)
Connection interval: 48.75 msec (0x0027)
Connection latency: 0.00 msec (0x0000)
Supervision timeout: 5000 msec (0x01f4)
Master clock accuracy: 0x01
@ MGMT Event: Device Connected (0x000b) plen 13 {0x0002} [hci0] 7.416643
LE Address: 6D:B3:5A:EA:CB:50 (Resolvable)
Flags: 0x00000000
Data length: 0
< HCI Command: LE Read Remote Used Features (0x08|0x0016) plen 2 [hci0] 7.434359
Handle: 64
> HCI Event: Command Status (0x0f) plen 4 [hci0] 7.434958
LE Read Remote Used Features (0x08|0x0016) ncmd 1
Status: Success (0x00)
< HCI Command: LE Set Scan Enable (0x08|0x000c) plen 2 [hci0] 7.435064
Scanning: Disabled (0x00)
Filter duplicates: Disabled (0x00)
> HCI Event: Command Complete (0x0e) plen 4 [hci0] 7.437506
LE Set Scan Enable (0x08|0x000c) ncmd 1
Status: Success (0x00)
< HCI Command: LE Set Scan Parameters (0x08|0x000b) plen 7 [hci0] 7.437630
Type: Passive (0x00)
Interval: 60.000 msec (0x0060)
Window: 30.000 msec (0x0030)
Own address type: Public (0x00)
Filter policy: Ignore not in white list (0x01)
> HCI Event: Command Complete (0x0e) plen 4 [hci0] 7.438086
LE Set Scan Parameters (0x08|0x000b) ncmd 1
Status: Success (0x00)
< HCI Command: LE Set Scan Enable (0x08|0x000c) plen 2 [hci0] 7.438189
Scanning: Enabled (0x01)
Filter duplicates: Enabled (0x01)
> HCI Event: Command Complete (0x0e) plen 4 [hci0] 7.438938
LE Set Scan Enable (0x08|0x000c) ncmd 1
Status: Success (0x00)
> ACL Data RX: Handle 64 flags 0x02 dlen 11 [hci0] 7.610374
ATT: Read By Group Type Request (0x10) len 6
Handle range: 0x0001-0xffff
Attribute group type: Primary Service (0x2800)
> HCI Event: LE Meta Event (0x3e) plen 10 [hci0] 8.007841
LE Connection Update Complete (0x03)
Status: Success (0x00)
Handle: 64
Connection interval: 7.50 msec (0x0006)
Connection latency: 0.00 msec (0x0000)
Supervision timeout: 5000 msec (0x01f4)
> HCI Event: LE Meta Event (0x3e) plen 12 [hci0] 8.022370
LE Read Remote Used Features (0x04)
Status: Success (0x00)
Handle: 64
Features: 0x1d 0x00 0x00 0x00 0x00 0x00 0x00 0x00
LE Encryption
Extended Reject Indication
Slave-initiated Features Exchange
LE Ping
< ACL Data TX: Handle 64 flags 0x00 dlen 16 [hci0] 8.022557
LE L2CAP: Connection Parameter Update Request (0x12) ident 1 len 8
Min interval: 40
Max interval: 56
Slave latency: 0
Timeout multiplier: 500
> ACL Data RX: Handle 64 flags 0x02 dlen 10 [hci0] 8.037404
LE L2CAP: Connection Parameter Update Response (0x13) ident 1 len 2
Result: Connection Parameters accepted (0x0000)
< ACL Data TX: Handle 64 flags 0x00 dlen 18 [hci0] 8.056423
ATT: Read By Group Type Response (0x11) len 13
Attribute data length: 6
Attribute group list: 2 entries
Handle range: 0x0001-0x0005
UUID: Generic Access Profile (0x1800)
Handle range: 0x0006-0x0009
UUID: Generic Attribute Profile (0x1801)
> ACL Data RX: Handle 64 flags 0x02 dlen 11 [hci0] 8.067455
ATT: Read By Group Type Request (0x10) len 6
Handle range: 0x000a-0xffff
Attribute group type: Primary Service (0x2800)
> HCI Event: Number of Completed Packets (0x13) plen 5 [hci0] 8.068874
Num handles: 1
Handle: 64
Count: 2
< ACL Data TX: Handle 64 flags 0x00 dlen 26 [hci0] 8.093368
ATT: Read By Group Type Response (0x11) len 21
Attribute data length: 20
Attribute group list: 1 entry
Handle range: 0x000a-0x0014
UUID: Vendor specific (ffffffff-ffff-ffff-ffff-fffffffffff0)
> ACL Data RX: Handle 64 flags 0x02 dlen 11 [hci0] 8.104908
ATT: Read By Group Type Request (0x10) len 6
Handle range: 0x0015-0xffff
Attribute group type: Primary Service (0x2800)
< ACL Data TX: Handle 64 flags 0x00 dlen 9 [hci0] 8.126027
ATT: Error Response (0x01) len 4
Read By Group Type Request (0x10)
Handle: 0x0015
Error: Attribute Not Found (0x0a)
> ACL Data RX: Handle 64 flags 0x02 dlen 11 [hci0] 8.142444
ATT: Read By Type Request (0x08) len 6
Handle range: 0x0001-0x0005
Attribute type: Include (0x2802)
> HCI Event: Number of Completed Packets (0x13) plen 5 [hci0] 8.143707
Num handles: 1
Handle: 64
Count: 2
< ACL Data TX: Handle 64 flags 0x00 dlen 9 [hci0] 8.147126
ATT: Error Response (0x01) len 4
Read By Type Request (0x08)
Handle: 0x0001
Error: Attribute Not Found (0x0a)
> ACL Data RX: Handle 64 flags 0x02 dlen 11 [hci0] 8.157415
ATT: Read By Type Request (0x08) len 6
Handle range: 0x0001-0x0005
Attribute type: Characteristic (0x2803)
< ACL Data TX: Handle 64 flags 0x00 dlen 20 [hci0] 8.160994
ATT: Read By Type Response (0x09) len 15
Attribute data length: 7
Attribute data list: 2 entries
Handle: 0x0002
Value: 020300002a
Handle: 0x0004
Value: 020500012a
> ACL Data RX: Handle 64 flags 0x02 dlen 11 [hci0] 8.172405
ATT: Read By Type Request (0x08) len 6
Handle range: 0x0005-0x0005
Attribute type: Characteristic (0x2803)
> HCI Event: Number of Completed Packets (0x13) plen 5 [hci0] 8.172580
Num handles: 1
Handle: 64
Count: 2
< ACL Data TX: Handle 64 flags 0x00 dlen 9 [hci0] 8.175935
ATT: Error Response (0x01) len 4
Read By Type Request (0x08)
Handle: 0x0005
Error: Attribute Not Found (0x0a)
> ACL Data RX: Handle 64 flags 0x02 dlen 11 [hci0] 8.187369
ATT: Read By Type Request (0x08) len 6
Handle range: 0x0006-0x0009
Attribute type: Include (0x2802)
< ACL Data TX: Handle 64 flags 0x00 dlen 9 [hci0] 8.190371
ATT: Error Response (0x01) len 4
Read By Type Request (0x08)
Handle: 0x0006
Error: Attribute Not Found (0x0a)
> ACL Data RX: Handle 64 flags 0x02 dlen 11 [hci0] 8.202431
ATT: Read By Type Request (0x08) len 6
Handle range: 0x0006-0x0009
Attribute type: Characteristic (0x2803)
> HCI Event: Number of Completed Packets (0x13) plen 5 [hci0] 8.203385
Num handles: 1
Handle: 64
Count: 2
< ACL Data TX: Handle 64 flags 0x00 dlen 13 [hci0] 8.206600
ATT: Read By Type Response (0x09) len 8
Attribute data length: 7
Attribute data list: 1 entry
Handle: 0x0007
Value: 200800052a
> ACL Data RX: Handle 64 flags 0x02 dlen 11 [hci0] 8.217417
ATT: Read By Type Request (0x08) len 6
Handle range: 0x0008-0x0009
Attribute type: Characteristic (0x2803)
< ACL Data TX: Handle 64 flags 0x00 dlen 9 [hci0] 8.220542
ATT: Error Response (0x01) len 4
Read By Type Request (0x08)
Handle: 0x0008
Error: Attribute Not Found (0x0a)
> ACL Data RX: Handle 64 flags 0x02 dlen 9 [hci0] 8.232412
ATT: Find Information Request (0x04) len 4
Handle range: 0x0009-0x0009
> HCI Event: Number of Completed Packets (0x13) plen 5 [hci0] 8.233326
Num handles: 1
Handle: 64
Count: 2
< ACL Data TX: Handle 64 flags 0x00 dlen 10 [hci0] 8.236097
ATT: Find Information Response (0x05) len 5
Format: UUID-16 (0x01)
Handle: 0x0009
UUID: Client Characteristic Configuration (0x2902)
> ACL Data RX: Handle 64 flags 0x02 dlen 11 [hci0] 8.254911
ATT: Read By Type Request (0x08) len 6
Handle range: 0x000a-0x0014
Attribute type: Include (0x2802)
< ACL Data TX: Handle 64 flags 0x00 dlen 9 [hci0] 8.257998
ATT: Error Response (0x01) len 4
Read By Type Request (0x08)
Handle: 0x000a
Error: Attribute Not Found (0x0a)
> ACL Data RX: Handle 64 flags 0x02 dlen 11 [hci0] 8.269937
ATT: Read By Type Request (0x08) len 6
Handle range: 0x000a-0x0014
Attribute type: Characteristic (0x2803)
> HCI Event: Number of Completed Packets (0x13) plen 5 [hci0] 8.270951
Num handles: 1
Handle: 64
Count: 2
< ACL Data TX: Handle 64 flags 0x00 dlen 27 [hci0] 8.274584
ATT: Read By Type Response (0x09) len 22
Attribute data length: 21
Attribute data list: 1 entry
Handle: 0x000b
Value: 0a0c0003003333333333333333333333333313
> ACL Data RX: Handle 64 flags 0x02 dlen 11 [hci0] 8.284914
ATT: Read By Type Request (0x08) len 6
Handle range: 0x000c-0x0014
Attribute type: Characteristic (0x2803)
< ACL Data TX: Handle 64 flags 0x00 dlen 27 [hci0] 8.288595
ATT: Read By Type Response (0x09) len 22
Attribute data length: 21
Attribute data list: 1 entry
Handle: 0x000e
Value: 080f0005003333333333333333333333333313
> ACL Data RX: Handle 64 flags 0x02 dlen 11 [hci0] 8.307421
ATT: Read By Type Request (0x08) len 6
Handle range: 0x000f-0x0014
Attribute type: Characteristic (0x2803)
> HCI Event: Number of Completed Packets (0x13) plen 5 [hci0] 8.308334
Num handles: 1
Handle: 64
Count: 2
< ACL Data TX: Handle 64 flags 0x00 dlen 27 [hci0] 8.311648
ATT: Read By Type Response (0x09) len 22
Attribute data length: 21
Attribute data list: 1 entry
Handle: 0x0011
Value: 10120007003333333333333333333333333313
> ACL Data RX: Handle 64 flags 0x02 dlen 11 [hci0] 8.322401
ATT: Read By Type Request (0x08) len 6
Handle range: 0x0012-0x0014
Attribute type: Characteristic (0x2803)
< ACL Data TX: Handle 64 flags 0x00 dlen 9 [hci0] 8.325415
ATT: Error Response (0x01) len 4
Read By Type Request (0x08)
Handle: 0x0012
Error: Attribute Not Found (0x0a)
> ACL Data RX: Handle 64 flags 0x02 dlen 9 [hci0] 8.337361
ATT: Find Information Request (0x04) len 4
Handle range: 0x000d-0x000d
> HCI Event: Number of Completed Packets (0x13) plen 5 [hci0] 8.338277
Num handles: 1
Handle: 64
Count: 2
< ACL Data TX: Handle 64 flags 0x00 dlen 10 [hci0] 8.341007
ATT: Find Information Response (0x05) len 5
Format: UUID-16 (0x01)
Handle: 0x000d
UUID: Characteristic User Description (0x2901)
> ACL Data RX: Handle 64 flags 0x02 dlen 9 [hci0] 8.352388
ATT: Find Information Request (0x04) len 4
Handle range: 0x0010-0x0010
< ACL Data TX: Handle 64 flags 0x00 dlen 10 [hci0] 8.355296
ATT: Find Information Response (0x05) len 5
Format: UUID-16 (0x01)
Handle: 0x0010
UUID: Characteristic User Description (0x2901)
> ACL Data RX: Handle 64 flags 0x02 dlen 9 [hci0] 8.367413
ATT: Find Information Request (0x04) len 4
Handle range: 0x0013-0x0014
> HCI Event: Number of Completed Packets (0x13) plen 5 [hci0] 8.368251
Num handles: 1
Handle: 64
Count: 2
< ACL Data TX: Handle 64 flags 0x00 dlen 14 [hci0] 8.371096
ATT: Find Information Response (0x05) len 9
Format: UUID-16 (0x01)
Handle: 0x0013
UUID: Client Characteristic Configuration (0x2902)
Handle: 0x0014
UUID: Characteristic User Description (0x2901)
> ACL Data RX: Handle 64 flags 0x02 dlen 7 [hci0] 8.382770
ATT: Exchange MTU Request (0x02) len 2
Client RX MTU: 255
< ACL Data TX: Handle 64 flags 0x00 dlen 7 [hci0] 8.385864
ATT: Exchange MTU Response (0x03) len 2
Server RX MTU: 255
> HCI Event: Number of Completed Packets (0x13) plen 5 [hci0] 8.397320
Num handles: 1
Handle: 64
Count: 2
> HCI Event: LE Meta Event (0x3e) plen 10 [hci0] 8.465343
LE Connection Update Complete (0x03)
Status: Success (0x00)
Handle: 64
Connection interval: 60.00 msec (0x0030)
Connection latency: 0.00 msec (0x0000)
Supervision timeout: 5000 msec (0x01f4)
> ACL Data RX: Handle 64 flags 0x02 dlen 9 [hci0] 8.644851
ATT: Write Request (0x12) len 4
Handle: 0x0013
Data: 0100
< ACL Data TX: Handle 64 flags 0x00 dlen 5 [hci0] 8.648926
ATT: Write Response (0x13) len 0
> ACL Data RX: Handle 64 flags 0x02 dlen 9 [hci0] 8.764880
ATT: Write Request (0x12) len 4
Handle: 0x0013
Data: 0000
< ACL Data TX: Handle 64 flags 0x00 dlen 5 [hci0] 8.768936
ATT: Write Response (0x13) len 0
> ACL Data RX: Handle 64 flags 0x02 dlen 9 [hci0] 8.884933
ATT: Write Request (0x12) len 4
Handle: 0x0013
Data: 0100
> HCI Event: Number of Completed Packets (0x13) plen 5 [hci0] 8.886011
Num handles: 1
Handle: 64
Count: 2
< ACL Data TX: Handle 64 flags 0x00 dlen 5 [hci0] 8.890188
ATT: Write Response (0x13) len 0
> ACL Data RX: Handle 64 flags 0x02 dlen 11 [hci0] 9.004875
ATT: Write Request (0x12) len 6
Handle: 0x000c
Data: 317c6964
< ACL Data TX: Handle 64 flags 0x00 dlen 5 [hci0] 9.033321
ATT: Write Response (0x13) len 0
> ACL Data RX: Handle 64 flags 0x02 dlen 24 [hci0] 9.125075
> HCI Event: Number of Completed Packets (0x13) plen 5 [hci0] 9.126033
Num handles: 1
Handle: 64
Count: 2
> ACL Data RX: Handle 64 flags 0x01 dlen 24 [hci0] 9.126060
> ACL Data RX: Handle 64 flags 0x01 dlen 23 [hci0] 9.127135
ATT: Write Request (0x12) len 66
Handle: 0x000f
Data: 307c307c7b22446576696365416363657373546f6b656e223a2232363465663937302d346362362d313165612d383230612d623832376562316564313439227d
< ACL Data TX: Handle 64 flags 0x00 dlen 5 [hci0] 9.165770
ATT: Write Response (0x13) len 0
> HCI Event: Number of Completed Packets (0x13) plen 5 [hci0] 9.432895
Num handles: 1
Handle: 64
Count: 1
...
After (fail):
> HCI Event: LE Meta Event (0x3e) plen 19 [hci0] 5.509223
LE Connection Complete (0x01)
Status: Success (0x00)
Handle: 64
Role: Slave (0x01)
Peer address type: Random (0x01)
Peer address: 48:3F:15:CC:76:5F (Resolvable)
Connection interval: 48.75 msec (0x0027)
Connection latency: 0.00 msec (0x0000)
Supervision timeout: 5000 msec (0x01f4)
Master clock accuracy: 0x01
@ MGMT Event: Device Connected (0x000b) plen 13 {0x0002} [hci0] 5.509416
LE Address: 7C:03:5E:9F:D1:A7 (OUI 7C-03-5E)
Flags: 0x00000000
Data length: 0
< HCI Command: LE Read Remote Used Features (0x08|0x0016) plen 2 [hci0] 5.514306
Handle: 64
> HCI Event: Command Status (0x0f) plen 4 [hci0] 5.515424
LE Read Remote Used Features (0x08|0x0016) ncmd 1
Status: Success (0x00)
< HCI Command: LE Set Scan Enable (0x08|0x000c) plen 2 [hci0] 5.515546
Scanning: Disabled (0x00)
Filter duplicates: Disabled (0x00)
> HCI Event: Command Complete (0x0e) plen 4 [hci0] 5.517443
LE Set Scan Enable (0x08|0x000c) ncmd 1
Status: Success (0x00)
< HCI Command: LE Set Scan Parameters (0x08|0x000b) plen 7 [hci0] 5.517576
Type: Passive (0x00)
Interval: 60.000 msec (0x0060)
Window: 30.000 msec (0x0030)
Own address type: Public (0x00)
Filter policy: Ignore not in white list (0x01)
> HCI Event: Command Complete (0x0e) plen 4 [hci0] 5.518191
LE Set Scan Parameters (0x08|0x000b) ncmd 1
Status: Success (0x00)
< HCI Command: LE Set Scan Enable (0x08|0x000c) plen 2 [hci0] 5.518314
Scanning: Enabled (0x01)
Filter duplicates: Enabled (0x01)
> HCI Event: Command Complete (0x0e) plen 4 [hci0] 5.519025
LE Set Scan Enable (0x08|0x000c) ncmd 1
Status: Success (0x00)
< HCI Command: LE Set Scan Enable (0x08|0x000c) plen 2 [hci0] 5.545371
Scanning: Disabled (0x00)
Filter duplicates: Disabled (0x00)
> HCI Event: Command Complete (0x0e) plen 4 [hci0] 5.548676
LE Set Scan Enable (0x08|0x000c) ncmd 1
Status: Success (0x00)
< HCI Command: LE Add Device To White List (0x08|0x0011) plen 7 [hci0] 5.548813
Address type: Random (0x01)
Address: 48:3F:15:CC:76:5F (Resolvable)
> HCI Event: Command Complete (0x0e) plen 4 [hci0] 5.550213
LE Add Device To White List (0x08|0x0011) ncmd 1
Status: Success (0x00)
< HCI Command: LE Set Scan Parameters (0x08|0x000b) plen 7 [hci0] 5.550348
Type: Passive (0x00)
Interval: 60.000 msec (0x0060)
Window: 30.000 msec (0x0030)
Own address type: Public (0x00)
Filter policy: Ignore not in white list (0x01)
> HCI Event: Command Complete (0x0e) plen 4 [hci0] 5.551350
LE Set Scan Parameters (0x08|0x000b) ncmd 1
Status: Success (0x00)
< HCI Command: LE Set Scan Enable (0x08|0x000c) plen 2 [hci0] 5.551468
Scanning: Enabled (0x01)
Filter duplicates: Enabled (0x01)
> HCI Event: Command Complete (0x0e) plen 4 [hci0] 5.552194
LE Set Scan Enable (0x08|0x000c) ncmd 1
Status: Success (0x00)
> ACL Data RX: Handle 64 flags 0x02 dlen 11 [hci0] 5.751468
ATT: Read By Group Type Request (0x10) len 6
Handle range: 0x0001-0xffff
Attribute group type: Primary Service (0x2800)
> HCI Event: LE Meta Event (0x3e) plen 10 [hci0] 6.145226
LE Connection Update Complete (0x03)
Status: Success (0x00)
Handle: 64
Connection interval: 7.50 msec (0x0006)
Connection latency: 0.00 msec (0x0000)
Supervision timeout: 5000 msec (0x01f4)
> HCI Event: LE Meta Event (0x3e) plen 12 [hci0] 6.159776
LE Read Remote Used Features (0x04)
Status: Success (0x00)
Handle: 64
Features: 0x1d 0x00 0x00 0x00 0x00 0x00 0x00 0x00
LE Encryption
Extended Reject Indication
Slave-initiated Features Exchange
LE Ping
< ACL Data TX: Handle 64 flags 0x00 dlen 16 [hci0] 6.159947
LE L2CAP: Connection Parameter Update Request (0x12) ident 1 len 8
Min interval: 40
Max interval: 56
Slave latency: 0
Timeout multiplier: 500
> ACL Data RX: Handle 64 flags 0x02 dlen 10 [hci0] 6.174753
LE L2CAP: Connection Parameter Update Response (0x13) ident 1 len 2
Result: Connection Parameters accepted (0x0000)
> HCI Event: Number of Completed Packets (0x13) plen 5 [hci0] 6.414272
Num handles: 1
Handle: 64
Count: 1
< HCI Command: Disconnect (0x01|0x0006) plen 3 [hci0] 10.174344
Handle: 64
Reason: Remote User Terminated Connection (0x13)
> HCI Event: Command Status (0x0f) plen 4 [hci0] 10.175510
Disconnect (0x01|0x0006) ncmd 1
Status: Success (0x00)
> HCI Event: Disconnect Complete (0x05) plen 4 [hci0] 15.169553
Status: Success (0x00)
Handle: 64
Reason: LMP Response Timeout / LL Response Timeout (0x22)
@ MGMT Event: Device Disconnected (0x000c) plen 8 {0x0002} [hci0] 15.169664
LE Address: 7C:03:5E:9F:D1:A7 (OUI 7C-03-5E)
Reason: Unspecified (0x00)
debian version: 9.3
Raspbian GNU/Linux 9 (stretch)
Linux raspberrypi 4.9.59+ #1047 Sun Oct 29 11:47:10 GMT 2017 armv6l GNU/Linux
NOTE: if we change the bluetooth mac address of the Raspberry PI using: https://scribles.net/changing-a-bluetooth-device-address-on-raspberry-pi/, before running bleno, the Android is able to connect to BLE again.