This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

gatt_init procedure prevents long write SDK14.2

Hello,

I need to long WRITE AND long READ from a central/client (android) to a peripheral server (nrf52). when I says long it means longer than the MTU.

LONG READ

I made my long read successful by changing the MTU using the GATT procedure and specifying the variable NRF_SDH_BLE_GATT_MAX_MTU_SIZE = 247

/**@brief Function for initializing the GATT library. */
void BleApp::gatt_init(void) {
	ret_code_t err_code;

	err_code = nrf_ble_gatt_init(&m_gatt, on_gatt_evt);
	APP_ERROR_CHECK(err_code);

	err_code = nrf_ble_gatt_att_mtu_periph_set(&m_gatt,
	NRF_SDH_BLE_GATT_MAX_MTU_SIZE);         // UPDATE MTU HERE
	APP_ERROR_CHECK(err_code);

	NRF_LOG_DEBUG("[INIT] GATT");
}

LONG WRITE

I made my long write successful by using the queued write sequence:

1) BLE_EVT_USER_MEM_REQUEST

2.1) BLE_GATTS_OP_WRITE_REQ

....

2.n) BLE_GATTS_OP_WRITE_REQ

3) BLE_GATTS_OP_EXEC_WRITE_REQ_NOW

4) BLE_EVT_USER_MEM_RELEASE

But it works only if:

  1. The MTU is not changed (20 bytes), which is a problem because I need it for read
  2. The packet is not too big. If more than (approx) 100B, I receive only the mem_request and the mem_release

someone can give me a hint ? I m' sotcked 

thanks,

yacine

Parents
  • this happens at connection establishment: I set both server and client mtu to 247 and it seems to be ok. only very small packets are recevived correctly. other lead to a disconnect that I can see in the android log (no pertinent info, just the peripheral has disconnected for this write....)

    <debug> thc_ble_tds: [TDS] GAP Connected.
    <debug> ble_gatt: Requesting to update ATT MTU to 247 bytes on connection 0x0.

    <debug> ble_gatt: Requesting to update data length to 251 on connection 0x0.

    <info> thc_ble_app: [APP] Connection established.
    <debug> ble_gatt: ATT MTU updated to 247 bytes on connection 0x0 (response).

    <debug> thc_ble_app: [APP] MTU updated
    <debug> ble_gatt: Data length updated to 251 on connection 0x0.

    <debug> ble_gatt: max_rx_octets: 27

    <debug> ble_gatt: max_tx_octets: 251

    <debug> ble_gatt: max_rx_time: 328

    <debug> ble_gatt: max_tx_time: 2120

    <debug> thc_ble_app: [APP] MTU unchanged
    <info> thc_ble_app: [APP] LLData Channel PDU payload length updated.
    <info> thc_ble_app: [APP] Connection Parameters updated.
    <debug> ble_gatt: Peer on connection 0x0 requested a data length of 27 bytes.

    <debug> ble_gatt: Updating data length to 27 bytes on connection 0x0.

    <info> thc_ble_app: [APP] Data Length Update Request.
    <debug> ble_gatt: Data length updated to 251 on connection 0x0.

    <debug> ble_gatt: max_rx_octets: 27

    <debug> ble_gatt: max_tx_octets: 251

    <debug> ble_gatt: max_rx_time: 328

    <debug> ble_gatt: max_tx_time: 2120

    <debug> thc_ble_app:[APP] MTU unchanged
    <info> thc_ble_app: [APP] LL Data Channel PDU payload length updated.
    <debug> ble_gatt: Peer on connection 0x0 requested an ATT MTU of 247 bytes.

    <debug> ble_gatt: Updating ATT MTU to 247 bytes (desired: 247) on connection 0x0.

    <debug> thc_ble_app: [APP] MTU updated
    <info> thc_ble_app: [APP] Connection Parameters updated.
    <debug> ble_gatt: Peer on connection 0x0 requested a data length of 251 bytes.

    <debug> ble_gatt: Updating data length to 251 bytes on connection 0x0.

    <info> thc_ble_app: [APP] Data Length Update Request.
    <debug> ble_gatt: Data length updated to 251 on connection 0x0.

    <debug> ble_gatt: max_rx_octets: 251

    <debug> ble_gatt: max_tx_octets: 251

    <debug> ble_gatt: max_rx_time: 2120

    <debug> ble_gatt: max_tx_time: 2120

Reply
  • this happens at connection establishment: I set both server and client mtu to 247 and it seems to be ok. only very small packets are recevived correctly. other lead to a disconnect that I can see in the android log (no pertinent info, just the peripheral has disconnected for this write....)

    <debug> thc_ble_tds: [TDS] GAP Connected.
    <debug> ble_gatt: Requesting to update ATT MTU to 247 bytes on connection 0x0.

    <debug> ble_gatt: Requesting to update data length to 251 on connection 0x0.

    <info> thc_ble_app: [APP] Connection established.
    <debug> ble_gatt: ATT MTU updated to 247 bytes on connection 0x0 (response).

    <debug> thc_ble_app: [APP] MTU updated
    <debug> ble_gatt: Data length updated to 251 on connection 0x0.

    <debug> ble_gatt: max_rx_octets: 27

    <debug> ble_gatt: max_tx_octets: 251

    <debug> ble_gatt: max_rx_time: 328

    <debug> ble_gatt: max_tx_time: 2120

    <debug> thc_ble_app: [APP] MTU unchanged
    <info> thc_ble_app: [APP] LLData Channel PDU payload length updated.
    <info> thc_ble_app: [APP] Connection Parameters updated.
    <debug> ble_gatt: Peer on connection 0x0 requested a data length of 27 bytes.

    <debug> ble_gatt: Updating data length to 27 bytes on connection 0x0.

    <info> thc_ble_app: [APP] Data Length Update Request.
    <debug> ble_gatt: Data length updated to 251 on connection 0x0.

    <debug> ble_gatt: max_rx_octets: 27

    <debug> ble_gatt: max_tx_octets: 251

    <debug> ble_gatt: max_rx_time: 328

    <debug> ble_gatt: max_tx_time: 2120

    <debug> thc_ble_app:[APP] MTU unchanged
    <info> thc_ble_app: [APP] LL Data Channel PDU payload length updated.
    <debug> ble_gatt: Peer on connection 0x0 requested an ATT MTU of 247 bytes.

    <debug> ble_gatt: Updating ATT MTU to 247 bytes (desired: 247) on connection 0x0.

    <debug> thc_ble_app: [APP] MTU updated
    <info> thc_ble_app: [APP] Connection Parameters updated.
    <debug> ble_gatt: Peer on connection 0x0 requested a data length of 251 bytes.

    <debug> ble_gatt: Updating data length to 251 bytes on connection 0x0.

    <info> thc_ble_app: [APP] Data Length Update Request.
    <debug> ble_gatt: Data length updated to 251 on connection 0x0.

    <debug> ble_gatt: max_rx_octets: 251

    <debug> ble_gatt: max_tx_octets: 251

    <debug> ble_gatt: max_rx_time: 2120

    <debug> ble_gatt: max_tx_time: 2120

Children
Related