Hello
I am trying to connect arduino mega to a webpage via SM5100B cellular shield.
#include <string.h>
#define BUFFSIZ 90
char at_buffer[BUFFSIZ];
char buffidx;
int firstTimeInLoop = 1;
int GPRS_registered;
int GPRS_AT_ready;
char incoming_char=0; //Will hold the incoming character from the Serial Port.
char buffer[60];
String myString=“1”;
// Do system wide initialization here in this function
void setup()
{
Serial.begin(9600);
Serial1.begin(9600);
//Let’s get started!
Serial.println(“Starting SM5100B Communication…”);
for (int i = 20; i < 1; i–) {
delay(1000);
Serial.println(i);
}
/* Currently GPRS is not registered and AT is not ready */
GPRS_registered = 0;
GPRS_AT_ready = 0;
}
/* Reads AT String from the SM5100B GSM/GPRS Module */
void readATString(void) {
char c;
buffidx= 0; // start at begninning
while (1) {
if(Serial1.available() > 0) {
c=Serial1.read();
if (c == -1) {
at_buffer[buffidx] = ‘\0’;
return;
}
if (c == ‘\n’) {
continue;
}
if ((buffidx == BUFFSIZ - 1) || (c == ‘\r’)){
at_buffer[buffidx] = ‘\0’;
return;
}
at_buffer[buffidx++]= c;
}
}
}
/* Processes the AT String to determine if GPRS is registered and AT is ready */
void ProcessATString() {
if( strstr(at_buffer, “+SIND: 1”) != 0 ) {
GPRS_registered = 0;
Serial.println(“SIM inserted”);
}
if( strstr(at_buffer, “+SIND: 3”) != 0 ) {
GPRS_registered = 0;
Serial.println(“GSM Call ready”);
}
if( strstr(at_buffer, “+SIND: 8”) != 0 ) {
GPRS_registered = 0;
Serial.println(“GSM Network Not Available”);
}
if( strstr(at_buffer, “+SIND: 11”) != 0 ) {
GPRS_registered=0;
Serial.println(“GSM Registered to network”);
}
if( strstr(at_buffer, “+SIND: 4”) != 0 ) {
GPRS_registered=1;
GPRS_AT_ready=1;
Serial.println(“GSM SMS ready”);
}
}
//-------------------------------------------------------------------------
void loop() {
/* If called for the first time, loop until GPRS and AT is ready */
if(firstTimeInLoop) {
firstTimeInLoop = 0;
while (GPRS_registered == 0 && GPRS_AT_ready == 0) {
readATString();
ProcessATString();
}
delay(1000);
Serial.println(“GPRS Attaching”);
Serial1.print(“AT+CGATT?”);
delay(1000);
Serial.println(“Setting up PDP Context”);
Serial1.print(“AT+CGDCONT=1,"ip","internet","",0,0”);
delay(1000);
Serial.println(“Sending Password”);
Serial1.print(“AT+CGPCO=0,"","", 1”);
delay(1000);
Serial.println(“Activating PDP Context”);
Serial1.print(“AT+CGACT=1,1”);
delay(1000);
Serial.println(“Configuring TCP connection to TCP Server”);
Serial1.print(“AT+SDATACONF=1,"TCP","81.180.216.9",80”);
delay(1000);
while(Serial1.available()){
incoming_char=Serial1.read();
Serial.print(incoming_char);
}
Serial.println(“Starting TCP Connection”);
Serial1.print(“AT+SDATASTART=1,1”);
Serial1.print("AT+SSTRSEND=1,"GET ");
Serial1.print(“/ggo/data.php”);
Serial1.print(" HTTP/1.1\n");
Serial1.print(" Connection: keep-alive\n");
}
Serial.println(“Checking Connection Status\n”);
Serial1.print(“AT+SDATASTATUS=1”);
delay(1000);
while(Serial1.available()){
incoming_char=Serial1.read();
Serial.print(incoming_char);
}
}
any ideas why is not apearing on the web server(apache) log files?
Thanks
Iulian