send message fails with est. netwk. conn.

Hi all,

I am trying to send ~400 byte JSON formatted strings using the cloudPrintGPS() function included below. After each HologramCloud.sendMessage() call I check to see the status of the call - it usually returns failure, but not always. I also print out the network status and most of the time I have an established network connection and a good signal strength. What could be causing my issue? I call this cloudPrintGPS() function using the Dash timer about every couple seconds. Below is my code and the output from the serial port. Thanks so much for the help!.

I have most of the JSON data hardcoded right now for debugging purposes.

/* ------------------------------------------------------------------------------------------------------
    FUNCTION: Print GPS status information to cloud
   ----------------------------------------------------------------------------------------------------*/
void cloudPrintGPS()
{
  int funcStatus;

  /* create size of json object based on formula */
  const unsigned int jsonObjSize = JSON_ARRAY_SIZE(7) + JSON_OBJECT_SIZE(18);
  //DEBUG_PRINT(jsonObjSize);
  /* make sure object does not exceed the maximum hologram message size */
  if (jsonObjSize > MAX_MSG_LEN)
  {
    DEBUG_PRINT("\nCloudPrintGPS(): ERROR - message size (");
    DEBUG_PRINT(jsonObjSize);
    DEBUG_PRINT(") is too large\n");
  }
 
  root["DevSN"] = Dash.serialNumber();
  root["DevStatus"] = devStatus;
  root["BurstID"] = bidU;
  JsonArray& Time = root.createNestedArray("Time");
  Time.add(2018);
  Time.add(04);
  Time.add(20);
  Time.add(15);
  Time.add(50);
  Time.add(1);
  Time.add(0);
  root["GPSLat"] = 41.8524921;
  root["GPSLon"] = -87.9248239;
  root["GPSFix"] = true;
  root["GPSFixQ"] = 1;
  root["GPSSat"] = 11;
  root.printTo(jsonCharArr);

  /* Send message and check status if send fails!*/
  HologramCloud.clear();
  funcStatus = HologramCloud.sendMessage(jsonCharArr);
  if (!funcStatus)
  {
    DEBUG_PRINTLN("\nHologramCloud.sendMessage(jsonCharArr) failed!");
    getConnStatus();    
    DEBUG_PRINT("Signal Strength: "); DEBUG_PRINTLN(HologramCloud.getSignalStrength());
  }

}

/* ------------------------------------------------------------------------------------------------------
  FUNCTION: Cloud event callback
  -----------------------------------------------------------------------------------------------------*/
int getConnStatus() 
{
  int status = HologramCloud.getConnectionStatus();
  switch (status)
  {
    case CLOUD_REGISTERED :
      DEBUG_PRINTLN("getConnStatus(): Registered on the network.");
      break;
    case CLOUD_CONNECTED :
      DEBUG_PRINTLN("getConnStatus(): Network connection established.");
      break;
    case CLOUD_ERR_UNAVAILABLE:
      DEBUG_PRINTLN("getConnStatus(): Modem not available.");
      break;
    case CLOUD_ERR_SIM :
      DEBUG_PRINTLN("getConnStatus(): No valid SIM card found.");
      break;
    case CLOUD_ERR_UNREGISTERED :
      DEBUG_PRINTLN("getConnStatus(): Could not register on the network.");
      break;
    case CLOUD_ERR_SIGNAL :
      DEBUG_PRINTLN("getConnStatus(): No tower was found.");
      break;
    case CLOUD_ERR_CONNECT :
      DEBUG_PRINTLN("getConnStatus(): SIM card not active.");
      break;
    case CLOUD_ERR_MODEM_OFF:
      DEBUG_PRINTLN("getConnStatus(): Modem is powered off.");
      break;
    default:
      DEBUG_PRINTLN("getConnStatus(): Function Error.");
      break;
  }
  return status;
}

Here is the serial port output:

HologramCloud.sendMessage(jsonCharArr) failed!
getConnStatus(): Network connection established.
Signal Strength: 23

What does it look like on the cloud side? Is any data making it to the dashboard? What is the status of your SIM card?

Full disclosure - sometimes the messages work all the time…meaning the cloud receives them and I can route them to my custom endpoint. When they fail - they seem to fail 98% of the time - no data shows up on the dashboard.

I apologize for my green-ness with cellular tech, but I think the answer to the SIM question is that it is active. I have used it to successfully send data to the cloud and route it to the custom endpoint using a webhook in the past.

Chris, Sorry I didn’t reply to you directly but I did reply in the thread.

When you wake the device and send (ostensibly outside of the cloudPrintGPS() function?), do you verify you are attached to the tower agin before sending? Are you sending diagnostic data back to the cloud? It seems like you need a bit more diagnostic info being returned from your functions, can you think of other things you might be able to output from these functions to the serial port?

I provide the following while loop in my void setup() function:

/* wait for a network connection */
while (getConnStatus() != CLOUD_CONNECTED)
{
Dash.snooze(100);
}

One other update, the hologram cloud dashboard shows activity from my device but doesn’t show any messages in the console. I am not sure how to interpret the data shown after clicking the “inspect” button on the device’s page but it seems like maybe we could learn something from that data?

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