So here’s an interesting one. I loaded the Hologram-provided sample sketch for SMS-receive & act (attached). (Howto send data to dash pro? - #6 by zheng). Works swell. I added a single line to send a message back to the Cloud (“SMS receipt confirmed!”). The issue: The sketch works fine for several hours, but then seems to somehow time out, no longer recognizing incoming SMS’s. The SMS’s are indeed making it to the Dash – they report fine via the IDE serial monitor, but the sketch just seems to ignore them. Thoughts?
Other maybe-useful background & notes:
– LED continues to flash every 5 seconds; that, plus the fact that I’m seeing the SMS’s on the serial monitor, tells me the Dash is still running, and of course that the SMS’s are making it to the Dash. No network timeouts that I can see!
– My device is stationary, with a good connection to AT&T Mobility here in Michigan.
– Resetting the Dash (button near antenna) seems to reset some radio stuff, but the lack of SMS recognition continues.
– Resetting the Dash (middle button) brings everything instantly back to normal for a few hours.
// https://community.hologram.io/t/howto-send-data-to-dash-pro/293/6
// EFFECTS: Strips away the length number from the payload as it's not needed.
String stripOffLengthNumber(String payload) {
int index = 0;
while (payload[index] == ',') {
++index;
}
while (payload[index] != ',') {
++index;
}
++index;
payload.remove(0, index);
return payload;
}
void setup() {
/* Serial Setup */
SerialUSB.begin(9600); /* USB UART */
SerialCloud.begin(115200); /* Konekt Cloud */
delay(4000); /* Delay 4 seconds to wait for Usb Serial to Init.*/
/* Setup Konekt Dash */
Dash.begin();
Dash.pulseLED(100,5000); /* Set the User Led to flash every 5 seconds */
/* Serial Print Info */
SerialUSB.println("Konekt Dash SMS Receiving Example Started!");
SerialUSB.print("Using Boot Version: ");
SerialUSB.println(Dash.bootVersion()); /* Print Dash Bootloader Version */
SerialCloud.println("Hello, World!"); /* one-time message */
}
String tempBuffer = "";
String payload = "";
bool foundSMS = false;
void loop() {
char currChar;
/* the code here will pass data between Cloud<-->UART */
while (SerialCloud.available()) {
currChar = (char)SerialCloud.read();
// check if the current buffer hits the SMSRCVD code.
if (!foundSMS) {
if (tempBuffer == "SMSRCVD") {
foundSMS = true;
}
}
// If it received the SMSRCVD code, the payload will get populated until
// we get a \n.
else if (currChar == '\n'){
SerialUSB.println("\nSMS received: ");
payload = stripOffLengthNumber(payload);
SerialUSB.println(payload);
// DO SOMETHING WITH SMS HERE.
SerialCloud.println("SMS receipt confirmed!"); // This is the only new line added by me.
// reset foundSMS and the payload for the next iteration.
foundSMS = false;
payload = "";
}
else {
payload.concat(currChar);
}
// Only keep a sliding buffer length of size 7
// (need to only check for SMSRCVD).
if (tempBuffer.length() >= 7) {
tempBuffer.remove(0, 1);
}
// add latest char to our buffer.
tempBuffer.concat(currChar);
SerialUSB.write(currChar);
}
delay(500);
}