Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
co2ampel
ampel-firmware
Commits
7a1888cf
Commit
7a1888cf
authored
May 15, 2021
by
Eric Duminil
Browse files
Adding parameters as test
parent
f0b9f433
Changes
1
Hide whitespace changes
Inline
Side-by-side
ampel-firmware/web_server.cpp
View file @
7a1888cf
...
...
@@ -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
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment