Hub.status.connected response is incorrect?

Hi! I just had something weird happen with my device and thought I’d report it.

I have the following code:

bool isModemConnected()
{
  bool isModemConnected = false;
  J *hubStatusRequest = notecard.newRequest("hub.status");

  J *response = notecard.requestAndResponse(hubStatusRequest);
  isModemConnected = JGetBool(response, "connected");

  notecard.deleteResponse(response);

  Serial.print("Modem connected?: ");
  Serial.println(isModemConnected);

  return isModemConnected;
}

Most of the time this code works as expected. However, sometimes I see things in a weird state:

image

Here it looks to me like hub.status is indicating that the modem has successfully connected, but the connected result is still 0?

I poll the modem every 30 seconds waiting for the issue to resolve, but it doesn’t. The status never changes.

Then I kill power to my device, then restart it, and the issue resolves itself with me having changed no code.

[INFO] {"req":"hub.set","mode":"continuous","outbound":60,"inbound":60,"duration":60,"crc":"0001:7ECDB008"}
[INFO] {}
turnOnModem successful.
[INFO] {"req":"hub.status","crc":"0002:5874FEF1"}
[INFO] {"status":"4s starting communications {wait-module} {connecting}"}
Modem connected?: 0
[INFO] {"req":"hub.status","crc":"0003:5874FEF1"}
[INFO] {"status":"29s waiting for wireless service {wait-service} {connecting}"}
Modem connected?: 0
[INFO] {"req":"hub.status","crc":"0004:5874FEF1"}
[INFO] {"connected":true,"status":"connected (session open) {connected}"}
Modem connected?: 1
[INFO] {"req":"web.get","route":"GetSchedules","crc":"0005:5328B37A"}
[INFO] {"result":200,"body":{"schedules":[{"days_of_week":["thursday"],"duration":11,"minutes_past_midnight":1218}]}}
Schedule Count:0
[INFO] {"req":"hub.set","mode":"off","crc":"0006:C0794E2C"}
[INFO] {}
turnOffModem successful.

I’ve had this happen twice in the last hour of development. It’s not clear to me if I’m misunderstanding something or if I’m bumping into a bug.

Thanks!

Hi @Meo,

This is a good question. The connected:true response indicates that the Notecard has an active connection via whatever wireless transport mechanism it’s using AND that it has made a connection to Notehub. Without that response (like in your example) the Notecard may have made a successful cellular connection, but it hasn’t yet connected to Notehub. This shouldn’t take 30 seconds though. What firmware version of the Notecard are you on?

I don’t think this is related, but I would also recommend reading up on the types of penalty boxes a Notecard can be in, especially the Inability to Connect to Notehub penalty box.

Rob

Hey, thanks for the response.

Okay, I appreciate the clarification. That’s helpful.

I bet you it was the penalty box. I was frequently turning my device on/off as I flashed new firmware onto it trying to triage an issue.

It would be nice if any penalty box issues were highlighted in the connection metadata if they’re preventing the initial connection from being established. I realize this is redundant, but seems like it’d be more clear.

Cheers