hi guys,
now i have 2 pieces 52832 boards; A(PERIPHERAL) and B(CENTRAL); both run the nus service.
B(CENTRAL)--->A(PERIPHERAL) Through ble_nus_c_string_send();
and A(PERIPHERAL)--->B(CENTRAL) use ble_nus_data_send();
B(CENTRAL)--->A(PERIPHERAL) the data transfor is slow,(when i use phone connect to --->A(PERIPHERAL)and send data via nus is good )
the cfg is
uint32_t ble_nus_c_string_send(ble_nus_c_t * p_ble_nus_c, uint8_t * p_string, uint16_t length)
{
VERIFY_PARAM_NOT_NULL(p_ble_nus_c);
nrf_ble_gq_req_t write_req;
memset(&write_req, 0, sizeof(nrf_ble_gq_req_t));
if (length > BLE_NUS_MAX_DATA_LEN)
{
NRF_LOG_WARNING("Content too long.");
return NRF_ERROR_INVALID_PARAM;
}
if (p_ble_nus_c->conn_handle == BLE_CONN_HANDLE_INVALID)
{
NRF_LOG_WARNING("Connection handle invalid.");
return NRF_ERROR_INVALID_STATE;
}
write_req.type = NRF_BLE_GQ_REQ_GATTC_WRITE;
write_req.error_handler.cb = gatt_error_handler;
write_req.error_handler.p_ctx = p_ble_nus_c;
write_req.params.gattc_write.handle = p_ble_nus_c->handles.nus_rx_handle;
write_req.params.gattc_write.len = length;
write_req.params.gattc_write.offset = 0;
write_req.params.gattc_write.p_value = p_string;
write_req.params.gattc_write.write_op = BLE_GATT_OP_WRITE_CMD;//BLE_GATT_OP_WRITE_CMD BLE_GATT_OP_WRITE_REQ
write_req.params.gattc_write.flags = BLE_GATT_EXEC_WRITE_FLAG_PREPARED_WRITE;
return nrf_ble_gq_item_add(p_ble_nus_c->p_gatt_queue, &write_req, p_ble_nus_c->conn_handle);
}
#define NRF_SDH_BLE_GAP_DATA_LENGTH 107
#define NRF_SDH_BLE_CENTRAL_LINK_COUNT 1
#define NRF_SDH_BLE_GAP_EVENT_LENGTH 24
#define NRF_SDH_BLE_GATT_MAX_MTU_SIZE 103
i want to send 200bytes via ble_nus_c_string_send() and get the event :BLE_GATTC_EVT_WRITE_CMD_TX_COMPLETE,
case BLE_GATTC_EVT_WRITE_CMD_TX_COMPLETE:
BLE_LOG("send count=%04d",p_ble_evt->evt.gattc_evt.params.write_cmd_tx_complete.count);
break;
send count =0001;It's one every time.
Is my operation correct?
how to use evt BLE_GATTC_EVT_WRITE_RSP and BLE_GATTC_EVT_WRITE_CMD_TX_COMPLETE?and BLE_GATT_OP_WRITE_CMD BLE_GATT_OP_WRITE_REQ?
to Improve Bluetooth communication data rate?
thanks