btashton commented on pull request #1661: URL: https://github.com/apache/incubator-nuttx/pull/1661#issuecomment-690766972
> I'm trying to follow where these changes are going, to understand how to adapt the ATT layer. I see that an L2CAP socket will do: > > bluetooth_send -> bluetooth_l2cap_send -> psock_bluetooth_sendto -> netdev TX queue (bluetooth_sendto_eventhandler) -> radio->r_req_data (btnet_req_data) -> bt_l2cap_send -> bt_conn_send > > whereas the ATT layer calls directly into `bt_l2cap_send`. I'm guessing this is the point where the socket should be used. However, at this point the ATT layer uses a `bt_conn_s` to identify a given connection. I imagine that replacing this with just the socket fd would be enough. Does that sound right to you? The server socket logic for an ATT channel would look something like this. Were srcaddr is the local device address and cliaddr will end up being the address of the device that connected to the server. ``` int sock, clisock; struct sockaddr_l2 srcaddr, cliaddr; sock = socket(PF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_L2CAP); srcaddr.l2_family = AF_BLUETOOTH; srcaddr.l2_cid = htole16(0x0004); srcaddr.l2_bdaddr_type = src_type; srcaddr.l2_bdaddr = src; bind(sock, (struct sockaddr *) &srcaddr, sizeof(srcaddr)); listen(sock, 5); optlen = sizeof(cliaddr); clisock = accept(sock, (struct sockaddr *) &cliaddr, &optlen); close(sock); ``` I did notice that both **accept** and **listen** are not supported by the socket interface right now so that would need to be implemented. ---------------------------------------------------------------- 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