Gbox 4.20
Grow box automation and monitoring - <a href='https://sites.google.com/site/growboxguy/'>https://sites.google.com/site/growboxguy/</a>
 
Loading...
Searching...
No Matches
ELClientWebServer.h
Go to the documentation of this file.
1
7// Copyright (c) 2016 by Cs. Karai and T. von Eicken
8
9#ifndef _EL_CLIENT_WEB_SERVER_H_
10#define _EL_CLIENT_WEB_SERVER_H_
11
12#include <Arduino.h>
13#include "ELClient.h"
14#include "FP.h"
15
116
117// This class implements functions for the web-server
119public:
120 // Initialize with an ELClient object
122
123 // initializes the web-server
124 void setup();
125
126 // creates a URL handler
127 URLHandler * createURLHandler(const char * URL);
128 // creates a URL handler from flash
129 URLHandler * createURLHandler(const __FlashStringHelper * URL);
130 // creates a URL handler from String
131 URLHandler * createURLHandler(const String &s);
132
133 // destroys a URL handler
134 void destroyURLHandler(URLHandler * handler);
135
136 // sets int value of a HTML field
137 void setArgInt(const char * name, int32_t value);
138 // sets int value of a HTML field
139 void setArgInt(const __FlashStringHelper * name, int32_t value);
140 // sets JSON value of a HTML field
141 void setArgJson(const char * name, const char * value);
142 // sets JSON value of a HTML field
143 void setArgJson(const __FlashStringHelper * name, const char * value);
144 // sets JSON value of a HTML field
145 void setArgJson(const __FlashStringHelper * name, const __FlashStringHelper * value);
146 // sets string value of a HTML field
147 void setArgString(const char * name, const char * value);
148 // sets string value of a HTML field
149 void setArgString(const __FlashStringHelper * name, const char * value);
150 // sets string value of a HTML field
151 void setArgString(const __FlashStringHelper * name, const __FlashStringHelper * value);
152 // sets boolean value of a HTML field
153 void setArgBoolean(const char * name, uint8_t value);
154 // sets boolean value of a HTML field
155 void setArgBoolean(const __FlashStringHelper * name, uint8_t value);
156 // sets null value of a HTML field
157 void setArgNull(const char * name);
158 // sets null value of a HTML field
159 void setArgNull(const __FlashStringHelper * name);
160 // sets float value of a HTML field
161 void setArgFloat(const char * name, float f);
162 // sets float value of a HTML field
163 void setArgFloat(const __FlashStringHelper * name, float f);
164
165
166 // setFieldCb: gets the value of the field as integer
167 int32_t getArgInt();
168 // setFieldCb: gets the value of the field as string
169 char * getArgString();
170 // setFieldCb: gets the value of the field as boolean
171 uint8_t getArgBoolean();
172 // setFieldCb: gets the value of the field as float
173 float getArgFloat();
174
175
186 static ELClientWebServer * getInstance() { return instance; }
187
188private:
189 ELClient* _elc;
190
191 static void webServerPacketHandler(void * packet);
192 void processResponse(ELClientResponse *packet); // internal
193 static ELClientWebServer * instance;
194
195 uint8_t remote_ip[4];
196 uint16_t remote_port;
197
198 struct URL_HANDLER * handlers;
199 char * arg_ptr;
200 FP<void, void*> webServerCb;
201};
202
203#endif // _EL_CLIENT_WEB_SERVER_H_
struct URL_HANDLER URLHandler
Definitions for ELClient.
Core Utility - Templated Function Pointer Class.
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.
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.
API abstraction for a Function Pointers.
Definition FP.h:136
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.