Compare commits
No commits in common. "feature/log-config-json" and "develop" have entirely different histories.
feature/lo
...
develop
@ -1,6 +1,5 @@
|
|||||||
use std::{collections::{BTreeMap, HashMap}, sync::Mutex};
|
use std::{collections::HashMap, sync::Mutex};
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use strum::{EnumIter, IntoEnumIterator};
|
|
||||||
use strum_macros::IntoStaticStr;
|
use strum_macros::IntoStaticStr;
|
||||||
|
|
||||||
use esp_idf_svc::systime::EspSystemTime;
|
use esp_idf_svc::systime::EspSystemTime;
|
||||||
@ -130,7 +129,7 @@ mod tests {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#[derive(IntoStaticStr, EnumIter, Serialize, PartialEq, Eq, PartialOrd, Ord, Clone)]
|
#[derive(IntoStaticStr)]
|
||||||
pub enum LogMessage {
|
pub enum LogMessage {
|
||||||
#[strum(serialize = "Reset due to {{txt_long}} requires rtc clear {{a}} and force config mode {{b}}")]
|
#[strum(serialize = "Reset due to {{txt_long}} requires rtc clear {{a}} and force config mode {{b}}")]
|
||||||
reset_reason,
|
reset_reason,
|
||||||
@ -156,15 +155,4 @@ pub enum LogMessage {
|
|||||||
mqtt_stay_alive_rec,
|
mqtt_stay_alive_rec,
|
||||||
#[strum(serialize = "Unknown topic recieved {{txt_long}}")]
|
#[strum(serialize = "Unknown topic recieved {{txt_long}}")]
|
||||||
unknown_topic,
|
unknown_topic,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LogMessage {
|
|
||||||
pub fn to_log_localisation_config() -> BTreeMap<LogMessage,&'static str> {
|
|
||||||
let mut data = BTreeMap::new();
|
|
||||||
for msg_type in LogMessage::iter() {
|
|
||||||
let s: &'static str = msg_type.clone().into();
|
|
||||||
data.insert(msg_type, s);
|
|
||||||
}
|
|
||||||
data
|
|
||||||
}
|
|
||||||
}
|
|
@ -5,7 +5,7 @@ use std::{
|
|||||||
sync::{atomic::AtomicBool, Arc},
|
sync::{atomic::AtomicBool, Arc},
|
||||||
};
|
};
|
||||||
use crate::{
|
use crate::{
|
||||||
espota::OtaUpdate, get_version, log::LogMessage, map_range_moisture, plant_hal::{FileInfo, PLANT_COUNT}, BOARD_ACCESS
|
espota::OtaUpdate, get_version, map_range_moisture, plant_hal::{FileInfo, PLANT_COUNT}, BOARD_ACCESS,
|
||||||
};
|
};
|
||||||
use anyhow::bail;
|
use anyhow::bail;
|
||||||
use chrono::DateTime;
|
use chrono::DateTime;
|
||||||
@ -214,10 +214,6 @@ fn get_log(
|
|||||||
anyhow::Ok(Some(serde_json::to_string(&output)?))
|
anyhow::Ok(Some(serde_json::to_string(&output)?))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_log_localization_config() -> Result<std::string::String, anyhow::Error> {
|
|
||||||
anyhow::Ok(serde_json::to_string(&LogMessage::to_log_localisation_config())?)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_version_web(
|
fn get_version_web(
|
||||||
_request: &mut Request<&mut EspHttpConnection>,
|
_request: &mut Request<&mut EspHttpConnection>,
|
||||||
) -> Result<Option<std::string::String>, anyhow::Error> {
|
) -> Result<Option<std::string::String>, anyhow::Error> {
|
||||||
@ -370,11 +366,6 @@ pub fn httpd(reboot_now: Arc<AtomicBool>) -> Box<EspHttpServer<'static>> {
|
|||||||
handle_error_to500(request, get_log)
|
handle_error_to500(request, get_log)
|
||||||
})
|
})
|
||||||
.unwrap();
|
.unwrap();
|
||||||
server.fn_handler("/log_localization", Method::Get, |request| {
|
|
||||||
cors_response(request, 200, &get_log_localization_config().unwrap())
|
|
||||||
|
|
||||||
})
|
|
||||||
.unwrap();
|
|
||||||
server
|
server
|
||||||
.fn_handler("/battery", Method::Get, |request| {
|
.fn_handler("/battery", Method::Get, |request| {
|
||||||
handle_error_to500(request, get_battery_state)
|
handle_error_to500(request, get_battery_state)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user