Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
co2ampel
ampel-firmware
Commits
28b9a578
Commit
28b9a578
authored
May 17, 2021
by
Eric Duminil
Browse files
Every parameter defined?
parent
0fe497e8
Changes
1
Hide whitespace changes
Inline
Side-by-side
ampel-firmware/web_config.cpp
View file @
28b9a578
...
...
@@ -22,15 +22,16 @@ namespace web_config {
IotWebConf
*
iotWebConf
;
// -- Configuration specific key. The value should be modified if config structure was changed.
const
char
config_version
[
IOTWEBCONF_CONFIG_VERSION_LENGTH
]
=
"a04"
;
const
char
config_version
[
IOTWEBCONF_CONFIG_VERSION_LENGTH
]
=
"a05"
;
// -- Configuration specific key. The value should be modified if config structure was changed.
using
namespace
iotwebconf
;
/**
*
Service
s
*
WiFi param
s
*/
CheckboxTParameter
ampelWifiParam
=
Builder
<
CheckboxTParameter
>
(
"WiFi"
).
label
(
"WiFi"
).
defaultValue
(
true
).
build
();
IntTParameter
<
uint16_t
>
wifiTimeoutParam
=
Builder
<
IntTParameter
<
uint16_t
>>
(
"wifi_timeout"
).
label
(
"WiFi timeout"
).
defaultValue
(
WIFI_TIMEOUT
).
min
(
0
).
placeholder
(
"[s]"
).
build
();
//TODO: Distribute to corresponding classes, possibly with callbacks?
/**
...
...
@@ -41,29 +42,51 @@ namespace web_config {
//TODO: UIntTParameter?
IntTParameter
<
uint16_t
>
timestepParam
=
Builder
<
IntTParameter
<
uint16_t
>>
(
"timestep"
).
label
(
"Measurement timestep"
).
defaultValue
(
MEASUREMENT_TIMESTEP
).
min
(
2
).
max
(
1800
).
step
(
1
).
placeholder
(
"
2..1800
"
).
build
();
2
).
max
(
1800
).
placeholder
(
"
[s]
"
).
build
();
FloatTParameter
temperatureOffsetParam
=
Builder
<
FloatTParameter
>
(
"temp_offset"
).
label
(
"Temperature offset"
).
defaultValue
(
TEMPERATURE_OFFSET
).
placeholder
(
"
-3
"
).
step
(
0.1
).
build
();
"
[K]
"
).
step
(
0.1
).
build
();
IntTParameter
<
uint16_t
>
altitudeParam
=
Builder
<
IntTParameter
<
uint16_t
>>
(
"altitude"
).
label
(
"Altitude"
).
defaultValue
(
ALTITUDE_ABOVE_SEA_LEVEL
).
min
(
0
).
step
(
1
).
build
();
ALTITUDE_ABOVE_SEA_LEVEL
).
min
(
0
).
step
(
1
).
placeholder
(
"[m]"
).
build
();
IntTParameter
<
uint16_t
>
atmosphericCO2Param
=
Builder
<
IntTParameter
<
uint16_t
>>
(
"atmospheric_co2"
).
label
(
"Atmospheric CO2 concentration"
).
defaultValue
(
ATMOSPHERIC_CO2_CONCENTRATION
).
min
(
400
).
max
(
2000
).
step
(
1
).
placeholder
(
"
400..2000
"
).
build
();
ATMOSPHERIC_CO2_CONCENTRATION
).
min
(
400
).
max
(
2000
).
step
(
1
).
placeholder
(
"
ppm
"
).
build
();
CheckboxTParameter
autoCalibrateParam
=
Builder
<
CheckboxTParameter
>
(
"asc"
).
label
(
"Auto-calibration"
).
defaultValue
(
true
).
build
();
/**
* LED
*/
ParameterGroup
ledParams
=
ParameterGroup
(
"LED"
,
"LED"
);
IntTParameter
<
uint8_t
>
maxBrightnessParam
=
Builder
<
IntTParameter
<
uint8_t
>>
(
"max_brightness"
).
label
(
"Max Brightness"
).
defaultValue
(
MAX_BRIGHTNESS
).
min
(
0
).
max
(
255
).
build
();
IntTParameter
<
uint8_t
>
minBrightnessParam
=
Builder
<
IntTParameter
<
uint8_t
>>
(
"min_brightness"
).
label
(
"Min Brightness"
).
defaultValue
(
MIN_BRIGHTNESS
).
min
(
0
).
max
(
255
).
build
();
IntTParameter
<
uint8_t
>
ledCountParam
=
Builder
<
IntTParameter
<
uint8_t
>>
(
"led_count"
).
label
(
"LED ring"
).
defaultValue
(
LED_COUNT
).
min
(
12
).
max
(
16
).
step
(
4
).
build
();
// # define HTTP_USER "co2ampel"
// # define HTTP_PASSWORD "my_password"
// WARNING: If AMPEL_LORAWAN is enabled, you need to modify the 3 following constants!
// This EUI must be in little-endian format, so least-significant-byte first.
// When copying an EUI from ttnctl output, this means to reverse the bytes.
/**
* CSV
*/
OptionalParameterGroup
csvParams
=
OptionalParameterGroup
(
"CSV"
,
"CSV"
,
true
);
IntTParameter
<
uint16_t
>
csvTimestepParam
=
Builder
<
IntTParameter
<
uint16_t
>>
(
"csv_timestep"
).
label
(
"CSV timestep"
).
defaultValue
(
CSV_INTERVAL
).
min
(
0
).
step
(
1
).
build
();
Builder
<
IntTParameter
<
uint16_t
>>
(
"csv_timestep"
).
label
(
"CSV timestep"
).
defaultValue
(
CSV_INTERVAL
).
min
(
0
).
step
(
1
).
placeholder
(
"[s]"
).
build
();
/**
* MQTT
...
...
@@ -72,7 +95,7 @@ namespace web_config {
IntTParameter
<
uint16_t
>
mqttTimestepParam
=
Builder
<
IntTParameter
<
uint16_t
>>
(
"mqtt_timestep"
).
label
(
"MQTT timestep"
).
defaultValue
(
MQTT_SENDING_INTERVAL
).
min
(
0
).
step
(
1
).
defaultValue
(
300
).
build
();
MQTT_SENDING_INTERVAL
).
min
(
0
).
step
(
1
).
defaultValue
(
300
).
placeholder
(
"[s]"
).
build
();
CheckboxTParameter
mqttCommandsParam
=
Builder
<
CheckboxTParameter
>
(
"mqtt_commands"
).
label
(
"MQTT commands"
).
defaultValue
(
false
).
build
();
...
...
@@ -98,7 +121,7 @@ namespace web_config {
TextTParameter
<
STRING_LEN
>
ntpParam
=
Builder
<
TextTParameter
<
STRING_LEN
>>
(
"ntp_server"
).
label
(
"NTP Server"
).
defaultValue
(
NTP_SERVER
).
build
();
IntTParameter
<
int16_t
>
timeOffsetParam
=
Builder
<
IntTParameter
<
int16_t
>>
(
"timezone"
).
label
(
"Timezone"
).
defaultValue
(
(
UTC_OFFSET_IN_SECONDS
)
/
3600
).
min
(
-
23
).
max
(
23
).
step
(
1
).
build
();
(
UTC_OFFSET_IN_SECONDS
)
/
3600
).
min
(
-
23
).
max
(
23
).
step
(
1
).
placeholder
(
"[h]"
).
build
();
CheckboxTParameter
dstParam
=
Builder
<
CheckboxTParameter
>
(
"dst"
).
label
(
"Daylight Saving Time"
).
defaultValue
(
false
).
build
();
...
...
@@ -112,7 +135,14 @@ namespace web_config {
OptionalParameterGroup
loraParams
=
OptionalParameterGroup
(
"LoRaWan"
,
"LoRaWan"
,
false
);
IntTParameter
<
uint16_t
>
loraTimestepParam
=
Builder
<
IntTParameter
<
uint16_t
>>
(
"lora_timestep"
).
label
(
"LoRa timestep"
).
defaultValue
(
LORAWAN_SENDING_INTERVAL
).
min
(
0
).
step
(
1
).
defaultValue
(
300
).
build
();
LORAWAN_SENDING_INTERVAL
).
min
(
0
).
step
(
1
).
defaultValue
(
300
).
placeholder
(
"[s]"
).
build
();
TextTParameter
<
17
>
deviceEUIParam
=
Builder
<
TextTParameter
<
17
>>
(
"device_eui"
).
label
(
"Device EUI"
).
defaultValue
(
"70B3D5..."
).
build
();
TextTParameter
<
17
>
appEUIParam
=
Builder
<
TextTParameter
<
17
>>
(
"app_eui"
).
label
(
"App EUI"
).
defaultValue
(
"00EA07..."
).
build
();
TextTParameter
<
32
>
appKeyParam
=
Builder
<
TextTParameter
<
32
>>
(
"app_key"
).
label
(
"App key"
).
defaultValue
(
"81CCFE..."
).
build
();
OptionalGroupHtmlFormatProvider
optionalGroupHtmlFormatProvider
;
...
...
@@ -137,6 +167,7 @@ namespace web_config {
iotWebConf
->
setHtmlFormatProvider
(
&
optionalGroupHtmlFormatProvider
);
iotWebConf
->
addSystemParameter
(
&
ampelWifiParam
);
iotWebConf
->
addSystemParameter
(
&
wifiTimeoutParam
);
co2Params
.
addItem
(
&
timestepParam
);
co2Params
.
addItem
(
&
temperatureOffsetParam
);
...
...
@@ -144,6 +175,10 @@ namespace web_config {
co2Params
.
addItem
(
&
atmosphericCO2Param
);
co2Params
.
addItem
(
&
autoCalibrateParam
);
ledParams
.
addItem
(
&
maxBrightnessParam
);
ledParams
.
addItem
(
&
minBrightnessParam
);
ledParams
.
addItem
(
&
ledCountParam
);
timeParams
.
addItem
(
&
ntpParam
);
timeParams
.
addItem
(
&
timeOffsetParam
);
timeParams
.
addItem
(
&
dstParam
);
...
...
@@ -157,9 +192,14 @@ namespace web_config {
mqttParams
.
addItem
(
&
mqttUserParam
);
mqttParams
.
addItem
(
&
mqttPasswordParam
);
//TODO: Only for ESP32
loraParams
.
addItem
(
&
loraTimestepParam
);
loraParams
.
addItem
(
&
deviceEUIParam
);
loraParams
.
addItem
(
&
appEUIParam
);
loraParams
.
addItem
(
&
appKeyParam
);
iotWebConf
->
addParameterGroup
(
&
co2Params
);
iotWebConf
->
addParameterGroup
(
&
ledParams
);
iotWebConf
->
addParameterGroup
(
&
timeParams
);
iotWebConf
->
addParameterGroup
(
&
csvParams
);
iotWebConf
->
addParameterGroup
(
&
mqttParams
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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