Is it possible to convert a char into an unsigned int?
I have this bit of code (Needs the webduino library)
#include <SPI.h>
#include <Ethernet.h>
#include <WebServer.h>
static uint8_t mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
static uint8_t ip[] = { 192, 168, 1, 97 };
#define PREFIX ""
#define NAMELEN 32
#define VALUELEN 500
WebServer webserver(PREFIX, 80);
void testCmd(WebServer &server, WebServer::ConnectionType type, char *url_tail, bool tail_complete) {
char name[NAMELEN];
char value[VALUELEN];
server.httpSuccess();
if (type == WebServer::POST) {
server.readPOSTparam(name, NAMELEN, value, VALUELEN);
if(strcmp(name,"type") == 0) {
if(strcmp(value,"test") == 0) {
while (server.readPOSTparam(name, NAMELEN, value, VALUELEN)) {
if(strcmp(name,"data") == 0) {
server.print("data: ");
server.print(value);
//value needs to be an unsigned int.
}
}
}
}
}
}
void setup() {
Ethernet.begin(mac, ip);
webserver.addCommand("test", &testCmd);
webserver.begin();
}
void loop() {
char buff[64];
int len = 64;
webserver.processConnection(buff, &len);
}
The request made to the server can be done with cURL using this
curl -d "type=test&data=9050,4600,43350,2150,600,2150,550,4400,550,4450,550,2150,550,2200,550,2150,550,2200,550,2200,550,2150,550,2200,550,2150,550,4450,550,4400,550,2200,550" http://192.168.1.210/test
When the cURL request is made, I need to take value in the string compare on line 20 and make it an unsigned int with the data payload from the post. I'm not sure how I would get the data payload converted to an unsigned int... or if it's even possible.
Anyone help?