• I can't resist trying to learn something new, so I managed to implement quick&dirty BLE time broadcast for Debian 11.

    Broadcast side (bash, bluez), one broadcast per second for 60 seconds:

    sudo hciconfig hci0 leadv 3
    for (( n=1; n<60; n++ ))
    do
        time=$(date +%s)
        hex=$(printf '%010X' $time)
        echo $hex
        sudo hcitool -i hci0 cmd 0x08 0x0008 1E 02 01 1A 1A FF FF FF \
            ${hex:0:2} ${hex:2:2} ${hex:4:2} ${hex:6:2} ${hex:8:2} \
            00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        sleep 1
    done
    sudo hciconfig hci0 noleadv
    

    Receiver side, received_time is Unix timestamp in seconds:

    packets=100;
    NRF.setScan(function(d) {
      packets--;
      if (packets == 0) {
        NRF.setScan();
      } else if (d.manufacturer == 65535) {
        let received_time = 0;
        for (let i = 0; i < 5; i++) {
          received_time <<= 8;
          received_time += d.manufacturerData[i];
        }
      }
    });
    
About

Avatar for malaire @malaire started