Electron AT Commands - Tests & Issues (Cell Location / GSM Tracking)

Dear All,

I am currently trying out various AT commands using below outlined script.

Everything works as expected besides two AT Commands I would be really eager to make work, as they are getting detailed information about the cellular environment (Serving Cell and Neighbor Cells):

AT+CGED=5 (Cell Environment Description - one shot serving cell and neighbour cells dump)
AT+COPS=5 (Operator Selection - Extended Network Scan)

Whenever I fire any of those two commands the electron does not respond anymore.
As I could imagine that those commands do scans, I would be also interested in intermediate results … but how can I get access to those results and how can I limit the scan time?

I am digging now since days in the AT Command Manual but cannot find a solution.

Any hint is highly appreciated!

br,
Rainer


// ‘AT+ …’’ to fire AT Command
// ‘A’ to cancel AT Command - fire a single ‘A’ charcter into the AT Channel - though doesn’t work, question is why …
// ‘1’ to turn modem on
// ‘0’ to turn modem off
// ‘c’ to connect to the gsm network
// ‘d’ to disconnect from gsm notwork
// ‘C’ to connect to paricle cloud
// ‘D’ to disconnect from particle cloud

SYSTEM_MODE(MANUAL);
int callbackAT(int type, const char* buf, int len, char* param){
    Serial.println("---------");
    Serial.println("LOOPSTART");
    Serial.println("---------");
    String sbuf = buf;
    sbuf[len]='\0';
    Serial.println("Length: " + (String) len);
    Serial.println("Buffer = " + sbuf);
    switch(type) {
      case TYPE_UNKNOWN :
          Serial.println("TYPE_UNKNOWN");
          break; /* optional */
      case TYPE_OK :
          Serial.println("TYPE_OK");
          break; /* optional */
      case TYPE_ERROR :
          Serial.println("TYPE_ERROR");
          break; /* optional */
      case TYPE_RING :
          Serial.println("TYPE_RING");
          break; /* optional */
      case TYPE_CONNECT :
          Serial.println("TYPE_CONNECT");
          break; /* optional */
      case TYPE_NOCARRIER :
          Serial.println("TYPE_NOCARRIER");
          break; /* optional */
      case TYPE_NODIALTONE :
          Serial.println("TYPE_NODIALTONE");
          break; /* optional */
      case TYPE_NOANSWER :
          Serial.println("TYPE_NOANSWER");
          break; /* optional */
      case TYPE_PROMPT :
          Serial.println("TYPE_PROMPT");
          break; /* optional */
      case TYPE_PLUS :
          Serial.println("TYPE_PLUS");
          break; /* optional */
      case TYPE_TEXT :
          Serial.println("TYPE_TEXT");
          break; /* optional */
      case TYPE_ABORTED :
          Serial.println("TYPE_ABORTED");
          break; /* optional */
      /* you can have any number of case statements */
      default : /* Optional */
       Serial.println("Shouldn't happen");
    }
    Serial.println("-------");
    Serial.println("LOOPEND");
    Serial.println("-------");
    return WAIT;
}


void setup()
{
  Serial.begin(9600);
}

void loop()
{
  int i = 0;
  char commandbuffer[100]="";
  String command="";
  char response[3000]="";
  //comnandbuffer="";
  // THERE IS SOMETHING ON SERIAL
  if (Serial.available())
  {
    while( Serial.available() && i< 99) {
      commandbuffer[i++] = Serial.read();
    }
    //  LINEFEED RETRIEVED, START EXECUTION PROCESS
    if (commandbuffer[i-1] == '\n') {
      commandbuffer[i-1]='\r';
      commandbuffer[i]= '\n';
      command = (String) commandbuffer;
      Serial.println("String retrieved: " + command);
    // EXECUTE COMMAND
      switch(command[0]) {
        case 'A' :
          // EXECUTE AT - COMMAND
          Serial.println("------ EXECUTING AT COMMAND START-------");
          if (RESP_OK == Cellular.command(callbackAT, response, 20000, command))
          {
            Serial.println("------ EXECUTING AT COMMAND END  -------");
      //      Serial.println("MY_APP_RESPONSE:");
      //      Serial.println(response);
          }
          else
          {
            Serial.println("NOT RESP_OK Detected");
    //        Serial.println("MY_APP_RESPONSE:");
    //        Serial.println(response);
          }

          break;
        case '1' :
          // TURN MODEM ON
          Serial.println("Turn Modem On");
          Cellular.on();
          break;
        case '0' :
          // TURN MODEM OFF
          Serial.println("Turn Modem Off");
          Cellular.off();
          break;
        case 'c' :
          // CONNECT TO CELLULAR NETWORK
          Serial.println("Connecting to Cellular Network");
          Cellular.connect(); // unfortunately comes back only if connected successfully
          if (Cellular.ready() == true) {
            Serial.println("Connected: IP Address has been assigned");
          }
          else Serial.println("Connected: NO Address has been assigned");
          break;
        case 'C' :
          // CONNECT TO THE PARTICLE CLOUD
          Serial.println("Connecting to Particle Cloud");
          if (Particle.connected() == false) {
            Particle.connect();
          }
          break;
        case 'd' :
          // DISCONNECT TO CELLULAR NETWORK
          Serial.println("Disconnecting from Cellular Network - DOESN'T WORK AT THIS TIME");
          Cellular.disconnect();
          break;
        case 'D' :
          // DISCONNECT FROM THE PARTICLE CLOUD
          Serial.println("Disconnecting from Particle Cloud");
          if (Particle.connected())
          Particle.disconnect();
          break;
        case 'r' :
          Serial.println("Getting CellularSignal - DOESN'T WORK AT THIS TIME");
          // DISCONNECT FROM THE PARTICLE CLOUD
          //CellularSignal sig = Cellular.RSSI();
          //Serial.println(sig.rssi);
          //Serial.println(sig.qual);
          //Serial.println(sig); // Complete structure also*/
          break;
        default :
          // AT - COMMAND
          Serial.println("Wrong Character Input");
        }
    }
  }
}

I am interested in your success with these 2 commands! Will you post here?

1 Like

See response here on how to collect data for some of these longer running commands, and the COPS=5 specifically:

1 Like