Closed shirou closed 9 years ago
We rely on kernel v3.14+ though you can find the patches for older kernels. v3.10 should have no conflict apply those patches if I remember correctly :-)
To gain complete and exclusive control of the HCI device, gatt uses HCI_CHANNEL_USER (introduced in Linux v3.14) instead of HCI_CHANNEL_RAW. Those who must use an older kernel may patch in these relevant commits from Marcel Holtmann:
Bluetooth: Introduce new HCI socket channel for user operation
Bluetooth: Introduce user channel flag for HCI devices
Bluetooth: Refactor raw socket filter into more readable code
Thank you! I will try it.
I have not read source code deeper, but if paypal/gatt does not work with HCI_CHANNEL_RAW
, I think newSocket()
should return err instead of trying HCI_CHANNEL_RAW.
https://github.com/paypal/gatt/blob/master/linux/device.go#L80
And, since noble works well on the Edison, I hope paypal/gatt also work with old kernel. (I will read noble and bluez code later)
I read noble code and found it invokes a small c program which uses bluez. https://github.com/sandeepmistry/noble/blob/master/lib/linux/hci-ble.js#L7
I think this architecture is not suite for paypal/gatt, so I close this issue. I you have any other suggestion, I will appreciate. Thank you.
@shirou
I want to use paypal/gatt on the Intel Edison (Linux edison 3.10.17-poky-edison+ #1 SMP PREEMPT Fri Jun 19 12:06:40 CEST 2015 i686 GNU/Linux)
, for discovering BLE peripherals.
So I modified some files, and had succeeded it. https://github.com/mrkm/gatt/commit/7734366089cd979468a5071e948a2fbf8bbf11ce
To use these patched codes, compile with -tags=hci_channel_raw
option.
go build -a -tags=hci_channel_raw discoverer.go
(Make sure rfkill unblock bluetooth
and hciconfig hci0 up
)
@mrkm wow, it's looks like great works! I have not checked on my Edison yet, but tomorrow, I will do!
@mrkm I confirmed your code works great on my Edison. Bravo!! How about create new device struct and add to HCI_CHANNEL_RAW handling ? Then, your code can be merged to this repository.
@shirou Thank you for your testing and kind advice. I'll give it a try!
@mrkm any plans to rebase this and get it to be merged ?
@abourget Sorry, I don't have enough time to do that.
I see there is some duplicate code.. is it a big effort to rework that patch into something elegantly mergeable ? Do you think it takes a lot of familiarity with bluetooth's internals ?
From https://github.com/paypal/gatt/pull/20, I expected gatt works on Intel Edison, but not worked.
examples/discover.go starts scanning but nothing happen.
My environment is below. To avoid cross compiling issue, I have started from self build on Intel Edison.
Thanks!