Closed leoneu closed 10 years ago
The gatt_server example hangs after calling srv.AdvertiseAndServe().
AdvertiseAndServe
is intended to block, much like net/http
's ListenAndServe
. You can always go srv.AdvertiseAndServe
instead. (Or put it inside a closure so that you can check the error message.)
I can see the Peripheral name using LightBlue but not the characteristics.
Hmmm. So to be clear, you see the peripheral broadcasting, but you can't connect to it? Or is it that you can connect to it, but you don't get back a listing of services?
If you're using LightBlue on your laptop, please try turning off wi-fi on your laptop and trying again. Or try LightBlue from a phone.
I mean it never gets to output the log message: "Advertising service..." as I can see in your demo. It seems to be hanging before reaching that message. I can see the standard services advertised for the device on LightBlue such as 1800, 1801, etc. but not the service from the sample program. So the connection seems to be OK. The same happens on Intel/Linux.
Could be something related to the BLE device, I'll try to get a different one. If you have suggestions on how I can debug, let me know.
The problem doesn't seem to be hardware related. I was able to connect using command line tools. Example in Stack Overflow.
Hmmm. A few more sanity checks:
sudo service bluetooth stop
hci
shim separately? /usr/local/bin/hci-ble 0
I now stopped the bluetooth service, no change.
> sudo hciconfig hci0 up
> hciconfig hci0
hci0: Type: BR/EDR Bus: USB
BD Address: 00:02:72:C5:C1:80 ACL MTU: 1021:8 SCO MTU: 64:1
UP RUNNING PSCAN
RX bytes:7333 acl:12 sco:0 events:520 errors:0
TX bytes:9423 acl:11 sco:0 commands:504 errors:0
> /usr/local/bin/hci-ble 0
hciDeviceId 0
adapterState poweredOn
...
[hangs here]
Thanks for your patience with me as we sort this out.
I now stopped the bluetooth service, no change.
Bummer. The bluetooth service would definitely have caused the symptoms you see.
Are you willing to try gatt_server.go
again one more time, just to sanity check? Note that many centrals aggressively cache a peripheral's services and characteristic, so you might need to power cycle your phone or clear your OS X Bluetooth cache in order for them to see the new services and characteristics. (See http://godoc.org/github.com/paypal/gatt. Yes, it is very frustrating.)
> /usr/local/bin/hci-ble 0
hciDeviceId 0
adapterState poweredOn
...
[hangs here]
Is the ...
part of the output? Does it represent elided output? Or does it just represent "hang"?
Good news! I replaced the Plugable BLE dongle with a CSR BLE dongle and now it works. In summary:
I will do more testing to see if I find anything else. Thanks!
Sweet. Thanks!
If you're game, I'd love a pull request starting a section on known (non-)functional BLE adapters. The one I use is http://www.amazon.com/gp/product/B007GFX0PY/ref=oh_details_o00_s00_i00?ie=UTF8&psc=1.
go.dbus looks promising. I'd love to not have to do all that awful c shim muck. If you look into it and/or get anything working, please keep me posted!
The gatt_server example hangs after calling srv.AdvertiseAndServe().
I can see the Peripheral name using LightBlue but not the characteristics. The sample server never prints an output to stdout, just hangs there.
I'm using the plugable USB dongle: