big improvement, not theere yet
This commit is contained in:
@@ -15,6 +15,7 @@ use embassy_sync::signal::Signal;
|
||||
use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex;
|
||||
use embassy_time::{Duration, Timer};
|
||||
use projekt_final::bus::I2cInner;
|
||||
use projekt_final::mqtt::client::mqtt_set_imu;
|
||||
|
||||
use esp_alloc as _;
|
||||
use esp_backtrace as _;
|
||||
@@ -179,14 +180,7 @@ async fn main(spawner: Spawner) -> ! {
|
||||
"{{\"ax\":{:.2},\"ay\":{:.2},\"az\":{:.2},\"t\":{:.1}}}",
|
||||
reading.accel_g[0], reading.accel_g[1], reading.accel_g[2], reading.temp_c
|
||||
);
|
||||
// CRITICAL FIX: Use non-blocking publish for sensor data
|
||||
// If MQTT channel is full, we drop this reading rather than blocking
|
||||
if !mqtt_try_publish("esp32/imu", payload.as_bytes(), QualityOfService::QoS0, false) {
|
||||
mqtt_publish_drops += 1;
|
||||
if mqtt_publish_drops % 10 == 1 {
|
||||
log::warn!("MQTT publish dropped (total: {})", mqtt_publish_drops);
|
||||
}
|
||||
}
|
||||
mqtt_set_imu(payload.as_bytes());
|
||||
}
|
||||
}
|
||||
Either3::Third(_) => {
|
||||
|
||||
Reference in New Issue
Block a user