• Oh nice :-)

    BTW one possibility for Service Data is to advertise "Date Time" 0x2A08 as per https://forum.micropython.org/viewtopic.php?t=9577&p=53698
    it is 7 bytes format

                 0 1  2     3   4    5      6
    Description  Year Month Day Hour Minute Second
    Minimum      1582 1     1   0    0      0
    Maximum      9999 12    31  23   59     59
    

    Then one could pass options {filters: [{serviceData:{"2a08":{}}}]} and it should work. I tried it with ESP32 running espruino and it worked for me
    On ESP32 I've run

    NRF.setAdvertising({
      0x2a08 : [0xe6,0x07,1,22,17,19,30]
    })
    

    and then on another device this worked

    >packets=2
    =2
    >NRF.setScan(function(d) {
    :  packets--;
    :  if (packets<=0)
    :    NRF.setScan(); // stop scanning
    :  else
    :    console.log(d); // print packet info
    :},{filters: [{serviceData:{"2a08":{}}}]});
    =undefined
    BluetoothDevice: {
      "id": "b4:e6:2d:89:01:27 public",
      "rssi": -51,
      "data": new Uint8Array([2, 1, 6, 10, 22, 8, 42, 230, 7, 1, 22, 17, 19, 30, 14, 9, 69, 83, 80, 51, 50, 46, 106, 115, 32, 48, 49, 50, 53, 0, 0]).buffer,
      "name": "ESP32.js 0125",
      "serviceData": {
        "2a08": new Uint8Array([230, 7, 1, 22, 17, 19, 30]).buffer
       }
     }
    > 
    
  • I'm now including milliseconds also for more precision. Bangle.js 2 doesn't support setting time at millisecond precision, but this works quite nicely (wait until next exact second and then set time):

          let delta = 1000 - (received_time % 1000);
          setTimeout(function() {
            setTime((received_time + delta) / 1000);
          }, delta);
    
About

Avatar for malaire @malaire started