Hi! I am working on a project that uses the Multilink example. On the client (nRF51422 w. SD 120) my program crashes and starts the main loop again after a few seconds. I have narrowed it down to in the client_handling.c file in the client_handling_ble_evt_handler().
The p_ble_evt->header.evt_id is 27. Then of course none of the cases is entered. What is causing this?
The problem has occured after I changed my server to send data with sd_ble_gatts_hvx() instead of sd_ble_gatts_value_set(), to preserve battery life. But with the nRF Master app the server data transfer and notification seems to work just fine.
Any suggestions?
Thanks!
/Christian
void client_handling_ble_evt_handler(ble_evt_t * p_ble_evt)
{
client_t * p_client = NULL;
uint32_t err_code;
uint8_t z;
char buffer[10];
uint32_t index = client_find(p_ble_evt->evt.gattc_evt.conn_handle);
if (index != MAX_CLIENTS)
{
p_client = &m_client[index];
}
switch (p_ble_evt->header.evt_id)
{
case BLE_GATTC_EVT_WRITE_RSP:
if ((p_ble_evt->evt.gattc_evt.gatt_status == BLE_GATT_STATUS_ATTERR_INSUF_AUTHENTICATION) ||
(p_ble_evt->evt.gattc_evt.gatt_status == BLE_GATT_STATUS_ATTERR_INSUF_ENCRYPTION))
{
uint32_t err_code = dm_security_setup_req(&p_client->handle);
APP_ERROR_CHECK(err_code);
}
on_evt_write_rsp(p_ble_evt, p_client);
break;
case BLE_GATTC_EVT_HVX:
on_evt_hvx(p_ble_evt, p_client, index);
break;
case BLE_GATTC_EVT_TIMEOUT:
on_evt_timeout(p_ble_evt, p_client);
break;
case BLE_GATTC_EVT_CHAR_DISC_RSP:
//err_code = sd_ble_gattc_read(p_ble_evt->evt.gatts_evt.conn_handle,17,0);
APP_ERROR_CHECK(err_code);
break;
case BLE_GATTC_EVT_READ_RSP:
if(p_ble_evt->evt.gattc_evt.params.read_rsp.handle==17)
{
z = p_ble_evt->evt.gattc_evt.params.read_rsp.data[0];
p_client->client_acc_z_value = z;
err_code = sd_ble_gattc_read(p_ble_evt->evt.gatts_evt.conn_handle,17,0);
APP_ERROR_CHECK(err_code);
}
break;
default:
debug_printf("Evt not found\n\r");
break;
}
if (p_client != NULL)
{
ble_db_discovery_on_ble_evt(&(p_client->srv_db), p_ble_evt);
}
}