Arduino SM5100b http post request problems.can anyone help me out.

Hi,
here the set of at commands am using to set-up a pdp context to a server.
i keep getting CME error:29 ,4 and also STCPC:1(socket disconnected).
Here s the code ..

#include <PString.h>

/*
SparkFun Cellular Shield - Pass-Through Sample Sketch
SparkFun Electronics
Written by Ryan Owens
CC by v3.0
3/8/10
This version - example 26.1a - for Arduino Mega
Run jumpers from GSM shield pin 2 to Mega 19, and shield 3 to Mega 18
Ensure that there is NOT a connection from shield pins RX and TX to anywhere.
*/

#include <string.h> //Used for string manipulations
//#include<PString.h>
char incoming_char=0; //Will hold the incoming character from the Serial Port.
char buffer[1500];
PString myString(buffer,sizeof(buffer));

void setup()
{
//Initialize serial ports for communication.
Serial.begin(9600); // for terminal communication
Serial1.begin(9600); // for GSM module communication
Serial.println("Starting SM5100B Communication...");
}

void loop() {

delay(40000);

Serial.println("Reg!!");
//
Serial1.print("AT+CGATT?\r");
delay(200);

while(Serial1.available() == 0);
//delay(1000);
while(Serial1.available() != 0)
{
incoming_char=Serial1.read(); //Get the character from the cellular serial port.
Serial.print(incoming_char); //Print the incoming character to the terminal.
}

Serial.println("1");

//2
Serial1.print("AT+CGDCONT=1,"IP","www"\r");
delay(200);
while(Serial1.available() == 0);
//delay(1000);
while(Serial1.available() != 0)
{
incoming_char=Serial1.read(); //Get the character from the cellular serial port.
Serial.print(incoming_char); //Print the incoming character to the terminal.
}

Serial.println("2");

//3
Serial1.print("AT+CGPCO=0,"","", 1\r");
delay(200);
while(Serial1.available() == 0);
//delay(1000);
while(Serial1.available() != 0)
{
incoming_char=Serial1.read(); //Get the character from the cellular serial port.
Serial.print(incoming_char); //Print the incoming character to the terminal.
}

Serial.println("3");

//4
Serial1.print("AT+CGACT=1,1\r");
delay(200);
while(Serial1.available() == 0);
// delay(1000);
while(Serial1.available() != 0)
{
incoming_char=Serial1.read(); //Get the character from the cellular serial port.
Serial.print(incoming_char); //Print the incoming character to the terminal.
}

Serial.println("4");

//5
Serial1.print("AT+SDATACONF=1,"TCP","saga143.appspot.com",80\r");
//Serial1.print("AT+SDATACONF=1,"TCP","192.168.9.16",9999\r");
delay(2000);
while(Serial1.available() == 0);
//delay(1000);
while(Serial1.available() != 0)
{
incoming_char=Serial1.read(); //Get the character from the cellular serial port.
Serial.print(incoming_char); //Print the incoming character to the terminal.
}

Serial.println("5");

//6
Serial1.print("AT+SDATASTART=1,1\r");
delay(5000);
while(Serial1.available() == 0);
//delay(1000);
while(Serial1.available() != 0)
{
incoming_char=Serial1.read(); //Get the character from the cellular serial port.
Serial.print(incoming_char); //Print the incoming character to the terminal.
}

Serial.println("6");
delay(5000);
//7
Serial1.print("AT+SDATASTATUS=1\r");
delay(200);
while(Serial1.available() == 0);
//delay(1000);
while(Serial1.available() != 0)
{
incoming_char=Serial1.read(); //Get the character from the cellular serial port.
Serial.print(incoming_char); //Print the incoming character to the terminal.
}

Serial.println("7");

//8
//"POST /irss HTTP/1.1\r\nHost: saga143.appspot.com\r\nContent-Type: image/jpeg\r\nContent-Length: 5\r\n\r\n/9j/4"
//Serial1.print("AT+SSTRSEND=1,"GET /irss HTTP/1.1\n"\r");
/* myString.println("AT+SSTRSEND=1,"POST /irss HTTP/1.1");
myString.println("Host: saga143.appspot.com");
myString.println("Content-Type: image/jpeg");
myString.println("Content-Length: 5");
myString.println();
myString.println("/9j/4"\r");
Serial.println(myString);
Serial1.write(myString);*/
Serial1.print("AT+SDATATSEND=1,50");
Serial1.print(13,BYTE);
delay(100);
while(Serial1.available() == 0);
//delay(1000);
while(Serial1.available() != 0)
{
incoming_char=Serial1.read(); //Get the character from the cellular serial port.
Serial.print(incoming_char); //Print the incoming character to the terminal.
}

Serial1.print("POST /irss HTTP/1.1");
Serial1.print(13,BYTE);
Serial1.print(10,BYTE);

Serial1.print("Host: saga143.appspot.com");
Serial1.print(13,BYTE);
Serial1.print(10,BYTE);

Serial1.print("Content-Type: image/jpeg");
Serial1.print(13,BYTE);
Serial1.print(10,BYTE);

Serial1.print("Content-Length: 5");
Serial1.print(13,BYTE);
Serial1.print(10,BYTE);
Serial1.print(13,BYTE);
Serial1.print(10,BYTE);

Serial1.print("/9j/4");
Serial1.print(13,BYTE);*/

Serial1.print(26,BYTE);
//Serial1.write("");
// Serial1.write(26);
//delay(500);
while(Serial1.available() == 0);
//delay(1000);
while(Serial1.available() != 0)
{
incoming_char=Serial1.read(); //Get the character from the cellular serial port.
Serial.print(incoming_char); //Print the incoming character to the terminal.
}

Serial.println("8");

Serial1.println("AT+SDATASTATUS=1");
delay(200);
while(Serial1.available() == 0);
//delay(1000);
while(Serial1.available() != 0)
{
incoming_char=Serial1.read(); //Get the character from the cellular serial port.
Serial.print(incoming_char); //Print the incoming character to the terminal.
}

//9
Serial1.print("AT+SDATASTATUS=0\r");
delay(200);
while(Serial1.available() != 0)
{
incoming_char=Serial1.read(); //Get the character from the cellular serial port.
Serial.print("10"+incoming_char); //Print the incoming character to the terminal.
}

//10
Serial1.print("AT+SDATASTART=1,0\r");
delay(200);
while(Serial1.available() == 0);
//delay(1000);
while(Serial1.available() != 0)
{
incoming_char=Serial1.read(); //Get the character from the cellular serial port.
Serial.print(incoming_char); //Print the incoming character to the terminal.
}

Serial.println("9");

while(1);

}

Any help would be greatly appreciated..i have feeling it gotta do with at the post request.

Http post request on SM5100b working fine with the above code..Just make sure that the data length is proper along with cr and lf....:slight_smile:

I hate to say it but I've been having the same sort of issues with HTTP requests. In the short term I've been using a small processing sketch running on a different port to read data from the SM5100B, which works perfectly.

I hope a solution comes around!