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
dea00172
Commit
dea00172
authored
May 16, 2021
by
Eric Duminil
Browse files
Trying to add more config
parent
d1730e23
Changes
2
Hide whitespace changes
Inline
Side-by-side
ampel-firmware/web_config.cpp
View file @
dea00172
...
...
@@ -17,19 +17,34 @@ namespace web_config {
IotWebConf
*
iotWebConf
;
// -- Configuration specific key. The value should be modified if config structure was changed.
const
char
config_version
[]
=
"ampel_test_v
3
"
;
const
char
config_version
[]
=
"ampel_test_v
4
"
;
static
const
char
chooserValues
[][
STRING_LEN
]
=
{
"red"
,
"blue"
,
"darkYellow"
};
static
const
char
chooserNames
[][
STRING_LEN
]
=
{
"Red"
,
"Blue"
,
"Dark yellow"
};
iotwebconf
::
ParameterGroup
group1
=
iotwebconf
::
ParameterGroup
(
"group1"
,
""
);
iotwebconf
::
IntTParameter
<
int16_t
>
intParam
=
iotwebconf
::
Builder
<
iotwebconf
::
IntTParameter
<
int16_t
>>
(
"intParam"
).
label
(
"Int param"
).
defaultValue
(
30
).
min
(
1
).
max
(
100
).
step
(
1
).
placeholder
(
"1..100"
).
build
();
// -- We can add a legend to the separator
iotwebconf
::
ParameterGroup
serviceParams
=
iotwebconf
::
ParameterGroup
(
"Services"
,
"Services"
);
iotwebconf
::
CheckboxTParameter
ampelWifiParam
=
iotwebconf
::
Builder
<
iotwebconf
::
CheckboxTParameter
>
(
"WiFi"
).
label
(
"WiFi"
).
defaultValue
(
true
).
build
();
iotwebconf
::
CheckboxTParameter
ampelCSVParam
=
iotwebconf
::
Builder
<
iotwebconf
::
CheckboxTParameter
>
(
"CSV"
).
label
(
"CSV"
).
defaultValue
(
true
).
build
();
iotwebconf
::
CheckboxTParameter
ampelMQTTParam
=
iotwebconf
::
Builder
<
iotwebconf
::
CheckboxTParameter
>
(
"MQTT"
).
label
(
"MQTT"
).
defaultValue
(
true
).
build
();
iotwebconf
::
CheckboxTParameter
ampelLoRaWANParam
=
iotwebconf
::
Builder
<
iotwebconf
::
CheckboxTParameter
>
(
"LoRaWAN"
).
label
(
"LoRaWAN"
).
defaultValue
(
false
).
build
();
iotwebconf
::
ParameterGroup
co2Params
=
iotwebconf
::
ParameterGroup
(
"co2"
,
"CO2 Sensor"
);
//TODO: UIntTParameter?
iotwebconf
::
IntTParameter
<
uint16_t
>
timestepParam
=
iotwebconf
::
Builder
<
iotwebconf
::
IntTParameter
<
uint16_t
>>
(
"timestep"
).
label
(
"Measurement timestep"
).
defaultValue
(
MEASUREMENT_TIMESTEP
).
min
(
2
).
max
(
1800
).
step
(
1
).
placeholder
(
"2..1800"
).
build
();
iotwebconf
::
FloatTParameter
temperatureOffsetParam
=
iotwebconf
::
Builder
<
iotwebconf
::
FloatTParameter
>
(
"temp_offset"
).
label
(
"Temperature offset"
).
defaultValue
(
TEMPERATURE_OFFSET
).
placeholder
(
"-3"
).
build
();
iotwebconf
::
ParameterGroup
group2
=
iotwebconf
::
ParameterGroup
(
"c_factor"
,
"Calibration factor"
);
iotwebconf
::
FloatTParameter
floatParam
=
iotwebconf
::
Builder
<
iotwebconf
::
FloatTParameter
>
(
"floatParam"
).
label
(
"Float param"
).
defaultValue
(
0.0
).
step
(
0.1
).
placeholder
(
"e.g. 23.4"
).
build
();
iotwebconf
::
CheckboxTParameter
checkboxParam
=
iotwebconf
::
Builder
<
iotwebconf
::
CheckboxTParameter
>
(
"checkParam"
).
label
(
"Check param"
).
defaultValue
(
true
).
build
();
iotwebconf
::
SelectTParameter
<
STRING_LEN
>
chooserParam
=
...
...
@@ -55,14 +70,16 @@ namespace web_config {
void
initialize
()
{
iotWebConf
=
new
IotWebConf
(
ampel
.
sensorId
,
&
dnsServer
,
&
http
,
HTTP_PASSWORD
,
config_version
);
group1
.
addItem
(
&
intParam
);
group2
.
addItem
(
&
floatParam
);
group2
.
addItem
(
&
checkboxParam
);
group2
.
addItem
(
&
chooserParam
);
serviceParams
.
addItem
(
&
ampelWifiParam
);
serviceParams
.
addItem
(
&
ampelMQTTParam
);
serviceParams
.
addItem
(
&
ampelCSVParam
);
serviceParams
.
addItem
(
&
ampelLoRaWANParam
);
co2Params
.
addItem
(
&
timestepParam
);
co2Params
.
addItem
(
&
temperatureOffsetParam
);
iotWebConf
->
addSystemParameter
(
&
config
::
stringParam
);
iotWebConf
->
addParameterGroup
(
&
group1
);
iotWebConf
->
addParameterGroup
(
&
group2
);
iotWebConf
->
addParameterGroup
(
&
serviceParams
);
iotWebConf
->
addParameterGroup
(
&
co2Params
);
sensor_console
::
defineCommand
(
"reset_config"
,
[]()
{
Serial
.
println
(
F
(
"Resetting config..."
));
...
...
ampel-firmware/web_config.h
View file @
dea00172
...
...
@@ -9,7 +9,7 @@
#define STRING_LEN 64
//
#include "config.h"
#include "config.h"
#include <IotWebConf.h>
#include <IotWebConfTParameter.h>
...
...
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