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

s130 Cental peripheral error 3002 : NRF_ERROR_SOFTDEVICE_NOT_ENABLED

Hi I'm trying to send adc value from peripheral to central. I'm using nrf51822 with softdevice s130_1.0.0 and SDK v10.0.0 .

I'm getting error 3002 which I figured out, it is STK+NRF_ERROR_SOFTDEVICE_NOT_ENABLED. I also call softdevice_handler_isEnabled() function in main which is returning true.

here is my code

uint32_t ble_adc_on_adc_change(ble_adc_t * p_adc, uint16_t adc_state)
{
    ble_gatts_hvx_params_t params;
    uint16_t len = 2;
		uint8_t data[2] 	=	{(uint8_t) (adc_state>>8), (uint8_t) adc_state}; 	
	  
    memset(&params, 0, sizeof(params));
    params.type = BLE_GATT_HVX_NOTIFICATION;
    params.handle = p_adc->adc_char_handle.value_handle;
    params.p_data = data;
    params.p_len = &len;
		
    return  sd_ble_gatts_hvx(p_adc->conn_handle, &params);
}

Can any one please let me know how to correct this.

  • No it's not STK+NRF_ERROR_SOFTDEVICE_NOT_ENABLED. If you look at the documentation for the function it tells you the return codes it can return and their derivation, and you can click on them to break them down more.

    #define BLE_ERROR_INVALID_CONN_HANDLE   (NRF_ERROR_STK_BASE_NUM+0x002)
    

    that's 0x3002

  • Yes that why I wrote NRF_ERROR_SOFTDEVICE_NOT_ENABLED

    here is the nrf_error.h file code

    #define NRF_ERROR_BASE_NUM      (0x0)       ///< Global error base
    #define NRF_ERROR_SDM_BASE_NUM  (0x1000)    ///< SDM error base
    #define NRF_ERROR_SOC_BASE_NUM  (0x2000)    ///< SoC error base
    #define NRF_ERROR_STK_BASE_NUM  (0x3000)    ///< STK error base
    /** @} */
    
    #define NRF_SUCCESS                           (NRF_ERROR_BASE_NUM + 0)  ///< Successful command
    #define NRF_ERROR_SVC_HANDLER_MISSING         (NRF_ERROR_BASE_NUM + 1)  ///< SVC handler is missing
    #define NRF_ERROR_SOFTDEVICE_NOT_ENABLED      (NRF_ERROR_BASE_NUM + 2)  ///< SoftDevice has not been enabled
    #define NRF_ERROR_INTERNAL                    (NRF_ERROR_BASE_NUM + 3)  ///< Internal Error
    #define NRF_ERROR_NO_MEM                      (NRF_ERROR_BASE_NUM + 4)  ///< No Memory for operation
    #define NRF_ERROR_NOT_FOUND                   (NRF_ERROR_BASE_NUM + 5)  ///< Not found
    #define NRF_ERROR_NOT_SUPPORTED               (NRF_ERROR_BASE_NUM + 6)  ///< Not supported
    #define NRF_ERROR_INVALID_PARAM               (NRF_ERROR_BASE_NUM + 7)  ///< Invalid Parameter
    #define NRF_ERROR_INVALID_STATE               (NRF_ERROR_BASE_NUM + 8)  ///< Invalid state, operation disallowed in this state
    #define NRF_ERROR_INVALID_LENGTH              (NRF_ERROR_BASE_NUM + 9)  ///< Invalid Length
    #define NRF_ERROR_INVALID_FLAGS               (NRF_ERROR_BASE_NUM + 10) ///< Invalid Flags
    #define NRF_ERROR_INVALID_DATA                (NRF_ERROR_BASE_NUM + 11) ///< Invalid Data
    #define NRF_ERROR_DATA_SIZE                   (NRF_ERROR_BASE_NUM + 12) ///< Data size exceeds limit
    #define NRF_ERROR_TIMEOUT                     (NRF_ERROR_BASE_NUM + 13) ///< Operation timed out
    #define NRF_ERROR_NULL                        (NRF_ERROR_BASE_NUM + 14) ///< Null Pointer
    #define NRF_ERROR_FORBIDDEN                   (NRF_ERROR_BASE_NUM + 15) ///< Forbidden Operation
    #define NRF_ERROR_INVALID_ADDR                (NRF_ERROR_BASE_NUM + 16) ///< Bad Memory Address
    #define NRF_ERROR_BUSY                        (NRF_ERROR_BASE_NUM + 17) ///< Busy
    
  • Hi

    Error 0x3002 is BLE_ERROR_INVALID_CONN_HANDLE. It is defined in ble_err.h as:

    #define BLE_ERROR_INVALID_CONN_HANDLE    (NRF_ERROR_STK_BASE_NUM+0x002) /**< Invalid connection handle. */
    

    where NRF_ERROR_STK_BASE_NUM is defined as 0x3000 in nrf_error.h.

    You are probably getting this error because you are calling ble_adc_on_adc_change() and sd_ble_gatts_hvx() without being in a connection. If you look in the SDK examples you will see that we always check for a valid connection before we call sd_ble_gatts_hvx() like this:

    if (p_hrs->conn_handle != BLE_CONN_HANDLE_INVALID)
    {
        ....
        err_code = sd_ble_gatts_hvx()
        ....
    }
    
Related