Commit 7a1888cf authored by Eric Duminil's avatar Eric Duminil
Browse files

Adding parameters as test

parent f0b9f433
......@@ -24,6 +24,7 @@
# include "lorawan.h"
#endif
#include <IotWebConf.h>
#include <IotWebConfUsing.h> // This loads aliases for easier class names.
namespace config {
// Values should be defined in config.h
......@@ -64,12 +65,41 @@ namespace web_server {
IotWebConf *iotWebConf;
#define STRING_LEN 128
#define NUMBER_LEN 32
// -- Configuration specific key. The value should be modified if config structure was changed.
#define CONFIG_VERSION "dem2"
char stringParamValue[STRING_LEN];
char intParamValue[NUMBER_LEN];
char floatParamValue[NUMBER_LEN];
char checkboxParamValue[STRING_LEN];
char chooserParamValue[STRING_LEN];
static char chooserValues[][STRING_LEN] = { "red", "blue", "darkYellow" };
static char chooserNames[][STRING_LEN] = { "Red", "Blue", "Dark yellow" };
IotWebConfTextParameter stringParam = IotWebConfTextParameter("String param", "stringParam", stringParamValue,
STRING_LEN);
IotWebConfParameterGroup group1 = IotWebConfParameterGroup("group1", "");
IotWebConfNumberParameter intParam = IotWebConfNumberParameter("Int param", "intParam", intParamValue, NUMBER_LEN,
"20", "1..100", "min='1' max='100' step='1'");
// -- We can add a legend to the separator
IotWebConfParameterGroup group2 = IotWebConfParameterGroup("c_factor", "Calibration factor");
IotWebConfNumberParameter floatParam = IotWebConfNumberParameter("Float param", "floatParam", floatParamValue,
NUMBER_LEN, NULL, "e.g. 23.4", "step='0.1'");
IotWebConfCheckboxParameter checkboxParam = IotWebConfCheckboxParameter("Check param", "checkParam",
checkboxParamValue, STRING_LEN, true);
IotWebConfSelectParameter chooserParam = IotWebConfSelectParameter("Choose param", "chooseParam", chooserParamValue,
STRING_LEN, (char*) chooserValues, (char*) chooserNames, sizeof(chooserValues) / STRING_LEN, STRING_LEN);
void update() {
iotWebConf->doLoop(); // Listen for HTTP requests from clients
}
void initialize() {
iotWebConf = new IotWebConf(ampel.sensorId, &dnsServer, &http, HTTP_PASSWORD); // So that sensorId is defined.
iotWebConf = new IotWebConf(ampel.sensorId, &dnsServer, &http, HTTP_PASSWORD, "ampel_test_v1");
const int ONBOARD_LED_PIN = 2;
# ifdef ESP8266
......@@ -79,7 +109,20 @@ namespace web_server {
# endif
iotWebConf->setWifiConnectionTimeoutMs(1000UL * WIFI_TIMEOUT);
#if defined(ESP8266)
WiFi.hostname(ampel.sensorId);
#elif defined(ESP32)
WiFi.setHostname(ampel.sensorId);
#endif
group1.addItem(&intParam);
group2.addItem(&floatParam);
group2.addItem(&checkboxParam);
group2.addItem(&chooserParam);
iotWebConf->addSystemParameter(&stringParam);
iotWebConf->addParameterGroup(&group1);
iotWebConf->addParameterGroup(&group2);
iotWebConf->setWifiConnectionCallback([]() {
led_effects::showKITTWheel(color::green);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment