sensor sweep tester
This commit is contained in:
@@ -201,8 +201,8 @@ pub(crate) async fn create_v4(
|
||||
log::info!("Can bus mode ");
|
||||
let twai_config = Some(twai::TwaiConfiguration::new(
|
||||
peripherals.twai,
|
||||
peripherals.gpio0,
|
||||
peripherals.gpio2,
|
||||
peripherals.gpio0,
|
||||
TWAI_BAUDRATE,
|
||||
TwaiMode::Normal,
|
||||
));
|
||||
@@ -458,4 +458,24 @@ impl<'a> BoardInteraction<'a> for V4<'a> {
|
||||
async fn get_mptt_current(&mut self) -> Result<Current, FatError> {
|
||||
self.charger.get_mppt_current()
|
||||
}
|
||||
|
||||
async fn detect_sensors(&mut self) -> Result<alloc::string::String, FatError> {
|
||||
// Delegate to sensor autodetect and build JSON
|
||||
use alloc::string::ToString;
|
||||
let detected = self.sensor.autodetect().await?;
|
||||
// Build JSON manually to avoid exposing internal types
|
||||
let mut s = alloc::string::String::from("{\"plants\":[");
|
||||
for (i, (a, b)) in detected.iter().enumerate() {
|
||||
if i != 0 {
|
||||
s.push(',');
|
||||
}
|
||||
s.push_str("{\"a\":");
|
||||
s.push_str(if *a { "true" } else { "false" });
|
||||
s.push_str(",\"b\":");
|
||||
s.push_str(if *b { "true" } else { "false" });
|
||||
s.push('}');
|
||||
}
|
||||
s.push_str("]}");
|
||||
Ok(s)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user