nRF UART central data send error

I'm trying to connect a nRF52832 DK to a secondary device (BLUETOOTH LOW ENERGY TINYSHIELD (ST)) where the nRF is the central. The example correctly connects to the board when it starts advertising but when I enter data over UART via PuTTY, I'm faced with an error (128).

I've tried to connect to a nRF52840 dongle with nRF connect and an Android phone setup with the UART service UUID and UART TX / UART RX characteristics. This behaves the same.

My second thought was that it has to do with security/bonding. However, since this is initiated from the Central, this would've been included in the NUS service included in the example so this doesn't seem correct. 

Since the error (128) means socket not connected, I figured there must be something wrong with the connection. I've tried to modify &nus_client in bt_nus_client_send() to NULL so it would be sent to any connection available. However, this results in an 'Operation already in progress' error (120). 

Any idea what I'm missing?

  • Hi Simon,

    Thanks for providing the XML file to sanity check my setup. With your XML I was having similar issues. Therefore, I started with a fresh example to retrace my steps. This fresh example worked like intended.

    I edited the example with:

    prj.conf
    CONFIG_BT_SCAN_NAME_CNT=1
    and main.c

        err = bt_scan_filter_add(BT_SCAN_FILTER_TYPE_NAME, "BlueNRG");
        if (err) {
            LOG_ERR("Scanning filters cannot be set (err %d)", err);
            return err;
        }

        err = bt_scan_filter_enable(BT_SCAN_NAME_FILTER, false);
        if (err) {
            LOG_ERR("Filters cannot be turned on (err %d", err);
            return err;
        }
    This allows auto-connect to my peripheral. After this, I was able to write from the peripheral to the nRF52 but not the other way around. This turned out to be caused by not having the right properties set up for the UART_RX characteristic. With this fix everything is working as intended. 
    I'm still not sure why my original example was not behaving as intended but I'm happy the fresh example works.

    Thanks for your help.

    Glenn

  • Glad to hear you figured it out, although it's very strange that the XML file did not work for you.

    Best regards,

    Simon

Related