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;
}