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 .

Parents
  • 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)

Reply
  • 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)

Children
  • 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