Massive Bluetooth speed improvements

Posted on
  • Hi!

    Recent (cutting edge) builds of Espruino for nRF5x chips (eg. all official Espruino Bluetooth boards) are now much faster at communicating over Bluetooth. I managed to get a whole bunch of changes in:

    Speed negotiation now happens 0.1 second after connecting, not 5s. This massively improves connection speed for pretty much everything.

    Bluetooth UART transmit now attempts to send multiple transmit packets in one connection interval. This code:

    function go() {
      var t = getTime();
      for (var i=0;i<200;i++)print(("                    "+i).substr(-18));
      print(getTime()-t);
    }
    

    Used to take around 8 seconds. On pretty much all platforms it's down under 1.5s now (so over a 4x speed boost).

    High speed device-device comms - it used to be that when you connected from one Espruino to another their settings would mean they defaulted to a 20ms connection interval. You can now max this out by supplying some settings to the connect method:

    NRF.requestDevice({ filters: [{ namePrefix: 'Pixl.js' }] }).then(function(device) {
      return device.gatt.connect({minInterval:7.5, maxInterval:7.5});
    }).then(function(g) {
      ...
    

    Improved Web IDE If you're using espruino.com/ide make sure you hit refresh - there have been a few changes that should really improve Web Bluetooth transfer speed!

    Finally, Espruino requests between a 7.5 and 20ms connection interval. Usually this means that the connecting device chooses 20ms to get the lowest power consumption. You can change it to be slower with NRF.setLowPower(true), but you can't get it faster at the moment.

    Espruino now defaults to 7.5ms, and after around a minute of inactivity it slows down to 200ms to save power (which will massively help with power consumption connected devices). Do more than one operation on BLE and it'll bump back up - it's hardly noticeable, but the >2x speed improvement to code uploads really is noticeable.

    You you don't like it there's now NRF.setConnectionInterval to give you full control though.

    I'd be really interested to hear your impressions of the new builds - does the connection process still work smoothly for you? do you have any issues with it?

  • No issues connecting to Pixl for me. Chrome app or Web IDE.

  • Is it noticeably faster for you?

  • The web IDE is very fast. It scans and finds the devices really quickly. And seems to upload quickly too. I didn't remark on it Gordon as I don't use the web IDE day to day, so don't have something to compare to.

    I use (probably) an old/soon to be deprecated chrome app, but the if you want a comparison between those two - they are like chalk cheese for me. Web IDE much faster.

  • tried with a PuckJS, uploaded v199 and it fails on connecting via webIDE:

    >>> BLE configured. Receiving data...
    Connected [object Object]
    Received a prompt after sending newline... good!
    >>> Sending...
    ---> "\u0010print(\"<\",\"<<\",JSON.stringify┬ş(process.env),\">>\",\">\")\n"
    >>> Sent
    WARNING: No result found for "process.env" - just got ""
    ERROR: [notify_error] Unable to retrieve board information. Connection Error?
    Device found {"portName":"Puck.js cb34"}
    [success] Connected to Web Bluetooth, Puck.js cb34 (No response from board)
    >>> Connected to Web Bluetooth, Puck.js cb34 (No response from board)
    

    did a hard reset - still nothing :(

  • on a second PuckJS on which v199 works, everything in webIDE is so slow, the UART timing example takes 39.19 seconds ­čś│

  • There had to be someone :) So you're saying that the normal 1v99 Puck.js build works for you, but is just really slow. However the cutting edge build doesn't work at all?

    What type of computer are you connecting from? Please can you start a new post about this, as it seems something is just generally broken unrelated to these changes if 1v99 is that slow.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Massive Bluetooth speed improvements

Posted by Avatar for Gordon @Gordon

Actions