Go Down

Topic: Build an UDP server via AT commands (Read 324 times) previous topic - next topic

j0sete

I'm trying to build an UDP server using the GSM v2 shield via AT commands. I'm following the process from Quectel GSM TCPIP Application Note V1.2, I'm using this code like an AT forward program (see code below).
I write the commands:

at+qilocip // to know my IP
at+qiserver=1 // Start UDP server

I can read message from serial like OK or SERVER OK, but can't receive any message from netcat client, plus I can't write more command, anything I write via serial is send to netcat client, where am I making a mistake ??

Code: [Select]


#include <GSM.h>
#include <GSM3ShieldV1ServerProvider.h>

// PIN Number
#define PINNUMBER "myPIN"

// APN data
#define GPRS_APN       "APN" // replace your GPRS APN
#define GPRS_LOGIN     "LOGIN"    // replace with your GPRS login
#define GPRS_PASSWORD  "PASS" // replace with your GPRS password

GSM3ShieldV1ServerProvider modemAccess;

GSMServer webServer;
GPRS gprs;
GSM gsmAccess;

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

  while(!Serial);
 
  //modemAccess.begin();
  //modemAccess.restartModem();
  webServer.begin();

  boolean notConnected = true;

  Serial.println("Attach a la red...");
  while (notConnected) {
    if ((gsmAccess.begin(PINNUMBER) == GSM_READY) &
        (gprs.attachGPRS(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD) == GPRS_READY)) {
      notConnected = false;
    } else {
      Serial.println("Not connected");
      delay(1000);
    }
  }

  Serial.println("Esperando comando");

}

void loop() {

  String modemResponse;
  String comando = "";

  if ( Serial.available() ) {
    comando = Serial.readString();
    Serial.print(comando);

    modemResponse=modemAccess.writeModemCommand(comando, 1000);

    Serial.println(modemResponse);
    Serial.println("Esperando comando");
  }

  if( modemAccess.available() ) {

    while( modemAccess.available() ) {
      char c = modemAccess.read();
      modemResponse += c;
    }
   
  }

}



Go Up