简体   繁体   中英

gatttool and hcitool on Linux

I'm trying to connect to a device using gatttool on Linux. I run hcitool lescan to get the device MAC address, and then gatttool -i hci1 -b <macaddr> -t random -I . Then I type connect . I see [CON] as expected, but the problem is that it disappears automatically after about 1s, with no error messages. I have been searching for hours, but I don't see why that is so?

Note: I have run hcitool lecc before running gatttool one time just to try it, but it seems to me that since then, gatttool connection is not working properly anymore (unexpected disconnection as explained above). Is it because I have used hcitool lecc ? If yes, is there a way to "undo" it?

Not sure if this helps you because I'm seeing this behavior on my Raspberry Pi (an up-to-date wheezy version) and bluez 5.18 (released April 2014.)

  1. I can connect to my BLE peripheral from the command line after doing an lecc without any problems. I don't think you need to reset after an lecc . Regardless, if you do want to reset your BT dongle because it is in some funky state, look at this excellent step-by-step guide to reset the BT dongle. I have followed these steps with consistent results.

  2. I can connect and query say primary but more often than not, the connection drops before I can manually type in primary . See the results below. If I use the up/down arrows after connecting to quickly scroll to primary , I am able to see primary services offered by this peripheral without any problems.

~ $ sudo gatttool -I -i hci0 -m 48 -b 20:CD:39:A8:11:AF

[20:CD:39:A8:11:AF][LE]> connect

Attempting to connect to 20:CD:39:A8:11:AF

Connection successful

[20:CD:39:A8:11:AF][LE]> primary

Command Failed: Disconnected

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM