• Yes but first it needs to be solved on Espruino side, it has same issue as web bluetooth :-) The code does not know currently negotiated MTU so does not know how much can be sent safely as the rest is discarded.

    Just tested such simple service https://gist.github.com/fanoush/04d0777f­99bb4d153aa1a40aa218db55 and if I set maxlen over MTU size the rest is silently cut. But otherwise it works, tested with Serial Bluetooth Terminal (as it can set any two suitable characteristics for input/output) and as long as I keep it below MTU size it works and larger data gets through.

    So as linked in my previous post we need to add NRF_BLE_GATT_EVT_ATT_MTU_UPDATED event and set nordic uart size according to that and also preferably make it available for js code somewhere. Not sure if web bluetooth already have some api proposal for this, I'd put it on connection object somehow. Tried to think how to add it but the code is too complicated for me (does it need to be queued as JSBLEP_xx pending event in ble_evt_handler or can be written directly somewhere).

    EDIT:
    however at least the nordic uart look easy, it is hopefully just about making
    BLE_NUS_MAX_DATA_LEN dynamic, allocate array up to NRF_BLE_MAX_MTU_SIZE-3 (by changing it here) and then check it here for real negotiated MTU from the event, not array size. I'll try that.

About

Avatar for fanoush @fanoush started