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

When 'ble_nus_data_send()' run, NRF_ERROR_INVALID_STATE is output

Hello
I am using sdk17.0.2 and nrf52840.

I used nrf52832 to combine ble_app_uart and crypto_aes_ctr codes.  And now I'm going to move the code to nrf52840.

However, there is a new problem that has not existed before.  An error 'nrf_error_invalid_state' is output when data is sent to the app via 'bl_nus_data_send'.

        //test
        char app_test[100];
        int test_value = 5;
        
        if(connection_state == 1)
        {
          test_value++;

          sprintf(app_test, "%d", test_value); 
          uint16_t length_test_valuel = strlen(app_test);

          err_code = ble_nus_data_send(&m_nus, &app_test, &length_test_valuel, m_conn_handle);
          check_nus_send = err_code;
          if ((err_code != NRF_ERROR_INVALID_STATE) && 
                (err_code != NRF_ERROR_RESOURCES) &&
                (err_code != NRF_ERROR_NOT_FOUND) &&
                (err_code != BLE_ERROR_GATTS_SYS_ATTR_MISSING)) 
                {
                    APP_ERROR_CHECK(err_code);
                    NRF_LOG_INFO("OK");
                }

          else
            NRF_LOG_INFO("Fail");

          NRF_LOG_INFO("%d", check_nus_send); //err_code : NRF_ERROR_INVALID_STATE(Invalid state, operation disallowed in this state)

          nrf_delay_ms(2000);
        }

When I modified the existing code to nrf52840, I modified the pca10056, softdevice in the settings.  Are there any additional changes to make when modifying from nrf52832 to nrf52840?

Thank you.

Related