btashton edited a comment on pull request #1661: URL: https://github.com/apache/incubator-nuttx/pull/1661#issuecomment-695827055
> > Right now it is calling `bt_hci_recieve` which I think needs to be changed to input the data to the networking layer and let the network driver figure how to process this, right? What is the interface I should use for this? Is it `bluetooth_input`? I'm guessing `bt_netdev.c` should be extended to be able to directly receive HCI packets and not only L2CAP packets via `btnet_l2cap_receive`. > > Isn't this a problem similar to the Ethernet raw packet input? In that case, the driver does not call any of the *_input() functions, instead is calls a packet tap function (pkt_input()). The raw packet logic then decides of the packet is one that it should pick off or not. It returns an indication if the packet was consumed or not. If it was not consumed, then the network driver dispatches to a protocol-specific network stack input function. > > Can the network decide if the packet is an HCI packet based on the addressing in the packet and on some configured socket address? In Linux this is done by looking at what channel the socket is connected to via BTPROTO_HCI. RAW is basically a dumb pipe that just requires the interface to be up but you might stomp on the kernel managing it (like using i2ctool). USER actually requires the interface to be down and explicitly disconnects and other use. CONTROL implements the management API. You can see how I connected via the USER channel here in the sim: ``` /**************************************************************************** * Name: bthcisock_host_open * * Description: * Open a User Channel HCI socket on the Host for the given device. * This will also disconnect the device from existing management. It can * still be monitored using an HCI monitor socket. * * Input Parameters: * dev_idx: This is the device index to be connected to. HCI0 would be 0. * * Returned Value: * Zero is returned on success; a negated errno value is returned on any * failure. * ****************************************************************************/ int bthcisock_host_open(int dev_idx) { int err; struct sockaddr_hci addr; int fd = socket(PF_BLUETOOTH, SOCK_RAW | SOCK_CLOEXEC | SOCK_NONBLOCK, BTPROTO_HCI); if (fd < 0) { return fd; } /* We must bring the device down before binding to user channel */ err = ioctl(fd, HCIDEVDOWN, 0); if (err < 0) { return err; } memset(&addr, 0, sizeof(addr)); addr.hci_family = AF_BLUETOOTH; addr.hci_dev = dev_idx; addr.hci_channel = HCI_CHANNEL_USER; err = bind(fd, (struct sockaddr *) &addr, sizeof(addr)); if (err < 0) { close(fd); return err; } return fd; } ``` ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org