Best way to determine based on API whether the Notecard is having difficulty connecting to cell network?

I am looking for a boolean indicator of whether or not the Notecard is having trouble connecting to a cell network, so that I can light an LED on our Feather to indicate that for troubleshooting. That seems simple, but I’ve been having trouble finding a reliable way to get that info.

I disconnected the antenna from my board to simulate connection problems. The best way I can find to tell that there is an issue is to do hub.sync.status. The problem here is that many of the fields in this response are completely different depending on what’s going on. For example, there is an “alert” property that indicates a problem, but that field is only there on some responses. Can I infer by the absence of this property that everything is cool? There is also a “mode” property, but I don’t have a list of what the possible modes are or what they mean, so it’s tough to programmatically check that field to make a determination.

I suspect there is a super easy approach that I am missing and I will feel dumb but relieved at the reply I get. Can anyone suggest a clean approach to determining whether a Notecard is unable to connect?

Scott

1 Like

Hi @scase,

I’m sorry this question seems to have fallen through the cracks! I would recommend using the card.wireless.penalty API. This will tell you if an individual device is actively having trouble connecting to a cell network.

For example:

{
  "req": "card.wireless.penalty"
}

If the response contains minutes, that is the number of minutes since the network registration failure:

{
  "seconds": 3324,
  "minutes": 69,
  "status": "network: can't connect (55.4 min remaining) {registration-failure}{network}{extended-network-failure}",
  "count": 6
}

Hope that helps!
Rob