I want to control the connection to send data for about 100ms, but the service discovery process takes about 300ms. When the service characteristics are known, I want to inform the host of the characteristics in advance, so as to skip the discovery process. However, during the data sending process, the bottom layer reports an error,this is my code:
ble_nus_c_evt_t nus_c_evt;
ret_code_t err_code;
memset(&nus_c_evt,0,sizeof(ble_nus_c_evt_t));
// the handle values of rx, tx, and ccd may be different in your project.
nus_c_evt.handles.nus_rx_handle = 0x0d;
nus_c_evt.handles.nus_tx_handle = 0x0f;
nus_c_evt.handles.nus_tx_cccd_handle = 0x10;
nus_c_evt.conn_handle = 0;
nus_c_evt.evt_type = BLE_NUS_C_EVT_DISCOVERY_COMPLETE;
p_ble_nus_c->p_gatt_queue->p_conn_handles[0] = 0;
p_ble_nus_c->p_gatt_queue->p_req_queue->p_cb->max_utilization = 1;
p_db_discovery->srv_count = 1;
p_db_discovery->srv_count = 1;
p_db_discovery->services[0].srv_uuid.uuid = 0x01;
p_db_discovery->services[0].srv_uuid.type = 0x02;
p_db_discovery->discovery_in_progress = 1;
p_db_discovery->services[0].char_count = 2;
p_db_discovery->services[0].charateristics[0].characteristic.uuid.uuid = 0x02;
p_db_discovery->services[0].charateristics[0].characteristic.uuid.type = 0x02;
p_db_discovery->services[0].charateristics[0].characteristic.char_props.write_wo_resp = 1;
p_db_discovery->services[0].charateristics[0].characteristic.char_props.write = 1;
p_db_discovery->services[0].charateristics[1].characteristic.uuid.uuid = 0x03;
p_db_discovery->services[0].charateristics[1].characteristic.uuid.type = 0x02;
// p_db_discovery->services[0].charateristics[1].characteristic.char_props.write_wo_resp = 1;
p_db_discovery->services[0].charateristics[1].characteristic.char_props.notify = 1;
err_code = ble_nus_c_handles_assign(p_ble_nus_c, nus_c_evt.conn_handle,&nus_c_evt.handles);//分配连接句柄
APP_ERROR_CHECK(err_code);
err_code = ble_nus_c_tx_notif_enable(p_ble_nus_c);//使能cccd通知
APP_ERROR_CHECK(err_code);
I put it after BLE_GAP_EVT_CONNECTED,it is err log:
00> <info> app: ATT MTU exchange completed.
00>
00> <info> app: Ble NUS max data length set to 0xF4(244)
00>
00> <info> app: scan time:100ms
00>
00> <debug> nrf_ble_gq: nrf_ble_gq_on_ble_evt request queue...
00>
00> <debug> nrf_ble_gq: Processing the request queue...
00>
00> <debug> nrf_ble_gq: GATTC Write Request
00>
00> <debug> nrf_ble_gq: Pointer to freed memory block: 0x2000332C.
00>
00> <debug> nrf_ble_gq: SD GATT procedure (1) succeeded on connection handle: 0.
00>
00> <debug> nrf_ble_gatt: Data length updated to 251 on connection 0x0.
00>
00> <debug> nrf_ble_gatt: max_rx_octets: 251
00>
00> <debug> nrf_ble_gatt: max_tx_octets: 251
00>
00> <debug> nrf_ble_gatt: max_rx_time: 2120
00>
00> <debug> nrf_ble_gatt: max_tx_time: 2120
00>
00> <debug> nrf_ble_gq: nrf_ble_gq_on_ble_evt request queue...
00>
00> <debug> nrf_ble_gq: Processing the request queue...
//=================
,can you give me some ideas?thankyou