Working on a arduino code, but its C code. Having the problem that I want a variable with int to increase in a loop to run with the url:
student.cs.hioa.no/~s180343/updatedb.php?verdi=%d
The updatedb.php files takes the parameter and saves it to the database.
#include <Process.h>
char buffer[50];
int val=1200;
void setup() {
// Initialize Bridge
Bridge.begin();
// Initialize Serial
Serial.begin(9600);
// Wait until a Serial Monitor is connected.
while (!Serial);
// run various example processes
//runCurl(val);
//runCpuInfo();
}
void loop() {
Serial.println("Starting");
sprintf (buffer, "student.cs.hioa.no/~s180343/updatedb.php?verdi=%d", val);
val++;
Serial.println(buffer);
runCurl();
delay(5000);
// Do nothing here.
}
void runCurl() {
// curl is command line program for transferring data using different internet protocols
Process p; // Create a process and call it "p"
p.begin("curl"); // Process that launch the "curl" command
p.addParameter(buffer); // Add the URL parameter to "curl"
p.run(); // Run the process and wait for its termination
// A process output can be read with the stream methods
while (p.available()>0) {
char c = p.read();
Serial.print(c);
}
// Ensure the last bit of data is sent.
Serial.flush();
}