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;
                     
                   }
                     
                 }
               }
  • If I send less data using above code, again, it is OK

  • 12292 means BLE_ERROR_NO_TX_PACKETS, I have change NRF_ERROR_BUSY to BLE_ERROR_NO_TX_PACKETS on above code , and run the program. Again, the program reset (not reset by APP_ERROR_CHECK)

  • just saying "its urgent, help help help help help" doesn't really do anything at all so perhaps stop that. People are trying to help you and try to remember we have way less information than you do. if the application is resetting in the code you've posted, then it's APP_ERROR_CHECK(), however much you're sure it's not. If it's resetting elsewhere, then it's in code you haven't posted.

    So firstly are you sure this is the piece of code in which you are resetting?

    Secondly comment out the APP_ERROR_CHECK() and see if you stop resetting.

    What does your hardfault handler look like, does that have a reset in it, are you going there?

    Chips don't reset just for fun, they enter a piece of code which calls the NVIC reset function and reset.

  • "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 don't see how that makes the image transfer demo incompatible. You should be able to use that in the same way.

    The image transfer demo is based on ble_app_uart, and the main difference is that a flag is set when the BLE_ERROR_NO_TX_PACKETS error occurs, and it will exit the while loop rather than trying to upload packets over and over.

    Once the BLE_GATTS_EVT_HVN_TX_COMPLETE event occurs it will then continue to send more packets, assuming there is still data left in the application buffer.

    It should be possible to modify the ble_app_uart application in the same way, so that you use the BLE_GATTS_EVT_HVN_TX_COMPLETE to continue the data transfer after the BLE_ERROR_NO_TX_PACKETS error occurs.

    Best regards
    Torbjørn

Related