How can user firmware know that deviceOS synced a Ledger?

This is useful in the case of a sleepy device.
Say the device wakes up, publishes then goes back to sleep.
I would like to check if any/all ledgers were already processed (synced, with new values, or verified that there were no changes in them) so the device can go back to sleep knowing it did not miss any ledger updates.

I think I just witnessed a publish cycle of a sleepy device that took around 2 seconds to finish the publish work and went to sleep, but did not get a ledger update I had sent from the cloud.
In this case this is a cloud-to-device ledger.

So if the code would have been able to ask DeviceOS if the ledgers were all done syncing (they weren't in this case, I presume), then I could code accordingly and make the device remain awake while the ledgers are all sync'ed.

Is there such a call?
Thank you.

I believe onSync in the Ledger class should do that, but only for one ledger. You'd have to check all of them if you have multiple ledgers.

You can also monitor lastSynced() and lastUpdated() if you want to poll for changes in a ledger instead of using a callback.

Hi and thanks.

My understanding:

OnSync() only gets triggered when I change the ledger in the cloud.
lastSynced() gives me the last time the value was updated, but only changes when I change the ledger from the cloud side.
lastUpdated() seems similar to lastSynced() for some reason.

My tests:

Changed the ledger last night:
lastSynced()

0000019588 [app] INFO: Last sync was 52154000 ms ago (~52154 seconds, ~869 minutes, ~14 hours ago)

lastUpdated()

0000019597 [app] INFO: Last updated was 52144571 ms ago (~52144 seconds, ~869 minutes, ~14 hours ago)

just changed it now:

0000056591 [app] INFO: Last sync was 7000 ms ago (~7 seconds, ~0 minutes, ~0 hours ago)
0000056599 [app] INFO: Last updated was 14095 ms ago (~14 seconds, ~0 minutes, ~0 hours ago)

Device goes to sleep then wakes up and connects to cloud+publishes, then goes to sleep again.

0000022567 [app] INFO: Last sync was 291000 ms ago (~291 seconds, ~4 minutes, ~0 hours ago)
0000022575 [app] INFO: Last updated was 298095 ms ago (~298 seconds, ~4 minutes, ~0 hours ago)

Could it be that lastSync() is not functioning properly?
Another option is that I misunderstood/missed something.

Thanks