NOTES¶
Command Handler — Remote Control via MQTT
Send commands from the cloud or a phone via MQTT to control when and how the sensor node acquires data.
Intuition¶
Command-Driven Architecture¶
The sensor node doesn't decide when to sample — it waits for MQTT commands. This enables:
- Cloud control: one server commands all nodes
- Flexible scheduling: delayed and time-triggered tasks
- Low power: nodes can sleep when idle
Command Format¶
Commands arrive on MQTT_SUBSCRIBE_TOPIC (/mqtt/server); responses go to MQTT_PUBLISH_TOPIC (/mqtt/node).
Format: SENSE,<MODE>,<PARAMS>
Commands¶
| Command | Meaning | Example |
|---|---|---|
SENSE,ONLINE,F=f | Start online sensing | SENSE,ONLINE,F=20 |
SENSE,ONLINE,STOP | Stop online | |
SENSE,ONLINE,STATUS | Query status | |
SENSE,OFFLINE,F=f,D=d | Start offline | SENSE,OFFLINE,F=100,D=30 |
SENSE,OFFLINE,F=f,D=d,DL=s | Delayed start | SENSE,OFFLINE,F=100,D=10,DL=300 |
SENSE,OFFLINE,F=f,D=d,TIME=t | Scheduled start | SENSE,OFFLINE,F=100,D=10,TIME=251231120000 |
SENSE,RT,START,F=f | Start RT processing | SENSE,RT,START,F=50 |
SENSE,RT,DETECT=ON | Enable threshold detect |
API¶
esp_err_t sensing_command_init(void);
esp_err_t sensing_command_process(const char *command, int command_len);
Notes¶
Response format
SENSE,<MODE>,<STATUS>,<INFO>. Example: SENSE,ONLINE,OK,F=20.
Case sensitive
SENSE,ONLINE works; SENSE,online does not.
Delayed start
Implemented via esp_timer one-shot timer. Can be cancelled by a STOP command.