Dear All,
I am bit surpised to see that a const char does not keep it's value. I am passing a char variable in the fourth parameter of the function
inet.httpPOST(host, port_post, path_post, getGPSCoords() , "Result", 1000);
getGPSCoords() return an array (char):
lo=608.474403&la=4613.160156&al=466.355804&ti=20130715174943.000&ve=0.000000
The header of the function is
int InetGSM::httpPOST(const char* server, int port, const char* path, const char* parameters, char* result, int resultlength){
// code
Serial.println(parameters);
}
parameters is a const char but the Serial.print(), inside of the InetGSM function does not display what I show in the above quote. It trunk the value.
More I add Serial.print into the InetGSM function more it trunked.
Here is the full code of InetGSM
I add 6 Serial.print in that function and I show the result
int InetGSM::httpPOST(const char* server, int port, const char* path, const char* parameters, char* result, int resultlength)
{
Serial.println(F("Starting to send"));
Serial.println(parameters); // lo=608.474403&la=4613.160156&al=466.355804&ti=20130715174950.3U79
Serial.println(parameters); // lo=608.474403&la=4613.160156&al=466.355804&ti=20130715174950
boolean connected=false;
int n_of_at=0;
char itoaBuffer[8];
int num_char;
char end_c[2];
end_c[0]=0x1a;
end_c[1]='\0';
while(n_of_at<3){
if(!connectTCP(server, port)){
#ifdef DEBUG_ON
Serial.println("DB:NOT CONN");
#endif
n_of_at++;
}
else{
connected=true;
n_of_at=3;
}
}
if(!connected){
Serial.println(F("Not connected"));
return 0;
}
Serial.println(parameters); // display : ^y
Serial.println(parameters); //display: : ^y
gsm.SimpleWrite("POST ");
gsm.SimpleWrite(path);
gsm.SimpleWrite(" HTTP/1.1\nHost: ");
gsm.SimpleWrite(server);
gsm.SimpleWrite("\n");
gsm.SimpleWrite("User-Agent: Arduino\n");
gsm.SimpleWrite("Content-Type: application/x-www-form-urlencoded\n");
gsm.SimpleWrite("Content-Length: ");
itoa(strlen(parameters),itoaBuffer,10);
gsm.SimpleWrite(itoaBuffer);
gsm.SimpleWrite("\n\n");
gsm.SimpleWrite(parameters);
gsm.SimpleWrite("\n\n");
gsm.SimpleWrite(end_c);
Serial.println(parameters); // display : ^y
Serial.println(parameters); /display : ^y
switch(gsm.WaitResp(10000, 10, "SEND OK")){
case RX_TMOUT_ERR:
return 0;
break;
case RX_FINISHED_STR_NOT_RECV:
return 0;
break;
}
delay(50);
#ifdef DEBUG_ON
Serial.println("DB:SENT");
#endif
int res= gsm.read(result, resultlength);
Serial.println(F("Data sent"));
//gsm.disconnectTCP();
return res;
}
Is there any reasons?
Do you need more code?