This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Multi-NUS-Master forwards gibberish from Peripherals

After several months of attempts, I was finally able to load, build, and flash the code from multi-NUS-master.zip using the VS version of nRF Connect, onto the nRF52840 DevKit. The code appears to run, and it connects to multiple Peripherals via the NUS service. When a peripheral sends data via NUS, the master tries to forward it via the Interface MCU to the USB serial port. However, the data is gibberish. I have looked at the data being received, on the serial TxD line (P0.06) between the nRF52840 and the Interface MCU. It should be pure printable ASCII text, but the first few bytes are 0x00, 0x1D, 0x00, 0x20, 0x03. The over-the-air BLE data is fine, because I can view that with a single-connection version of the uart-c example running on another board. So I am suspecting that somewhere in the multi-NUS-master code a buffer is not being allocated correctly, a pointer is corrupted, etc. I furhter suspect the underlying problem is that I missed configuring something important in the nRF Connect or VS installation. Can anybody give me some pointers? (pun intended)

  • Hi Steve, 

    Have you tried to test with the exact SDK version that the author made the example for ? 


    If you look into the nus_client.h located at \nrf\include\bluetooth\services in SDK v1.5.0/1.4.1 and in SDK v1.9.1 you can find these differences: 

    So in SDK v1.9.1 the nus client instance is returned to the call back when it was not there in SDK v1.4.1 (and SDK v1.5.0)

    This will cause a trouble if you just try to use the example out of the box in the new SDK v1.9.1

    The input arguments was not correctly aligned between the ble_data_received() and ble_data_sent() callbacks. 

    What you need to do is to change the definition of ble_data_received() and ble_data_sent() to these: 

    static uint8_t ble_data_received(struct bt_nus_client *nus, const uint8_t *const data, uint16_t len)
    
    static void ble_data_sent(struct bt_nus_client *nus, uint8_t err, const uint8_t *const data, uint16_t len)

    So that the first argument is struct bt_nus_client *nus. 

    on_received() function is defined in nus_client.c in \nrf\subsys\bluetooth\services.
    Note that the source code of the program is not just in main.c but also in the SDK libraries as shown here:

    The nus_client.c library is automatically added by Cmakelist when you configure CONFIG_BT_NUS_CLIENT=y
Related