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
634af243
Commit
634af243
authored
Apr 17, 2021
by
Eric Duminil
Browse files
Refactor. Fewer dependencies for MQTT
parent
3d479e99
Changes
6
Hide whitespace changes
Inline
Side-by-side
ampel-firmware/csv_writer.cpp
View file @
634af243
...
...
@@ -118,7 +118,7 @@ namespace csv_writer {
Serial
.
println
();
sensor_commands
::
defineIntCallback
(
"csv"
,
setCSVinterval
,
" 60 (Sets CSV writing interval, in s)"
);
//
sensor_commands::defineCallback("format_filesystem",
FS_LIB.format
);
sensor_commands
::
defineCallback
(
"format_filesystem"
,
formatFilesystem
,
"(Deletes the whole filesystem.)"
);
}
File
openOrCreate
()
{
...
...
@@ -175,4 +175,9 @@ namespace csv_writer {
Serial
.
println
(
"s."
);
led_effects
::
showKITTWheel
(
color
::
green
,
1
);
}
void
formatFilesystem
()
{
FS_LIB
.
format
();
led_effects
::
showKITTWheel
(
color
::
blue
,
2
);
}
}
ampel-firmware/csv_writer.h
View file @
634af243
...
...
@@ -27,6 +27,7 @@ namespace csv_writer {
extern
const
String
filename
;
void
setCSVinterval
(
int32_t
csv_interval
);
void
formatFilesystem
();
}
#endif
ampel-firmware/mqtt.cpp
View file @
634af243
...
...
@@ -99,12 +99,7 @@ namespace mqtt {
if
(
messageString
==
"publish"
)
{
Serial
.
println
(
F
(
"Forcing MQTT publish now."
));
publish
(
sensor
::
timestamp
,
sensor
::
co2
,
sensor
::
temperature
,
sensor
::
humidity
);
#ifdef AMPEL_CSV
}
else
if
(
messageString
==
"format_filesystem"
)
{
FS_LIB
.
format
();
led_effects
::
showKITTWheel
(
color
::
blue
,
2
);
#endif
last_sent_at
=
0
;
}
else
if
(
messageString
==
"night_mode"
)
{
led_effects
::
toggleNightMode
();
}
else
if
(
messageString
==
"local_ip"
)
{
...
...
ampel-firmware/mqtt.h
View file @
634af243
...
...
@@ -5,10 +5,6 @@
#include
"config.h"
#include
"led_effects.h"
#include
"sensor_commands.h"
#ifdef AMPEL_CSV
# include "csv_writer.h"
#endif
#include
"co2_sensor.h"
#include
"src/lib/PubSubClient/src/PubSubClient.h"
#include
"wifi_util.h"
namespace
config
{
...
...
ampel-firmware/sensor_commands.cpp
View file @
634af243
...
...
@@ -16,6 +16,10 @@ namespace sensor_commands {
Callback
callbacks
[
MAX_CALLBACKS
];
void
defineCallback
(
const
char
*
name
,
void
(
*
function
)(
void
),
const
char
*
doc
)
{
}
void
defineIntCallback
(
const
char
*
name
,
void
(
*
function
)(
int32_t
),
const
char
*
doc
)
{
if
(
callbacks_count
<
MAX_CALLBACKS
)
{
callbacks
[
callbacks_count
]
=
Callback
(
name
,
function
,
doc
);
...
...
ampel-firmware/sensor_commands.h
View file @
634af243
...
...
@@ -8,6 +8,6 @@
namespace
sensor_commands
{
void
run
(
const
char
*
command
);
//TODO: Add defineIntCallback?
void
defineIntCallback
(
const
char
*
command
,
void
(
*
function
)(
int32_t
),
const
char
*
doc
);
void
defineCallback
(
const
char
*
command
,
void
(
*
function
)(
void
),
const
char
*
doc
);
}
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