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
abe61df3
Commit
abe61df3
authored
Feb 14, 2022
by
Eric Duminil
Browse files
Renaming back
parent
fc8d4a3d
Pipeline
#5818
passed with stage
in 2 minutes and 31 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
ampel-firmware/csv_writer.cpp
View file @
abe61df3
...
...
@@ -162,7 +162,7 @@ namespace csv_writer {
void
logIfTimeHasCome
(
const
char
*
timeStamp
,
const
int16_t
&
co2
,
const
float
&
temperature
,
const
float
&
humidity
)
{
unsigned
long
now
=
seconds
();
if
(
now
-
last_written_at
>
config
::
csv_
timestep
)
{
if
(
now
-
last_written_at
>
config
::
csv_
interval
)
{
last_written_at
=
now
;
log
(
timeStamp
,
co2
,
temperature
,
humidity
);
}
...
...
@@ -172,9 +172,9 @@ namespace csv_writer {
* Callbacks for sensor commands *
*****************************************************************/
void
setCSVinterval
(
int32_t
csv_interval
)
{
config
::
csv_
timestep
=
csv_interval
;
config
::
csv_
interval
=
csv_interval
;
Serial
.
print
(
F
(
"Setting CSV Interval to : "
));
Serial
.
print
(
config
::
csv_
timestep
);
Serial
.
print
(
config
::
csv_
interval
);
Serial
.
println
(
"s."
);
config
::
save
();
led_effects
::
showKITTWheel
(
color
::
green
,
1
);
...
...
ampel-firmware/mqtt.cpp
View file @
abe61df3
...
...
@@ -142,17 +142,10 @@ namespace mqtt {
Serial
.
println
(
F
(
" Connected."
));
last_failed_at
=
0
;
}
else
{
char
const
*
mqtt_statuses
[]
=
{
// As defined in PubSubClient
"Connection timeout"
,
// -4
"Connection lost"
,
"Connection failed"
,
"Disconnected"
,
"Connected"
,
// 0
"Bad protocol"
,
"Bad client ID"
,
"Unavailable"
,
"Bad credentials"
,
"Unauthorized"
};
// 5
// As defined in PubSubClient, between -4 and 5
const
__FlashStringHelper
*
mqtt_statuses
[]
=
{
F
(
"Connection timeout"
),
F
(
"Connection lost"
),
F
(
"Connection failed"
),
F
(
"Disconnected"
),
F
(
"Connected"
),
F
(
"Bad protocol"
),
F
(
"Bad client ID"
),
F
(
"Unavailable"
),
F
(
"Bad credentials"
),
F
(
"Unauthorized"
)
};
last_failed_at
=
seconds
();
Serial
.
print
(
mqtt_statuses
[
mqttClient
.
state
()
+
4
]);
Serial
.
print
(
"! (Code="
);
...
...
@@ -166,7 +159,7 @@ namespace mqtt {
void
publishIfTimeHasCome
(
const
char
*
timestamp
,
const
int16_t
&
co2
,
const
float
&
temp
,
const
float
&
hum
)
{
// Send message via MQTT according to sending interval
unsigned
long
now
=
seconds
();
if
(
now
-
last_sent_at
>
config
::
mqtt_sending_
timestep
)
{
if
(
now
-
last_sent_at
>
config
::
mqtt_sending_
interval
)
{
last_sent_at
=
now
;
publish
(
timestamp
,
co2
,
temp
,
hum
);
}
...
...
@@ -184,9 +177,9 @@ namespace mqtt {
* Callbacks for sensor commands *
*****************************************************************/
void
setMQTTinterval
(
int32_t
sending_interval
)
{
config
::
mqtt_sending_
timestep
=
sending_interval
;
config
::
mqtt_sending_
interval
=
sending_interval
;
Serial
.
print
(
F
(
"Setting MQTT sending interval to : "
));
Serial
.
print
(
config
::
mqtt_sending_
timestep
);
Serial
.
print
(
config
::
mqtt_sending_
interval
);
Serial
.
println
(
"s."
);
config
::
save
();
led_effects
::
showKITTWheel
(
color
::
green
,
1
);
...
...
ampel-firmware/web_config.cpp
View file @
abe61df3
...
...
@@ -328,7 +328,7 @@ namespace config {
bool
is_csv_active
()
{
return
web_config
::
csvParams
.
isActive
();
}
uint16_t
&
csv_
timestep
=
web_config
::
csvTimestepParam
.
value
();
uint16_t
&
csv_
interval
=
web_config
::
csvTimestepParam
.
value
();
// MQTT
bool
is_mqtt_active
()
{
...
...
@@ -338,7 +338,7 @@ namespace config {
char
*
mqtt_user
=
web_config
::
mqttUserParam
.
value
();
char
*
mqtt_password
=
web_config
::
mqttPasswordParam
.
value
();
uint16_t
&
mqtt_port
=
web_config
::
mqttPortParam
.
value
();
uint16_t
&
mqtt_sending_
timestep
=
web_config
::
mqttTimestepParam
.
value
();
uint16_t
&
mqtt_sending_
interval
=
web_config
::
mqttTimestepParam
.
value
();
bool
&
mqtt_encryption
=
web_config
::
mqttEncryptionParam
.
value
();
bool
&
allow_mqtt_commands
=
web_config
::
mqttCommandsParam
.
value
();
...
...
ampel-firmware/web_config.h
View file @
abe61df3
...
...
@@ -36,7 +36,7 @@ namespace config {
//CSV
bool
is_csv_active
();
// [true / false]
extern
uint16_t
&
csv_
timestep
;
// [s]
extern
uint16_t
&
csv_
interval
;
// [s]
// MQTT
bool
is_mqtt_active
();
// [true / false]
...
...
@@ -44,7 +44,7 @@ namespace config {
extern
char
*
mqtt_user
;
extern
char
*
mqtt_password
;
extern
uint16_t
&
mqtt_port
;
extern
uint16_t
&
mqtt_sending_
timestep
;
// [s]
extern
uint16_t
&
mqtt_sending_
interval
;
// [s]
extern
bool
&
mqtt_encryption
;
// [true / false]
extern
bool
&
allow_mqtt_commands
;
// [true / false]
...
...
ampel-firmware/web_server.cpp
View file @
abe61df3
...
...
@@ -208,8 +208,8 @@ namespace web_server {
// Body
snprintf_P
(
content
,
sizeof
(
content
),
body_template
,
config
::
ampel_name
(),
sensor
::
co2
,
sensor
::
temperature
,
sensor
::
humidity
,
sensor
::
timestamp
,
config
::
measurement_timestep
,
csv_writer
::
last_successful_write
,
config
::
csv_
timestep
,
csv_writer
::
getAvailableSpace
()
/
1024
,
mqtt
::
connected
?
"Yes"
:
"No"
,
mqtt
::
last_successful_publish
,
config
::
mqtt_sending_
timestep
,
config
::
csv_
interval
,
csv_writer
::
getAvailableSpace
()
/
1024
,
mqtt
::
connected
?
"Yes"
:
"No"
,
mqtt
::
last_successful_publish
,
config
::
mqtt_sending_
interval
,
#if defined(ESP32)
lorawan
::
connected
?
"Yes"
:
"No"
,
config
::
lorawan_frequency_plan
,
lorawan
::
last_transmission
,
config
::
lorawan_sending_interval
,
...
...
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