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

Send packet continuously over nus

Is it OK  to send multiple packet continuously over nus at below way without waiting for packet transmit complete?

      i=UserUart.RxBuf[1]+2;
           index = 0;
           while(i>0)
           {
             if(i>20)
             {
               err_code = ble_nus_string_send(&m_nus, UserUart.RxBuf+index, 20);
               if (err_code != NRF_ERROR_INVALID_STATE)
               {
                   APP_ERROR_CHECK(err_code);
               }
               i -= 20;
               index += 20;
             }
             else 
             {
               err_code = ble_nus_string_send(&m_nus, UserUart.RxBuf+index, i);
               if (err_code != NRF_ERROR_INVALID_STATE)
               {
                   APP_ERROR_CHECK(err_code);
               }
               i = 0;
               
             }
               
           }
Parents
  • Can I modify the code to below? Can below code make sure that all packet are deliveried

      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;
    
             }
    
           }
    
Reply
  • Can I modify the code to below? Can below code make sure that all packet are deliveried

      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;
    
             }
    
           }
    
Children
No Data
Related