Personally I think the abstraction is in the wrong place. In most systems including Linux you provide HCI, L2CAP and RFCOMM sockets from the kernel, then all the GATT and connection management logic is moved into a daemon that runs in user space. Some devices do not exposed HCI so the kernel implements a virtual HCI inteface.
This is going to make things like Bluetooth mesh even harder to implement. This is also the abstraction that's Zephyr also mostly take. With the exception of the case where it is implementing the controller. In that case it still exports the HCI interface. https://docs.zephyrproject.org/latest/guides/bluetooth/bluetooth-arch.html --Brennan On Sun, Aug 23, 2020, 8:16 PM Matias N. <mat...@imap.cc> wrote: > Hi, > > I'm continuing work on BLE on the NRF52832 and I would like to instantiate > a GATT server (to eventually provide HID over GATT for providing a > bluetooth mouse). Looking at the upper layers of BLE in NuttX you can see > that it ends up in a network devices which exposes different functionality > via IOCTL calls. While there are calls to access GATT attributes as a > client (discovering, reading, writing, etc. to a remote GATT server), > there's no interface for instantiating a server. > > Looking at bt_gatt.h, there are definitions which can be used to register > a table of characteristics using bt_gatt_register() call. Now, this table > holds pointers to callback functions which are invoked to retrieve the > value of each characteristic, as it is requested by the remote client. This > means that if I were to expose this bt_gatt_register() function via an > IOCTL call (receiving a pointer to the table), the networking layer would > be calling into a userspace function. As this is undesireable I'm thinking > what would be the best way to support this. > > An alternative would be to skip the network layer completely, writing a > device driver representing the mouse itself and have that driver interact > with bt_* functions. This way, all of this is at OS level. However, there's > a lot of functionality on the bt_netdev level which I would be losing and > I'm not sure if it is supposed to be used like this (ie, having something > in parallel to the network layer accessing BLE from a driver). > > Anyone with knowledge of BLE have any hints? I don't know how for example > Linux decouples this. > > Best, > Matias