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.

Parents
  • 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()
        ....
    }
    
Reply
  • 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()
        ....
    }
    
Children
Related