• Currently accuracy is quite bad - that sudo hcitool sets up repeated broadcast which I change every second, so accuracy is about 1 second here.

    To get better accuracy I'd need to learn how to send broadcast at once without delay. BLE seems to have inherent random delay of around ~10 ms so e.g. 1 ms accuracy is not possible, but I think that accuracy of <100ms should be possible.

  • 1 ms accuracy is not possible

    I think it is but not with such simple code. Great quick example. Few random ideas -
    you can use setScan with right filter, this needs to be combined with some unique data in advertisement - e.g. manufacturer or serviceData. I think for serviceData id you could use id of specific characteristics in ble current time service or any other defined to contain time and then the data could match the format. It is not exactly to the standard but is close enough to not conflict with anything. see also https://devzone.nordicsemi.com/f/nordic-­q-a/4048/what-service-data-can-be-added-­to-the-advertising-package

    manufacturer is ok too but if you have more espruino devices you'll get more matches, with serviceData it would be unique

    https://www.bluetooth.com/specifications­/assigned-numbers/
    https://www.bluetooth.com/specifications­/specs/current-time-service-1-1/

    the 16bit assigned numbers for different entities are unique and not overlapping between types so that's why I think you can put it safely to serviceData even if it is not id for service

    as for accuracy - ntp prococol can do it quite well over internet, bluetoth timing is strict, advertising packets are timed/spaced in deterministic way. the bash+hci command is probably the worst part here. I tried latest espruino with esp32 yesterday, looks like it can do ntp over wifi and can do Bluetooth advertising. I hope we could possibly generate advertising packet (or scan response packet) on the fly there. But anyway even second accuracy is good enough too.

    EDIT: for esp32 to be usable for that we'd probably need something like this https://github.com/gmag11/ESPNtpClient to have the time in esp32 accurate to 1ms

About

Avatar for fanoush @fanoush started