Cannot reconfigure BLE peripheral UART example to send data I have stored in buffer please help

Hello I have seen ALOT of posts referencing to first build and run ble peripheral uart example and then from there that it will be easy to remove the uart from the functionality if so desired but I cannot seem to get this to work.

I have tried many different approaches over the past few weeks and no matter what I do I cannot get an app up and running that allows me to use my PCB as peripheral that automatically sends a buffer of data (a bunch of SSIDs concatenated) on connection of central device (NRF Connect app). Is there please a snippet of code you can provide me that shows how to go from using the uart to having my own custom service that just sends a buffered message over ble?

  • I know this is more of a C question than  Nordic, I apologize for that but is there a chance you can give me pseudo code example of how this might be done? I am having a hard time reconciling stepping through the index for parsing the message and moving my message queue window.

    Thank you for your help 

  • Hmm,

    Actually on a second thought, looking at how ble_nus_data_send() is implemented, I think it would better to divide the buffer that you're going to send into 20 byte arrays first, and then after that pass the 20 byte array to ble_nus_data_send(). So you fill the data buffer with 20 bytes, when it has reached 20 bytes you call ble_nus_data_send() and then restart the process.

    regards

    Jared 

  • Ok I will give that a try and see if I can implement it, thank you for the follow up

  • I am able to split the messages into 20 byte chunks with a small function but oddly, my code execution stays at the first:

                  err_code = ble_nus_data_send(&m_nus, data_array1, &length, m_conn_handle); call

    Despite the data_array1 appearing at NRFConnect on my Android... should I be looking for confirmation

  • I have stripped ble_nus_data_send() completely down to this for sending 8 20 byte packets:

        case APP_UART_DATA_READY:

                NRF_LOG_DEBUG("Ready to send data over BLE NUS");

                  ble_nus_data_send(&m_nus, data_array1, &packetSize, m_conn_handle);
                  ble_nus_data_send(&m_nus, data_array2, &packetSize, m_conn_handle);
                  ble_nus_data_send(&m_nus, data_array3, &packetSize, m_conn_handle);
                  ble_nus_data_send(&m_nus, data_array4, &packetSize, m_conn_handle);
                  ble_nus_data_send(&m_nus, data_array5, &packetSize, m_conn_handle);
                  ble_nus_data_send(&m_nus, data_array6, &packetSize, m_conn_handle);
                  ble_nus_data_send(&m_nus, data_array7, &packetSize, m_conn_handle);
                  ble_nus_data_send(&m_nus, data_array8, &packetSize, m_conn_handle);
                  break;

    But oddly, execution just keeps cycling through the sends and does not break after the 8th, does that make sense?

Related