Peripheral Uart: NUS RX TX characteristics not working on Windows

CONFIG

  • Example reproduced: NRF Peripheral Uart
  • SoC Used: USI AzureSphere Combo Module
  • Windows Version: 11 enterprise (version 10.0.22000)
  • Board type: NRF52DK_nrf52832

Goal:

Setup a windows console that echos the messages received on the COM Port associated to the BLE peripheral

Problem Explainations:

I've managed to connect and pair the BLE Peripheral UART example on my USI Devkit to my Windows machine as expected. The J-LINK RTT Viewer shows the paired and connected status accordingly. Although this solution has worked on the Iphone NRF Connect app to receive and send messages both ways, I'm unable to get any messages to the Windows COM Port.

First, in the Nordic app, I get a data.err stating that the socket isn't connected when I try to send a message through the BLE.
 

Although, In Device Manager, I can see that the BLE Device is shown as a Network Adapter, a COM Port and a bluetooth device.

Even with all this, when I look at the services related with the connected Devkit, I can see that the UART RX and TX characteristics are present but they don't seem to allow any communication.

I'm unsure why this is happening. I can deconnect the devkit from my Windows machine and connect it to the Iphone and all goes as expected on the phone. No code changes are needed when changing between both devices. 

Thanks!

  • Let me see if I understand your issue correctly.

    The following works:

    The following fails:

    Have I understood it correctly?

    From the log I can see that it fails here: https://github.com/nrfconnect/sdk-nrf/blob/v2.1.0/samples/bluetooth/peripheral_uart/src/main.c#L629

    Can you debug the bt_nus_send function? Does it return here (1), here (2), or here(3)? Have you enabled notifications on the Bluetooth central side? If it fails in (1) or (2), could you stored the returned value as an int and print it out?

    Best regards,

    Simon

  • Hi Simon,

    Thanks for the reply. I've detailed my setup below. The link from HL App to Iphone is working both ways. HL App console has sent messages to Iphone and received messages from the phone. All I had to change was the UART GPIOs between the Azure Sphere module and the Nordic.

    The Azure sphere uart example is from here: https://github.com/Azure/azure-sphere-samples/tree/main/Samples/UART/UART_HighLevelApp 

    Setup:



    What's not working is here:


    Here is my prj.conf

    #
    # Copyright (c) 2018 Nordic Semiconductor
    #
    # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
    #
    
    # Enable the UART driver
    CONFIG_UART_ASYNC_API=y
    CONFIG_NRFX_UARTE0=y
    CONFIG_SERIAL=y
    
    CONFIG_GPIO=y
    # Make sure printk is printing to the UART console
    CONFIG_CONSOLE=y
    
    CONFIG_HEAP_MEM_POOL_SIZE=2048
    
    CONFIG_BT=y
    CONFIG_BT_PERIPHERAL=y
    CONFIG_BT_DEVICE_NAME="Nordic_UART_Service"
    CONFIG_BT_DEVICE_APPEARANCE=63
    CONFIG_BT_MAX_CONN=2
    CONFIG_BT_MAX_PAIRED=2
    
    
    # Enable the NUS service
    CONFIG_BT_NUS=y
    
    # Enable bonding
    CONFIG_BT_SETTINGS=y
    CONFIG_FLASH=y
    CONFIG_FLASH_PAGE_LAYOUT=y
    CONFIG_FLASH_MAP=y
    CONFIG_NVS=y
    CONFIG_SETTINGS=y
    # CONFIG_BT_NUS_UART_ASYNC_ADAPTER=y
    
    # Enable DK LED and Buttons library
    CONFIG_DK_LIBRARY=y
    
    # This example requires more workqueue stack
    CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
    
    # Config logger
    CONFIG_LOG=y
    CONFIG_USE_SEGGER_RTT=y
    CONFIG_LOG_BACKEND_RTT=y
    CONFIG_LOG_BACKEND_UART=n
    
    CONFIG_ASSERT=y
    CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC=y
    CONFIG_BT_BONDING_REQUIRED=y
    
    CONFIG_BT_SMP=y
    


    Here is my app.overlay
    /*
     * Copyright (c) 2022 Nordic Semiconductor ASA
     *
     * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
     */
    
     / {
    	chosen {
    		nordic,nus-uart = &uart0;
    	};
    };
    
    &pinctrl {
    	uart0_default: uart0_default {
    		group1 {
    			psels = <NRF_PSEL(UART_TX, 0, 26)>,
    				<NRF_PSEL(UART_RX, 0, 28)>,
    				<NRF_PSEL(UART_RTS, 0, 25)>,
    				<NRF_PSEL(UART_CTS, 0, 27)>;
    		};
    	};
    
    	uart0_sleep: uart0_sleep {
    		group1 {
    			psels = <NRF_PSEL(UART_TX, 0, 26)>,
    				<NRF_PSEL(UART_RX, 0, 28)>,
    				<NRF_PSEL(UART_RTS, 0, 25)>,
    				<NRF_PSEL(UART_CTS, 0, 27)>;
    			low-power-enable;
    		};
    	};
    };
    
    &arduino_spi {
    	status = "disabled";
    };
    &spi1 {
    	status = "disabled";
    };
    &arduino_i2c {
    	status = "disabled";
    };
    &i2c1 {
    	status = "disabled";
    };
    &i2s0 {
    	status = "disabled";
    };
    &pwm0 {
    	status = "disabled";
    };



    Responses:


    For the  bt_nus_send , when bonded and connected, I enter here if the message I try to send comes from the HL App. 

    Although, when using windows, I reach the end of bt_gatt_notify_cb with data.err = -ENOTCONN

    With further testing, I could confirm that everything goes well on the NRF Connect app for receiving the HL App messages only when I click on this in-app button below. Without it, I get the same -ENOTCONN error value and hence the same error message (peripheral_uart: Failed to send data over BLE connection. Error: -128) in the JLink RTT Viewer.


    I'm not sure what is the equivalent for this button on Windows. I looked online and couldn't find a clear information about it.

    For this question: Have you enabled notifications on the Bluetooth central side?

    I'm not 100% sure what you're referring too. Sorry. I hope this information helps.

  • frousseau said:
    With further testing, I could confirm that everything goes well on the NRF Connect app for receiving the HL App messages only when I click on this in-app button below. Without it, I get the same -ENOTCONN error value and hence the same error message (peripheral_uart: Failed to send data over BLE connection. Error: -128) in the JLink RTT Viewer.

    What app are you using on Windows to communicate with the nRF52832? If you're not able to enable notifications for the TX characteristic on that app, you won't be able to send any messages (notifications) to the computer. Please contact the company/developers that have created that app.

    It seems like you have figured out how to enable notifications in the nRF Connect Mobile app (blue button with white arrows pointing down).

    Some theory about notifications and Bluetooth Low Energy roles

    In order to be able to send data over Bluetooth from the server (peripheral_uart) to the client (app or Windows machine), you need to do it through notifications (or indications).

    Read more about the different Bluetooth Low Energy roles, server, client, peripheral, central here:

     What is a client and server in BLE? 

    Read more about notifications here:

    https://www.oreilly.com/library/view/iot-projects-with/9781788399449/aa82aa0b-bdb3-4c94-b330-fd2ad0465ec7.xhtml

    In order to be able to notify from the server, the client needs to enable notifications. More specifically, you enable notifications by writing to the CCCD, read more about it here: https://www.oreilly.com/library/view/getting-started-with/9781491900550/ch04.html 

    Best regards,

    Simon

  • As of now, I'm only trying to reproduce what is stated in the testing section of the Nordic Peripheral Uart example here: https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/samples/bluetooth/peripheral_uart/README.html#testing

    I am not using any special app to communicate with the NRF52832. I connected and paired the Devkit using the Windows bluetooth embedded features. I followed the steps in the example for Putty on Windows and thought I would have all the messages from the Nordic UART forwarded on the COM port created on Windows. 

    So I have the JLink RTT Viewer for debugging but nothing comes on the COM port as stated in the testing section of the example. Read or write from the Putty console on the COM port 7 shown in my original post does nothing.

    Regards,

    Francis

  • frousseau said:
    I am not using any special app to communicate with the NRF52832. I connected and paired the Devkit using the Windows bluetooth embedded features.

    This is not possible, see  RE: Connecting NRF52840 DK with PC through BLE for explanations why.

    "The Nordic UART service is a proprietary BLE service which enables transferring strings wirelessly, but support for this is not available in Windows, etc., and is not mappable to any virtual COM port in the OS.

    For later OSes, you can use BLE API to connect and interact with BLE devices from applications...."

    Best regards,

    Simon 

Related