I’m trying to determine the best way to check the status of the last attempt to reach out to notehub. I am currently using the hub.sync.status and checking if the “completed” field is there.
Reading through some of the docs, it looks like the completed field is there in the case where the notecard is in the penalty box.
{“req”:“hub.sync.status”}
{“alert”:true,“status”:“connect delayed (60 min remaining): can’t open session to discovery service: socket: cannot find host: blah.notefile.net {service}{host-unreachable} {service}{extended-service-failure}”,“time”:1638397092,“completed”:24}
Looking for recommendations on how to check last connection attempt is successful (including hub.sync and outbound interval) … how have you done this?
The completed field will tell you the seconds since the last completion of a sync with Notehub (though that does not guarantee that the sync was successful, as you see here). I would also look for alert:true. If that exists, there was an error during the most recent sync. Finally, the status field contains a lot of useful information as well (anything in the curly braces {} are static status/error codes that do not change between Notecard firmware versions).
Unfortunately, even when the connection was successful, I get the alert:true for other reasons, so I found the alert not reliable to use as my trigger/flag. I want to have a simple way to constantly monitor the last connection attempt and if the last message had an alert:true → it would be difficult to set my status LED to indicate something is wrong with my comms. It sounds I may have to do a combo of checking for completed (because that gets set when successful after a hub.sync) && alert not set.
Yeah, sorry I wasn’t clear but my suggestion is to use the alert:true in combination with measuring seconds since the last successful sync. There are MANY points of potential network failure in between a Notecard and Notehub that are dependent upon cellular carriers, towers, etc.