47 webServerCb.
attach(&ELClientWebServer::webServerPacketHandler);
51void ELClientWebServer::webServerPacketHandler(
void * response)
190 hnd->
next = handlers;
218 handlers = hnd->
next;
270 uint32_t cb = (uint32_t)&webServerCb;
278 response->
popArg(&shrt, 2);
281 response->
popArg(remote_ip, 4);
282 response->
popArg(&remote_port, 2);
285 uint16_t urlLen = response->
popArgPtr((
void**)&url);
290 if( hnd->
URL.length() == urlLen && memcmp( url, hnd->
URL.c_str(), urlLen ) == 0 )
299 _elc->
_debug->print(F(
"Handler not found for URL:"));
301 for(uint16_t i=0; i < urlLen; i++)
302 _elc->
_debug->print( url[i] );
313 int idLen = response->
popArgPtr((
void**)&idPtr);
317 memcpy(
id, idPtr, idLen);
327 while( cnt < response->argc() )
330 int idLen = response->
popArgPtr((
void**)&idPtr);
331 int nameLen = strlen(idPtr+1);
332 int valueLen = idLen - nameLen -2;
335 arg_ptr = (
char *)malloc(valueLen+1);
336 arg_ptr[valueLen] = 0;
337 memcpy(arg_ptr, idPtr + 2 + nameLen, valueLen);
358 _elc->
Request((uint8_t *)&remote_port, 2);
365 _elc->
Request((uint8_t *)NULL, 0);
406 uint8_t nlen = strlen(name);
407 uint8_t vlen = strlen(value);
408 char buf[nlen+vlen+3];
411 strcpy(buf+2+nlen, value);
412 _elc->
Request(buf, nlen+vlen+2);
452 const char * name_p =
reinterpret_cast<const char *
>(name);
453 const char * value_p =
reinterpret_cast<const char *
>(value);
455 uint8_t nlen = strlen_P(name_p);
456 uint8_t vlen = strlen_P(value_p);
457 char buf[nlen+vlen+3];
459 strcpy_P(buf+1, name_p);
460 strcpy_P(buf+2+nlen, value_p);
461 _elc->
Request(buf, nlen+vlen+2);
502 const char * name_p =
reinterpret_cast<const char *
>(name);
504 uint8_t nlen = strlen_P(name_p);
505 uint8_t vlen = strlen(value);
506 char buf[nlen+vlen+3];
508 strcpy_P(buf+1, name_p);
509 strcpy(buf+2+nlen, value);
510 _elc->
Request(buf, nlen+vlen+2);
566 uint8_t nlen = strlen(name);
567 uint8_t vlen = strlen(value);
568 char buf[nlen+vlen+3];
571 strcpy(buf+2+nlen, value);
572 _elc->
Request(buf, nlen+vlen+2);
627 const char * name_p =
reinterpret_cast<const char *
>(name);
628 const char * value_p =
reinterpret_cast<const char *
>(value);
630 uint8_t nlen = strlen_P(name_p);
631 uint8_t vlen = strlen_P(value_p);
632 char buf[nlen+vlen+3];
634 strcpy_P(buf+1, name_p);
635 strcpy_P(buf+2+nlen, value_p);
636 _elc->
Request(buf, nlen+vlen+2);
690 const char * name_p =
reinterpret_cast<const char *
>(name);
692 uint8_t nlen = strlen_P(name_p);
693 uint8_t vlen = strlen(value);
694 char buf[nlen+vlen+3];
696 strcpy_P(buf+1, name_p);
697 strcpy(buf+2+nlen, value);
698 _elc->
Request(buf, nlen+vlen+2);
731 uint8_t nlen = strlen(name);
735 buf[2 + nlen] = value;
769 const char * name_p =
reinterpret_cast<const char *
>(name);
771 uint8_t nlen = strlen_P(name_p);
774 strcpy_P(buf+1, name_p);
775 buf[2 + nlen] = value;
809 uint8_t nlen = strlen(name);
813 memcpy(buf+2+nlen, &value, 4);
847 const char * name_p =
reinterpret_cast<const char *
>(name);
849 uint8_t nlen = strlen_P(name_p);
852 strcpy_P(buf+1, name_p);
853 memcpy(buf+2+nlen, &value, 4);
890 uint8_t nlen = strlen(name);
930 const char * name_p =
reinterpret_cast<const char *
>(name);
932 uint8_t nlen = strlen_P(name_p);
935 strcpy_P(buf+1, name_p);
969 uint8_t nlen = strlen(name);
973 memcpy(buf+2+nlen, &value, 4);
1007 const char * name_p =
reinterpret_cast<const char *
>(name);
1009 uint8_t nlen = strlen_P(name_p);
1012 strcpy_P(buf+1, name_p);
1013 memcpy(buf+2+nlen, &value, 4);
1041 return (int32_t)atol(arg_ptr);
1094 if( strcmp_P(arg_ptr, PSTR(
"on")) == 0 )
1096 if( strcmp_P(arg_ptr, PSTR(
"true")) == 0 )
1098 if( strcmp_P(arg_ptr, PSTR(
"yes")) == 0 )
1100 if( strcmp_P(arg_ptr, PSTR(
"1")) == 0 )
1129 return atof(arg_ptr);
Definitions for ELClientWebServer.
int16_t popArg(void *data, uint16_t maxLen)
Extract an argument from the response packet.
int16_t popArgPtr(void **data)
Extract pointer to an argument from the response packet.
void setArgString(const char *name, const char *value)
Sets string value of a field.
void setArgBoolean(const char *name, uint8_t value)
Sets boolean value of a field.
void setArgInt(const char *name, int32_t value)
Sets integer value of a field.
ELClientWebServer(ELClient *elc)
Creates a Web-Server instance.
void setup()
Initializes web-server.
float getArgFloat()
Returns an HTML field value as float.
void setArgJson(const char *name, const char *value)
Sets JSON value of a field.
int32_t getArgInt()
Returns an HTML field value as integer.
uint8_t getArgBoolean()
Returns an HTML field value as boolean.
void setArgFloat(const char *name, float f)
Sets float value of a field.
void destroyURLHandler(URLHandler *handler)
Unregisters an destroys an URL handler.
char * getArgString()
Returns an HTML field value as string.
static ELClientWebServer * getInstance()
Returns the singleton web-server instance.
void setArgNull(const char *name)
Sets null value to a field.
URLHandler * createURLHandler(const char *URL)
Creates and registers an URL handler.
void Request(uint16_t cmd, uint32_t value, uint16_t argc)
Start a request.
void attach(T *item, retT(T::*method)(argT))
FP< void, char * > setFieldCb
callback for setting a field from a HTML form
FP< void, char * > loadCb
Callback for HTML page loading.
struct URL_HANDLER * next
next handler
FP< void, char * > buttonCb
callback for a HTML button press
String URL
the URL to handle
FP< void, char * > refreshCb
Callback for HTML page refresh.