There would be multiple ways to do that, but I just needed a quick and dirty “extension” of the SoftAP demo to take an input and pass that back for my application task.
So I just added an extra /control.html
which contained the extra settings I desired as a <form>...</form>
. But you can do that just as well in the original /index.html
.
The only thing you’d have to do is to capture the const char* url
and distill the form data you are interested in out of the URL and then strip off that extra stuff.
As said, quick and dirty
void myPage(const char* url, ResponseCallback* cb, void* cbArg, Reader* body, Writer* result, void* reserved)
{
char _url[strlen(url)+1];
char* query;
char* value;
strcpy(_url, url); // create a working copy of url
if (strcmp(strtok_r(_url, "?&", &query), myPages[0].url) == 0)
{ // is it my page (which I put to the front of myPages
for(; query; strtok_r(NULL, "?&", &query))
{ // iterate over possibly query parameters?
if(strcmp(strtok_r(query, "=", &value), "myValue") == 0)
{ // I'm only interested in this specific key
char* val = strtok_r(NULL, "?&=", &value);
doSomethingWith(val);
}
}
}
... // rest of original sample
}