You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The web server is configured in the library, which sends webmord files when entering the IP board.Webmord files are sewn in the Progmem (to the program code) in binary form - you do not need to upload files to FS, everything works out of the box.A light html file is loaded each time, and scripts and styles are cramped by a browser to speed up loading.In fact, they are loaded once after updating the library.Webmord is a web application that communicates with the HTTP board.When loading, it requests a package with widgets and other information at the board, the package has a binary json format.
74
76
75
-
### Database
76
-
The library is integrated with [gyverdb] (https://github.com/gyverlibs/gyverdb) - a relatively quick database for storing data from any type.Settings automatically reads and updates the data in the database, so it is recommended to study how to work with the database on the description page Gyverdb.When using Gyverdbfile, the database will automatically write to the file with changes, and the file system will take care of the optimal wear of the Flash memory.When starting, it is recommended to initialize the database by indicating the keys and the corresponding initial values and types.These values will be recorded only in thatCranberry, if the recording in the database does not yet exist.At the same time, the automatic renewal of the database works only for existing records, i.e.Settings will only work with nourishing cells and will not create new ones.Minimum example:
77
+
## Captive Portal
78
+
In all three server implementations, the DNS is configured to work as Captive Portal - if the ESP operates in access point (AP or AP_STA), then when connecting to the point, the browser window with the settings page will automatically open.
79
+
80
+
### database
81
+
The library is integrated with [gyverdb] (https://github.com/gyverlibs/gyverdb) - a relatively quick database for storing data from any type.Settings automatically reads and updates the data in the database, soCranberries are mental to study how to work with a database on the description page Gyverdb.When using Gyverdbfile, the database will automatically write to the file with changes, and the file system will take care of the optimal wear of the Flash memory.When starting, it is recommended to initialize the database by indicating the keys and the corresponding initial values and types.These values will be recorded only if the recording in the database does not yet exist.At the same time, the automatic renewal of the database works only for existing records, i.e.Settings will only work with nourishing cells and will not create new ones.Minimum example:
77
82
`` `CPP
78
83
// connect libraries and create databases and settings
79
84
#include <gyverdbfile.h>
@@ -133,8 +138,10 @@ sett.tick ();
133
138
}
134
139
`` `
135
140
136
-
## Mayer
137
-
The package is assembled by a build in a builder - a function in a program that is called when a request from webmord comes.Inside the builder, you need to call the components in the order in which they should be in webmord.Calling the component adds information about it to the package.At this stage, the value is also reading for the widget according to its ID from the database, if it is connected and the value is not indicated clearly.
141
+
## biller
142
+
The package is assembled by a build in a builder - a function in a program that is called when a request from webmord comes.Inside the builder, you need to call the components in the order in which they should be in webmord.Calling the component adds information about it to the package.At this stage, the value is also reading for the widget according to its ID from the database, if it is connected and *the value is not indicated explicitly *.
143
+
144
+
> If you need the parameter to be read from the database, but you need to specify the argument after it - the value must be specified `Text ()` as it is made in the default function.For example, color for Label `B.Label (Key," Label! ", Text (), sets :: colors :: Mint);`.If you specify an empty line (`B.Label (Key," Label! "," ", Sets :: colors :: Mint);`) - an empty line will go as a value, i.e.The value is not from the database.
138
145
139
146
`` `CPP
140
147
Gyverdb DB;
@@ -175,8 +182,8 @@ Serial.println (B.Build (). Value ());
175
182
`` `
176
183
177
184
### containers
178
-
Widgets can be combined into containers.The container must be started and finished, since the data package is assembled linearly in order to optimize speed and memory.The Begin Container method will always return True for the beauty of the organization of code in the Condition block:
179
-
```CPP
185
+
Widgets can be combined into containers.The container must be started and finished, since the data package is assembled linearly in order to optimize speed and memory.The `begin -stagnant method will always return True for the beauty of the organization of code in the conditions:
You can create an invested menu.The specified title will be displayed on the button and in the page heading at the entrance to the menu.All widgets and groups located in the block with the menu will be on a separate page.The nuclearment of the menu is unlimited.
Webmord monitors the status of the device, with a communication loss, the Offline text will appear in the page title.After losing the connection, webmord will request information about widgets, this is very convenient when developing - for example, add a widget, load the firmware.During this time, webmord already understands that the device is offline and with the first successful connection, it displays relevant widgets.When changing the values of webmord widgets, he also monitors the delivery of the package, when the communication error will appear the inscription error in the corresponding widget.
250
258
259
+
### Authorization
260
+
The system provides for authorization: if in the firmware, indicate the password different from the empty line - webmord will work in the “guest” mode: only widgets allowed to guests are displayed, the file manager and OTA are hidden and blocked.To enter the password, you need to go to the menu (right upper button) and press on the key.The gray key means that the authorization is disabled, the green is authorized, red - the wrong password.The password can contain any characters and have any length - in explicitly it is not stored and not transmitted.The password is stored in the browser and the authorization works automatically when the page reloads.
261
+
262
+
The Guest virtual container is provided for the separation of admin and guest access.If the password is installed and the client is not authorized, he will only see widgets from guest containers.For the correct operation, the guest container should not be interrupted by conventional containers.Example:
Settings (const string & title = "", gyverdb* db = nullptr);
260
296
297
+
// Install the password on the webmord.Empty line "" to turn off
298
+
Void setpass (Text Pass);
299
+
300
+
// Reload page.Can be called anywhere + in the update processor
301
+
VOID RELOAD ();
302
+
261
303
// Install page title
262
304
VOID settitle (Constation String & Title);
263
305
@@ -285,46 +327,111 @@ VOID Tick ();
285
327
// Info about build
286
328
Build Build ();
287
329
288
-
// Reload page
330
+
// Reload page (call in action)
289
331
VOID RELOAD ();
290
332
291
333
// containers
334
+
// allow unauthorized customers the following code
335
+
Bool Betinguest ();
336
+
337
+
// prohibit non -authorized customers
338
+
VOID Enguest ();
339
+
340
+
// group
292
341
Bool BeginGroup (Text Title = Text ());
293
342
VOID EndGroup ();
294
343
344
+
// Bethered menu
295
345
Bool Beginmenu (Text Title);
296
346
VOID ENDMENU ();
297
347
348
+
// Row buttons
298
349
Bool Beginbuttons ();
299
350
VOID Endbuttons ();
300
351
301
-
// Passive widgets
352
+
// Widgets
353
+
// Passive
354
+
// multi -line text
302
355
VOID Paragraph (Size_T ID, Text Label, Text Text = Text ());
356
+
357
+
// Text value
303
358
Void Label (Size_T ID, Text Label, Text Text = Text (), Uint32_T Color = Sets_default_color);
304
359
Void Label (Size_t ID, Text Label, Text Text, Sets :: Colors Color);
305
360
306
-
// Active widgets
361
+
// without ID
362
+
Void Label (Text Label, Text Text = Text (), Uint32_t Color = Sets_default_color);
363
+
Void Label (Text Label, Text Text, Sets :: Colors Color);
364
+
365
+
// LED (turned on - green, turned off - red)
366
+
VOID LED (SIZE_T ID, Text Label, Bool Value);
367
+
VOID LED (Text Label, Bool Value);
368
+
369
+
// Active
370
+
// Entering text and numbers
307
371
Bool Input (Size_T ID, Text Label, Text Value = Text ());
372
+
373
+
// Password entering
374
+
// you can install a "plug" for a password, for example "***" so that the password does not display in the browser
308
375
Bool Pass (Size_T ID, Text Label, Text Value = Text ());
376
+
377
+
// Input of color, the result in the usual 24-bit format
309
378
Bool Color (Size_T ID, Text Label, Text Value = Text ());
379
+
380
+
// switch, result 1/0
310
381
Bool Switch (Size_T ID, Text Label, Text Value = Text ());
382
+
383
+
// Date, result in unix seconds
311
384
Bool Date (Size_T ID, Text Label, Text Value = Text ());
312
-
Bool Time (Size_T ID, Text Label, Text Value = Text ());
385
+
386
+
// Date and time, result in UNIX seconds
313
387
Bool DateTime (Size_T ID, Text Label, Text Value = Text ());
314
-
Bool Slider (Size_T ID, Text Label, Float Min =0, Float Max = 100, Float Step = 1, Text Unit = Text (), Text Value = Text ());
388
+
389
+
// Time, result in seconds from the beginning of the day
390
+
Bool Time (Size_T ID, Text Label, Text Value = Text ());
391
+
392
+
// Slider
393
+
Bool Slider (Size_t ID, Text Label, Float Min = 0, Float Max = 100, Float Step = 1, Text Unit = Text (), Text Value = Text ());
315
394
316
395
// button can be added both inside the buttons container, and as a single widget
317
396
Bool Button (Size_T ID, Text Label, Uint32_T Color = Sets_default_color);
318
397
Bool Button (Size_T ID, Text Label, Sets :: Colors Color);
319
398
320
-
// options are divided;
399
+
// list of choice, options in the form of text are separated;
321
400
Bool Select (Size_T ID, Text Label, Text Options, Text Value = Text ());
322
401
323
-
// For activation, send an empty update to its ID
402
+
// Confirmation window, for activation, send an empty update to its ID
324
403
Bool Confirm (Size_T ID, Text Label);
325
404
`` `
326
405
327
-
Here `Text` is a universal text format, takes lines in any form.When indicating `value`, its value will be sent different from the standard.Otherwise, the value from the database will be sent if it is connected.If you need the value of the number - use the `value` designer, for example` B.color ("color", "color", value (my_color)); `where` my_color` is `uint32_t`.
406
+
Here `Text` is a universal text format, takes lines in any form.When indicating `value`, its value will be sent different from the standard.Otherwise, the value from the database will be sent if it is connected.If you need a value as a value - use the constructor `vaLue`, for example `B.color (" color "," color ", value (my_color));` where `my_color` is` uint32_t`.
407
+
408
+
### Build
409
+
Info about build
410
+
`` `CPP
411
+
// Client is authorized (or password is not indicated, i.e. all admins)
412
+
Bool ISGranted ();
413
+
414
+
// ID widget (action)
415
+
size_t id ();
416
+
417
+
// Widget value (action)
418
+
Text & Value ();
419
+
`` `
420
+
421
+
### containers
422
+
`` `CPP
423
+
// Guest access container
424
+
Class guestaccess (Builder & B);
425
+
426
+
// Container group of widgets
427
+
Class Group (Builder & B, Text Title = Text ());
428
+
429
+
// container of an invested menu
430
+
Class Menu (Builder & B, Text Title);
431
+
432
+
// Container buttons
433
+
Class Buttons (Builder & B);
434
+
`` `
328
435
329
436
## updater
330
437
`` `CPP
@@ -337,8 +444,8 @@ VOID update (Size_T ID, Text Value);
337
444
// update with Float
338
445
VOID update (Size_t ID, Float Value, Uint8_t Dec = 2);
0 commit comments