My MKRGSM1400 hangs after a random amount of time (sometime after a couple of se…conds, sometimes after an hour).
The Code (based on the `GsmWebClient` example, but then 'get' is put in a loop). The` Serial Monitor` provides a trace (see below)
If I want to upload new code to the MKR1400, I need to reset it first using the little reset button to 'unhang' it.
I'm using a MacBook Pro (15-inch, 2017) with High Sierra (10.13.4 (17E199)), Thunderbolt 3 to USB dongle. The MKR1400 has a charged 850mAh battery attached to it (I also tried a 2000mAh battery, same result).
Used both Arduino IDE 1.8.5. and 1.9.0 Beta - same result, hangs at random places during the run.
```
#include <MKRGSM.h>
#include "arduino_secrets.h"
// Please enter your sensitive data in the Secret tab or arduino_secrets.h
// PIN Number
const char PINNUMBER[] = SECRET_PINNUMBER;
// APN data
const char GPRS_APN[] = SECRET_GPRS_APN;
const char GPRS_LOGIN[] = SECRET_GPRS_LOGIN;
const char GPRS_PASSWORD[] = SECRET_GPRS_PASSWORD;
// initialize the library instance
GSMClient client;
GPRS gprs;
GSM gsmAccess(true);
// URL, path and port (for example: arduino.cc)
char server[] = "arduino.cc";
char path[] = "/asciilogo.txt";
int port = 80; // port 80 is the default for HTTP
void setup() {
// initialize serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {}
Serial.println("Starting Arduino web client.");
// connection state
boolean connected = false;
// After starting the modem with GSM.begin()
// attach the shield to the GPRS network with the APN, login and password
while (!connected) {
if ((gsmAccess.begin(PINNUMBER) == GSM_READY) &&
(gprs.attachGPRS(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD) == GPRS_READY)) {
connected = true;
} else {
Serial.println("Not connected");
delay(1000);
}
}
}
void loop() {
Serial.println("connecting...");
// if you get a connection, report back via serial:
if (client.connect(server, port))
{
Serial.println("connected");
// Make a HTTP request:
client.print("GET ");
client.print(path);
client.println(" HTTP/1.1");
client.print("Host: ");
client.println(server);
client.println("Connection: close");
client.println();
Serial.println("awaiting response");
while (true) {
// if there are incoming bytes available
// from the server, read them and print them:
if (client.available())
char c = client.read();
// if the server's disconnected, stop the client:
if (!client.available() && !client.connected()) {
Serial.println();
Serial.println("disconnecting.");
client.stop();
break;
}
}
}
else
{
// if you didn't get a connection to the server:
Serial.println("connection failed");
}
delay(5000);
}
```
The content of the serial monitor:
```
21:49:19.604 -> Starting Arduino web client.
21:49:23.393 -> ⸮AT
21:49:23.605 -> OK
21:49:23.605 -> AT+IPR=921600
21:49:23.605 -> OK
21:49:23.712 -> AT
21:49:23.712 -> OK
21:49:23.712 -> AT+UPSV=3
21:49:23.712 -> OK
21:49:23.817 -> AT+CPIN?
```
...
```
21:51:57.115 -> +UUSORD: 0,2
21:51:57.115 -> AT+USORD=0,1
21:51:57.115 -> +USORD: 0,1,"20"
21:51:57.115 ->
21:51:57.115 -> OK
21:51:57.115 ->
21:51:57.115 -> +UUSORD: 0,1
21:51:57.115 -> AT+USORD=0,1
21:51:57.115 -> +USORD: 0,1,"0A"
21:51:57.115 ->
21:51:57.115 -> OK
21:51:57.369 ->
21:51:57.369 -> +UUSOCL: 0
21:51:57.369 ->
21:51:57.369 -> disconnecting.
21:52:02.352 -> connecting...
21:52:02.463 -> AT+USOCR=6
21:52:02.463 -> +USOCR: 0
21:52:02.463 ->
21:52:02.463 -> OK
21:52:02.675 -> AT+USOCO=0,"arduino.cc",80
21:52:02.961 -> OK
21:52:02.961 -> connected
21:52:02.961 -> AT+USOWR=0,4,"47455420"
21:52:02.961 -> +USOWR: 0,4
21:52:02.961 ->
21:52:02.961 -> OK
21:52:02.961 -> AT+USOWR=0,14,"2F61736369696C6F676F2E747874"
21:52:02.961 -> +USOWR: 0,14
21:52:02.961 ->
21:52:02.961 -> OK
21:52:02.961 -> AT+USOWR=0,9,"20485454502F312E31"
21:52:02.997 -> +USOWR: 0,9
21:52:02.997 ->
21:52:02.997 -> OK
21:52:02.997 -> AT+USOWR=0,2,"0D0A"
21:52:02.997 -> +USOWR: 0,2
21:52:02.997 ->
21:52:02.997 -> OK
21:53:05.524 ->
21:53:05.524 -> +UUSOCL: 0
```
A regular successful sequence would be:
```
connecting...
AT+USOCR=6
+USOCR: 0
OK
AT+USOCO=0,"arduino.cc",80
OK
connected
AT+USOWR=0,4,"47455420"
+USOWR: 0,4
OK
AT+USOWR=0,14,"2F61736369696C6F676F2E747874"
+USOWR: 0,14
OK
AT+USOWR=0,9,"20485454502F312E31"
+USOWR: 0,9
OK
AT+USOWR=0,2,"0D0A"
+USOWR: 0,2
OK
```
**processing broke here and should normally continue with the messages below.
Yet, +UUSOCL: 0 is the last message before the MKR1400 hangs**
```
AT+USOWR=0,6,"486F73743A20"
+USOWR: 0,6
OK
AT+USOWR=0,10,"61726475696E6F2E6363"
+USOWR: 0,10
OK
AT+USOWR=0,2,"0D0A"
+USOWR: 0,2
OK
AT+USOWR=0,17,"436F6E6E656374696F6E3A20636C6F7365"
+USOWR: 0,17
OK
AT+USOWR=0,2,"0D0A"
+USOWR: 0,2
OK
AT+USOWR=0,2,"0D0A"
+UOWR: 0,2
OK
awaiting response
```