inet.httpGet make path variable

Hi Arduino guys,

I have been working on a project for a few weeks now. My project is about reading values and posting them to our webservice.

I have a question on how to use to following command : inet.httpGET

Why this isn't working : (i can see no connection between the service and arduino)

char telnr[10];
char *url;

telnr = 03574543512;
url = "/arduino/add.php?action=boot&phonenr=";
strcat( url, telnr);
numdata=inet.httpGET("", 80, url, msg, 50);

This example below works but i need to make the string variable. ( i can see the connection to our server )

numdata=inet.httpGET("", 80, "/arduino/add.php?action=boot&phonenr=03574543512", msg, 50);

What am I doing wrong?

Thx in advance.

char *url;

url is a pointer. Currently, it points to nothing.

url = "/arduino/add.php?action=boot&phonenr=";

Now, url points to a FIXED-LENGTH block of memory.

strcat( url, telnr);

You can't append onto a fixed-length block of memory.

You COULD create an array that was big enough to hold the URL AND the part you want to append to it, then use strcpy() to copy the url there, and strcat() to append the other part.

PaulS thank you very much!!

So this means i needs to check out all different kinds of data types in C++.

At the moment i am into PHP.

So this means i needs to check out all different kinds of data types in C++.

Always a good idea.

At the moment i am into PHP.

Nothing wrong with that. It’s not a strongly typed language like C, nor does it require that you think about memory like C and C++ does, but it does require logical thinking.

I think i have the same issue when i want to convert time_t or now() to a string.

i am doing the following now :

url = "/arduino/goaddmyvalues.php?actie=value&telnr=";
strcpy( url1, url);
strcat( url1, telnr);
strcat( url1, "&waarde=");   
itoa (sensorVerbruik,sensorVerbruik1,10);
strcat( url1, sensorVerbruik1);        
strcat( url1, "&tijd=");   
strcat( url1, now() );   
numdata=inet.httpGET("", 80, url1, msg, 50);

strcat( url1, now() ); // The problem is in this line. i tried the same as this : itoa (now(),now1,10); strcat( url1, now1);

but it show '1be' instead of the timestamp 1398531...

How can we solve this?

Enough with the snippets. What does now() return? If it returns, as I expect, an unsigned long, then strcat() is not going to be able to deal with that, in the way that you expect.

Why not just use sprintf() to populate the URL string, and let it deal with the conversion from ints to strings?

I have made it works with sending data from analog pin: this is part of code:

int data; char buffer[60]; ... void loop(){ if(millis() > time + timeBetweenReadings){ data = analogRead(0); sprintf(buffer, "/log_file.php?load=%d", data); // Serial.println(buffer); time = millis(); inet.httpGET("", 80, buffer, msg,0); } }