A Dash Riddle

I power down the Dash modem and put the device into deep sleep for 15 minutes. On waking up it turns the modem power on and then goes into a loop waiting for the modem to be connected:

  while (!HologramCloud.isConnected() && cnt++<35) {
   Dash.snooze(200);
  }

- or - 

  while (!HologramCloud.isConnected() && cnt++<35) {
    delay(200);
  }

The first one doesn’t work and the second one ends up working. The docs give me the impression that the first one is just a lower power version of delay. Why wouldn’t it work?

Alternately, is there any way to go into sleep and have the modem wake the system up when it’s connected?

Turns out it was just a coincidence. Seems like we don’t have the best cell service at our house and I think when testing the delay it was just within the timeframe while during the snooze test it fell right outside of it. Cranking up timeouts helped.

1 Like

And now I’m flummoxed again. ':^)

  int cnt = 0;
  // wait for modem to get good connection
  while (!HologramCloud.isConnected() && cnt++<30) {
    Dash.snooze(500);
  }

  HologramCloud.print(cnt);
  ... (other stuff)
  HologramCloud.sendMessage();

The last two times I deployed this code the count is either at or very near max count (last week that equaled 10s this week 15s). But the thing is, even when count is max (i.e. never got a good isConnected) I am still getting the sendMessage contents in the dashboard.

From looking at the source code isConnected calls getConnectionStatus and compares the returned status to CLOUD_CONNECTED. I see there’s another function “isRegistered” that returns true if it’s either connected or registered. Which do we need to be able to do Hologram.sendMessage call?

Digging a bit deeper it looks like sendMessage calls the modem with a 10s timeout (in a couple places?). So maybe it will chill for a while waiting for a good connection?

The thing is the last time I had this out in the woods (using delay instead of snooze) it would average about 6 seconds to get a good connection. Since I’m having it go into deep sleep with modem off, which makes it hard to use the serial port (and my home cell network sucks), it’s been kind of hard to troubleshoot this. Any guidance as to the best practice of waking from deep sleep and powering on the modem to being ready to do a Hologram.sendMessage would be much appreciate.

Could add
HologramCloud.getSignalStrength()
my bet is you’re about in the same strength than me ==8-11 making connection erratic

I had the idea to use your script but rather than a 0.5x30 timeout, a 2s x 30cnt. do you think it could help?

Well, the first time I was using delay instead of snooze it was a 50ms delay x 140 cnt and normally got a connect around 120 cnt (6s). And me, thinking I could save some precious battery, thought “why not snooze for a longer period”? Maybe I should go back to the old way and see if it still works the same.

My next idea is to wake up from deep sleep, power up the modem, go back into deep sleep for 6 seconds or so, then try to blast out a sendMessage when it wakes up.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.