Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How send simple string message ble_peripheral to central multilink example.

Hi,

I am using nRF52832 DK and other same custom board, sdk v15.0 with SES IDE. My application like this:

For ble peripheral used example ble_app_uart and for central used multilink example.

I want to send sensor data using ble_app_uart to central multi-link after completed sending sensor device will go to sleep and it will again wake-up after 1Hr and automatically connect to central and send sensor value to connected central. This will continuous monitoring process and my sensor device is battery operate supply.

Now, i am facing following issues:

  1. How i can send simple string message to connected central, which function and how i can use in my peripheral side.
  2. I was refer this link and also changes done replace ble_lbs_c  by ble_nus_c  but not receiving and also not able to show incoming message on console at central side.
  3. My peripheral device is connected to central and in peripheral i written simple code for sending message:

void send_to_central()
{
    uint32_t err_code;
     uint16_t length = (uint16_t)5;
    char string[5] = "Hello";
    err_code = ble_nus_data_send(&m_nus, string, &length, m_conn_handle);
    APP_ERROR_CHECK(err_code);
    if ( (err_code != NRF_ERROR_INVALID_STATE) && (err_code != NRF_ERROR_BUSY) &&
         (err_code != NRF_ERROR_NOT_FOUND) )
          {
              APP_ERROR_CHECK(err_code);
          }
  NRF_LOG_INFO("Send to central\r\n");
}

But Not receiving at central side. Please help me where i am wrong.

Please provide me example code for sending and receiving string message over peripheral to central.

 Thanks in advanced.

Parents Reply Children
  • Thanks for your reply,

    I checked as you provided above link and i have already done changes in my peripheral as well as central code.

    I noticed at central side the notification is not enabled the "ble_nus_c_evt_handler" is not generated in central why it so happen. 

    could you please provide me small sending function snippet for peripheral. I want to send message directly once connected event generated in peripheral.

    Is problem for communication if i use nRF52832 DK for multilink and sparkfun nRF52832 custom board for peripheral because both of board file is different. If yes for sparkfun how i add custom board.h file.  

    We have less time for develop solution.

    Thanks..!!!

  • Hi Bjorn,

    I solved issue by self which is notification is not enabled. So now discovery completed log is generated and also RX event generated.

    But i have question how i know at central side notification is enable and now ready for sending data from peripheral. 

    Is it any trigger option for once peripheral connected to central and also their notification is enabled then i want to send sensor value.

    Thanks...!!! 

  • Take a look at the ble_nus_c_evt_handler, especially the BLE_NUS_C_EVT_DISCOVERY_COMPLETE case & the ble_nus_c_tx_notif_enable() function inside main.c of the uart central example. In that same function, there is a log print which says that the central is connected to a peripheral device that uses the Nordic UART service.

  • I am able to sent all sensor data to multilink central by referring ble_nus_c_evt_handler and other event handler also. But now still facing issue for connecting more than one peripheral to one central.

    How i connect multiple peripheral connection with one central i checked connection handle. 

    Which event and function use for multiple and concurrent connection for peripheral side so i will look and debug where should i wrong.

    Thanks you so much..!!!

  • Great to hear that you figured it out! Good luck with further development.

Related