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

Send Data packets of about 50 bytes from central to a peripheral device with or without establishing a connection

Hello 

I am using SDK15.3 and nrf52832 development board. 

In my setup,

1. I have a  few peripheral nodes whose only job is to transmit some arbitrary packets ( say P),

2. a node that acts as both central and peripheral( say T) which reads the advertisement packets from P and gets it RSSI values and then sends this RSSI array ( from mulitple P nodes) to a  gateway(say G), which is a central node.

My issues are

a)  Setting up this node T. Please suggest which example from SDK 15.0 and higher is suitable for this.

b) How to send data from 'T' to 'G'. The size of data is about 40 bytes. I realised the data sent in the advertisement as manuf_data is about 15 bytes ( correct me if I'm wrong about this). So how to send data after establishing a connection? Please suggest suitable examples.

Thank you in advance. 

Parents Reply
  • Okay. I have declared the data_array[BLE_NUS_MAX_DATA_LEN] in the function  uart_event_handle(app_uart_evt_t * p_event)

    and i am passing it as a parameter in the function 

     ble_nus_c_string_send(&m_ble_nus_c, data_array, index);

    void uart_event_handle(app_uart_evt_t * p_event)
    {
        //added
        NRF_LOG_INFO("in uart_evt_handle\r\n");
        //static uint8_t data_array[BLE_NUS_MAX_DATA_LEN];
        static uint8_t data_array[BLE_NUS_MAX_DATA_LEN] = "1,2,3\r\n";
        NRF_LOG_INFO("array = %x\r\n",data_array);
        static uint16_t index = 0;
        uint32_t ret_val;
    
        switch (p_event->evt_type)
        {
            /**@snippet [Handling data from UART] */
            case APP_UART_DATA_READY:
                UNUSED_VARIABLE(app_uart_get(&data_array[index]));
                index++;
    
                if ((data_array[index - 1] == '\n') || (index >= (m_ble_nus_max_data_len)))
                {
                    NRF_LOG_DEBUG("Ready to send data over BLE NUS");
                    NRF_LOG_INFO("Ready to send data over BLE NUS");
                    NRF_LOG_HEXDUMP_DEBUG(data_array, index);
    
                    do
                    {
                        ret_val = ble_nus_c_string_send(&m_ble_nus_c, data_array, index);
                        if ( (ret_val != NRF_ERROR_INVALID_STATE) && (ret_val != NRF_ERROR_RESOURCES) )
                        {
                            APP_ERROR_CHECK(ret_val);
                        }
                    } while (ret_val == NRF_ERROR_RESOURCES);
    
                    index = 0;
                }
                break;

    Also, I am definitely not sure if this is the right way. Please suggest me with an alternative way to send an array between UART central and peripheral nodes.

Children
Related