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

Sending Data Over BLE 5 Modules in Long Range with ble_app_uart

Hi,

I wanted to send data over Bluetooth 5.0 modules and to see on a terminal. So I used nRF52840 DK as central device ( ble_app_uart_c) and Fanstel modules ( ble_app_uart) as peripheral. I programmed them successfully and observed that nRF52840 DK paired with advertising Fanstel module (LED 1 is ON) . I see printed data on the terminal. Everything is fine so far. I've couple of questions. 

1. I know that long range advertisement is done by coded PHY (with nrf52840). Is it possible that I can send data in long range by using ble_app_uart ? Fanstel module I use supports BLE data rates: 2Mbps, 1Mbps, 500kbps,125kbps and I want to increase the range as possible as I can.

2. Can more than one advertising peripheral pair with the central device ?

3. In ble_app_uart, name of the advertising device is specified :

 

#define DEVICE_NAME                     "Nordic_UART"

I can't find related code line in ble_app_uart_c. How can I change the name of device central tries to connect to ?

4. I used RTT Viewer to see data because Putty didn't work I don't know why. Are there any other programs you could suggest for this operation ?

5. Is it enough to use NRF_LOG_INFO to print data ? I mean should I use a function ?. Also, I would like to know  the maximum data length I can send  with ble_app_uart example.

I will be very glad if you help me.

Thank you in advance.

Best Regards.

Parents
  • Hi,

    1. It advertises on 1M by default but can be modified to advertise on coded PHY instead. Please take a look at the 2 examples I uploaded here: https://devzone.nordicsemi.com/f/nordic-q-a/40476/unable-to-convert-to-long-range-after-looking-at-umpteen-examples--/157300#157300 

    2. Yes, except that ble_app_uart example does not support pairing by default. It will reject any pairing requests coming from the central. Do you wish to support link encryption in your project? In that case, I'd recommend looking for examples that include the Peer Manager library : Peer Manager

    3. It doesn't check the device name, only that it contains the NUS service UUID. The UUID filter is enabled in scan_init().

    4. RTT log should be displayed automatically in Segger embedded studio while debugging. But you may have to disable 'NRF_FPRINTF_FLAG_AUTOMATIC_CR_ON_LF_ENABLED' in sdk_config.h for it to work properly. 

    5.  It can send up to 244 in one packet provided the peer device also supports it. There is no limit to how many packets you can send. And yes you can use NRF_LOG_INFO to print data.

    Best regards,

    Vidar

  • Thank you Vidar !

    -I will review the examples you added and will check examples that includes Peer Manager.

    -I've just reviewed scan_init() function. The thing is that I don't know how to find UUID of my periphreal device. I tried to see UUID on nRF Connect but I can see only MAC address. I think I should put UUID in advertising packet, shouldn't I ?

    - My purpose is to send data from peripheral device to central device and print data on the terminal. I only see strings like "Connected to device with Nordic UART Service " on RTT viewer when advertising device pairs with the central. For example, what should I do if I just want to send a "Hello World" over peripheral and print it on the terminal ?

    Best Regards

  • OpenCircuit said:
    I've just reviewed scan_init() function. The thing is that I don't know how to find UUID of my periphreal device. I tried to see UUID on nRF Connect but I can see only MAC address. I think I should put UUID in advertising packet, shouldn't I ?

     Yes, the UUID must be included in the advertisement payload for this filter to wokr. But you can filter on other paramaters such as the device name. You can take a look at the ble_app_blinky_c example for an example of how to set up a device name filter with the Scanning Module

    OpenCircuit said:
    My purpose is to send data from peripheral device to central device and print data on the terminal. I only see strings like "Connected to device with Nordic UART Service " on RTT viewer when advertising device pairs with the central. For example, what should I do if I just want to send a "Hello World" over peripheral and print it on the terminal ?

     The examples prints out the data received on BLE out on the UART interface. Instructions on how to test this can be found in the example documentation here: Nordic UART Service Client

  • Thank you for your answer.I can see UUID of my peripheral device on nRF Connect.

    Also, I used Tera Term and finally saw the data on the terminal. I think only printf() function prints data on UART, doesn't it ?

    I have another confusion:


    - Don't we see the data we sent by using printf() function on ble_app_uart_c  already ? Do I actually send data or it only prints "Connected to device with Nordic UART Service." when central device pairs with the advertising peripheral device ?
    - If I should send data by creating packets, could you please tell me that where should I start to create packet ?

Reply
  • Thank you for your answer.I can see UUID of my peripheral device on nRF Connect.

    Also, I used Tera Term and finally saw the data on the terminal. I think only printf() function prints data on UART, doesn't it ?

    I have another confusion:


    - Don't we see the data we sent by using printf() function on ble_app_uart_c  already ? Do I actually send data or it only prints "Connected to device with Nordic UART Service." when central device pairs with the advertising peripheral device ?
    - If I should send data by creating packets, could you please tell me that where should I start to create packet ?

Children
  • Happy to help:)

    OpenCircuit said:
    Also, I used Tera Term and finally saw the data on the terminal. I think only printf() function prints data on UART, doesn't it ?

     The nRF logging module (Logger module) supports logging over UART, but it's not enabled in this particular example because the UARTE0 instance is already being used for the serial port emulation.  

    OpenCircuit said:
    Don't we see the data we sent by using printf() function on ble_app_uart_c  already ? Do I actually send data or it only prints "Connected to device with Nordic UART Service." when central device pairs with the advertising peripheral device ?

     printf() is redirected to uart_tx()  and received by the serial client (tera term). It's data received on the UART RX (e.g., from Tera term) that will be relayed to the other device over BLE. 

    OpenCircuit said:
    If I should send data by creating packets, could you please tell me that where should I start to create packet ?

     See Handling data received from UART. You pass the data you want to send to ble_nus_c_string_send()

  • Okay, I understand now.  Sorry for the late answer :)
    Before I verify your answer, I would like to clear somethings up:

    - When should we use ble_nus_string_send instead of printf() function to monitor received data ?

    - ble_nus_c_string_send() is in  ble UART Central example. But I want to send data from peripheral to central. So I think  I should use ble_nus_data_send function in ble UART periphreal example, shouldn't I ? Let's say I write this in main() in ble_app_uart example :

    static uint8_t data_array[BLE_NUS_MAX_DATA_LEN] = "Hello World";
            uint16_t length = 11;
    
            ble_nus_data_send(&m_nus, data_array, &length, m_conn_handle);

    After that, what should I do to see data on the central side ?

    Thank you in advance.

  • OpenCircuit said:
    When should we use ble_nus_string_send instead of printf() function to monitor received data ?

     Use ble_nus_string_send()  when you want to send data to a connected peer device and printf when you want to print something out on the UART interface.

    OpenCircuit said:
    ble_nus_c_string_send() is in  ble UART Central example. But I want to send data from peripheral to central. So I think  I should use ble_nus_data_send function in ble UART periphreal example, shouldn't I ? Let's say I write this in main() in ble_app_uart example :

     Yes, you can use the function to send data. Check the return value to see if the data is being sent or not.

    uint32_t err_code = ble_nus_data_send(&m_nus, data_array, &length, m_conn_handle);

    NRF_LOG_INFO ("ble_nus_data_send returned 0x%x", err_code) // return value 0 is the same as NRF_SUCCESS

Related