Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Käppler
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 {
...
@@ -118,7 +118,7 @@ namespace csv_writer {
Serial
.
println
();
Serial
.
println
();
sensor_commands
::
defineIntCallback
(
"csv"
,
setCSVinterval
,
" 60 (Sets CSV writing interval, in s)"
);
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
()
{
File
openOrCreate
()
{
...
@@ -175,4 +175,9 @@ namespace csv_writer {
...
@@ -175,4 +175,9 @@ namespace csv_writer {
Serial
.
println
(
"s."
);
Serial
.
println
(
"s."
);
led_effects
::
showKITTWheel
(
color
::
green
,
1
);
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 {
...
@@ -27,6 +27,7 @@ namespace csv_writer {
extern
const
String
filename
;
extern
const
String
filename
;
void
setCSVinterval
(
int32_t
csv_interval
);
void
setCSVinterval
(
int32_t
csv_interval
);
void
formatFilesystem
();
}
}
#endif
#endif
ampel-firmware/mqtt.cpp
View file @
634af243
...
@@ -99,12 +99,7 @@ namespace mqtt {
...
@@ -99,12 +99,7 @@ namespace mqtt {
if
(
messageString
==
"publish"
)
{
if
(
messageString
==
"publish"
)
{
Serial
.
println
(
F
(
"Forcing MQTT publish now."
));
Serial
.
println
(
F
(
"Forcing MQTT publish now."
));
publish
(
sensor
::
timestamp
,
sensor
::
co2
,
sensor
::
temperature
,
sensor
::
humidity
);
last_sent_at
=
0
;
#ifdef AMPEL_CSV
}
else
if
(
messageString
==
"format_filesystem"
)
{
FS_LIB
.
format
();
led_effects
::
showKITTWheel
(
color
::
blue
,
2
);
#endif
}
else
if
(
messageString
==
"night_mode"
)
{
}
else
if
(
messageString
==
"night_mode"
)
{
led_effects
::
toggleNightMode
();
led_effects
::
toggleNightMode
();
}
else
if
(
messageString
==
"local_ip"
)
{
}
else
if
(
messageString
==
"local_ip"
)
{
...
...
ampel-firmware/mqtt.h
View file @
634af243
...
@@ -5,10 +5,6 @@
...
@@ -5,10 +5,6 @@
#include
"config.h"
#include
"config.h"
#include
"led_effects.h"
#include
"led_effects.h"
#include
"sensor_commands.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
"src/lib/PubSubClient/src/PubSubClient.h"
#include
"wifi_util.h"
#include
"wifi_util.h"
namespace
config
{
namespace
config
{
...
...
ampel-firmware/sensor_commands.cpp
View file @
634af243
...
@@ -16,6 +16,10 @@ namespace sensor_commands {
...
@@ -16,6 +16,10 @@ namespace sensor_commands {
Callback
callbacks
[
MAX_CALLBACKS
];
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
)
{
void
defineIntCallback
(
const
char
*
name
,
void
(
*
function
)(
int32_t
),
const
char
*
doc
)
{
if
(
callbacks_count
<
MAX_CALLBACKS
)
{
if
(
callbacks_count
<
MAX_CALLBACKS
)
{
callbacks
[
callbacks_count
]
=
Callback
(
name
,
function
,
doc
);
callbacks
[
callbacks_count
]
=
Callback
(
name
,
function
,
doc
);
...
...
ampel-firmware/sensor_commands.h
View file @
634af243
...
@@ -8,6 +8,6 @@
...
@@ -8,6 +8,6 @@
namespace
sensor_commands
{
namespace
sensor_commands
{
void
run
(
const
char
*
command
);
void
run
(
const
char
*
command
);
//TODO: Add defineIntCallback?
void
defineIntCallback
(
const
char
*
command
,
void
(
*
function
)(
int32_t
),
const
char
*
doc
);
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