diff --git a/rust/sdkconfig.defaults b/rust/sdkconfig.defaults index c22133f..f9edd2d 100644 --- a/rust/sdkconfig.defaults +++ b/rust/sdkconfig.defaults @@ -1,5 +1,5 @@ # Rust often needs a bit of an extra main task stack size compared to C (the default is 3K) -CONFIG_ESP_MAIN_TASK_STACK_SIZE=20000 +CONFIG_ESP_MAIN_TASK_STACK_SIZE=25000 # Use this to set FreeRTOS kernel tick frequency to 1000 Hz (100 Hz by default). # This allows to use 1 ms granuality for thread sleeps (10 ms by default). diff --git a/rust/src/main.rs b/rust/src/main.rs index 40022e7..e6a05f4 100644 --- a/rust/src/main.rs +++ b/rust/src/main.rs @@ -105,7 +105,7 @@ fn safe_main() -> anyhow::Result<()> { // Bind the log crate to the ESP Logging facilities esp_idf_svc::log::EspLogger::initialize_default(); - if esp_idf_sys::CONFIG_MAIN_TASK_STACK_SIZE < 20000 { + if esp_idf_sys::CONFIG_MAIN_TASK_STACK_SIZE < 25000 { error!( "stack too small: {} bail!", esp_idf_sys::CONFIG_MAIN_TASK_STACK_SIZE @@ -517,7 +517,7 @@ fn safe_main() -> anyhow::Result<()> { let _ = board.mqtt_publish( &config, "/deepsleep", - "Entering low voltage long deep sleep".as_bytes(), + "low Volt 12h".as_bytes(), ); } 12 * 60 @@ -527,7 +527,7 @@ fn safe_main() -> anyhow::Result<()> { let _ = board.mqtt_publish( &config, "/deepsleep", - "Entering after pump restart deep sleep".as_bytes(), + "after pump".as_bytes(), ); } 0 @@ -536,7 +536,7 @@ fn safe_main() -> anyhow::Result<()> { let _ = board.mqtt_publish( &config, "/deepsleep", - "Entering normal mode 20m deep sleep".as_bytes(), + "normal 20m".as_bytes(), ); } 20 @@ -546,11 +546,16 @@ fn safe_main() -> anyhow::Result<()> { let _ = board.mqtt_publish( &config, "/deepsleep", - "Entering night mode 1h deep sleep".as_bytes(), + "night 1h".as_bytes(), ); } 60 }; + if online_mode == OnlineMode::Online { + let _ = board.mqtt_publish(&config, "/state", "sleep".as_bytes()); + } + + //determine next event //is light out of work trigger soon? //is battery low ?? diff --git a/rust/src/plant_hal.rs b/rust/src/plant_hal.rs index b404bf4..efbd087 100644 --- a/rust/src/plant_hal.rs +++ b/rust/src/plant_hal.rs @@ -621,6 +621,7 @@ impl PlantCtrlBoardInteraction for PlantCtrlBoard<'_> { qos: AtLeastOnce, retain: true, }), + client_id: Some("plantctrl"), keep_alive_interval : Some(Duration::from_secs(60*60*2)), //room for improvement ..Default::default() @@ -716,14 +717,22 @@ impl PlantCtrlBoardInteraction for PlantCtrlBoard<'_> { println!("Some error assembling full_topic 2"); bail!("Some error assembling full_topic 2") }; - client.publish( + let publish = client.publish( &full_topic, embedded_svc::mqtt::client::QoS::ExactlyOnce, true, message, - )?; + ); + + match publish { + OkStd(_) => return Ok(()), + Err(err) => { + println!("Error during mqtt send on topic {} with message {:#?} error is {:?}",full_topic, message, err); + return Err(err)? + }, + } - return Ok(()); + ; } fn state_charge_percent(&mut self) -> Result { diff --git a/rust/src/webserver/config.html b/rust/src/webserver/config.html index 55bf906..5b0efcd 100644 --- a/rust/src/webserver/config.html +++ b/rust/src/webserver/config.html @@ -1,6 +1,13 @@ +

Current Firmware

+
+
Buildtime loading
+
Build githash loading
+
+

firmeware OTA v3

+

@@ -9,6 +16,8 @@

+ +

config

@@ -82,4 +91,4 @@ - \ No newline at end of file + diff --git a/rust/src/webserver/initial_config.html b/rust/src/webserver/initial_config.html index e0bb009..4924cb1 100644 --- a/rust/src/webserver/initial_config.html +++ b/rust/src/webserver/initial_config.html @@ -1,7 +1,11 @@ - +

Current Firmware

+
+
Buildtime loading
+
Build githash loading
+

firmeware OTA v3

diff --git a/rust/src/webserver/webserver.rs b/rust/src/webserver/webserver.rs index dcc4867..aa4af72 100644 --- a/rust/src/webserver/webserver.rs +++ b/rust/src/webserver/webserver.rs @@ -22,6 +22,12 @@ struct SSIDList<'a> { ssids: Vec<&'a String<32>>, } +#[derive(Serialize, Debug)] +struct VersionInfo<'a> { + git_hash: &'a str, + build_time: &'a str +} + pub fn httpd_initial(reboot_now: Arc) -> Box> { let mut server = shared(); server @@ -170,7 +176,14 @@ pub fn shared() -> Box> { server .fn_handler("/version", Method::Get, |request| { let mut response = request.into_ok_response()?; - response.write(env!("VERGEN_GIT_DESCRIBE").as_bytes())?; + let git_hash = env!("VERGEN_GIT_DESCRIBE"); + let build_time = env!("VERGEN_BUILD_TIMESTAMP"); + let version_info = VersionInfo{ + git_hash, + build_time, + }; + let version_info_json = serde_json::to_string(&version_info)?; + response.write(version_info_json.as_bytes())?; anyhow::Ok(()) }) .unwrap(); diff --git a/rust/src_webpack/src/ota.ts b/rust/src_webpack/src/ota.ts index c7ba758..2fcdc1c 100644 --- a/rust/src_webpack/src/ota.ts +++ b/rust/src_webpack/src/ota.ts @@ -33,5 +33,23 @@ export function uploadFile() { ajax.send(file); } +interface VersionInfo{ + git_hash:string, + build_time: string +} + let file1Upload = document.getElementById("file1") as HTMLInputElement; file1Upload.onchange = uploadFile; + +let firmware_buildtime = document.getElementById("firmware_buildtime") as HTMLDivElement; +let firmware_githash = document.getElementById("firmware_githash") as HTMLDivElement; + +document.addEventListener('DOMContentLoaded', function() { + fetch("/version") + .then(response => response.json()) + .then(json => json as VersionInfo) + .then(versionInfo => { + firmware_buildtime.innerText = versionInfo.build_time; + firmware_githash.innerText = versionInfo.git_hash; + }) +}, false); \ No newline at end of file