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

Data updating upto 241 bytes

Hello,

I have developed an application that transmits a string as a notification to the phone app whenever there is a corresponding command received from the phone app.

I actually want to send a string of size around 3KB. Now whenever I try to do that using a for loop to send chunks of 20 bytes of data at a time, the maximum number of bytes that I am able to see as notifications is 241 bytes. 

So how do I send the rest of data to the phone app?

Is this something to do with the connection interval?

If so how to solve this and send further data?

Any relevant links or details would be appreciated.

Thanks & Regards 

Sudeep R J

Parents Reply Children
  • Hi Simonr,

    I tried the NRF_ERROR_RESOURCES as you mentioned but now I am not able to receive any notifications from the TX_COMPLETE event. I am giving a command from phone app and it is it is detected as RX_DATA event and for that I have written a Hello World string which is notified and after that there is a program halt at  NRF_BREAKPOINT_COND breakpoint in app_error_weak.c. Earlier i was sending data and upto 241 bytes there was no problem. But now there is no transmission of data at all. Here is the data handler code that I have written.

    static void nus_data_handler(ble_nus_evt_t *p_evt)
    {
      
      if(p_evt->type == BLE_NUS_EVT_RX_DATA)
      {
        uint32_t err_code;
       
        static uint8_t data_array[BLE_NUS_MAX_DATA_LEN] = "Hello World";
        uint16_t length = sizeof(data_array) ;
        printf("Command Received : %d%d\n",p_evt->params.rx_data.p_data[0],p_evt->params.rx_data.p_data[1]);
        
       if(p_evt->params.rx_data.p_data[0]=='0' && p_evt->params.rx_data.p_data[1]=='2' )
       {
          err_code = ble_nus_data_send(&m_nus, data_array , &length, m_conn_handle);
          printf("data sent\n");
          if(err_code != NRF_SUCCESS)
          {
            APP_ERROR_CHECK(err_code);
         }
         
       }
      }
      if(p_evt->type == BLE_NUS_EVT_TX_RDY)
         {
           uint32_t err_code;
           uint8_t data_array1[20];  
         
           uint8_t data_array[242] = "12131415161718190471234567890101112131Heytherehowareyouhihkshuwrhibwbhvbvuewbaidhbuhwvvabhvsduverubvjhfvyuweqiqhidbqwejkfijsnoowhuiehisbfihbiqeajojqpowhijbhvbhbvwryguyhdjdieuyevuowsacihwaygbahbyfyugfrybfyrygiwhabiwfbyryi45966598kyuftd1589622k";
           
           while(1)
           {
             uint32_t k = i;
              for(uint8_t j=0;i<k+20;i++)
              {
                data_array1[j] = data_array[i];
                j++;
              }
              uint16_t length = sizeof(data_array1);
              err_code = ble_nus_data_send(&m_nus, data_array1 , &length, m_conn_handle);
              
             if(err_code == NRF_ERROR_RESOURCES)
              {
                break;
              }
              else if (err_code != NRF_SUCCESS) 
              {
                APP_ERROR_HANDLER(err_code);
              }
              
             
           }
           
           
           }
    }    

    If you could help me with any examples or documentation then that would be great.

    Thanks & Regards

    Sudeep R J

  • void ble_nus_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context)
    {
        if ((p_context == NULL) || (p_ble_evt == NULL))
        {
            return;
        }
    
        ble_nus_t * p_nus = (ble_nus_t *)p_context;
    
        switch (p_ble_evt->header.evt_id)
        {
            case BLE_GAP_EVT_CONNECTED:
                on_connect(p_nus, p_ble_evt);
                break;
    
            case BLE_GATTS_EVT_WRITE:
                on_write(p_nus, p_ble_evt);
                break;
    
            case BLE_GATTS_EVT_HVN_TX_COMPLETE:
                on_hvx_tx_complete(p_nus, p_ble_evt);
                break;
    
            default:
                // No implementation needed.
                break;
        }
    }

    This is the ble event handler that i am using from ble_nus.c

Related