running GSM server SIM808, need help pls

Hello,

I'm running Arduino UNO with Crowtail- SIM808, using #include <SoftwareSerial.h> and AT commands I can read remote pages however it force the sketch to pull the data over and over again, my goal is to push the data from the web into the Arduino, I've looked at the GSM Web Server however it is designed to work with the "Telefonica GSM/GPRS Shield", currently I can discover my WAN IP address but I cant make any success with sending anything to that address to be read by the Serial.Read in Arduino...

This is my first project using GSM module so any thought would be highly appreciated!

Thank you all in advance,
Best,
Ram


got some progress but hit another barrier :frowning:

I manage to run a server for a few seconds and then it just hangs while waiting for data.

the following is the my Server code:

#include <inetGSM.h>
#include <SoftwareSerial.h>
#include <SIM900.h>
#include <LOG.h>

//To change pins for Software Serial, use the two lines in GSM.cpp.
//Simple sketch to start a connection as server.

InetGSM inet;

char msg[50];
int numdata;
char inSerial[50];
int i = 0;
boolean started = false;
long lasttime = millis();

void setup()
{
	//Serial connection.
	Serial.begin(9600);
	Serial.println("GSM Shield testing.");
	//Start configuration of shield with baudrate.
	//For http uses is raccomanded to use 4800 or slower
	
	if (gsm.begin(2400)) {
		Serial.println("\nstatus=READY");
		started = true;
	}
	else Serial.println("\nstatus=IDLE");

	if (started) {
		//GPRS attach, put in order APN, username and password.
		//If no needed auth let them blank.
		if (inet.attachGPRS("sphone", "", ""))
			Serial.println("status=ATTACHED");
		else Serial.println("status=ERROR");
		delay(1000);
		
		//Read IP address.
		gsm.SimpleWriteln("AT+CIFSR");
		
		delay(5000);
		int i = 0;
		while (i<20) {
			gsm.SimpleRead();
			i++;
			
		}
		
		//TCP Server. Start the socket connection
		//as server on the assigned port.
		Serial.println(msg);
		delay(5000);
		if (inet.connectTCPServer(80))
			Serial.println("status=TCPSERVERWAIT");
		else Serial.println("ERROR in Server");
		lasttime = millis();
	}
};


void loop()
{
	if (started) {
		//Check if there is an active connection.
		if (inet.connectedClient()) {
			//Read and print the last message received.
			gsm.read(msg, 50);
			Serial.println(msg);
		}
	}
	else {
		serialhwread();
		serialswread();
	}

};

void serialhwread()
{
	i = 0;
	if (Serial.available() > 0) {
		while (Serial.available() > 0) {
			inSerial[i] = (Serial.read());
			delay(10);
			i++;
		}

		inSerial[i] = '\0';
		if (!strcmp(inSerial, "/END")) {
			Serial.println("_");
			inSerial[0] = 0x1a;
			inSerial[1] = '\0';
			gsm.SimpleWriteln(inSerial);
		}
		//Send a saved AT command using serial port.
		if (!strcmp(inSerial, "TEST")) {
			Serial.println("SIGNAL QUALITY");
			gsm.SimpleWriteln("AT+CSQ");
		}
		//Read last message saved.
		if (!strcmp(inSerial, "MSG")) {
			Serial.println(msg);
		}
		else {
			Serial.println(inSerial);
			gsm.SimpleWriteln(inSerial);
		}
		inSerial[0] = '\0';
	}
}

void serialswread()
{
	gsm.SimpleRead();
}

and this is the output to the Serial:

Opening port
Port open
GSM Shield testing.
ATT: OK
RIC:
OK

DB:ELSE
ATT: OK
RIC:
OK

DB:ELSE
ATT: OK
RIC:
OK

DB:ELSE
ATT: OK
RIC:
OK

DB:CORRECT BR
ATT: OK
RIC:
OK

ATT: OK
RIC:
OK

ATT: OK
RIC: ATE0
OK

ATT: OK
RIC:
OK

ATT: OK
RIC:
OK

ATT: OK
RIC:
OK

ATT: OK
RIC:
OK

ATT: +CPMS:
RIC:
+CPMS: 0,10,0,10,0,10

OK

ATT: OK
RIC:
OK

ATT: SHUT OK
RIC:
SHUT OK

status=READY
ATT: ERROR
RIC:
ERROR

DB:STARTING NEW CONNECTION
ATT: SHUT OK
RIC:
SHUT OK

DB:SHUTTED OK
ATT: OK
RIC:
OK

DB:APN OK
ATT: OK
RIC:
OK

DB:CONNECTION OK
ATT: ERROR
RIC:
10.164.22.56

DB:ASSIGNED AN IP
status=ATTACHED

10.164.22.56

status=TCPSERVERWAIT
ATT: CONNECT OK
RIC:
OK

SERVER OK

OK

STATE: SERVER LISTENING

Starting read..
Waiting for Data.....................................................................

Can anyone PLEASE help me figure this out???

although I'm having an exciting monologue here with myself I'll keep it up for other users to benefit my learning curve and hopefully someone will help me out.

The reason for the server hanging was whenever I selected text (copied the IP) from the Serial output it hangs.. so I don't dare to touch it anymore and it runs without any problems so that's one more step forward, Yay!

now that I have my GSM server up and running I'm trying to send it something... so... one more barrier I hit, I tried PUT, GET, POST & PING but there's no sign of anything getting to the Arduino, so I added some breakpoints and learned something new but mostly disturbing:

Not only I don't hit any of the breakpoints I get inside the loop only once while the GSM server keeps on updating the Serial window! WHAT THE FUNCTION IS GOING ON HERE??
Does anyone here can help a newbie please?

Additional update:

When sending the command "AT+CIFSR" I've noticed that the IP I'm getting is an internal one by my cellular provider, the addresses I got were 10.134.140.240 and such... so my next step was to register my current connection to a DDNS service, I really love working with Duck DNS so I added to my sketch a GET call that once I get internet connection I'll update my DDNS domain with my current IP, it is very simple for anyone who needs to update his IP behind a friendly name:

gsm.SimpleWriteln("AT+HTTPPARA="URL","http://www.duckdns.org/update?domains=ramuno&token=55518a0f-0fb6-4632-b93b-XXXXXXXXXXXXX&ip=\"");

once executed I looked at the my domain ramuno.duckdns.org and indeed I got a WAN IP address different than the one printed in my Serial window, Success!!!! BUT no joy :frowning: when trying PING, GET, POST or PUT I still can't get any reaction from the Arduino side :sob: :sob: :sob:
So....... once again...... anyone......... help........ please.......... newbie needs help.

changed the APN settings to a different setup by my cellular provider and I got an IP that is visible from outside! all is working well now!!

Thank you for your support.

I'm trying to do exactly what you did and your code works but I can't access Arduino from Ip address to determine if it's recieving requests, if you can please explain how you managed to send request to your Arduino I would much appreciate it.