Hi,
I have problem with ble_nus_c.c in SDK v11...
Normal operation is:
Connecting to target 57E19A190FDF
Connected to target
[DB]: Starting discovery of service with UUID 0x1 for Connection handle 0
Found service UUID 0x1
[DB]: Discovery of service with UUID 0x1 completed with success for Connectionhandle 0
The device has the Nordic UART Service
But some times I have only this:
Connecting to target 57E19A190FDF
Connected to target
[DB]: Starting discovery of service with UUID 0x1 for Connection handle 0
After some exploration, I found the problem: Sometimes ble_db_discovery_on_ble_evt(...) is in this
case BLE_GAP_EVT_DISCONNECTED:
on_disconnected(p_db_discovery, &(p_ble_evt->evt.gap_evt));
break;
and specialy in this case in ble_nus_c_on_ble_evt(...)
p_ble_evt->evt.gap_evt.conn_handle == p_ble_nus_c->conn_handle
is not true, and this code is not launched
{
ble_nus_c_evt_t nus_c_evt;
nus_c_evt.evt_type = BLE_NUS_C_EVT_DISCONNECTED;
p_ble_nus_c->conn_handle = BLE_CONN_HANDLE_INVALID;
p_ble_nus_c->evt_handler(p_ble_nus_c, &nus_c_evt);
}
result: the BLE_NUS_C_EVT_DISCONNECTED is never fired and the scan_start() is never called !!!
My workaround:
case BLE_GAP_EVT_DISCONNECTED:
if (/*p_ble_evt->evt.gap_evt.conn_handle == p_ble_nus_c->conn_handle
&&*/ p_ble_nus_c->evt_handler != NULL)
{
ble_nus_c_evt_t nus_c_evt;
nus_c_evt.evt_type = BLE_NUS_C_EVT_DISCONNECTED;
p_ble_nus_c->conn_handle = BLE_CONN_HANDLE_INVALID;
p_ble_nus_c->evt_handler(p_ble_nus_c, &nus_c_evt);
}
break;
Please can you confirm ?
Regards, Gaétan