Send long packets for Android using low MTU sizes

Hi,

In a ble_app_uart example I have problems to send long packets if the Android smartphone only accepts MTU sizes of 20 bytes. I'm using the nRF5_SDK_17.1.0, the S132 over the SES IDE and the nR52-DK board.

The application adjusts the MTU size to the value negotiated by the smartphone and it's set to 20 bytes. However, when I send longer packets the smartphone only receives a part. It looks like the device only send one packet and doesn't manages automatically the division of the full packet for sendidn it in different subpackets.

How could I setup the Softdevice so it could automatically manages this sending of a long packet in subpackets? Excuse me if there is other similar case about this, but I have not been able to find it.

Thank you in advance.

Regards,

Joel

Parents
  • Hi Sigurd,

    Thank you for your reply. 

    i also see that in the gatt_evt_handler() the management of the MTU size should also update the m_ble_nus_max_data_len value. But it doesn't look to work:

    /**@brief Function for handling events from the GATT library. */
    void gatt_evt_handler(nrf_ble_gatt_t * p_gatt, nrf_ble_gatt_evt_t const * p_evt)
    {
        if ((m_conn_handle == p_evt->conn_handle) && (p_evt->evt_id == NRF_BLE_GATT_EVT_ATT_MTU_UPDATED))
        {
            m_ble_nus_max_data_len = p_evt->params.att_mtu_effective - OPCODE_LENGTH - HANDLE_LENGTH;
            NRF_LOG_INFO("Data len is set to 0x%X(%d)", m_ble_nus_max_data_len, m_ble_nus_max_data_len);
        }
        NRF_LOG_DEBUG("ATT MTU exchange completed. central 0x%x peripheral 0x%x",
                      p_gatt->att_mtu_desired_central,
                      p_gatt->att_mtu_desired_periph);
    }

    I understand this piece of code should work, isn't it?

    Regards,

    Joel

Reply
  • Hi Sigurd,

    Thank you for your reply. 

    i also see that in the gatt_evt_handler() the management of the MTU size should also update the m_ble_nus_max_data_len value. But it doesn't look to work:

    /**@brief Function for handling events from the GATT library. */
    void gatt_evt_handler(nrf_ble_gatt_t * p_gatt, nrf_ble_gatt_evt_t const * p_evt)
    {
        if ((m_conn_handle == p_evt->conn_handle) && (p_evt->evt_id == NRF_BLE_GATT_EVT_ATT_MTU_UPDATED))
        {
            m_ble_nus_max_data_len = p_evt->params.att_mtu_effective - OPCODE_LENGTH - HANDLE_LENGTH;
            NRF_LOG_INFO("Data len is set to 0x%X(%d)", m_ble_nus_max_data_len, m_ble_nus_max_data_len);
        }
        NRF_LOG_DEBUG("ATT MTU exchange completed. central 0x%x peripheral 0x%x",
                      p_gatt->att_mtu_desired_central,
                      p_gatt->att_mtu_desired_periph);
    }

    I understand this piece of code should work, isn't it?

    Regards,

    Joel

Children
No Data
Related