• I think I answered this at JSOxford, but if anyone else is interested:

    Web Bluetooth doesn't let you create services on the device with the Web Browser.

    However to 'push' data from Espruino to a device with a Web Bluetooth browser, you just need to use notifications: http://www.espruino.com/About+Bluetooth+­LE#services-and-characteristics

    So on Espruino you do:

    NRF.setServices({
      0xBCDE : {
        0xABCD : {
          value : "Hello",
          maxLen : 5, 
          notify : true
    }}});
    function pushData(d) {
     NRF.updateServices({
      0xBCDE : {
        0xABCD : {
          value : d,
          notify : true
     }}});
    }
    

    And then on Web Bluetooth you get the characteristic as normal and then call startNotifications on it, which causes a characteristicvaluechanged event on it whenever you update the characteristic on Espruino.

    I don't think there's any info on the Espruino site about that yet, but there is a workshop I did which has the relevant code: https://github.com/gfwilliams/workshop-t­hingy52/blob/master/step5.md

About

Avatar for Gordon @Gordon started