On 8/24/2020 2:20 PM, Brennan Ashton wrote:
On Mon, Aug 24, 2020 at 12:34 PM Gregory Nutt <spudan...@gmail.com> wrote:
Some of the things you have speculated about would be contrary to these
principles. The basic wireless rules are:
1. Network sockets are used to communicate with complex wireless
networks (like bluetooth)
2. Character drivers should be avoided
3. Network interfaces must/should be compatible with corresponding Linux
interfaces.
I think if there are features that you want to implement, you might
first want to look at how those features are implemented in Linux. That
would be the correct way to proceed.
I fully agree with this. AF_BLUETOOTH is already in place, but it
only implements "BTPROTO_L2CAP" all of the GATT and
advertising/scanning related functionality is implemented over
"BTPROTO_HCI"
fd = socket(PF_BLUETOOTH, SOCK_RAW | SOCK_CLOEXEC | SOCK_NONBLOCK, BTPROTO_HCI);
addr.hci_family = AF_BLUETOOTH;
addr.hci_dev = dev_id;
addr.hci_channel = HCI_CHANNEL_RAW;
HCI event filters are then controlled via socket options with SOL_HCI
and HCI_FILTER
Most of these are defined in the NuttX bluetooth stack, but they have
not been implemented.
If you bind using HCI_CHANNEL_RAW and not the HCI_CHANNEL_USER the
Linux kernel will take care of some of the GAP related actions, there
is also a management socket that is exposed as well.
I see that there is an ioctl interface for the bluetooth network
driver, but I don't think this is really a good idea. GATT is really
something that should be handled in userspace.
I finally have a few weeks off, so I can see about making some HCI
socket progress, going to take a bit to get hardware setup for it
though.
--Brennan
I have been puzzling through the Goobledegook GATT server (GGK,
https://github.com/moovel/gatt-server fork). It uses the Bluez D-Bus
interface. It is GPLv3 so not a candidate for porting. And also not
much use for understanding APIs since the OS interface is hidden inside
of the Bluez D-Bus interface
(https://core.docs.ubuntu.com/en/stacks/bluetooth/bluez/docs/reference/dbus-api)
I think there are several of us who would help with clean
Linux-work-alike Bluetooth support.