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

How to debug NRF_ERROR_INVALID_STATE easily?

Hello,

I receive NRF_ERROR_INVALID_STATE error quite a few times because my own state handling is still a little buggy. I want to find all these errors. What would be the best way to debug this. Is there any possibility to read the current state of the softdevice? I am currently calling sd_ble_gattc_characteristics_discover after I received the BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP event. This results in an invalid state and I am not quite sure why this would happen. I would be very interested in getting the current state and maybe a possibility if advertising and/or scanning are currently switched on or if a connection is in progress,etc... The more information I can get from the SoftDevice (S130 0.9-alpha), the better.

Thanks a lot, Marius

Parents
  • Hello,

    here is my code that I call upon receiving the BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP event:

    void _bleServiceDiscoveryFinishedHandler(ble_evt_t* bleEvent){
    	u32 err = 0;
    	
    	//Service has been found
    	if(bleEvent->evt.gattc_evt.params.prim_srvc_disc_rsp.count > 0){
    		if(debugPlainC) tracel("Found service");
    		
    		//Service handle range has been found, now start discovery on characteristics
    		ble_gattc_handle_range_t handleRange;
    		handleRange.start_handle = bleEvent->evt.gattc_evt.params.prim_srvc_disc_rsp.services[0].handle_range.start_handle;
    		handleRange.end_handle = bleEvent->evt.gattc_evt.params.prim_srvc_disc_rsp.services[0].handle_range.end_handle;
    		
    		err = sd_ble_gattc_characteristics_discover(bleEvent->evt.gap_evt.conn_handle, &handleRange);
    		APP_ERROR_CHECK(err);
    	}
    }
    

    However I only received this error once while I was debugging and it has never occured again since. Maybe I have an error in that code snippet or maybe it was something else. I have just switched over from KEIL to developing with Eclipse and GCC.

  • @Marius: Could you update the case ? If you fixed the issue you can accept the answer so that the case is closed.

Reply Children
No Data
Related