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
0fe497e8
Commit
0fe497e8
authored
May 17, 2021
by
Eric Duminil
Browse files
Use namespace
parent
cd8a4314
Changes
1
Hide whitespace changes
Inline
Side-by-side
ampel-firmware/web_config.cpp
View file @
0fe497e8
#include
"web_config.h"
namespace
config
{
iotwebconf
::
TextTParameter
<
STRING_LEN
>
stringParam
=
iotwebconf
::
Builder
<
iotwebconf
::
TextTParameter
<
STRING_LEN
>>
(
"stringParam"
).
label
(
"String param"
).
build
();
using
namespace
iotwebconf
;
TextTParameter
<
STRING_LEN
>
stringParam
=
Builder
<
TextTParameter
<
STRING_LEN
>>
(
"stringParam"
).
label
(
"String param"
).
build
();
}
//TODO: Is there any conflict with SPIFFS/LittleFS?
...
...
@@ -29,79 +30,77 @@ namespace web_config {
/**
* Services
*/
iotwebconf
::
CheckboxTParameter
ampelWifiParam
=
iotwebconf
::
Builder
<
iotwebconf
::
CheckboxTParameter
>
(
"WiFi"
).
label
(
"WiFi"
).
defaultValue
(
true
).
build
();
CheckboxTParameter
ampelWifiParam
=
Builder
<
CheckboxTParameter
>
(
"WiFi"
).
label
(
"WiFi"
).
defaultValue
(
true
).
build
();
//TODO: Distribute to corresponding classes, possibly with callbacks?
/**
* CO2 sensor
*/
iotwebconf
::
ParameterGroup
co2Params
=
iotwebconf
::
ParameterGroup
(
"co2"
,
"CO2 Sensor"
);
//TODO: Conflict with labels?
ParameterGroup
co2Params
=
ParameterGroup
(
"co2"
,
"CO2 Sensor"
);
//TODO: Conflict with labels?
//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
();
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
();
iotwebconf
::
FloatTParameter
temperatureOffsetParam
=
iotwebconf
::
Builder
<
iotwebconf
::
FloatTParameter
>
(
"temp_offset"
).
label
(
"Temperature offset"
).
defaultValue
(
TEMPERATURE_OFFSET
).
placeholder
(
"-3"
).
step
(
0.1
).
build
();
FloatTParameter
temperatureOffsetParam
=
Builder
<
FloatTParameter
>
(
"temp_offset"
).
label
(
"Temperature offset"
).
defaultValue
(
TEMPERATURE_OFFSET
).
placeholder
(
"-3"
).
step
(
0.1
).
build
();
iotwebconf
::
IntTParameter
<
uint16_t
>
altitudeParam
=
iotwebconf
::
Builder
<
iotwebconf
::
IntTParameter
<
uint16_t
>>
(
"altitude"
).
label
(
"Altitude"
).
defaultValue
(
ALTITUDE_ABOVE_SEA_LEVEL
).
min
(
0
).
step
(
1
).
build
();
IntTParameter
<
uint16_t
>
altitudeParam
=
Builder
<
IntTParameter
<
uint16_t
>>
(
"altitude"
).
label
(
"Altitude"
).
defaultValue
(
ALTITUDE_ABOVE_SEA_LEVEL
).
min
(
0
).
step
(
1
).
build
();
iotwebconf
::
IntTParameter
<
uint16_t
>
atmosphericCO2Param
=
iotwebconf
::
Builder
<
iotwebconf
::
IntTParameter
<
uint16_t
>>
(
"atmospheric_co2"
).
label
(
"Atmospheric CO2 concentration"
).
defaultValue
(
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
();
iotwebconf
::
CheckboxTParameter
autoCalibrateParam
=
iotwebconf
::
Builder
<
iotwebconf
::
CheckboxTParameter
>
(
"asc"
).
label
(
"Auto-calibration"
).
defaultValue
(
true
).
build
();
CheckboxTParameter
autoCalibrateParam
=
Builder
<
CheckboxTParameter
>
(
"asc"
).
label
(
"Auto-calibration"
).
defaultValue
(
true
).
build
();
/**
* CSV
*/
iotwebconf
::
OptionalParameterGroup
csvParams
=
iotwebconf
::
OptionalParameterGroup
(
"CSV"
,
"CSV"
,
true
);
OptionalParameterGroup
csvParams
=
OptionalParameterGroup
(
"CSV"
,
"CSV"
,
true
);
iotwebconf
::
IntTParameter
<
uint16_t
>
csvTimestepParam
=
iotwebconf
::
Builder
<
iotwebconf
::
IntTParameter
<
uint16_t
>>
(
"csv_timestep"
).
label
(
"CSV timestep"
).
defaultValue
(
CSV_INTERVAL
).
min
(
0
).
step
(
1
).
build
();
IntTParameter
<
uint16_t
>
csvTimestepParam
=
Builder
<
IntTParameter
<
uint16_t
>>
(
"csv_timestep"
).
label
(
"CSV timestep"
).
defaultValue
(
CSV_INTERVAL
).
min
(
0
).
step
(
1
).
build
();
/**
* MQTT
*/
iotwebconf
::
OptionalParameterGroup
mqttParams
=
iotwebconf
::
OptionalParameterGroup
(
"MQTT"
,
"MQTT"
,
true
);
OptionalParameterGroup
mqttParams
=
OptionalParameterGroup
(
"MQTT"
,
"MQTT"
,
true
);
iotwebconf
::
IntTParameter
<
uint16_t
>
mqttTimestepParam
=
iotwebconf
::
Builder
<
iotwebconf
::
IntTParameter
<
uint16_t
>>
(
"mqtt_timestep"
).
label
(
"MQTT timestep"
).
defaultValue
(
MQTT_SENDING_INTERVAL
).
min
(
0
).
step
(
1
).
defaultValue
(
300
).
build
();
IntTParameter
<
uint16_t
>
mqttTimestepParam
=
Builder
<
IntTParameter
<
uint16_t
>>
(
"mqtt_timestep"
).
label
(
"MQTT timestep"
).
defaultValue
(
MQTT_SENDING_INTERVAL
).
min
(
0
).
step
(
1
).
defaultValue
(
300
).
build
();
iotwebconf
::
CheckboxTParameter
mqttCommandsParam
=
iotwebconf
::
Builder
<
iotwebconf
::
CheckboxTParameter
>
(
"mqtt_commands"
).
label
(
"MQTT commands"
).
defaultValue
(
false
).
build
();
CheckboxTParameter
mqttCommandsParam
=
Builder
<
CheckboxTParameter
>
(
"mqtt_commands"
).
label
(
"MQTT commands"
).
defaultValue
(
false
).
build
();
iotwebconf
::
TextTParameter
<
STRING_LEN
>
mqttServerParam
=
iotwebconf
::
Builder
<
iotwebconf
::
TextTParameter
<
STRING_LEN
>>
(
"mqtt_server"
).
label
(
"MQTT Server"
).
defaultValue
(
MQTT_SERVER
).
build
();
TextTParameter
<
STRING_LEN
>
mqttServerParam
=
Builder
<
TextTParameter
<
STRING_LEN
>>
(
"mqtt_server"
).
label
(
"MQTT Server"
).
defaultValue
(
MQTT_SERVER
).
build
();
iotwebconf
::
IntTParameter
<
uint16_t
>
mqttPortParam
=
iotwebconf
::
Builder
<
iotwebconf
::
IntTParameter
<
uint16_t
>>
(
"mqtt_port"
).
label
(
"MQTT Port"
).
defaultValue
(
MQTT_PORT
).
build
();
IntTParameter
<
uint16_t
>
mqttPortParam
=
Builder
<
IntTParameter
<
uint16_t
>>
(
"mqtt_port"
).
label
(
"MQTT Port"
).
defaultValue
(
MQTT_PORT
).
build
();
iotwebconf
::
TextTParameter
<
STRING_LEN
>
mqttUserParam
=
iotwebconf
::
Builder
<
iotwebconf
::
TextTParameter
<
STRING_LEN
>>
(
"mqtt_user"
).
label
(
"MQTT User"
).
defaultValue
(
MQTT_USER
).
build
();
TextTParameter
<
STRING_LEN
>
mqttUserParam
=
Builder
<
TextTParameter
<
STRING_LEN
>>
(
"mqtt_user"
).
label
(
"MQTT User"
).
defaultValue
(
MQTT_USER
).
build
();
//TODO: Show the number of * for password?
iotwebconf
::
PasswordTParameter
<
STRING_LEN
>
mqttPasswordParam
=
iotwebconf
::
Builder
<
iotwebconf
::
PasswordTParameter
<
STRING_LEN
>>
(
"mqtt_password"
).
label
(
"MQTT password"
).
defaultValue
(
MQTT_PASSWORD
).
build
();
PasswordTParameter
<
STRING_LEN
>
mqttPasswordParam
=
Builder
<
PasswordTParameter
<
STRING_LEN
>>
(
"mqtt_password"
).
label
(
"MQTT password"
).
defaultValue
(
MQTT_PASSWORD
).
build
();
/**
* NTP Time
*/
iotwebconf
::
ParameterGroup
timeParams
=
iotwebconf
::
ParameterGroup
(
"NTP"
,
"Time server"
);
iotwebconf
::
TextTParameter
<
STRING_LEN
>
ntpParam
=
iotwebconf
::
Builder
<
iotwebconf
::
TextTParameter
<
STRING_LEN
>>
(
"ntp_server"
).
label
(
"NTP Server"
).
defaultValue
(
NTP_SERVER
).
build
();
iotwebconf
::
IntTParameter
<
int16_t
>
timeOffsetParam
=
iotwebconf
::
Builder
<
iotwebconf
::
IntTParameter
<
int16_t
>>
(
"timezone"
).
label
(
"Timezone"
).
defaultValue
(
(
UTC_OFFSET_IN_SECONDS
)
/
3600
).
min
(
-
23
).
max
(
23
).
step
(
1
).
build
();
iotwebconf
::
CheckboxTParameter
dstParam
=
iotwebconf
::
Builder
<
iotwebconf
::
CheckboxTParameter
>
(
"dst"
).
label
(
"Daylight Saving Time"
).
defaultValue
(
false
).
build
();
ParameterGroup
timeParams
=
ParameterGroup
(
"NTP"
,
"Time server"
);
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
();
CheckboxTParameter
dstParam
=
Builder
<
CheckboxTParameter
>
(
"dst"
).
label
(
"Daylight Saving Time"
).
defaultValue
(
false
).
build
();
/**
* LED
...
...
@@ -110,12 +109,12 @@ namespace web_config {
/**
* LoRa & Stuff
*/
iotwebconf
::
OptionalParameterGroup
loraParams
=
iotwebconf
::
OptionalParameterGroup
(
"LoRaWan"
,
"LoRaWan"
,
false
);
iotwebconf
::
IntTParameter
<
uint16_t
>
loraTimestepParam
=
iotwebconf
::
Builder
<
iotwebconf
::
IntTParameter
<
uint16_t
>>
(
"lora_timestep"
).
label
(
"LoRa timestep"
).
defaultValue
(
LORAWAN_SENDING_INTERVAL
).
min
(
0
).
step
(
1
).
defaultValue
(
300
).
build
();
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
();
iotwebconf
::
OptionalGroupHtmlFormatProvider
optionalGroupHtmlFormatProvider
;
OptionalGroupHtmlFormatProvider
optionalGroupHtmlFormatProvider
;
void
update
()
{
iotWebConf
->
doLoop
();
// Listen for HTTP requests from clients
...
...
@@ -126,7 +125,7 @@ namespace web_config {
}
void
setWifiConnectionFailedCallback
(
void
(
*
function
)())
{
iotWebConf
->
setWifiConnectionFailedHandler
([
&
function
]()
->
iotwebconf
::
WifiAuthInfo
*
{
iotWebConf
->
setWifiConnectionFailedHandler
([
&
function
]()
->
WifiAuthInfo
*
{
function
();
return
NULL
;
});
...
...
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