MKR GSM 1400 - Losing Connection to Thinger.io

Hi @PeRSaMo,

Unfortunately, after looking for the code for a while I wasn’t able to find it. However, it is not difficult to implement using the client listener structure explained by @alvarolb on this post

something like this:

#include <ThingerMKRGSM.h>

#define USERNAME "your_user_name"
#define DEVICE_ID "your_device_id"
#define DEVICE_CREDENTIAL "your_device_credential"

#define PIN_NUMBER "your_pin"

#define GPRS_APN "your_apn_name"
#define GPRS_LOGIN "your_gprs_login"
#define GPRS_PASSWORD "your_gprs_password"

class ClientListener : public ThingerMKRGSM{
public:
    ClientListener(const char* user, const char* device, const char* device_credential) : 
      ThingerMKRGSM(user, device, device_credential){}
protected:
  virtual void thinger_state_listener(THINGER_STATE state){
    // call current implementation (debug)
    ThingerMKRGSM::thinger_state_listener(state);
    switch(state){
        case NETWORK_CONNECTING:
            break;
        case NETWORK_CONNECTED:
            break;
        case NETWORK_CONNECT_ERROR:
        //RESET THE PROCESSOR HERE
            break;
        case SOCKET_CONNECTING:
            break;
        case SOCKET_CONNECTED:
            break;
        case SOCKET_CONNECTION_ERROR:
            break;
        case SOCKET_DISCONNECTED:
            break;
        case SOCKET_TIMEOUT:
            break;
        case THINGER_AUTHENTICATING:
            break;
        case THINGER_AUTHENTICATED:
            break;
        case THINGER_AUTH_FAILED:
            break;
        case THINGER_STOP_REQUEST:
            break;
    }
  }
};

ClientListener thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL);

void setup() {
  Serial.begin(115200);

  // optional set pin number
  thing.set_pin(PIN_NUMBER);

  // set APN
  thing.set_apn(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD);

  // set builtin led to output
  pinMode(LED_BUILTIN, OUTPUT);

  // pin control example over internet (i.e. turning on/off a light, a relay, etc)
  thing["led"] << digitalPin(LED_BUILTIN);

  // resource output example (i.e. reading a sensor value, a variable, etc)
  thing["millis"] >> outputValue(millis());

  // more details at http://docs.thinger.io/arduino/
}

void loop() {
  thing.handle();
}

I’m sure that if you execute a reset command (or wire up a gpio to RST pin to make reset when digitalWrite(pin,1); ) It should reset the PCB just when the connection is closed, but maybe this will produce a lot of resets if the PCB is moving between different antennas.

Hope it helps