MTU between BLE_NUS & BLE_NUS_C is not exchanged, but BLE_NUS & iOS nRF Connect App is exchanged?

Hi,

  I am implementing NUS which is based on example BLE_NUS & BLE_NUS_C.

  The connection is not 1-to-1 but 1-to-7. i.e. 1 Central connects to 7 Peripherals.
  Although ultimate goal is 7 peripherals, I am just testing with 2 peripherals in the current phase.

  So far I have implemented:
  Peripheral side (BLE_NUS) is sending 78 Bytes data every 3 seconds.
  Central side (BLE_NUS_C) can accept 7 device (

NRF_SDH_BLE_CENTRAL_LINK_COUNT = 7
).
  Both NRF_SDH_BLE_GATT_MAX_MTU_SIZE is set to 300 in config.h.
  In gatt_init(void), I have added a log to print out the NRF_SDH_BLE_GATT_MAX_MTU_SIZE to confirm.
 
NRF_LOG_INFO("NRF_SDH_BLE_GATT_MAX_MTU_SIZE = %u", NRF_SDH_BLE_GATT_MAX_MTU_SIZE)
and confirmed it is 300 in log.

  What is the problem:
  When peripheral sends the data, let's say the conent is: "ABCDEFGHIJKLMNOPQRSTUVWXYZ......." (78 Bytes in total).
  On Central side (BLE_NUS_C_EVT_NUS_TX_EVT), the received data is only 20 Bytes.
  i.e. p_ble_nus_evt->p_data is "ABCDEFGHIJKLMNOPQRST" and p_ble_nus_evt->data_len is 20.

  I am quite sure that the Peripheral side is sending out whole 78 Bytes datas because if I connect to iOS nRF Connect App. I can see the whole 78 Bytes data and it keeps updating every 3 seconds.
  According from the RTT Log from Peripheral, I found that if the Peripheral connect with iOS nrfConnect, the log has printed out a message "ATT MTU exchange completed. central 0x12C peripheral 0x12C", where this log does not show up if it is connect to BLE_NUS_C (Central)

  Is there any hint how could I fix it?
  Or can I force update the MTU after connected?

  Thank you very much.
Joe

Parents
  • Hi,

      I would like to provide more information about my testing.

      I have read this document (https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v15.0.0%2Flib_ble_gatt.html). According to the document, i tried to print out the value of nrf_ble_gatt_eff_mtu_get and nrf_ble_gatt_data_length_get.

      

    case BLE_NUS_C_EVT_NUS_TX_EVT:
        // BLE RECEIVED
        NRF_LOG_INFO("p_ble_nus_evt->data_len = %u", p_ble_nus_evt->data_len);
        uint16_t eff_mtu = nrf_ble_gatt_eff_mtu_get(&m_gatt, m_ble_nus_c[p_ble_nus_evt->conn_handle].conn_handle);
        NRF_LOG_INFO("eff_mtu = %u", eff_mtu)
        uint8_t data_length_result = 0;
        err_code = nrf_ble_gatt_data_length_get(&m_gatt, m_ble_nus_c[p_ble_nus_evt->conn_handle].conn_handle, &data_length_result);
        APP_ERROR_CHECK(err_code);
        NRF_LOG_INFO("data_length_result = %u", data_length_result)

      The result is as follow:
      p_ble_nus_evt->data_len = 20
      eff_mtu = 23
      data_length_result = 27
      

    Joe

Reply
  • Hi,

      I would like to provide more information about my testing.

      I have read this document (https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v15.0.0%2Flib_ble_gatt.html). According to the document, i tried to print out the value of nrf_ble_gatt_eff_mtu_get and nrf_ble_gatt_data_length_get.

      

    case BLE_NUS_C_EVT_NUS_TX_EVT:
        // BLE RECEIVED
        NRF_LOG_INFO("p_ble_nus_evt->data_len = %u", p_ble_nus_evt->data_len);
        uint16_t eff_mtu = nrf_ble_gatt_eff_mtu_get(&m_gatt, m_ble_nus_c[p_ble_nus_evt->conn_handle].conn_handle);
        NRF_LOG_INFO("eff_mtu = %u", eff_mtu)
        uint8_t data_length_result = 0;
        err_code = nrf_ble_gatt_data_length_get(&m_gatt, m_ble_nus_c[p_ble_nus_evt->conn_handle].conn_handle, &data_length_result);
        APP_ERROR_CHECK(err_code);
        NRF_LOG_INFO("data_length_result = %u", data_length_result)

      The result is as follow:
      p_ble_nus_evt->data_len = 20
      eff_mtu = 23
      data_length_result = 27
      

    Joe

Children
No Data
Related