Waiting for and getting time at startup

Hi there,
I’m able to use card.time to get a timestamp for each sample grab and include it as I’m logging the sample data.

However, there are times at startup when the card time is not yet available and I get the following error message:
{“err”:“time is not yet set”,“zone”:“UTC,Unknown”}

I would like to ensure that I capture the time when the Swan first starts up or reboots. Could you recommend a good way to wait for the time to be available (or is there another way to skin the cat)?

The board sleeps for 10 minutes after startup and the time is always available for the second sample and beyond, it’s just at that initial startup or occasionally if it reboots.

I do know it must complete a hub.sync in order to get the time, so can I capture and test for a “true” hub.sync.status before moving on? Is there a more direct way or example you can point me to?

Using a Swan + LTE Cat-1 - NA Notecard + Notecarrier F

thanks in advance!
…Norm…

Hi @noforan,

There’s nothing wrong with putting a card.time request in a loop with a ~1 sec delay and check for a valid time, while you wait for the Notecard to sync with Notehub. Whenever the Notecard powers up, it will attempt to connect to Notehub regardless of the mode it is in as well.

Rob