87 |
88 |
92 |
95 |
96 |
97 |
--------------------------------------------------------------------------------
/include/README:
--------------------------------------------------------------------------------
1 |
2 | This directory is intended for project header files.
3 |
4 | A header file is a file containing C declarations and macro definitions
5 | to be shared between several project source files. You request the use of a
6 | header file in your project source file (C, C++, etc) located in `src` folder
7 | by including it, with the C preprocessing directive `#include'.
8 |
9 | ```src/main.c
10 |
11 | #include "header.h"
12 |
13 | int main (void)
14 | {
15 | ...
16 | }
17 | ```
18 |
19 | Including a header file produces the same results as copying the header file
20 | into each source file that needs it. Such copying would be time-consuming
21 | and error-prone. With a header file, the related declarations appear
22 | in only one place. If they need to be changed, they can be changed in one
23 | place, and programs that include the header file will automatically use the
24 | new version when next recompiled. The header file eliminates the labor of
25 | finding and changing all the copies as well as the risk that a failure to
26 | find one copy will result in inconsistencies within a program.
27 |
28 | In C, the usual convention is to give header files names that end with `.h'.
29 | It is most portable to use only letters, digits, dashes, and underscores in
30 | header file names, and at most one dot.
31 |
32 | Read more about using header files in official GCC documentation:
33 |
34 | * Include Syntax
35 | * Include Operation
36 | * Once-Only Headers
37 | * Computed Includes
38 |
39 | https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html
40 |
--------------------------------------------------------------------------------
/lib/README:
--------------------------------------------------------------------------------
1 |
2 | This directory is intended for project specific (private) libraries.
3 | PlatformIO will compile them to static libraries and link into executable file.
4 |
5 | The source code of each library should be placed in a an own separate directory
6 | ("lib/your_library_name/[here are source files]").
7 |
8 | For example, see a structure of the following two libraries `Foo` and `Bar`:
9 |
10 | |--lib
11 | | |
12 | | |--Bar
13 | | | |--docs
14 | | | |--examples
15 | | | |--src
16 | | | |- Bar.c
17 | | | |- Bar.h
18 | | | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
19 | | |
20 | | |--Foo
21 | | | |- Foo.c
22 | | | |- Foo.h
23 | | |
24 | | |- README --> THIS FILE
25 | |
26 | |- platformio.ini
27 | |--src
28 | |- main.c
29 |
30 | and a contents of `src/main.c`:
31 | ```
32 | #include
33 | #include
34 |
35 | int main (void)
36 | {
37 | ...
38 | }
39 |
40 | ```
41 |
42 | PlatformIO Library Dependency Finder will find automatically dependent
43 | libraries scanning project source files.
44 |
45 | More information about PlatformIO Library Dependency Finder
46 | - https://docs.platformio.org/page/librarymanager/ldf.html
47 |
--------------------------------------------------------------------------------
/lib/WebConfig/.piopm:
--------------------------------------------------------------------------------
1 | {"type": "library", "name": "WebConfig", "version": "1.4.1", "spec": {"owner": "gerlech", "id": 6874, "name": "WebConfig", "requirements": null, "uri": null}}
--------------------------------------------------------------------------------
/lib/WebConfig/LICENSE:
--------------------------------------------------------------------------------
1 | GNU LESSER GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 |
9 | This version of the GNU Lesser General Public License incorporates
10 | the terms and conditions of version 3 of the GNU General Public
11 | License, supplemented by the additional permissions listed below.
12 |
13 | 0. Additional Definitions.
14 |
15 | As used herein, "this License" refers to version 3 of the GNU Lesser
16 | General Public License, and the "GNU GPL" refers to version 3 of the GNU
17 | General Public License.
18 |
19 | "The Library" refers to a covered work governed by this License,
20 | other than an Application or a Combined Work as defined below.
21 |
22 | An "Application" is any work that makes use of an interface provided
23 | by the Library, but which is not otherwise based on the Library.
24 | Defining a subclass of a class defined by the Library is deemed a mode
25 | of using an interface provided by the Library.
26 |
27 | A "Combined Work" is a work produced by combining or linking an
28 | Application with the Library. The particular version of the Library
29 | with which the Combined Work was made is also called the "Linked
30 | Version".
31 |
32 | The "Minimal Corresponding Source" for a Combined Work means the
33 | Corresponding Source for the Combined Work, excluding any source code
34 | for portions of the Combined Work that, considered in isolation, are
35 | based on the Application, and not on the Linked Version.
36 |
37 | The "Corresponding Application Code" for a Combined Work means the
38 | object code and/or source code for the Application, including any data
39 | and utility programs needed for reproducing the Combined Work from the
40 | Application, but excluding the System Libraries of the Combined Work.
41 |
42 | 1. Exception to Section 3 of the GNU GPL.
43 |
44 | You may convey a covered work under sections 3 and 4 of this License
45 | without being bound by section 3 of the GNU GPL.
46 |
47 | 2. Conveying Modified Versions.
48 |
49 | If you modify a copy of the Library, and, in your modifications, a
50 | facility refers to a function or data to be supplied by an Application
51 | that uses the facility (other than as an argument passed when the
52 | facility is invoked), then you may convey a copy of the modified
53 | version:
54 |
55 | a) under this License, provided that you make a good faith effort to
56 | ensure that, in the event an Application does not supply the
57 | function or data, the facility still operates, and performs
58 | whatever part of its purpose remains meaningful, or
59 |
60 | b) under the GNU GPL, with none of the additional permissions of
61 | this License applicable to that copy.
62 |
63 | 3. Object Code Incorporating Material from Library Header Files.
64 |
65 | The object code form of an Application may incorporate material from
66 | a header file that is part of the Library. You may convey such object
67 | code under terms of your choice, provided that, if the incorporated
68 | material is not limited to numerical parameters, data structure
69 | layouts and accessors, or small macros, inline functions and templates
70 | (ten or fewer lines in length), you do both of the following:
71 |
72 | a) Give prominent notice with each copy of the object code that the
73 | Library is used in it and that the Library and its use are
74 | covered by this License.
75 |
76 | b) Accompany the object code with a copy of the GNU GPL and this license
77 | document.
78 |
79 | 4. Combined Works.
80 |
81 | You may convey a Combined Work under terms of your choice that,
82 | taken together, effectively do not restrict modification of the
83 | portions of the Library contained in the Combined Work and reverse
84 | engineering for debugging such modifications, if you also do each of
85 | the following:
86 |
87 | a) Give prominent notice with each copy of the Combined Work that
88 | the Library is used in it and that the Library and its use are
89 | covered by this License.
90 |
91 | b) Accompany the Combined Work with a copy of the GNU GPL and this license
92 | document.
93 |
94 | c) For a Combined Work that displays copyright notices during
95 | execution, include the copyright notice for the Library among
96 | these notices, as well as a reference directing the user to the
97 | copies of the GNU GPL and this license document.
98 |
99 | d) Do one of the following:
100 |
101 | 0) Convey the Minimal Corresponding Source under the terms of this
102 | License, and the Corresponding Application Code in a form
103 | suitable for, and under terms that permit, the user to
104 | recombine or relink the Application with a modified version of
105 | the Linked Version to produce a modified Combined Work, in the
106 | manner specified by section 6 of the GNU GPL for conveying
107 | Corresponding Source.
108 |
109 | 1) Use a suitable shared library mechanism for linking with the
110 | Library. A suitable mechanism is one that (a) uses at run time
111 | a copy of the Library already present on the user's computer
112 | system, and (b) will operate properly with a modified version
113 | of the Library that is interface-compatible with the Linked
114 | Version.
115 |
116 | e) Provide Installation Information, but only if you would otherwise
117 | be required to provide such information under section 6 of the
118 | GNU GPL, and only to the extent that such information is
119 | necessary to install and execute a modified version of the
120 | Combined Work produced by recombining or relinking the
121 | Application with a modified version of the Linked Version. (If
122 | you use option 4d0, the Installation Information must accompany
123 | the Minimal Corresponding Source and Corresponding Application
124 | Code. If you use option 4d1, you must provide the Installation
125 | Information in the manner specified by section 6 of the GNU GPL
126 | for conveying Corresponding Source.)
127 |
128 | 5. Combined Libraries.
129 |
130 | You may place library facilities that are a work based on the
131 | Library side by side in a single library together with other library
132 | facilities that are not Applications and are not covered by this
133 | License, and convey such a combined library under terms of your
134 | choice, if you do both of the following:
135 |
136 | a) Accompany the combined library with a copy of the same work based
137 | on the Library, uncombined with any other library facilities,
138 | conveyed under the terms of this License.
139 |
140 | b) Give prominent notice with the combined library that part of it
141 | is a work based on the Library, and explaining where to find the
142 | accompanying uncombined form of the same work.
143 |
144 | 6. Revised Versions of the GNU Lesser General Public License.
145 |
146 | The Free Software Foundation may publish revised and/or new versions
147 | of the GNU Lesser General Public License from time to time. Such new
148 | versions will be similar in spirit to the present version, but may
149 | differ in detail to address new problems or concerns.
150 |
151 | Each version is given a distinguishing version number. If the
152 | Library as you received it specifies that a certain numbered version
153 | of the GNU Lesser General Public License "or any later version"
154 | applies to it, you have the option of following the terms and
155 | conditions either of that published version or of any later version
156 | published by the Free Software Foundation. If the Library as you
157 | received it does not specify a version number of the GNU Lesser
158 | General Public License, you may choose any version of the GNU Lesser
159 | General Public License ever published by the Free Software Foundation.
160 |
161 | If the Library as you received it specifies that a proxy can decide
162 | whether future versions of the GNU Lesser General Public License shall
163 | apply, that proxy's public statement of acceptance of any version is
164 | permanent authorization for you to choose that version for the
165 | Library.
166 |
--------------------------------------------------------------------------------
/lib/WebConfig/README.md:
--------------------------------------------------------------------------------
1 | # WebConfig
2 |
3 | This Arduino Library works with ESP8266 and ESP32
4 |
5 | It allows to edit configuration data by a web form. The configuration data will be storde in the SPIFFS and can be reloades from there.
6 | The web form can be free formatted using JSON.
7 | If you start an AccessPoint, you can use WebConfig to edit access information for the local Network
8 |
9 | ## Constants:
10 |
11 | maximum number of parameters
12 | **MAXVALUES 20**
13 |
14 | maximum number of options per parameters
15 | **MAXOPTIONS 15**
16 |
17 | name for the config file
18 | **CONFFILE "/WebConf.conf"**
19 |
20 | Type of HTML input fields
21 | - INPUTTEXT 0 Simple text input
22 | - INPUTPASSWORD 1 Password input showing stars
23 | - INPUTNUMBER 2 Numeric input
24 | - INPUTDATE 3 Date input
25 | - INPUTTIME 4 Time input
26 | - INPUTRANGE 5 Slider
27 | - INPUTCHECKBOX 6 Checkbox
28 | - INPUTRADIO 7 Radio buttons
29 | - INPUTSELECT 8 Drop down list
30 | - INPUTCOLOR 9 Color picker
31 | - INPUTFLOAT 10 Floatingpoint number
32 | - INPUTTEXTAREA 11 Text area with multiple lines
33 | - INPUTMULTICHECK 12 Fieldset with multiple checkboxes. The result string has one character
34 | 0 or 1 for every option. 010010 means there are 6 options and option 2 and 5 are true
35 |
36 | ## Functions
37 |
38 | **void setDescription(String parameter);**
39 |
40 | load form descriptions create the internal structure from JSON String, delete existing entries
41 |
42 | **void addDescription(String parameter);**
43 |
44 | add more form descriptions from JSON String
45 |
46 | **void handleFormRequest(WebServer * server, const char * filename);**
47 |
48 | function to respond a HTTP request for the form use the filename
49 | to save.
50 |
51 | **void handleFormRequest(WebServer * server);**
52 |
53 | function to respond a HTTP request for the form use the default filename
54 | to save
55 |
56 | **int16_t getIndex(const char * name);**
57 |
58 | get the index for a value by parameter name
59 |
60 | **boolean readConfig(const char * filename);**
61 |
62 | read configuration from file with filename
63 |
64 | **boolean readConfig();**
65 |
66 | read configuration from file with default filename
67 |
68 | **boolean writeConfig(const char * filename);**
69 |
70 | write configuration to file with filename
71 |
72 | **boolean writeConfig();**
73 |
74 | write configuration to file with default filename
75 |
76 | **boolean deleteConfig(const char * filename);**
77 |
78 | delete configuration file with filename
79 |
80 | **boolean deleteConfig();**
81 |
82 | delete configutation file with default filename
83 |
84 | **const String getString(const char * name);**
85 |
86 | get a parameter value as String by its name
87 |
88 | **const char * getValue(const char * name);**
89 |
90 | get a parameter value as pointer to character array by its name
91 |
92 | **const int getInt(const char * name);**
93 |
94 | get a parameter value as integer by its name
95 |
96 | **const float getFloat(const char * name);**
97 |
98 | get a parameter value as floating point number by its name
99 |
100 | **const boolean getBool(const char * name);**
101 |
102 | get a parameter value as boolean by its name
103 |
104 | **const char * getApName();**
105 |
106 | get the accesspoint name
107 |
108 | **uint8_t getCount();**
109 |
110 | get the number of parameters
111 |
112 | **String getName(uint8_t index);**
113 |
114 | get the name of the parameter with index
115 |
116 | **String values\[MAXVALUES\];**
117 |
118 | direkt access to the parameter values
119 |
120 | **String getResults();**
121 |
122 | get the values for all fields in a JSON formatted string
123 |
124 | **void setValues(String json);**
125 |
126 | preset the values for all fields out of a JSON formatted string
127 |
128 | **void setValue(const char * name,String value);**
129 |
130 | set the value of the field named name with the value from value
131 |
132 | **void setLabel(const char * name, const char* label);**
133 |
134 | set the label for the field named name with the value from label
135 |
136 | **void clearOptions(uint8_t index);**
137 |
138 | remove all options for the selection field with index index
139 |
140 | **void clearOptions(const char * name);**
141 |
142 | remove all options for the selection field with name name
143 |
144 | **void addOption(uint8_t index, String option);**
145 |
146 | add an option to the selection field with index index. The value from parameter option is uesd for label and value
147 |
148 | **void addOption(uint8_t index, String option, String label);**
149 |
150 | add an option to the selection field with index index. The value from parameter option is uesd for the value and the value from parameter label is used for the label
151 |
152 | **void setOption(uint8_t index, uint8_t option_index, String option, String label);**
153 |
154 | modify an option in the selection field with index index. The option with index option_index gets the value from parameter option and the label from parameter label
155 |
156 | **void setOption(char * name, uint8_t option_index, String option, String label);**
157 |
158 | modify an option in the selection field with name name. The option with index option_index gets the value from parameter option and the label from parameter label
159 |
160 | **uint8_t getOptionCount(uint8_t index);**
161 |
162 | returns the number of options in the selection field with index index
163 |
164 | **uint8_t getOptionCount(char * name);**
165 |
166 | returns the number of options in the selection field with name name
167 |
168 | **void setButtons(uint8 buttons);**
169 |
170 | set the type of form. With BTN_CONFIG (0) the configuration mode will be set. This form is typical used to setup WiFi access. The form has two buttons "SAVE" and "RESTART". Modifications will be saved to SPIFFS automatically. With BTN_DONE (1), BTN_CANCEL (2) and BTN_DELETE (4) simple forms will be shown, without automatic saving. The form gets the specified Buttons. The buttons can be combined. So BTN_DONE+BTN_CANCEL+BTN_DELETE shows all three buttons. To react on button clicks, callback functions can be registered.
171 |
172 | **void registerOnSave(void (\*callback)(String results));**
173 |
174 | this function will be called after the "SAVE" button was clicked. The parameter results holds a JSON formatted string with the values from all fields.
175 |
176 | **void registerOnDone(void (\*callback)(String results));**
177 |
178 | this function will be called after the "DONE" button was clicked. The parameter results holds a JSON formatted string with the values from all fields.
179 |
180 | **void registerOnCancel(void (\*callback)());**
181 |
182 | this function will be called after the "CANCEL" button was clicked.
183 |
184 | **void registerOnDelete(void (\*callback)(String name));**
185 |
186 | this function will be called after the "DELETE" button was clicked. The parameter name holds the value of the field named "name" if such a field exists.
187 |
188 | ## Parameter definition with JSON
189 |
190 | \[{
191 | "name":"",
192 | "label":"",
193 | "type":0,
194 | "default":""
195 | "min":0,
196 | "max":0,
197 | "options":\[
198 | {"v":"","":""}
199 | \]
200 | }\]
201 |
202 | **name** String
203 | The name of the Parameter. This name will be used to save the parameter in the configuration file. It is also used to access the values.
204 |
205 | **label** String
206 | Defines the label for the web form
207 |
208 | **type** Integer
209 | Type of the HTML input element
210 | - INPUTTEXT Texteingabefeld
211 | - INPUTPASSWORD Passwort Eingabefeld
212 | - INPUTNUMBER Nummern Eingabefeld
213 | - INPUTDATE Datums Eingabefeld
214 | - INPUTTIME Zeit Eingabefeld
215 | - INPUTRANGE Slider zur Nummerneingabe
216 | - INPUTCHECKBOX Ja/Nein Auswahl
217 | - INPUTRADIO Mehrfachauswahl
218 | - INPUTSELECT Mehrfachauswahl aus Dropdown-Liste
219 | - INPUTCOLOR Farbauswahl
220 | - INPUTFLOAT Fließkommazahl
221 | - INPUTTEXTAREA Mehrzeiliges Textfeld
222 | - INPUTMULTICHECK Mehrere Checkboxen
223 |
224 | **default** String
225 | default value
226 |
227 | **min** Integer (optional)
228 | Minimum value for number input or columns for test area
229 |
230 | **max** Integer (optional)
231 | Maximum value for number input or rows for text area
232 |
233 | **options** List of objects (optional)
234 | A list to define options and values for multi select input fields on multi checkboxes the option name is used as label
235 |
236 |
237 | #### Example defines a JSON String with all types of input fields
238 |
239 | String params = "\["
240 | "{"
241 | "'name':'ssid',"
242 | "'label':'WLAN name',"
243 | "'type':"+String(INPUTTEXT)+","
244 | "'default':''"
245 | "},"
246 | "{"
247 | "'name':'area',"
248 | "'label':'Textarea',"
249 | "'type':"+String(INPUTTEXTAREA)+","
250 | "'default':'',"
251 | "'min':40,'max':5" //min = columns max = rows
252 | "},"
253 | "{"
254 | "'name':'pwd',"
255 | "'label':'WLAN Password',"
256 | "'type':"+String(INPUTPASSWORD)+","
257 | "'default':''"
258 | "},"
259 | "{"
260 | "'name':'amount',"
261 | "'label':'Amount',"
262 | "'type':"+String(INPUTNUMBER)+","
263 | "'min':-10,'max':20,"
264 | "'default':'1'"
265 | "},"
266 | "{"
267 | "'name':'float',"
268 | "'label':'Floatingpoint number',"
269 | "'type':"+String(INPUTTEXT)+","
270 | "'default':'1.00'"
271 | "},"
272 | "{"
273 | "'name':'duration',"
274 | "'label':'Duration (s)',"
275 | "'type':"+String(INPUTRANGE)+","
276 | "'min':5,'max':30,"
277 | "'default':'10'"
278 | "},"
279 | "{"
280 | "'name':'date',"
281 | "'label':'Date',"
282 | "'type':"+String(INPUTDATE)+","
283 | "'default':'2019-08-14'"
284 | "},"
285 | "{"
286 | "'name':'time',"
287 | "'label':'Time',"
288 | "'type':"+String(INPUTTIME)+","
289 | "'default':'18:30'"
290 | "},"
291 | "{"
292 | "'name':'col',"
293 | "'label':'Color',"
294 | "'type':"+String(INPUTCOLOR)+","
295 | "'default':'#ffffff'"
296 | "},"
297 | "{"
298 | "'name':'switch',"
299 | "'label':'Switch',"
300 | "'type':"+String(INPUTCHECKBOX)+","
301 | "'default':'1'"
302 | "},"
303 | "{"
304 | "'name':'gender',"
305 | "'label':'Gender',"
306 | "'type':"+String(INPUTRADIO)+","
307 | "'options':\["
308 | "{'v':'m','l':'male'},"
309 | "{'v':'f','l':'female'},"
310 | "{'v':'o','l':'other'}\],"
311 | "'default':'f'"
312 | "},"
313 | "{"
314 | "'name':'continent',"
315 | "'label':'Continent',"
316 | "'type':"+String(INPUTSELECT)+","
317 | "'options':\["
318 | "{'v':'EU','l':'Europe'},"
319 | "{'v':'AF','l':'Africa'},"
320 | "{'v':'AS','l':'Asia'},"
321 | "{'v':'AU','l':'Australia'},"
322 | "{'v':'AM','l':'America'}\],"
323 | "'default':'AM'"
324 | "},"
325 | "{"
326 | "'name':'wochentag',"
327 | "'label':'Wochentag',"
328 | "'type':"+String(INPUTMULTICHECK)+","
329 | "'options':["
330 | "{'v':'0','l':'Sonntag'},"
331 | "{'v':'1','l':'Montag'},"
332 | "{'v':'2','l':'Dienstag'},"
333 | "{'v':'3','l':'Mittwoch'},"
334 | "{'v':'4','l':'Donnerstag'},"
335 | "{'v':'5','l':'Freitag'},"
336 | "{'v':'6','l':'Samstag'}],"
337 | "'default':''"
338 | "}"
339 | "\]";
340 |
--------------------------------------------------------------------------------
/lib/WebConfig/examples/demo32/demo32.ino:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 |
5 | #include
6 |
7 | String params = "["
8 | "{"
9 | "'name':'ssid',"
10 | "'label':'Name des WLAN',"
11 | "'type':"+String(INPUTTEXT)+","
12 | "'default':''"
13 | "},"
14 | "{"
15 | "'name':'pwd',"
16 | "'label':'WLAN Passwort',"
17 | "'type':"+String(INPUTPASSWORD)+","
18 | "'default':''"
19 | "},"
20 | "{"
21 | "'name':'amount',"
22 | "'label':'Menge',"
23 | "'type':"+String(INPUTNUMBER)+","
24 | "'min':-10,'max':20,"
25 | "'default':'1'"
26 | "},"
27 | "{"
28 | "'name':'float',"
29 | "'label':'Fließkomma Zahl',"
30 | "'type':"+String(INPUTTEXT)+","
31 | "'default':'1.00'"
32 | "},"
33 | "{"
34 | "'name':'area',"
35 | "'label':'Mehr Text',"
36 | "'type':"+String(INPUTTEXTAREA)+","
37 | "'default':'',"
38 | "'min':40,'max':5" //min = columns max = rows
39 | "},"
40 | "{"
41 | "'name':'duration',"
42 | "'label':'Dauer(s)',"
43 | "'type':"+String(INPUTRANGE)+","
44 | "'min':5,'max':30,"
45 | "'default':'10'"
46 | "},"
47 | "{"
48 | "'name':'date',"
49 | "'label':'Datum',"
50 | "'type':"+String(INPUTDATE)+","
51 | "'default':'2019-08-14'"
52 | "},"
53 | "{"
54 | "'name':'time',"
55 | "'label':'Zeit',"
56 | "'type':"+String(INPUTTIME)+","
57 | "'default':'18:30'"
58 | "},"
59 | "{"
60 | "'name':'col',"
61 | "'label':'Farbe',"
62 | "'type':"+String(INPUTCOLOR)+","
63 | "'default':'#ffffff'"
64 | "},"
65 | "{"
66 | "'name':'switch',"
67 | "'label':'Schalter',"
68 | "'type':"+String(INPUTCHECKBOX)+","
69 | "'default':'1'"
70 | "},"
71 | "{"
72 | "'name':'gender',"
73 | "'label':'Geschlecht',"
74 | "'type':"+String(INPUTRADIO)+","
75 | "'options':["
76 | "{'v':'m','l':'männlich'},"
77 | "{'v':'w','l':'weiblich'},"
78 | "{'v':'x','l':'anderes'}],"
79 | "'default':'w'"
80 | "},"
81 | "{"
82 | "'name':'continent',"
83 | "'label':'Kontinent',"
84 | "'type':"+String(INPUTSELECT)+","
85 | "'options':["
86 | "{'v':'EU','l':'Europa'},"
87 | "{'v':'AF','l':'Afrika'},"
88 | "{'v':'AS','l':'Asien'},"
89 | "{'v':'AU','l':'Australien'},"
90 | "{'v':'AM','l':'Amerika'}],"
91 | "'default':'AM'"
92 | "},"
93 | "{"
94 | "'name':'wochentag',"
95 | "'label':'Wochentag',"
96 | "'type':"+String(INPUTMULTICHECK)+","
97 | "'options':["
98 | "{'v':'0','l':'Sonntag'},"
99 | "{'v':'1','l':'Montag'},"
100 | "{'v':'2','l':'Dienstag'},"
101 | "{'v':'3','l':'Mittwoch'},"
102 | "{'v':'4','l':'Donnerstag'},"
103 | "{'v':'5','l':'Freitag'},"
104 | "{'v':'6','l':'Samstag'}],"
105 | "'default':''"
106 | "}"
107 | "]";
108 |
109 | WebServer server;
110 | WebConfig conf;
111 |
112 | boolean initWiFi() {
113 | boolean connected = false;
114 | WiFi.mode(WIFI_STA);
115 | Serial.print("Verbindung zu ");
116 | Serial.print(conf.values[0]);
117 | Serial.println(" herstellen");
118 | if (conf.values[0] != "") {
119 | WiFi.begin(conf.values[0].c_str(),conf.values[1].c_str());
120 | uint8_t cnt = 0;
121 | while ((WiFi.status() != WL_CONNECTED) && (cnt<20)){
122 | delay(500);
123 | Serial.print(".");
124 | cnt++;
125 | }
126 | Serial.println();
127 | if (WiFi.status() == WL_CONNECTED) {
128 | Serial.print("IP-Adresse = ");
129 | Serial.println(WiFi.localIP());
130 | connected = true;
131 | }
132 | }
133 | if (!connected) {
134 | WiFi.mode(WIFI_AP);
135 | WiFi.softAP(conf.getApName(),"",1);
136 | }
137 | return connected;
138 | }
139 |
140 | void handleRoot() {
141 | conf.handleFormRequest(&server);
142 | if (server.hasArg("SAVE")) {
143 | uint8_t cnt = conf.getCount();
144 | Serial.println("*********** Konfiguration ************");
145 | for (uint8_t i = 0; i
2 | #include
3 | #include
4 |
5 |
6 | #include
7 |
8 | String params = "["
9 | "{"
10 | "'name':'ssid',"
11 | "'label':'Name des WLAN',"
12 | "'type':"+String(INPUTTEXT)+","
13 | "'default':''"
14 | "},"
15 | "{"
16 | "'name':'pwd',"
17 | "'label':'WLAN Passwort',"
18 | "'type':"+String(INPUTPASSWORD)+","
19 | "'default':''"
20 | "},"
21 | "{"
22 | "'name':'amount',"
23 | "'label':'Menge',"
24 | "'type':"+String(INPUTNUMBER)+","
25 | "'min':-10,'max':20,"
26 | "'default':'1'"
27 | "},"
28 | "{"
29 | "'name':'float',"
30 | "'label':'Fließkomma Zahl',"
31 | "'type':"+String(INPUTTEXT)+","
32 | "'default':'1.00'"
33 | "},"
34 | "{"
35 | "'name':'area',"
36 | "'label':'Mehr Text',"
37 | "'type':"+String(INPUTTEXTAREA)+","
38 | "'default':'',"
39 | "'min':40,'max':5" //min = columns max = rows
40 | "},"
41 | "{"
42 | "'name':'duration',"
43 | "'label':'Dauer(s)',"
44 | "'type':"+String(INPUTRANGE)+","
45 | "'min':5,'max':30,"
46 | "'default':'10'"
47 | "},"
48 | "{"
49 | "'name':'date',"
50 | "'label':'Datum',"
51 | "'type':"+String(INPUTDATE)+","
52 | "'default':'2019-08-14'"
53 | "},"
54 | "{"
55 | "'name':'time',"
56 | "'label':'Zeit',"
57 | "'type':"+String(INPUTTIME)+","
58 | "'default':'18:30'"
59 | "},"
60 | "{"
61 | "'name':'col',"
62 | "'label':'Farbe',"
63 | "'type':"+String(INPUTCOLOR)+","
64 | "'default':'#ffffff'"
65 | "},"
66 | "{"
67 | "'name':'switch',"
68 | "'label':'Schalter',"
69 | "'type':"+String(INPUTCHECKBOX)+","
70 | "'default':'1'"
71 | "},"
72 | "{"
73 | "'name':'gender',"
74 | "'label':'Geschlecht',"
75 | "'type':"+String(INPUTRADIO)+","
76 | "'options':["
77 | "{'v':'m','l':'männlich'},"
78 | "{'v':'w','l':'weiblich'},"
79 | "{'v':'x','l':'anderes'}],"
80 | "'default':'w'"
81 | "},"
82 | "{"
83 | "'name':'continent',"
84 | "'label':'Kontinent',"
85 | "'type':"+String(INPUTSELECT)+","
86 | "'options':["
87 | "{'v':'EU','l':'Europa'},"
88 | "{'v':'AF','l':'Afrika'},"
89 | "{'v':'AS','l':'Asien'},"
90 | "{'v':'AU','l':'Australien'},"
91 | "{'v':'AM','l':'Amerika'}],"
92 | "'default':'AM'"
93 | "},"
94 | "{"
95 | "'name':'wochentag',"
96 | "'label':'Wochentag',"
97 | "'type':"+String(INPUTMULTICHECK)+","
98 | "'options':["
99 | "{'v':'0','l':'Sonntag'},"
100 | "{'v':'1','l':'Montag'},"
101 | "{'v':'2','l':'Dienstag'},"
102 | "{'v':'3','l':'Mittwoch'},"
103 | "{'v':'4','l':'Donnerstag'},"
104 | "{'v':'5','l':'Freitag'},"
105 | "{'v':'6','l':'Samstag'}],"
106 | "'default':''"
107 | "}"
108 | "]";
109 |
110 | ESP8266WebServer server;
111 | WebConfig conf;
112 |
113 | boolean initWiFi() {
114 | boolean connected = false;
115 | WiFi.mode(WIFI_STA);
116 | Serial.print("Verbindung zu ");
117 | Serial.print(conf.values[0]);
118 | Serial.println(" herstellen");
119 | if (conf.values[0] != "") {
120 | WiFi.begin(conf.values[0].c_str(),conf.values[1].c_str());
121 | uint8_t cnt = 0;
122 | while ((WiFi.status() != WL_CONNECTED) && (cnt<20)){
123 | delay(500);
124 | Serial.print(".");
125 | cnt++;
126 | }
127 | Serial.println();
128 | if (WiFi.status() == WL_CONNECTED) {
129 | Serial.print("IP-Adresse = ");
130 | Serial.println(WiFi.localIP());
131 | connected = true;
132 | }
133 | }
134 | if (!connected) {
135 | WiFi.mode(WIFI_AP);
136 | WiFi.softAP(conf.getApName(),"",1);
137 | }
138 | return connected;
139 | }
140 |
141 | void handleRoot() {
142 | conf.handleFormRequest(&server);
143 | if (server.hasArg("SAVE")) {
144 | uint8_t cnt = conf.getCount();
145 | Serial.println("*********** Konfiguration ************");
146 | for (uint8_t i = 0; i
20 | #include
21 | #if defined(ESP32)
22 | #include "SPIFFS.h"
23 | #include
24 | #else
25 | #include
26 | #endif
27 | #include
28 | #include
29 |
30 | const char *inputtypes[] = {"text", "password", "number", "date", "time", "range", "check", "radio", "select", "color", "float"};
31 |
32 | // HTML templates
33 | // Template for header and begin of form
34 | const char HTML_START[] PROGMEM =
35 | "\n"
36 | "\n"
37 | "\n"
38 | "\n"
39 | "\n"
40 | "Konfiguration\n"
41 | "\n"
67 | "\n"
68 | "\n"
69 | "