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

send data by ble uart

Hi

I use SES and nRF52832 dongle . I want to send data on "ble uart" and get that data on "nRF UART v2.0" app. mean i want send a string in program while every 5 second and get it on mobile app. I did different ways. But it didn't work.

I use this example "\nRF5SDK160098a08e2\examples\ble_peripheral\ble_app_uart\pca10040\s132\ses"

pls help me .

  • it didn't work

    So what, exactly, did you do?

    And what investigation / testing / debugging have you done to find where it's going wrong ?

    Did the unmodified example work ?

    nRF52832 dongle

    Nordic don't make such a thing - so please give details.

    Or did you mean an nRF52832 DK (Development Kit):

    https://www.nordicsemi.com/Software-and-Tools/Development-Kits/nRF52-DK

    Or an nRF52840 Dongle:

    https://www.nordicsemi.com/Software-and-tools/Development-Kits/nRF52840-Dongle

  • I use a nRF52832 chip(SoC) on a PCB according to Nordic reference circuitry schematic. The circuit and chip are working properly. i can advertising and successful connection to smart phone with "nRF UART v2.0" app.

    I want every 5 second, send a string from the chip program and get it for real time on "nRF UART v2.0" app .

    What is your solution to this work? What should I do?

    How do I modify this example ? "\nRF5SDK160098a08e2\examples\ble_peripheral\ble_app_uart\pca10040\s132\ses"

  • Hello,

    Bizadi said:
    What is your solution to this work? What should I do?

    To have a task executed at a certain interval, I would suggest setting up a timer for the specific period, and then have it call the send function after that time.
    Many examples already demonstrate this in some capacity, but I would recommend that you take a look at the Timer Example from the SDK to see the simplest form.

    When it comes to implement it into the Nordic UART example it depends on how you would like this to function. The unmodified example is set to transmit whatever it receives through UART to its peer over the BLE link.
    Are you intending for the device to hold the connection in between the timeout, or do you intend for the device to go to sleep and then wakeup to send every 5 seconds, or something else?
    Its capacity to receive UART input will depend on these choices.

    Best regards,
    Karl

  • thanks for your quick reply .

    1-

    My problem is modify or setting  for send a string.

    I use this command :"ble_nus_data_send(p_nus,"My String",p_length,conn_handle);" in "ble_app_uart" example.

    is this command correct?

    Do I need to make any special modify or settings to use this command?

    What are the values of the variables? (like "p_nus" pointer)

    2-

    I do not use RX and TX pins . what is value for define "SER_APP_CTS_PIN" and "SER_APP_RTS_PIN" ?

    #define SER_APP_RX_PIN      23 // UART RX pin number.
    #define SER_APP_TX_PIN       24 // UART TX pin number.
    #define SER_APP_CTS_PIN     2 // UART Clear To Send pin number.
    #define SER_APP_RTS_PIN    25 // UART Request To Send pin number.

    When we don't use those pins, should they be connected in the circuit? (PULL-UP or PULL-DOWN)

  • Hello,

    Bizadi said:
    thanks for your quick reply .

    No problem at all, I am happy to help!

    Bizadi said:

    My problem is modify or setting  for send a string.

    I use this command :"ble_nus_data_send(p_nus,"My String",p_length,conn_handle);" in "ble_app_uart" example.

    is this command correct?

    Do I need to make any special modify or settings to use this command?

    No. Please see the function declaration:

    uint32_t ble_nus_data_send(ble_nus_t * p_nus, uint8_t * p_data, uint16_t * p_length, uint16_t conn_handle)

    The p_data argument needs to be a pointer to a uint8_t array. In the UART example, this uint8_t array is a c string(char array). It will not work inputting the entire string as the argument.
    Instead, you should do something like this:

    #define STR_LENGTH 12
    
    char my_c_string[STR_LENGTH] = {"My C String"};
    uint16_t length = sizeof(my_c_string);
    
    ble_nus_data_send(p_nus, my_c_string, &length, m_conn_handle);


    Bizadi said:
    What are the values of the variables? (like "p_nus" pointer)

    Are you using Segger embedded stuidos? Then you may right click any variable and click "Go to definition" to see where it is defined.
    As you then will see, the p_nus is the instance of the NUS service.

    Bizadi said:
    what is value for define "SER_APP_CTS_PIN" and "SER_APP_RTS_PIN" ?

    I do not understand what you are asking me here. The defines you have listed is just to point to the pin number for the respective functionality - its a very good practice to replace magic numbers with properly named macros, which I highly recommend for increased readability.

    Bizadi said:
    When we don't use those pins, should they be connected in the circuit? (PULL-UP or PULL-DOWN)

    If they are not used, you may just leave them to the default unused GPIO configuration - disconnected inputs. If you do not use UART at all then you may disable the entire UART module and all its configurations.

    Best regards,
    Karl

Related