Hello,
I am doing a project using nRF51822, s130 and SDK 11. I have modified the example ble_ap_hrs_rscs_relay.
My problem comes when I try to update a notification in a characteristic as peripheral. I have added the char like this:
uint8_t default_value_baliza_state=0x00;
static uint32_t baliza_baliza_state_char_add(ble_baliza_t * p_baliza, const ble_baliza_init_t * p_baliza_init)
{
ble_gatts_char_md_t char_md;
ble_gatts_attr_t attr_char_value;
ble_uuid_t ble_uuid;
ble_gatts_attr_md_t attr_md;
const uint8_t user_desc[]=USER_DESC_BALIZA_STATE;
memset(&char_md, 0, sizeof(char_md));
char_md.char_props.read = 1;
char_md.char_props.write = 0;
char_md.p_char_user_desc = (uint8_t *) user_desc;
char_md.char_user_desc_size = USER_DESC_BALIZA_STATE_LENGTH;
char_md.char_user_desc_max_size = USER_DESC_BALIZA_STATE_LENGTH;
char_md.p_char_pf = NULL;
char_md.p_user_desc_md = NULL;
char_md.p_cccd_md = NULL;
char_md.p_sccd_md = NULL;
char_md.char_props.notify = 1;
ble_uuid.type = 0X01;
ble_uuid.uuid = baliza_BALIZA_STATE_UUID;
memset(&attr_md, 0, sizeof(attr_md));
BLE_GAP_CONN_SEC_MODE_SET_OPEN(&attr_md.read_perm);
BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&attr_md.write_perm);
attr_md.vloc = BLE_GATTS_VLOC_USER;
attr_md.rd_auth = 1;
attr_md.wr_auth = 1;
attr_md.vlen = 0;
memset(&attr_char_value, 0, sizeof(attr_char_value));
attr_char_value.p_uuid = &ble_uuid;
attr_char_value.p_attr_md = &attr_md;
attr_char_value.init_len = 1;
attr_char_value.init_offs = 0;
attr_char_value.max_len = 1;
attr_char_value.p_value = &default_value_baliza_state;
return sd_ble_gatts_characteristic_add(p_baliza->service_handle, &char_md,
&attr_char_value,
&p_baliza->baliza_baliza_state_handles);
}
Then, when I want to update the char with the desired value, I call my function:
uint32_t ble_baliza_baliza_state_send( ble_baliza_t * p_baliza, uint8_t state)
{
uint32_t err_code;
if (p_baliza->conn_handle != BLE_CONN_HANDLE_INVALID)
{
uint16_t len;
ble_gatts_hvx_params_t hvx_params;
len=1;
memset(&hvx_params, 0, sizeof(hvx_params));
hvx_params.handle = p_baliza->baliza_baliza_state_handles.value_handle;
hvx_params.type = BLE_GATT_HVX_NOTIFICATION;
hvx_params.offset = 0;
hvx_params.p_len = &len;
hvx_params.p_data = &state;
err_code = sd_ble_gatts_hvx(p_baliza->conn_handle, &hvx_params);
APP_ERROR_CHECK(err_code);
}
}
My code crashes with sd_ble_gatts_hvx with err_code=0x0003401.
Could anyone help? If more information is needed (like type definitions) please ask.
Thank you very much