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

If I disconnect and reconnect while receiving data through Notify, an error occurs.

Hello

I am using nrf52832 and ble_app_uart of SDK v17.0.

I am sending data to the app every second through the notify function.  If I try to disconnect and reconnect Bluetooth while sending data like this, the connection will fail and stop working.

I tested sending data using the ble_app_uart example.  Similarly, enabling notify will cause an error when reconnecting Bluetooth. (If notify is disabled, there is no problem reconnecting.)

I couldn't find any problems with debugging.  

This is the code I used to send the data. Could there be a problem here?

    // Enter main loop.
    for (;;)
    {
        uint32_t err_code;

        idle_state_handle();

      //Send to app 1 and 2 test
      int test1 = 1;
      char test1_value[20]; 
      sprintf(test1_value, "%d", test1); 
      uint16_t length_test1 = strlen(test1_value); 

      err_code = ble_nus_data_send(&m_nus, &test1_value, &length_test1, m_conn_handle);
      if ((err_code != NRF_ERROR_INVALID_STATE) &&
                          (err_code != NRF_ERROR_RESOURCES) &&
                          (err_code != NRF_ERROR_NOT_FOUND))
                      {
                          APP_ERROR_CHECK(err_code);
                      } 

      int test2 = 2;
      char test2_value[20]; 
      sprintf(test2_value, "%d", test2); 
      uint16_t length_test2 = strlen(test2_value); 

      err_code = ble_nus_data_send(&m_nus, &test2_value, &length_test2, m_conn_handle);
      if ((err_code != NRF_ERROR_INVALID_STATE) &&
                          (err_code != NRF_ERROR_RESOURCES) &&
                          (err_code != NRF_ERROR_NOT_FOUND))
                      {
                          APP_ERROR_CHECK(err_code);
                      } 

        nrf_delay_ms(500);
    }

Is there anything known about this problem?
Thank you.

Related