arduino-libraries / MKRNB

36 stars 43 forks source link

+CME ERROR: Operation not allowed - randomly #20

Open guydillen opened 5 years ago

guydillen commented 5 years ago

Hi,

Using my Arduino MKR 1500 sending UDP messages results in randomly giving an error: "+CME ERROR: Operation not allowed". I use the example program (see below). Sometimes I get this message after 24hrs successfully sending messages, sometimes after sending a few messages.

void connect() { 
  while (!connected) {
      if ((nbAccess.begin("","xxx.yyy") == NB_READY) && (gprs.attachGPRS() == GPRS_READY)) {
        connected = true;
        String carrier = nbScanner.getCurrentCarrier();
        Serial.print("Connected to ");
        Serial.print(carrier);
        Serial.println(" network");
      }
      else {
        Serial.println("Not connected");
        delay(1000);
      } 
    }
    Serial.println("\nStarting connection to server...");
    udp.begin(localPort);
  }
}

Example sketch:

#include <MKRNB.h>

unsigned int localPort = 3000;          // local port to listen for UDP packets

IPAddress awsServer(x, xxx, xxx, xx); 

const int UDP_MESSAGE_SIZE = 10;

byte packetBuffer[UDP_MESSAGE_SIZE];    //buffer to hold the outgoing messages

// Initialize the library instance
NBClient client;
GPRS gprs;
NB nbAccess(1);
NBScanner nbScanner;

// An UDP instance to let us send and receive packets over UDP
NBUDP udp;

void setup() {
  // Open serial communications and wait for port to open
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  // Connection state
  boolean connected = false;

  // After starting the modem with NB.begin()
  // attach the shield to the GPRS network with the APN, login and password
  while (!connected) {
    if ((nbAccess.begin("","xxx.yyy") == NB_READY) && (gprs.attachGPRS() == GPRS_READY)) {
      connected = true;
      String carrier = nbScanner.getCurrentCarrier();
      Serial.print("Connected to ");
      Serial.print(carrier);
      Serial.println(" network");
    }
    else {
      Serial.println("Not connected");
      delay(1000);
    } 
  }
  Serial.println("\nStarting connection to server...");
  udp.begin(localPort);

  //sendUDPMessage(awsServer);
  //delay(60000);
}

void loop() {
  sendUDPMessage(awsServer);
  delay(900000);
}

// send an UDP message to the Amazon AWS UDP server at the given address
unsigned long sendUDPMessage(IPAddress& address)
{
  // set all bytes in the buffer to 0
  memset(packetBuffer, 0, UDP_MESSAGE_SIZE);
  //packetBuffer[0]  = 0x62;
  packetBuffer[0]  = 98;
  packetBuffer[1]  = 98;
  packetBuffer[2]  = 97;
  packetBuffer[3]  = 106;
  packetBuffer[4]  = 107;
  packetBuffer[5]  = 108;

  udp.beginPacket(address, 1200); //UDP messages are to port 1200
  udp.write(packetBuffer, UDP_MESSAGE_SIZE);
  udp.endPacket();
}
Rocketct commented 5 years ago

Hi @guydillen could you share the log of the at command?

guydillen commented 5 years ago

Hi @Rocketct , in the mean time I already changed y sketch a little bit by adding a separate connect function, but obviously I still get this CME ERROR message after a while.

This is the serial output:

23:19:35.788 -> Attempting to connect to the cellular network
23:19:40.115 -> AT

23:19:40.115 -> OK
23:19:40.218 -> AT

23:19:40.218 -> OK
23:19:40.218 -> AT+CMEE=0

23:19:40.218 -> OK
23:19:40.424 -> AT+CFUN=0

23:19:40.424 -> OK
23:19:40.630 -> AT+CPIN?

23:19:40.630 -> +CPIN: READY
23:19:40.630 -> 
23:19:40.630 -> OK
23:19:40.838 -> AT+CMGF=1

23:19:40.838 -> OK
23:19:41.044 -> AT+UDCONF=1,1

23:19:41.044 -> OK
23:19:41.215 -> AT+CTZU=1

23:19:41.215 -> OK
23:19:41.422 -> AT+CGDCONT=1,"IP",""

23:19:41.422 -> OK
23:19:41.630 -> AT+UAUTHREQ=1,0

23:19:41.630 -> OK
23:19:41.836 -> AT+CFUN=1

23:19:41.836 -> OK
23:19:42.041 -> AT+CEREG?

23:19:42.041 -> +CEREG: 0,0
23:19:42.041 -> 
23:19:42.041 -> OK
23:19:42.249 -> AT+CEREG?

23:19:42.249 -> +CEREG: 0,0
23:19:42.249 -> 
23:19:42.249 -> OK
23:19:42.456 -> AT+CEREG?

23:19:42.456 -> +CEREG: 0,0
23:19:42.456 -> 
23:19:42.456 -> OK
23:19:42.662 -> AT+CEREG?

23:19:42.662 -> +CEREG: 0,0
23:19:42.662 -> 
23:19:42.662 -> OK
23:19:42.834 -> AT+CEREG?

23:19:42.869 -> +CEREG: 0,0
23:19:42.869 -> 
23:19:42.869 -> OK
23:19:43.041 -> AT+CEREG?

23:19:43.041 -> +CEREG: 0,0
23:19:43.041 -> 
23:19:43.041 -> OK
23:19:43.247 -> AT+CEREG?

23:19:43.247 -> +CEREG: 0,0
23:19:43.247 -> 
23:19:43.247 -> OK
23:19:43.452 -> AT+CEREG?

23:19:43.452 -> +CEREG: 0,0
23:19:43.452 -> 
23:19:43.452 -> OK
23:19:43.659 -> AT+CEREG?

23:19:43.659 -> +CEREG: 0,0
23:19:43.659 -> 
23:19:43.659 -> OK
23:19:43.866 -> AT+CEREG?

23:19:43.866 -> +CEREG: 0,0
23:19:43.866 -> 
23:19:43.866 -> OK
23:19:44.070 -> AT+CEREG?

23:19:44.070 -> +CEREG: 0,0
23:19:44.070 -> 
23:19:44.070 -> OK
23:19:44.274 -> AT+CEREG?

23:19:44.274 -> +CEREG: 0,0
23:19:44.274 -> 
23:19:44.274 -> OK
23:19:44.479 -> AT+CEREG?

23:19:44.479 -> +CEREG: 0,0
23:19:44.479 -> 
23:19:44.479 -> OK
23:19:44.684 -> AT+CEREG?

23:19:44.684 -> +CEREG: 0,0
23:19:44.684 -> 
23:19:44.684 -> OK
23:19:44.892 -> AT+CEREG?

23:19:44.892 -> +CEREG: 0,0
23:19:44.892 -> 
23:19:44.892 -> OK
23:19:45.065 -> AT+CEREG?

23:19:45.065 -> +CEREG: 0,0
23:19:45.065 -> 
23:19:45.065 -> OK
23:19:45.270 -> AT+CEREG?

23:19:45.270 -> +CEREG: 0,0
23:19:45.270 -> 
23:19:45.270 -> OK
23:19:45.476 -> AT+CEREG?

23:19:45.476 -> +CEREG: 0,0
23:19:45.476 -> 
23:19:45.476 -> OK
23:19:45.680 -> AT+CEREG?

23:19:45.680 -> +CEREG: 0,0
23:19:45.680 -> 
23:19:45.680 -> OK
23:19:45.888 -> AT+CEREG?

23:19:45.888 -> +CEREG: 0,0
23:19:45.888 -> 
23:19:45.888 -> OK
23:19:46.093 -> AT+CEREG?

23:19:46.093 -> +CEREG: 0,0
23:19:46.093 -> 
23:19:46.093 -> OK
23:19:46.299 -> AT+CEREG?

23:19:46.299 -> +CEREG: 0,0
23:19:46.299 -> 
23:19:46.299 -> OK
23:19:46.506 -> AT+CEREG?

23:19:46.506 -> +CEREG: 0,0
23:19:46.506 -> 
23:19:46.506 -> OK
23:19:46.710 -> AT+CEREG?

23:19:46.710 -> +CEREG: 0,0
23:19:46.710 -> 
23:19:46.710 -> OK
23:19:46.915 -> AT+CEREG?

23:19:46.915 -> +CEREG: 0,0
23:19:46.915 -> 
23:19:46.915 -> OK
23:19:47.121 -> AT+CEREG?

23:19:47.121 -> +CEREG: 0,0
23:19:47.121 -> 
23:19:47.121 -> OK
23:19:47.292 -> AT+CEREG?

23:19:47.292 -> +CEREG: 0,0
23:19:47.292 -> 
23:19:47.292 -> OK
23:19:47.496 -> AT+CEREG?

23:19:47.496 -> +CEREG: 0,0
23:19:47.496 -> 
23:19:47.496 -> OK
23:19:47.703 -> AT+CEREG?

23:19:47.703 -> +CEREG: 0,0
23:19:47.703 -> 
23:19:47.703 -> OK
23:19:47.908 -> AT+CEREG?

23:19:47.908 -> +CEREG: 0,0
23:19:47.908 -> 
23:19:47.908 -> OK
23:19:48.112 -> AT+CEREG?

23:19:48.112 -> +CEREG: 0,0
23:19:48.112 -> 
23:19:48.112 -> OK
23:19:48.316 -> AT+CEREG?

23:19:48.316 -> +CEREG: 0,0
23:19:48.316 -> 
23:19:48.316 -> OK
23:19:48.523 -> AT+CEREG?

23:19:48.523 -> +CEREG: 0,0
23:19:48.523 -> 
23:19:48.523 -> OK
23:19:48.729 -> AT+CEREG?

23:19:48.729 -> +CEREG: 0,0
23:19:48.729 -> 
23:19:48.729 -> OK
23:19:48.934 -> AT+CEREG?

23:19:48.934 -> +CEREG: 0,0
23:19:48.934 -> 
23:19:48.934 -> OK
23:19:49.140 -> AT+CEREG?

23:19:49.140 -> +CEREG: 0,0
23:19:49.140 -> 
23:19:49.140 -> OK
23:19:49.346 -> AT+CEREG?

23:19:49.346 -> +CEREG: 0,0
23:19:49.346 -> 
23:19:49.346 -> OK
23:19:49.553 -> AT+CEREG?

23:19:49.553 -> +CEREG: 0,0
23:19:49.553 -> 
23:19:49.553 -> OK
23:19:49.724 -> AT+CEREG?

23:19:49.724 -> +CEREG: 0,0
23:19:49.724 -> 
23:19:49.724 -> OK
23:19:49.928 -> AT+CEREG?

23:19:49.928 -> +CEREG: 0,0
23:19:49.928 -> 
23:19:49.928 -> OK
23:19:50.133 -> AT+CEREG?

23:19:50.133 -> +CEREG: 0,0
23:19:50.133 -> 
23:19:50.133 -> OK
23:19:50.338 -> AT+CEREG?

23:19:50.338 -> +CEREG: 0,2
23:19:50.338 -> 
23:19:50.338 -> OK
23:19:50.547 -> AT+CEREG?

23:19:50.547 -> +CEREG: 0,2
23:19:50.547 -> 
23:19:50.547 -> OK
23:19:50.752 -> AT+CEREG?

23:19:50.752 -> +CEREG: 0,2
23:19:50.752 -> 
23:19:50.752 -> OK
23:19:50.958 -> AT+CEREG?

23:19:50.958 -> +CEREG: 0,2
23:19:50.958 -> 
23:19:50.958 -> OK
23:19:51.162 -> AT+CEREG?

23:19:51.162 -> +CEREG: 0,2
23:19:51.162 -> 
23:19:51.162 -> OK
23:19:51.368 -> AT+CEREG?

23:19:51.368 -> +CEREG: 0,2
23:19:51.368 -> 
23:19:51.368 -> OK
23:19:51.574 -> AT+CEREG?

23:19:51.574 -> +CEREG: 0,1
23:19:51.574 -> 
23:19:51.574 -> OK
23:19:52.089 -> AT+CGATT=1

23:19:52.089 -> OK
23:19:53.083 -> AT+CGACT?

23:19:53.083 -> +CGACT: 1,1
23:19:53.083 -> 
23:19:53.083 -> OK
23:19:53.083 -> You're connected to the cellular network
23:19:53.083 -> 
23:19:53.083 -> 
23:19:53.083 -> Starting connection to server...
23:19:53.118 -> AT+USOCR=17

23:19:53.118 -> +USOCR: 0
23:19:53.118 -> 
23:19:53.118 -> OK
23:19:53.152 -> AT+USOLI=0,3000

23:19:53.152 -> OK
23:19:53.186 -> AT+USOST=0,"x.xxx.xxx.xx",1200,10,"6262616A6B6C00000000"

23:19:53.186 -> +USOST: 0,10
23:19:53.186 -> 
23:19:53.186 -> OK
23:34:52.940 -> AT+USOST=0,"x.xxx.xxx.xx",1200,10,"6262616A6B6C00000000"

23:34:52.973 -> +USOST: 0,10
23:34:52.973 -> 
23:34:52.973 -> OK
23:49:52.787 -> AT+USOST=0,"x.xxx.xxx.xx",1200,10,"6262616A6B6C00000000"

23:49:52.787 -> +USOST: 0,10
23:49:52.787 -> 
23:49:52.787 -> OK
00:04:52.540 -> AT+USOST=0,"x.xxx.xxx.xx",1200,10,"6262616A6B6C00000000"

00:04:52.540 -> +USOST: 0,10
00:04:52.540 -> 
00:04:52.540 -> OK
00:19:52.365 -> AT+USOST=0,"x.xxx.xxx.xx",1200,10,"6262616A6B6C00000000"

00:19:52.365 -> +USOST: 0,10
00:19:52.365 -> 
00:19:52.365 -> OK
00:34:52.098 -> AT+USOST=0,"x.xxx.xxx.xx",1200,10,"6262616A6B6C00000000"

00:34:52.098 -> +USOST: 0,10
00:34:52.098 -> 
00:34:52.098 -> OK
00:49:51.905 -> AT+USOST=0,"x.xxx.xxx.xx",1200,10,"6262616A6B6C00000000"

00:49:51.905 -> +USOST: 0,10
00:49:51.905 -> 
00:49:51.905 -> OK
01:04:51.694 -> AT+USOST=0,"x.xxx.xxx.xx",1200,10,"6262616A6B6C00000000"

01:04:51.694 -> +USOST: 0,10
01:04:51.694 -> 
01:04:51.694 -> OK
01:19:51.432 -> AT+USOST=0,"x.xxx.xxx.xx",1200,10,"6262616A6B6C00000000"

01:19:51.473 -> +USOST: 0,10
01:19:51.473 -> 
01:19:51.473 -> OK
01:34:51.145 -> AT+USOST=0,"x.xxx.xxx.xx",1200,10,"6262616A6B6C00000000"

01:34:51.145 -> +USOST: 0,10
01:34:51.145 -> 
01:34:51.145 -> OK
01:49:50.876 -> AT+USOST=0,"x.xxx.xxx.xx",1200,10,"6262616A6B6C00000000"

01:49:50.876 -> +USOST: 0,10
01:49:50.876 -> 
01:49:50.876 -> OK
02:04:50.685 -> AT+USOST=0,"x.xxx.xxx.xx",1200,10,"6262616A6B6C00000000"

02:04:50.685 -> +USOST: 0,10
02:04:50.685 -> 
02:04:50.685 -> OK
02:19:50.556 -> AT+USOST=0,"x.xxx.xxx.xx",1200,10,"6262616A6B6C00000000"

02:19:50.556 -> +USOST: 0,10
02:19:50.556 -> 
02:19:50.556 -> OK
02:34:50.295 -> AT+USOST=0,"x.xxx.xxx.xx",1200,10,"6262616A6B6C00000000"

02:34:50.295 -> +USOST: 0,10
02:34:50.295 -> 
02:34:50.295 -> OK
02:49:50.075 -> AT+USOST=0,"x.xxx.xxx.xx",1200,10,"6262616A6B6C00000000"

02:49:50.075 -> +USOST: 0,10
02:49:50.075 -> 
02:49:50.075 -> OK
03:04:49.946 -> AT+USOST=0,"x.xxx.xxx.xx",1200,10,"6262616A6B6C00000000"

03:04:49.946 -> +USOST: 0,10
03:04:49.946 -> 
03:04:49.946 -> OK
03:19:49.875 -> AT+USOST=0,"x.xxx.xxx.xx",1200,10,"6262616A6B6C00000000"

03:19:49.875 -> +USOST: 0,10
03:19:49.875 -> 
03:19:49.875 -> OK
03:34:49.656 -> AT+USOST=0,"x.xxx.xxx.xx",1200,10,"6262616A6B6C00000000"

03:34:49.656 -> +USOST: 0,10
03:34:49.656 -> 
03:34:49.656 -> OK
03:49:49.443 -> AT+USOST=0,x.xxx.xxx.xx",1200,10,"6262616A6B6C00000000"

03:49:49.443 -> +USOST: 0,10
03:49:49.443 -> 
03:49:49.443 -> OK
04:04:49.220 -> AT+USOST=0,"x.xxx.xxx.xx",1200,10,"6262616A6B6C00000000"

04:04:49.220 -> +USOST: 0,10
04:04:49.220 -> 
04:04:49.220 -> OK
04:19:48.989 -> AT+USOST=0,"x.xxx.xxx.xx",1200,10,"6262616A6B6C00000000"

04:19:48.989 -> +USOST: 0,10
04:19:48.989 -> 
04:19:48.989 -> OK
04:34:48.764 -> AT+USOST=0,"x.xxx.xxx.xx",1200,10,"6262616A6B6C00000000"

04:34:48.764 -> +USOST: 0,10
04:34:48.764 -> 
04:34:48.764 -> OK
04:49:48.712 -> AT+USOST=0,"x.xxx.xxx.xx",1200,10,"6262616A6B6C00000000"

04:49:48.712 -> +USOST: 0,10
04:49:48.712 -> 
04:49:48.712 -> OK
05:04:48.700 -> AT+USOST=0,x.xxx.xxx.xx",1200,10,"6262616A6B6C00000000"

05:04:48.700 -> +USOST: 0,10
05:04:48.700 -> 
05:04:48.700 -> OK
05:19:48.650 -> AT+USOST=0,"x.xxx.xxx.xx",1200,10,"6262616A6B6C00000000"

05:19:48.650 -> +USOST: 0,10
05:19:48.650 -> 
05:19:48.650 -> OK
05:34:48.427 -> AT+USOST=0,"x.xxx.xxx.xx",1200,10,"6262616A6B6C00000000"

05:34:48.487 -> +USOST: 0,10
05:34:48.487 -> 
05:34:48.487 -> OK
05:49:48.267 -> AT+USOST=0,"x.xxx.xxx.xx",1200,10,"6262616A6B6C00000000"

05:49:48.267 -> +USOST: 0,10
05:49:48.267 -> 
05:49:48.267 -> OK
06:04:48.058 -> AT+USOST=0,x.xxx.xxx.xx",1200,10,"6262616A6B6C00000000"

06:04:48.092 -> +USOST: 0,10
06:04:48.092 -> 
06:04:48.092 -> OK
06:19:48.029 -> AT+USOST=0,"x.xxx.xxx.xx",1200,10,"6262616A6B6C00000000"

06:19:48.029 -> +USOST: 0,10
06:19:48.029 -> 
06:19:48.029 -> OK
06:34:48.267 -> AT+USOST=0,"x.xxx.xxx.xx",1200,10,"6262616A6B6C00000000"

06:49:48.560 -> 
06:49:48.560 -> OK
07:04:48.811 -> AT+USOST=0,"x.xxx.xxx.xx",1200,10,"6262616A6B6C00000000"

07:04:48.811 -> +USOST: 0,10
07:04:48.811 -> 
07:04:48.811 -> OK
07:19:48.953 -> AT+USOST=0,"x.xxx.xxx.xx",1200,10,"6262616A6B6C00000000"

07:19:49.326 -> +USOST: 0,10
07:19:49.326 -> 
07:19:49.326 -> OK
07:34:48.961 -> AT+USOST=0,"x.xxx.xxx.xx",1200,10,"6262616A6B6C00000000"

07:34:48.961 -> +USOST: 0,10
07:34:48.995 -> 
07:34:48.995 -> OK
07:49:48.988 -> AT+USOST=0,x.xxx.xxx.xx",1200,10,"6262616A6B6C00000000"

07:49:48.988 -> +USOST: 0,10
07:49:48.988 -> 
07:49:48.988 -> OK
08:04:49.025 -> AT+USOST=0,"x.xxx.xxx.xx",1200,10,"6262616A6B6C00000000"

08:04:49.025 -> +USOST: 0,10
08:04:49.025 -> 
08:04:49.025 -> OK
08:19:49.025 -> AT+USOST=0,"x.xxx.xxx.xx",1200,10,"6262616A6B6C00000000"

08:19:49.078 -> +USOST: 0,10
08:19:49.078 -> 
08:19:49.078 -> OK
08:34:48.962 -> AT+USOST=0,"x.xxx.xxx.xx",1200,10,"6262616A6B6C00000000"

08:34:48.996 -> +USOST: 0,10
08:34:48.996 -> 
08:34:48.996 -> OK
08:49:48.947 -> AT+USOST=0,"x.xxx.xxx.xx",1200,10,"6262616A6B6C00000000"

08:49:48.947 -> +USOST: 0,10
08:49:48.947 -> 
08:49:48.947 -> OK
09:04:48.942 -> AT+USOST=0,"x.xxx.xxx.xx",1200,10,"6262616A6B6C00000000"

09:04:48.942 -> +USOST: 0,10
09:04:48.942 -> 
09:04:48.942 -> OK
09:19:48.873 -> AT+USOST=0,"x.xxx.xxx.xx",1200,10,"6262616A6B6C00000000"

09:19:48.873 -> +USOST: 0,10
09:19:48.873 -> 
09:19:48.873 -> OK
09:34:48.687 -> AT+USOST=0,"x.xxx.xxx.xx",1200,10,"6262616A6B6C00000000"

09:34:48.687 -> +USOST: 0,10
09:34:48.687 -> 
09:34:48.687 -> OK
09:49:48.618 -> AT+USOST=0,"x.xxx.xxx.xx",1200,10,"6262616A6B6C00000000"

09:49:48.618 -> +USOST: 0,10
09:49:48.618 -> 
09:49:48.618 -> OK
10:04:48.540 -> AT+USOST=0,"x.xxx.xxx.xx",1200,10,"6262616A6B6C00000000"

10:04:48.540 -> +USOST: 0,10
10:04:48.540 -> 
10:04:48.540 -> OK
10:19:48.451 -> AT+USOST=0,"x.xxx.xxx.xx",1200,10,"6262616A6B6C00000000"

10:19:48.613 -> +USOST: 0,10
10:19:48.613 -> 
10:19:48.613 -> OK
10:34:48.444 -> AT+USOST=0,"x.xxx.xxx.xx",1200,10,"6262616A6B6C00000000"

10:34:48.444 -> +USOST: 0,10
10:34:48.444 -> 
10:34:48.444 -> OK
10:49:48.347 -> AT+USOST=0,"x.xxx.xxx.xx",1200,10,"6262616A6B6C00000000"

10:49:48.347 -> +USOST: 0,10
10:49:48.347 -> 
10:49:48.347 -> OK
11:04:48.250 -> AT+USOST=0,"x.xxx.xxx.xx",1200,10,"6262616A6B6C00000000"

11:04:48.250 -> +USOST: 0,10
11:04:48.250 -> 
11:04:48.250 -> OK
11:19:48.145 -> AT+USOST=0,"x.xxx.xxx.xx",1200,10,"6262616A6B6C00000000"

11:19:48.145 -> +USOST: 0,10
11:19:48.145 -> 
11:19:48.145 -> OK
11:34:47.879 -> AT+USOST=0,x.xxx.xxx.xx",1200,10,"6262616A6B6C00000000"

11:34:48.168 -> +USOST: 0,10
11:34:48.168 -> 
11:34:48.168 -> OK
11:49:47.587 -> AT+USOST=0,"x.xxx.xxx.xx",1200,10,"6262616A6B6C00000000"

11:49:47.587 -> +USOST: 0,10
11:49:47.587 -> 
11:49:47.587 -> OK
12:04:47.347 -> AT+USOST=0,"x.xxx.xxx.xx",1200,10,"6262616A6B6C00000000"

12:04:47.347 -> +USOST: 0,10
12:04:47.347 -> 
12:04:47.347 -> OK
12:19:47.096 -> AT+USOST=0,"x.xxx.xxx.xx",1200,10,"6262616A6B6C00000000"

12:19:47.096 -> +USOST: 0,10
12:19:47.096 -> 
12:19:47.096 -> OK
12:34:46.860 -> AT+USOST=0,"x.xxx.xxx.xx",1200,10,"6262616A6B6C00000000"

12:34:46.860 -> +USOST: 0,10
12:34:46.860 -> 
12:34:46.860 -> OK
12:49:46.662 -> AT+USOST=0,"x.xxx.xxx.xx",1200,10,"6262616A6B6C00000000"

12:49:46.662 -> +USOST: 0,10
12:49:46.662 -> 
12:49:46.662 -> OK
13:04:46.464 -> AT+USOST=0,"x.xxx.xxx.xx",1200,10,"6262616A6B6C00000000"

13:04:46.464 -> +USOST: 0,10
13:04:46.464 -> 
13:04:46.464 -> OK
13:19:46.212 -> AT+USOST=0,"x.xxx.xxx.xx",1200,10,"6262616A6B6C00000000"

13:19:46.212 -> +USOST: 0,10
13:19:46.212 -> 
13:19:46.212 -> OK
13:34:45.942 -> AT+USOST=0,"x.xxx.xxx.xx",1200,10,"6262616A6B6C00000000"

13:34:45.942 -> +USOST: 0,10
13:34:45.942 -> 
13:34:45.942 -> OK
13:49:45.718 -> AT+USOST=0,x.xxx.xxx.xx",1200,10,"6262616A6B6C00000000"

13:49:45.718 -> +USOST: 0,10
13:49:45.718 -> 
13:49:45.718 -> OK
14:04:45.384 -> AT+USOST=0,"x.xxx.xxx.xx",1200,10,"6262616A6B6C00000000"

14:04:45.384 -> +USOST: 0,10
14:04:45.384 -> 
14:04:45.384 -> OK
14:19:45.008 -> AT+USOST=0,"x.xxx.xxx.xx",1200,10,"6262616A6B6C00000000"

14:19:45.056 -> +USOST: 0,10
14:19:45.056 -> 
14:19:45.056 -> OK
14:34:44.720 -> AT+USOST=0,"x.xxx.xxx.xx",1200,10,"6262616A6B6C00000000"

14:34:44.720 -> +USOST: 0,10
14:34:44.720 -> 
14:34:44.720 -> OK
14:49:44.534 -> AT+USOST=0,"x.xxx.xxx.xx",1200,10,"6262616A6B6C00000000"

14:49:44.534 -> +USOST: 0,10
14:49:44.534 -> 
14:49:44.534 -> OK
15:04:44.475 -> AT+USOST=0,"x.xxx.xxx.xx",1200,10,"6262616A6B6C00000000"

15:04:44.475 -> +USOST: 0,10
15:04:44.475 -> 
15:04:44.475 -> OK
15:19:44.341 -> AT+USOST=0,"x.xxx.xxx.xx",1200,10,"6262616A6B6C00000000"

15:19:44.341 -> +CME ERROR: Operation not allowed
15:34:44.189 -> 
15:34:44.223 -> AT+USOST=0,"x.xxx.xxx.xx",1200,10,"6262616A6B6C00000000"

15:34:44.223 -> +CME ERROR: Operation not allowed
15:49:43.985 -> 
15:49:44.020 -> AT+USOST=0,"x.xxx.xxx.xx",1200,10,"6262616A6B6C00000000"

15:49:44.020 -> +CME ERROR: Operation not allowed
16:04:43.769 -> 
16:04:43.769 -> AT+USOST=0,"x.xxx.xxx.xx",1200,10,"6262616A6B6C00000000"

16:04:43.769 -> +CME ERROR: Operation not allowed
16:19:43.460 -> 
16:19:43.460 -> AT+USOST=0,"3.121.180.66",1200,10,"6262616A6B6C00000000"

16:19:43.460 -> +CME ERROR: Operation not allowed
16:34:43.201 -> 
16:34:43.201 -> AT+USOST=0,"x.xxx.xxx.xx",1200,10,"6262616A6B6C00000000"

16:34:43.270 -> +CME ERROR: Operation not allowed
16:49:42.935 -> 
16:49:42.969 -> AT+USOST=0,"x.xxx.xxx.xx",1200,10,"6262616A6B6C00000000"

16:49:42.969 -> +CME ERROR: Operation not allowed
17:04:42.702 -> 
17:04:42.702 -> AT+USOST=0,"x.xxx.xxx.xx",1200,10,"6262616A6B6C00000000"

17:04:42.702 -> +CME ERROR: Operation not allowed
17:19:42.333 -> 
17:19:42.333 -> AT+USOST=0,"x.xxx.xxx.xx",1200,10,"6262616A6B6C00000000"

17:19:42.333 -> +CME ERROR: Operation not allowed

The parts I changed:

void setup() {
  // Open serial communications and wait for port to open
  Serial.begin(115200);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }
}

void loop() {
  if (nbAccess.status() != NB_READY || gprs.status() != GPRS_READY) {
    connectNB();
  }
  sendUDPMessage(awsServer);
  delay(900000);
}

void connectNB() {
  Serial.println("Attempting to connect to the cellular network");

  while ((nbAccess.begin() != NB_READY) ||
         (gprs.attachGPRS() != GPRS_READY)) {
    // failed, retry
    Serial.print(".");
    delay(1000);
 }

  Serial.println("You're connected to the cellular network");
  Serial.println();

  Serial.println("\nStarting connection to server...");
  // Initialize, start listening on specified port
  udp.begin(localPort);
}
lekron42 commented 4 years ago

I have the same problem.. It just randomly fails to create a socket.

I noticed following behaviour: Uploading sketch --> Everything works Unplugging it and connecting it again --> CME Error: Operation not allowed

Since my device should run without a serial monitor connected, i use a watchdog to restart the system whenever this error occurs but this can result in more than 5 loops until it is able to create the sockets..

CptHolzschnauz commented 3 years ago

I had similar flaky problems. The cause was too many AT commands in too little time. The modem needs time to digest the commands.

furqon2710 commented 11 months ago

so is there any way to catch this failure by the library and do restart by it self when having this problem?