• Got larger MTU also working with SDK15 and nrf52840 dongle and there is interesting situation regarding nordic uart. In SDK12 the BLE_NUS_MAX_DATA_LEN is defined to 20 here https://github.com/espruino/Espruino/blo­b/master/targetlibs/nrf5x_12/components/­ble/ble_services/ble_nus/ble_nus.h#L73 no matter what MTU is at build or run time. So it needs change there. In SDK15 this is defined in same targetlibs/nrf5x_15/components/ble/ble_s­ervices/ble_nus/ble_nus.h to be (NRF_SDH_BLE_GATT_MAX_MTU_SIZE - OPCODE_LENGTH - HANDLE_LENGTH) so in my case it is 56 automatically. And so it seem to be working out of box with Android and also Chrome in Windows if larger MTU is negotiated (and in fact it is). However if MTU is not negotiated or is lower (it can be done in nrfconnect, MTU auto negotiation is configurable in settings so if disabled one can use request MTU connection menu item later) it breaks and espruino sends larger data than the other side can receive. So with SDK15 it is broken out of box in this case.

    However regarding this NRF_BLE_GATT_EVT_ATT_MTU_UPDATED it looks like it is more complicated as this is part of gatt module that is not linked to Espruino and in sdk12 is experimental and that event is there from SDK13 anyway. in sdk 12 it is here https://github.com/espruino/Espruino/blo­b/master/targetlibs/nrf5x_12/components/­ble/nrf_ble_gatt/nrf_ble_gatt.c So I guess similar MTU code can be part of ble_evt_handler near case BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST.

    EDIT: got it working, addded m_peripheral_att_mtu_effective near m_peripheral_conn_handle and in BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST I remember p_ble_evt->evt.gatts_evt.params.exchange­_mtu_request.client_rx_mtu and it seem to work. in nrfconnect I can use 'Request MTU' menu item and data received is splitted correctly by value I set there -3.

    So I guess I will do PR with everything possibly tomorrow or over weekend.


Avatar for fanoush @fanoush started