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

send large amount of data over nus

I am using below code to send data over nus. If the data size is 150 bytes, it is OK. However, if the data size is 200 bytes, the nRF51822 will reset. Please tell me how to solve. I am using nRF51822 with softdevie S130. My application is based on ble_uart_app

               if(user_m_conn_handle!=BLE_CONN_HANDLE_INVALID)
               {
                 i=UserUart.RxBuf[1]+2;
                 index = 0;
                 while(i>0)
                 {
                   if(i>20)
                   {
                     while((err_code = ble_nus_string_send(&m_nus, UserUart.RxBuf+index, 20)) == BLE_ERROR_NO_TX_PACKETS )
                     {
                       ;
                     }
                     if (err_code != NRF_ERROR_INVALID_STATE)
                     {
                         APP_ERROR_CHECK(err_code);
                     }
                     i -= 20;
                     index += 20;
                   }
                   else 
                   {
                     while((err_code = ble_nus_string_send(&m_nus, UserUart.RxBuf+index, i)) == BLE_ERROR_NO_TX_PACKETS)
                     {
                       ;
                     }
                     if (err_code != NRF_ERROR_INVALID_STATE)
                     {
                         APP_ERROR_CHECK(err_code);
                     }
                     i = 0;
                     
                   }
                     
                 }
               }
Parents
  • My application is different from the image transfer demo, I have to recive all 200 byte of data from uart and do some processing before sending the data over nus, I have modify the code as below (based on the image transfer demo), however it return error 12292 at ble_nus_string_send

          if(user_m_conn_handle!=BLE_CONN_HANDLE_INVALID)
           {
             i=UserUart.RxBuf[1]+2;
             index = 0;
             while(i>0)
             {
               if(i>20)
               {
    
                  do
                  {
                      err_code = ble_nus_string_send(&m_nus, UserUart.RxBuf+index, 20);
                      if ( (err_code != NRF_ERROR_INVALID_STATE) && (err_code != NRF_ERROR_BUSY) && err_code!=0 )
                      {
                          APP_ERROR_CHECK(err_code);
                      }
                  } while (err_code == NRF_ERROR_BUSY);
                 i -= 20;
                 index += 20;
               }
               else 
               {
                 
                  do
                  {
                      err_code = ble_nus_string_send(&m_nus, UserUart.RxBuf+index, i);
                      if ( (err_code != NRF_ERROR_INVALID_STATE) && (err_code != NRF_ERROR_BUSY)&& err_code!=0 )
                      {
                          APP_ERROR_CHECK(err_code);
                      }
                  } while (err_code == NRF_ERROR_BUSY);
                 i = 0;
                 
               }
                 
             }
           }
    
Reply
  • My application is different from the image transfer demo, I have to recive all 200 byte of data from uart and do some processing before sending the data over nus, I have modify the code as below (based on the image transfer demo), however it return error 12292 at ble_nus_string_send

          if(user_m_conn_handle!=BLE_CONN_HANDLE_INVALID)
           {
             i=UserUart.RxBuf[1]+2;
             index = 0;
             while(i>0)
             {
               if(i>20)
               {
    
                  do
                  {
                      err_code = ble_nus_string_send(&m_nus, UserUart.RxBuf+index, 20);
                      if ( (err_code != NRF_ERROR_INVALID_STATE) && (err_code != NRF_ERROR_BUSY) && err_code!=0 )
                      {
                          APP_ERROR_CHECK(err_code);
                      }
                  } while (err_code == NRF_ERROR_BUSY);
                 i -= 20;
                 index += 20;
               }
               else 
               {
                 
                  do
                  {
                      err_code = ble_nus_string_send(&m_nus, UserUart.RxBuf+index, i);
                      if ( (err_code != NRF_ERROR_INVALID_STATE) && (err_code != NRF_ERROR_BUSY)&& err_code!=0 )
                      {
                          APP_ERROR_CHECK(err_code);
                      }
                  } while (err_code == NRF_ERROR_BUSY);
                 i = 0;
                 
               }
                 
             }
           }
    
Children
No Data
Related