This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Operation not supported (95) when using NRF52

Hi,

I am interested in using a pair of NRF52840 USB dongles to communicate on the L2CAP layer. I have flashed the dongles with the Zephyr's hci_usb samples, and have been able to connect the dongles with bluetoothctl. Now, I want to do the same using the socket functionality to use the L2CAP communication layer, however, I am receiving strerror EOPNOTSUPP (95): "Operation not supported", when using client-side connect() from sys/socket.h. I'm afraid I'm doing something conceptually wrong, but I also get the exact same error when trying hci_inquiry() from bluetooth/l2cap.h

Code example:

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <bluetooth/bluetooth.h>
#include <bluetooth/l2cap.h>
#include <errno.h>

extern int errno ;

int main(void)
{
    struct sockaddr_l2 addr = { 0 };
    int s, status;
    char *message = "hello!";
    char dest[18] = "ED:67:8A:54:94:40";

    // allocate a socket
    s = socket(AF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_L2CAP);

    // set the connection parameters (who to connect to)
    addr.l2_family = PF_BLUETOOTH;
    addr.l2_psm = htobs(0x1001);
    str2ba( dest, &addr.l2_bdaddr );

    // connect to server
    status = connect(s, (struct sockaddr *)&addr, sizeof(addr));

    // send a message
    if( status == 0 ) {
        status = write(s, "hello!", 6);
    }

    int errnum = errno;
    if( status < 0 ) perror("uh oh");
    if( status < 0 ) fprintf(stderr, "Error number: %d\n", errno);

    close(s);
}

Some more info:

1) This isn't likely because I don't have a server-side listening since I get the same error with a different example using hci_inquiry() for scanning nearby devices.

2) The code reports "No route to host" (113) when unplugging the dongle.

3) Tried this code with NRF52_PCA10040 with hci_uart sample running.

4) Tried manually changing the default 00:00:00:00:00:00 address to something else.

5) Socket gets allocated properly

Hope you can help!

Parents
  • I'm sorry but nRF Connect SDK does not support nRF52840, only nRF9160. To use Zephyr samples on nRF52 series, please follow this guide. More information can be found in this link, and as stated in the bottom of the page: "Also if you want to get involved with Zephyr, or simply need help as a user, you can join the Zephyr mailing list or join the #zephyrproject IRC channel."

    Nordic Semiconductor is part of the Zephyr Project and contributes with misc. components/software, but we do not give support for Zephyr running on nRF52840.  

    Thanks for your understanding. 

    Best regards,

    Simon

  • Thanks, Simon. 

    I decided to post this here as this seemed to be an issue related to the NRF52 device's capabilities in running these commands, rather than the Zephyr HCI layer.

    Nevertheless, I got the dongles to connect! For anyone interested, hci_le_create_conn() from the Bluez HCI library seems to do the trick. I'm thinking that the connect() and hci_inquiry() functions are not targeted for BLE devices. Secondly, the HCI USB controllers must be running on separate hosts.

    Best of luck!

Reply
  • Thanks, Simon. 

    I decided to post this here as this seemed to be an issue related to the NRF52 device's capabilities in running these commands, rather than the Zephyr HCI layer.

    Nevertheless, I got the dongles to connect! For anyone interested, hci_le_create_conn() from the Bluez HCI library seems to do the trick. I'm thinking that the connect() and hci_inquiry() functions are not targeted for BLE devices. Secondly, the HCI USB controllers must be running on separate hosts.

    Best of luck!

Children
Related