This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

SDK17.1, SD140, nRF52840, sd_ble_gap_phy_update() sometimes errors with 0x08 (INVALID_STATE)

Hello,

We have a product using an nRF52840, with the SDK17.1, the 140 Softdevice, and an application based around the Nordic UART service (nus). We are seeing application crashes caused by the following code:

static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context)
{
    uint32_t err_code;

    switch (p_ble_evt->header.evt_id)
    {
        /* Other, not relevant cases */
        
        case BLE_GAP_EVT_PHY_UPDATE_REQUEST:
        {
            NRF_LOG_INFO("PHY update request.");
            ble_gap_phys_t const phys =
            {
                .rx_phys = BLE_GAP_PHY_AUTO,
                .tx_phys = BLE_GAP_PHY_AUTO,
            };
            err_code = sd_ble_gap_phy_update(p_ble_evt->evt.gap_evt.conn_handle, &phys);
            APP_ERROR_CHECK(err_code);
        } break;
        
        default:
            // No implementation needed.
            break;
    }
}

The returned error code is 0x08 (INVALID_STATE)

We think this is likely to be similar to our previous issue: https://devzone.nordicsemi.com/f/nordic-q-a/86152/sdk-15-2-0-sd-132-nrf52832-qfaa-sd_ble_gap_data_length_update-sometimes-errors-with-0x08-invalid_state and are planning to just ignore INVALID_STATE errors here in the future.

Still, can you explain what might cause these and confirm that they are safe to ignore?

Like in the previous case we aren't able to reproduce these reliably.


Thanks,
Mark

  • Hi Mark,

    Yes, this is the same thing. You can safely ignore this error (though obviously it means that there will be no data length update procedure, and if the ling is disconnecting you should get a BLE_GAP_EVT_DISCONNECTED shortly after).

    Einar

Related