add mosquitto example

This commit is contained in:
Sebastian Hugentobler 2024-11-18 08:21:14 +01:00
parent 8620bac46e
commit 77d293353e
Signed by: shu
GPG Key ID: BB32CF3CA052C2F0
3 changed files with 12 additions and 1 deletions

View File

@ -105,6 +105,17 @@ In order to decode a message, apply the above steps in reverse order.
All configuration is read on startup of the microcontroller.
## MQTT
To read and decode the MQTT messages one can use for example mosquitto as
follows (using the test.mosquitto.org broker):
```
mosquitto_sub -h test.mosquitto.org -p 1883 -t "temps/potato" | perl -e 'while(read(STDIN,$b,4)){printf "%.2f\n", unpack("f<",$b)}'
```
The perl magic is for decoding the floating point little endian representation.
## Outlook
- Pull the flash/config handling into separate library for testability

View File

@ -8,6 +8,7 @@ use serial_comm::{cobs, protocol::set_config::SetConfig};
use crate::flash::{Config, FlashError};
#[derive(Debug)]
#[allow(dead_code)]
pub struct Utf8Error(pub core::str::Utf8Error);
impl Format for Utf8Error {

View File

@ -13,7 +13,6 @@ use embassy_executor::Spawner;
use embassy_net::Stack;
use embassy_time::Timer;
use flash::{Config, FlashError};
use mqtt_protocol::publish::MAX_TOPIC_LENGTH;
use static_cell::StaticCell;
use temperature::{temperature_task, Temperature};
use usb_serial::{init_usb, usb_task};