{"action":"created","issue":{"url":"https://api.github.com/repos/arduino-libraries/MKRGSM/issues/66","repository_url":"https://api.github.com/repos/arduino-libraries/MKRGSM","labels_url":"https://api.github.com/repos/arduino-libraries/MKRGSM/issues/66/labels{/name}","comments_url":"https://api.github.com/repos/arduino-libraries/MKRGSM/issues/66/comments","events_url":"https://api.github.com/repos/arduino-libraries/MKRGSM/issues/66/events","html_url":"https://github.com/arduino-libraries/MKRGSM/issues/66","id":382834340,"node_id":"MDU6SXNzdWUzODI4MzQzNDA=","number":66,"title":"MKRGSM library not reliable","user":{"login":"alanoatwork","id":28883836,"node_id":"MDQ6VXNlcjI4ODgzODM2","avatar_url":"https://avatars0.githubusercontent.com/u/28883836?v=4","gravatar_id":"","url":"https://api.github.com/users/alanoatwork","html_url":"https://github.com/alanoatwork","followers_url":"https://api.github.com/users/alanoatwork/followers","following_url":"https://api.github.com/users/alanoatwork/following{/other_user}","gists_url":"https://api.github.com/users/alanoatwork/gists{/gist_id}","starred_url":"https://api.github.com/users/alanoatwork/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alanoatwork/subscriptions","organizations_url":"https://api.github.com/users/alanoatwork/orgs","repos_url":"https://api.github.com/users/alanoatwork/repos","events_url":"https://api.github.com/users/alanoatwork/events{/privacy}","received_events_url":"https://api.github.com/users/alanoatwork/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"Rocketct","id":37290960,"node_id":"MDQ6VXNlcjM3MjkwOTYw","avatar_url":"https://avatars3.githubusercontent.com/u/37290960?v=4","gravatar_id":"","url":"https://api.github.com/users/Rocketct","html_url":"https://github.com/Rocketct","followers_url":"https://api.github.com/users/Rocketct/followers","following_url":"https://api.github.com/users/Rocketct/following{/other_user}","gists_url":"https://api.github.com/users/Rocketct/gists{/gist_id}","starred_url":"https://api.github.com/users/Rocketct/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Rocketct/subscriptions","organizations_url":"https://api.github.com/users/Rocketct/orgs","repos_url":"https://api.github.com/users/Rocketct/repos","events_url":"https://api.github.com/users/Rocketct/events{/privacy}","received_events_url":"https://api.github.com/users/Rocketct/received_events","type":"User","site_admin":false},"assignees":[{"login":"Rocketct","id":37290960,"node_id":"MDQ6VXNlcjM3MjkwOTYw","avatar_url":"https://avatars3.githubusercontent.com/u/37290960?v=4","gravatar_id":"","url":"https://api.github.com/users/Rocketct","html_url":"https://github.com/Rocketct","followers_url":"https://api.github.com/users/Rocketct/followers","following_url":"https://api.github.com/users/Rocketct/following{/other_user}","gists_url":"https://api.github.com/users/Rocketct/gists{/gist_id}","starred_url":"https://api.github.com/users/Rocketct/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Rocketct/subscriptions","organizations_url":"https://api.github.com/users/Rocketct/orgs","repos_url":"https://api.github.com/users/Rocketct/repos","events_url":"https://api.github.com/users/Rocketct/events{/privacy}","received_events_url":"https://api.github.com/users/Rocketct/received_events","type":"User","site_admin":false}],"milestone":null,"comments":0,"created_at":"2018-11-20T20:24:41Z","updated_at":"2018-11-26T09:13:23Z","closed_at":null,"author_association":"NONE","body":"I've posted this before, but I'll try again. My code is pretty simple. I check for SMS messages and then reply back using Hologram's network. I'm using the latest MKRGSM library 1.3.1.  I also have a 1400 mAhr lithium battery connected so I'm confident that I don't have a hardware issue related to modem current.\r\n\r\nHere's my code:\r\n```\r\n#include <MKRGSM.h>\r\nconst char PINNUMBER[] = \" \";\r\nconst char GPRS_APN[] = \"hologram\";\r\nconst char GPRS_LOGIN[] = \" \";\r\nconst char GPRS_PASSWORD[] = \" \";\r\n\r\nString HOLOGRAM_DEVICE_KEY = \"********\";\r\nString HOLOGRAM_TOPIC = \"_SOCKETAPI_\";\r\n\r\nGSMClient client;\r\nGPRS gprs;\r\nGSM gsm(1);                                             // Enable debug\r\nGSM_SMS sms;\r\nGSMScanner scan;\r\n\r\nchar server[] = \"cloudsocket.hologram.io\";\r\nint port = 9999;\r\nboolean isSMSAvailable = false;\r\nchar sms_message[145];\r\n\r\nvoid setup() {\r\n  Serial.begin(115200);\r\n  //while(!Serial);\r\n\r\n  scan.begin();\r\n  connectGSM();\r\n}\r\n\r\nvoid connectGSM() {\r\n  boolean connected = false;\r\n\r\n  while (!connected) {\r\n    Serial.println(\"Begin GSM Access\");\r\n      \r\n    if ((gsm.begin() == GSM_READY) &&\r\n        (gprs.attachGPRS(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD) == GPRS_READY)) {\r\n      connected = true;\r\n      Serial.println(\"GSM Access Success\");\r\n      Serial.println(scan.getCurrentCarrier());\r\n    } \r\n    else {\r\n      Serial.println(\"Not connected\");\r\n      delay(1000);\r\n    }\r\n  }\r\n}\r\n\r\nvoid loop() {\r\n  if(Serial.available()) {\r\n    char c = Serial.read();\r\n    if(c == 'e')\r\n       MODEM.debug();\r\n    if(c == 'd')\r\n         MODEM.noDebug();\r\n  }\r\n  \r\n  // Get any new incoming txt messages\r\n  int c;\r\n  if (sms.available()) {\r\n    int i = 0;\r\n    while ((c = sms.read()) != -1) {\r\n      sms_message[i++] = (char)c;\r\n    }\r\n    sms_message[i] = '\\0';        // Terminate message\r\n    isSMSAvailable = true;\r\n    sms.flush();\r\n  }\r\n\r\n  if(gsm.isAccessAlive()) {\r\n    if(gprs.status() != GPRS_READY) {\r\n      if(gprs.attachGPRS(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD) == GPRS_READY)\r\n        Serial.println(\"GPRS ready!\");\r\n      else\r\n        Serial.println(\"GRPS not ready!\");\r\n    }\r\n  }\r\n  else {\r\n    Serial.println(\"Reconnect to GSM...\");\r\n    connectGSM();\r\n  }\r\n\r\n  // Send message back through hologram\r\n  if(isSMSAvailable) {\r\n    isSMSAvailable = false;\r\n\r\n    if (client.connect(server, port)) {\r\n      client.print(\"{\\\"k\\\":\\\"\" + HOLOGRAM_DEVICE_KEY + \"\\\",\\\"d\\\":\\\"\");\r\n      client.print(sms_message);\r\n      client.println(\"\\\",\\\"t\\\":\\\"\"+HOLOGRAM_TOPIC+\"\\\"}\");\r\n      client.stop();\r\n    }\r\n    else {\r\n      MODEM.send(\"AT+USOER\");\r\n    }\r\n  }\r\n\r\n  delay(1000);\r\n}`\r\n```\r\n\r\nIt takes anywhere from a few days to a week or more to exhibit the problem.  My logs typically look like this, where the incoming SMS message, \"Jdjd\", gets received and then repeated back to me via Hologram's network.\r\n\r\n```\r\nOK\r\nAT+CMGL=\"REC UNREAD\"\r\n\r\n+CMGL: 19,\"REC UNREAD\",\"+19495472010\",,\"18/11/14,03:53:24+00\"\r\nJdjd\r\n\r\nOK\r\nAT+CMGD=19\r\n\r\nOK\r\nAT+CREG?\r\n\r\n+CREG: 0,5\r\n\r\nOK\r\nAT+USOCR=6\r\n\r\n+USOCR: 0\r\n\r\nOK\r\nAT+USOCO=0,\"cloudsocket.hologram.io\",9999\r\n\r\nOK\r\nAT+USOWR=0,21,\"7B226B223A22433E383375242B57222C2264223A22\"\r\n\r\n+USOWR: 0,21\r\n\r\nOK\r\nAT+USOWR=0,4,\"4A646A64\"\r\n\r\n+USOWR: 0,4\r\n\r\nOK\r\nAT+USOWR=0,20,\"222C2274223A225F534F434B45544150495F227D\"\r\n\r\n+USOWR: 0,20\r\n\r\nOK\r\nAT+USOWR=0,2,\"0D0A\"\r\n\r\n+USOWR: 0,2\r\n\r\nOK\r\nAT+USOCL=0\r\n\r\nOK\r\nAT+CMGL=\"REC UNREAD\"\r\n\r\nOK\r\nAT+CREG?\r\n\r\n+CREG: 0,5`\r\n```\r\nHowever, after a week or so this happens:\r\n```\r\n`OK\r\nAT+CMGL=\"REC UNREAD\"\r\n\r\n+CMGL: 19,\"REC UNREAD\",\"+19495472010\",,\"18/11/20,19:51:00+00\"\r\nJDJDJ\r\n\r\nOK\r\nAT+CMGD=19\r\n\r\nOK\r\nAT+CREG?\r\n\r\n+CREG: 0,5\r\n\r\nOK\r\nAT+USOCR=6\r\n\r\n+USOCR: 0\r\n\r\nOK\r\nAT+USOCO=0,\"cloudsocket.hologram.io\",9999\r\n\r\nERROR\r\n\r\n+UUSOCL: 0\r\nAT+USOCL=0\r\n\r\nERROR\r\nAT+CMGL=\"REC UNREAD\"\r\n\r\nOK\r\nAT+CREG?\r\n\r\n+CREG: 0,5\r\n\r\nOK\r\nAT+CMGL=\"REC UNREAD\"\r\n\r\nOK\r\nAT+CREG?\r\n\r\n+CREG: 0,5\r\n\r\n````\r\n\r\nFrom then on, the library is never able to recover.\r\n\r\nAny help would be greatly appreciated. The code I submitted is a stripped down version of my application. I've been wanting to release my application using the MKRGSM board but I've been haunted by this issue.  I see there's some asynchronous options that aren't well documented and I'm reluctant to use this approach - besides, shouldn't this library be rock solid as documented!"},"comment":{"url":"https://api.github.com/repos/arduino-libraries/MKRGSM/issues/comments/441568096","html_url":"https://github.com/arduino-libraries/MKRGSM/issues/66#issuecomment-441568096","issue_url":"https://api.github.com/repos/arduino-libraries/MKRGSM/issues/66","id":441568096,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0MTU2ODA5Ng==","user":{"login":"Rocketct","id":37290960,"node_id":"MDQ6VXNlcjM3MjkwOTYw","avatar_url":"https://avatars3.githubusercontent.com/u/37290960?v=4","gravatar_id":"","url":"https://api.github.com/users/Rocketct","html_url":"https://github.com/Rocketct","followers_url":"https://api.github.com/users/Rocketct/followers","following_url":"https://api.github.com/users/Rocketct/following{/other_user}","gists_url":"https://api.github.com/users/Rocketct/gists{/gist_id}","starred_url":"https://api.github.com/users/Rocketct/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Rocketct/subscriptions","organizations_url":"https://api.github.com/users/Rocketct/orgs","repos_url":"https://api.github.com/users/Rocketct/repos","events_url":"https://api.github.com/users/Rocketct/events{/privacy}","received_events_url":"https://api.github.com/users/Rocketct/received_events","type":"User","site_admin":false},"created_at":"2018-11-26T09:13:23Z","updated_at":"2018-11-26T09:13:23Z","author_association":"CONTRIBUTOR","body":"Hi @alanoatwork, i'm work on this issue,  could you test the same sketch by imposing a timeout adding in the  ```connectGSM()``` ```gprs.setTimeout(180000); ``` and  ```gsm.setTimeout(180000)``` this should allow to come back to .loop function after 3 minutes and retry from samd waiting. "}}
{"actor":{"display_login":"Rocketct"}}