paypal / gatt

Gatt is a Go package for building Bluetooth Low Energy peripherals
BSD 3-Clause "New" or "Revised" License
1.13k stars 284 forks source link

Can not scan peripheral device after running server for several minutes #58

Open shanwen0120 opened 8 years ago

shanwen0120 commented 8 years ago

I can scan and get the server after I build and run the sample server, but after running up the server about 20 minutes, i can not get the server anymore. (Scan by LightBlue in iPhone and hcitool in Linux) If i shut down current unanswerable server and restart it, it appear immediately again. Is there any hint about this problem?

Thanks

roylee17 commented 8 years ago

Which platform are you running on, Linux or OS X? Do you need to access/connect to the server to trigger the problem, or just leave it advertising 20 mins and it happens?

To debug on Linux platforms, you can hcidump the device which gatt is running on. It might be helpful to see what happened before it become unanswerable.

shanwen0120 commented 8 years ago

This problem happens on both platform, and i just scan the server without any access/connection after start it. I think hcidump is a good advice and i'll try it for figuring out the problem.

Thank you, @roylee17

shanwen0120 commented 8 years ago

I can't get anything by hcidump when server disappear. The result of hcidump is below.


HCI sniffer - Bluetooth packet analyzer ver 5.28 device: hci0 snap_len: 1500 filter: 0xffffffff

< HCI Command: Read Local Supported Features (0x04|0x0003) plen 0

HCI Event: Command Complete (0x0e) plen 12 Read Local Supported Features (0x04|0x0003) ncmd 2 status 0x00 Features: 0xff 0xff 0xff 0xfe 0xdb 0xff 0x7b 0x87 < HCI Command: Read Local Version Information (0x04|0x0001) plen 0 HCI Event: Command Complete (0x0e) plen 12 Read Local Version Information (0x04|0x0001) ncmd 2 status 0x00 HCI Version: 4.0 (0x6) HCI Revision: 0x1e4d LMP Version: 4.0 (0x6) LMP Subversion: 0x3c55 Manufacturer: Realtek Semiconductor Corporation (93) < HCI Command: Read BD ADDR (0x04|0x0009) plen 0 HCI Event: Command Complete (0x0e) plen 10 Read BD ADDR (0x04|0x0009) ncmd 2 status 0x00 bdaddr A0:0A:BF:15:27:70 < HCI Command: Read Buffer Size (0x04|0x0005) plen 0 HCI Event: Command Complete (0x0e) plen 11 Read Buffer Size (0x04|0x0005) ncmd 2 status 0x00 ACL MTU 1021:8 SCO MTU 255:16 < HCI Command: Read Class of Device (0x03|0x0023) plen 0 HCI Event: Command Complete (0x0e) plen 7 Read Class of Device (0x03|0x0023) ncmd 2 status 0x00 class 0x000000 < HCI Command: Read Local Name (0x03|0x0014) plen 0 HCI Event: Command Complete (0x0e) plen 252 Read Local Name (0x03|0x0014) ncmd 2 status 0x00 name 'RTK_BT_4.0' < HCI Command: Read Voice Setting (0x03|0x0025) plen 0 HCI Event: Command Complete (0x0e) plen 6 Read Voice Setting (0x03|0x0025) ncmd 2 status 0x00 voice setting 0x0060 < HCI Command: Set Event Filter (0x03|0x0005) plen 1 type 0 condition 0 Clear all filters HCI Event: Command Complete (0x0e) plen 4 Set Event Filter (0x03|0x0005) ncmd 2 status 0x00 < HCI Command: Write Connection Accept Timeout (0x03|0x0016) plen 2 timeout 32000 HCI Event: Command Complete (0x0e) plen 4 Write Connection Accept Timeout (0x03|0x0016) ncmd 2 status 0x00 < HCI Command: Read Page Scan Activity (0x03|0x001b) plen 0 HCI Event: Command Complete (0x0e) plen 8 Read Page Scan Activity (0x03|0x001b) ncmd 2 status 0x00 interval 2048 window 18 < HCI Command: Read Page Scan Type (0x03|0x0046) plen 0 HCI Event: Command Complete (0x0e) plen 5 Read Page Scan Type (0x03|0x0046) ncmd 2 0000: 00 00 .. < HCI Command: LE Read Buffer Size (0x08|0x0002) plen 0 HCI Event: Command Complete (0x0e) plen 7 LE Read Buffer Size (0x08|0x0002) ncmd 2 status 0x00 pktlen 0x001b maxpkt 0x10 < HCI Command: LE Read Local Supported Features (0x08|0x0003) plen 0 HCI Event: Command Complete (0x0e) plen 12 LE Read Local Supported Features (0x08|0x0003) ncmd 2 status 0x00 features 0x0100000000000000 (Link Layer supports LE Encryption) < HCI Command: LE Read Advertising Channel Tx Power (0x08|0x0007) plen 0 HCI Event: Command Complete (0x0e) plen 5 LE Read Advertising Channel Tx Power (0x08|0x0007) ncmd 2 status 0x00 level 0x0 (dBm) < HCI Command: LE Read White List Size (0x08|0x000f) plen 0 HCI Event: Command Complete (0x0e) plen 5 LE Read White List Size (0x08|0x000f) ncmd 2 0000: 00 20 . < HCI Command: LE Read Supported States (0x08|0x001c) plen 0 HCI Event: Command Complete (0x0e) plen 12 LE Read Supported States (0x08|0x001c) ncmd 2 0000: 00 ff ff ff 1f 00 00 00 00 ......... < HCI Command: Set Event Mask (0x03|0x0001) plen 8 Mask: 0xfffffbff07f8bf3d HCI Event: Command Complete (0x0e) plen 4 Set Event Mask (0x03|0x0001) ncmd 2 status 0x00 < HCI Command: LE Set Event Mask (0x08|0x0001) plen 8 mask 0x1f00000000000000 (Reserved) HCI Event: Command Complete (0x0e) plen 4 LE Set Event Mask (0x08|0x0001) ncmd 2 status 0x00 < HCI Command: Read Local Supported Commands (0x04|0x0002) plen 0 HCI Event: Command Complete (0x0e) plen 68 Read Local Supported Commands (0x04|0x0002) ncmd 2 status 0x00 Commands: ffffff03ccffffff3ffffc9ff30fe8fe3ff78fff1c00000061f7ffff7f < HCI Command: Write Extended Inquiry Response (0x03|0x0052) plen 241 fec 0x00 HCI Event: Command Complete (0x0e) plen 4 Write Extended Inquiry Response (0x03|0x0052) ncmd 2 status 0x00 < HCI Command: Write Inquiry Mode (0x03|0x0045) plen 1 mode 2 HCI Event: Command Complete (0x0e) plen 4 Write Inquiry Mode (0x03|0x0045) ncmd 2 status 0x00 < HCI Command: Read Inquiry Response Transmit Power Level (0x03|0x0058) plen 0 HCI Event: Command Complete (0x0e) plen 5 Read Inquiry Response Transmit Power Level (0x03|0x0058) ncmd 2 status 0x00 level 0 < HCI Command: Read Local Extended Features (0x04|0x0004) plen 1 page 1 HCI Event: Command Complete (0x0e) plen 14 Read Local Extended Features (0x04|0x0004) ncmd 2 status 0x00 page 1 max 0 Features: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 < HCI Command: Delete Stored Link Key (0x03|0x0012) plen 7 bdaddr 00:00:00:00:00:00 all 1 HCI Event: Command Complete (0x0e) plen 6 Delete Stored Link Key (0x03|0x0012) ncmd 2 status 0x00 deleted 0 < HCI Command: Write Default Link Policy Settings (0x02|0x000f) plen 2 policy 0x0f Link policy: RSWITCH HOLD SNIFF PARK HCI Event: Command Complete (0x0e) plen 4 Write Default Link Policy Settings (0x02|0x000f) ncmd 2 status 0x00 < HCI Command: LE Set Advertising Data (0x08|0x0008) plen 32 0000: 12 02 01 0a 02 0a 00 0b 09 52 54 4b 5f 42 54 5f .........RTKBT 0010: 34 2e 30 00 00 00 00 00 00 00 00 00 00 00 00 00 4.0............. HCI Event: Command Complete (0x0e) plen 4 LE Set Advertising Data (0x08|0x0008) ncmd 2 status 0x00 < HCI Command: Reset (0x03|0x0003) plen 0 HCI Event: Command Complete (0x0e) plen 4 Reset (0x03|0x0003) ncmd 3 status 0x00 < HCI Command: Read Local Supported Features (0x04|0x0003) plen 0 HCI Event: Command Complete (0x0e) plen 12 Read Local Supported Features (0x04|0x0003) ncmd 2 status 0x00 Features: 0xff 0xff 0xff 0xfe 0xdb 0xfd 0x7b 0x87 < HCI Command: Read Local Version Information (0x04|0x0001) plen 0 HCI Event: Command Complete (0x0e) plen 12 Read Local Version Information (0x04|0x0001) ncmd 2 status 0x00 HCI Version: 4.0 (0x6) HCI Revision: 0x1e4d LMP Version: 4.0 (0x6) LMP Subversion: 0x3c55 Manufacturer: Realtek Semiconductor Corporation (93) < HCI Command: Read BD ADDR (0x04|0x0009) plen 0 HCI Event: Command Complete (0x0e) plen 10 Read BD ADDR (0x04|0x0009) ncmd 2 status 0x00 bdaddr A0:0A:BF:15:27:70 < HCI Command: Read Buffer Size (0x04|0x0005) plen 0 HCI Event: Command Complete (0x0e) plen 11 Read Buffer Size (0x04|0x0005) ncmd 2 status 0x00 ACL MTU 1021:8 SCO MTU 255:16 < HCI Command: Read Class of Device (0x03|0x0023) plen 0 HCI Event: Command Complete (0x0e) plen 7 Read Class of Device (0x03|0x0023) ncmd 2 status 0x00 class 0x000000 < HCI Command: Read Local Name (0x03|0x0014) plen 0 HCI Event: Command Complete (0x0e) plen 252 Read Local Name (0x03|0x0014) ncmd 2 status 0x00 name 'RTK_BT_4.0' < HCI Command: Read Voice Setting (0x03|0x0025) plen 0 HCI Event: Command Complete (0x0e) plen 6 Read Voice Setting (0x03|0x0025) ncmd 2 status 0x00 voice setting 0x0060 < HCI Command: Set Event Filter (0x03|0x0005) plen 1 type 0 condition 0 Clear all filters HCI Event: Command Complete (0x0e) plen 4 Set Event Filter (0x03|0x0005) ncmd 2 status 0x00 < HCI Command: Write Connection Accept Timeout (0x03|0x0016) plen 2 timeout 32000 HCI Event: Command Complete (0x0e) plen 4 Write Connection Accept Timeout (0x03|0x0016) ncmd 2 status 0x00 < HCI Command: Read Page Scan Activity (0x03|0x001b) plen 0 HCI Event: Command Complete (0x0e) plen 8 Read Page Scan Activity (0x03|0x001b) ncmd 2 status 0x00 interval 2048 window 18 < HCI Command: Read Page Scan Type (0x03|0x0046) plen 0 HCI Event: Command Complete (0x0e) plen 5 Read Page Scan Type (0x03|0x0046) ncmd 2 0000: 00 00 .. < HCI Command: LE Read Buffer Size (0x08|0x0002) plen 0 HCI Event: Command Complete (0x0e) plen 7 LE Read Buffer Size (0x08|0x0002) ncmd 2 status 0x00 pktlen 0x001b maxpkt 0x10 < HCI Command: LE Read Local Supported Features (0x08|0x0003) plen 0 HCI Event: Command Complete (0x0e) plen 12 LE Read Local Supported Features (0x08|0x0003) ncmd 2 status 0x00 features 0x0100000000000000 (Link Layer supports LE Encryption) < HCI Command: LE Read Advertising Channel Tx Power (0x08|0x0007) plen 0 HCI Event: Command Complete (0x0e) plen 5 LE Read Advertising Channel Tx Power (0x08|0x0007) ncmd 2 status 0x00 level 0x0 (dBm) < HCI Command: LE Read White List Size (0x08|0x000f) plen 0 HCI Event: Command Complete (0x0e) plen 5 LE Read White List Size (0x08|0x000f) ncmd 2 0000: 00 20 . < HCI Command: LE Read Supported States (0x08|0x001c) plen 0 HCI Event: Command Complete (0x0e) plen 12 LE Read Supported States (0x08|0x001c) ncmd 2 0000: 00 ff ff ff 1f 00 00 00 00 ......... < HCI Command: Set Event Mask (0x03|0x0001) plen 8 Mask: 0xfffffbff07d8bf3d HCI Event: Command Complete (0x0e) plen 4 Set Event Mask (0x03|0x0001) ncmd 2 status 0x00 < HCI Command: LE Set Event Mask (0x08|0x0001) plen 8 mask 0x1f00000000000000 (Reserved) HCI Event: Command Complete (0x0e) plen 4 LE Set Event Mask (0x08|0x0001) ncmd 2 status 0x00 < HCI Command: Read Local Supported Commands (0x04|0x0002) plen 0 HCI Event: Command Complete (0x0e) plen 68 Read Local Supported Commands (0x04|0x0002) ncmd 2 status 0x00 Commands: ffffff03ccffffff3ffffc9ff30fe8fe3ff78fff1c00000061f7ffff7f < HCI Command: Write Extended Inquiry Response (0x03|0x0052) plen 241 fec 0x00 HCI Event: Command Complete (0x0e) plen 4 Write Extended Inquiry Response (0x03|0x0052) ncmd 2 status 0x00 < HCI Command: Write Inquiry Mode (0x03|0x0045) plen 1 mode 2 HCI Event: Command Complete (0x0e) plen 4 Write Inquiry Mode (0x03|0x0045) ncmd 2 status 0x00 < HCI Command: Read Inquiry Response Transmit Power Level (0x03|0x0058) plen 0 HCI Event: Command Complete (0x0e) plen 5 Read Inquiry Response Transmit Power Level (0x03|0x0058) ncmd 2 status 0x00 level 0 < HCI Command: Read Local Extended Features (0x04|0x0004) plen 1 page 1 HCI Event: Command Complete (0x0e) plen 14 Read Local Extended Features (0x04|0x0004) ncmd 2 status 0x00 page 1 max 0 Features: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 < HCI Command: Delete Stored Link Key (0x03|0x0012) plen 7 bdaddr 00:00:00:00:00:00 all 1 HCI Event: Command Complete (0x0e) plen 6 Delete Stored Link Key (0x03|0x0012) ncmd 2 status 0x00 deleted 0 < HCI Command: Write Default Link Policy Settings (0x02|0x000f) plen 2 policy 0x0f Link policy: RSWITCH HOLD SNIFF PARK HCI Event: Command Complete (0x0e) plen 4 Write Default Link Policy Settings (0x02|0x000f) ncmd 2 status 0x00 < HCI Command: LE Set Advertising Data (0x08|0x0008) plen 32 0000: 12 02 01 0a 02 0a 00 0b 09 52 54 4b 5f 42 54 5f .........RTKBT 0010: 34 2e 30 00 00 00 00 00 00 00 00 00 00 00 00 00 4.0............. HCI Event: Command Complete (0x0e) plen 4 LE Set Advertising Data (0x08|0x0008) ncmd 2 status 0x00 < HCI Command: Reset (0x03|0x0003) plen 0 HCI Event: Command Complete (0x0e) plen 4 Reset (0x03|0x0003) ncmd 3 status 0x00 < HCI Command: Set Event Mask (0x03|0x0001) plen 8 Mask: 0xfffffbff07f8bf3d HCI Event: Command Complete (0x0e) plen 4 Set Event Mask (0x03|0x0001) ncmd 2 status 0x00 < HCI Command: LE Set Event Mask (0x08|0x0001) plen 8 mask 0x1f00000000000000 (Reserved) HCI Event: Command Complete (0x0e) plen 4 LE Set Event Mask (0x08|0x0001) ncmd 2 status 0x00 < HCI Command: Write Simple Pairing Mode (0x03|0x0056) plen 1 mode 0x01 HCI Event: Command Complete (0x0e) plen 4 Write Simple Pairing Mode (0x03|0x0056) ncmd 2 status 0x00 < HCI Command: Write LE Host Supported (0x03|0x006d) plen 2 0000: 01 00 .. HCI Event: Command Complete (0x0e) plen 4 Write LE Host Supported (0x03|0x006d) ncmd 2 0000: 00 . < HCI Command: Write Inquiry Mode (0x03|0x0045) plen 1 mode 2 HCI Event: Command Complete (0x0e) plen 4 Write Inquiry Mode (0x03|0x0045) ncmd 2 status 0x00 < HCI Command: Write Page Scan Type (0x03|0x0047) plen 1 0000: 01 . HCI Event: Command Complete (0x0e) plen 4 Write Page Scan Type (0x03|0x0047) ncmd 2 0000: 00 . < HCI Command: Write Inquiry Scan Type (0x03|0x0043) plen 1 type 1 HCI Event: Command Complete (0x0e) plen 4 Write Inquiry Scan Type (0x03|0x0043) ncmd 2 status 0x00 < HCI Command: Write Class of Device (0x03|0x0024) plen 3 class 0x040240 HCI Event: Command Complete (0x0e) plen 4 Write Class of Device (0x03|0x0024) ncmd 2 status 0x00 < HCI Command: Write Page Timeout (0x03|0x0018) plen 2 timeout 8192 HCI Event: Command Complete (0x0e) plen 4 Write Page Timeout (0x03|0x0018) ncmd 2 status 0x00 < HCI Command: Write Default Link Policy Settings (0x02|0x000f) plen 2 policy 0x05 Link policy: RSWITCH SNIFF HCI Event: Command Complete (0x0e) plen 4 Write Default Link Policy Settings (0x02|0x000f) ncmd 2 status 0x00 < HCI Command: Host Buffer Size (0x03|0x0033) plen 7 ACL MTU 4096:20 SCO MTU 255:10 HCI Event: Command Complete (0x0e) plen 4 Host Buffer Size (0x03|0x0033) ncmd 2 status 0x00 < HCI Command: LE Set Scan Parameters (0x08|0x000b) plen 7 type 0x01 (active) interval 10.000ms window 10.000ms own address: 0x00 (Public) policy: All HCI Event: Command Complete (0x0e) plen 4 LE Set Scan Parameters (0x08|0x000b) ncmd 2 status 0x00 < HCI Command: LE Set Advertise Enable (0x08|0x000a) plen 1 0000: 00 . HCI Event: Command Complete (0x0e) plen 4 LE Set Advertise Enable (0x08|0x000a) ncmd 2 status 0x00 < HCI Command: LE Set Advertising Parameters (0x08|0x0006) plen 15 min 152.500ms, max 152.500ms type 0x00 (ADV_IND - Connectable undirected advertising) ownbdaddr 0x00 (Public) directbdaddr 0x00 (Public) 00:00:00:00:00:00 channelmap 0x07 filterpolicy 0x00 (Allow scan from any, connection from any) HCI Event: Command Complete (0x0e) plen 4 LE Set Advertising Parameters (0x08|0x0006) ncmd 2 status 0x00 < HCI Command: LE Set Advertise Enable (0x08|0x000a) plen 1 0000: 00 . HCI Event: Command Complete (0x0e) plen 4 LE Set Advertise Enable (0x08|0x000a) ncmd 2 status 0x00 < HCI Command: LE Set Scan Response Data (0x08|0x0009) plen 32 0000: 0c 0b 09 49 4e 46 41 4e 49 5f 42 4c 45 00 00 00 ...INFANI_BLE... 0010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ HCI Event: Command Complete (0x0e) plen 4 LE Set Scan Response Data (0x08|0x0009) ncmd 2 status 0x00 < HCI Command: LE Set Advertise Enable (0x08|0x000a) plen 1 0000: 00 . HCI Event: Command Complete (0x0e) plen 4 LE Set Advertise Enable (0x08|0x000a) ncmd 2 status 0x00 < HCI Command: LE Set Advertising Data (0x08|0x0008) plen 32 0000: 15 02 01 06 11 06 8d b9 7b e0 d5 b6 db b7 55 49 ........{.....UI 0010: 3c c5 04 a7 c6 54 00 00 00 00 00 00 00 00 00 00 <....T.......... HCI Event: Command Complete (0x0e) plen 4 LE Set Advertising Data (0x08|0x0008) ncmd 2 status 0x00 < HCI Command: LE Set Advertise Enable (0x08|0x000a) plen 1 0000: 01 . HCI Event: Command Complete (0x0e) plen 4 LE Set Advertise Enable (0x08|0x000a) ncmd 2 status 0x00


I checked the code in device_linux.go is setting advertise mode as "LE General Discoverable Mode", so it shouldn't disappear after starting for a while, is there anyone can figure something out by the above result of hcidump?

Thanks so much.