diff --git a/board/PlantCtrlESP32.kicad_pro b/board/PlantCtrlESP32.kicad_pro index fa618af..7c67634 100644 --- a/board/PlantCtrlESP32.kicad_pro +++ b/board/PlantCtrlESP32.kicad_pro @@ -58,14 +58,32 @@ "width": 0.0 } ], - "drc_exclusions": [], + "drc_exclusions": [ + "footprint_symbol_mismatch|177050000|59025000|a624af3d-bffa-4ff7-9554-e16d3c677f69|00000000-0000-0000-0000-000000000000", + "footprint_symbol_mismatch|237580000|53970000|c9d8d35b-26b7-4992-9d25-be9130d57b1a|00000000-0000-0000-0000-000000000000", + "footprint_symbol_mismatch|256580000|49370000|b33af7ef-63da-4a51-8d8a-183cadd974de|00000000-0000-0000-0000-000000000000", + "net_conflict|177050000|59025000|09cad967-1882-4dd3-8900-445282e228e5|00000000-0000-0000-0000-000000000000", + "net_conflict|177050000|59025000|20ab85c0-b3f3-4826-a86d-065fee01e11f|00000000-0000-0000-0000-000000000000", + "net_conflict|177050000|59025000|3da9717d-9800-42f9-97d1-56d23bf085aa|00000000-0000-0000-0000-000000000000", + "net_conflict|177050000|59025000|444aab2b-3a9b-444e-b60c-b5b5ff830942|00000000-0000-0000-0000-000000000000", + "net_conflict|177050000|59025000|6b067fd3-d374-4937-8779-958994d9163b|00000000-0000-0000-0000-000000000000", + "net_conflict|177050000|59025000|9839c562-7672-4ea8-a74d-bea83ae26677|00000000-0000-0000-0000-000000000000", + "net_conflict|177050000|59025000|9ce2df19-edf4-40d2-8e85-8c33008b8df0|00000000-0000-0000-0000-000000000000", + "net_conflict|177050000|59025000|a8ab716a-cd1e-4842-ad8e-3d6d1db9770b|00000000-0000-0000-0000-000000000000", + "net_conflict|177050000|59025000|aaf09ae3-4ace-49d7-a050-44cb4c93d63b|00000000-0000-0000-0000-000000000000", + "net_conflict|177050000|59025000|af55e8a2-ba8d-462e-807f-99ca5906f801|00000000-0000-0000-0000-000000000000", + "net_conflict|177050000|59025000|c36efd78-869f-40e7-86fc-97e5ed683fec|00000000-0000-0000-0000-000000000000", + "net_conflict|177050000|59025000|d668fda0-e4be-4e1f-95b8-8cd59a67cb21|00000000-0000-0000-0000-000000000000", + "net_conflict|177050000|59025000|d99401c6-2b75-46f7-8616-cdd7755709ee|00000000-0000-0000-0000-000000000000", + "net_conflict|177050000|59025000|f1fd5816-e8bd-4ba6-9d53-54b58d25e2dc|00000000-0000-0000-0000-000000000000" + ], "meta": { "filename": "board_design_settings.json", "version": 2 }, "rule_severities": { "annular_width": "ignore", - "clearance": "warning", + "clearance": "error", "connection_width": "warning", "copper_edge_clearance": "error", "copper_sliver": "warning", @@ -80,7 +98,6 @@ "footprint_type_mismatch": "ignore", "hole_clearance": "error", "hole_near_hole": "error", - "holes_co_located": "warning", "invalid_outline": "error", "isolated_copper": "warning", "item_on_disabled_layer": "error", @@ -446,8 +463,8 @@ "no_connect_dangling": "warning", "pin_not_connected": "error", "pin_not_driven": "error", - "pin_to_pin": "ignore", - "power_pin_not_driven": "ignore", + "pin_to_pin": "error", + "power_pin_not_driven": "error", "similar_labels": "warning", "simulation_model_issue": "ignore", "unannotated": "error", @@ -1222,19 +1239,13 @@ "label": "Description", "name": "Description", "show": false - }, - { - "group_by": false, - "label": "LCSC Part", - "name": "LCSC Part", - "show": false } ], "filter_string": "", "group_symbols": true, "name": "", "sort_asc": true, - "sort_field": "Value" + "sort_field": "LCSC_PART_NUMBER" }, "connection_grid_size": 50.0, "drawing": { @@ -1270,7 +1281,7 @@ "meta": { "version": 0 }, - "model_mode": 4, + "model_mode": 0, "workbook_filename": "" }, "page_layout_descr_file": "", diff --git a/board/PlantCtrlESP32.kicad_sch b/board/PlantCtrlESP32.kicad_sch index 4621439..c0b3ddf 100644 --- a/board/PlantCtrlESP32.kicad_sch +++ b/board/PlantCtrlESP32.kicad_sch @@ -9311,12 +9311,6 @@ (color 0 0 0 0) (uuid "5aef8b40-8452-4805-a5e4-da8d93469853") ) - (junction - (at 461.01 532.13) - (diameter 0) - (color 0 0 0 0) - (uuid "5daa4784-f5ea-45b1-b6e6-5ed7605a4fd9") - ) (junction (at 604.52 85.09) (diameter 0) @@ -9647,6 +9641,12 @@ (color 0 0 0 0) (uuid "95e16490-1476-42b0-b339-2eae951bab1c") ) + (junction + (at 468.63 537.21) + (diameter 0) + (color 0 0 0 0) + (uuid "96c7bb99-d9fa-47f7-b3d9-aa357eb350aa") + ) (junction (at 151.13 307.34) (diameter 0) @@ -10257,18 +10257,10 @@ (at 38.1 364.49) (uuid "133b7027-41a1-4e09-a1e6-24d8bb033b2a") ) - (no_connect - (at 396.24 523.24) - (uuid "16bd24e1-85b5-4789-83d0-c7b0f2148660") - ) (no_connect (at 128.27 50.8) (uuid "16cd29f7-51e5-42c3-ada2-8a4c178b95ad") ) - (no_connect - (at 468.63 535.94) - (uuid "4e457355-1d35-45ea-8f21-39e64314e210") - ) (no_connect (at 184.15 67.31) (uuid "6d645bf1-339f-4b38-a26a-bdd168ca591e") @@ -12687,16 +12679,6 @@ ) (uuid "50f6b5b1-5983-4df6-ba22-5686c3cfdbfe") ) - (wire - (pts - (xy 461.01 532.13) (xy 464.82 532.13) - ) - (stroke - (width 0) - (type default) - ) - (uuid "51a32a10-8287-45f0-bd16-12558c588428") - ) (wire (pts (xy 299.72 281.94) (xy 299.72 284.48) @@ -12947,6 +12929,16 @@ ) (uuid "5b5c70bc-6004-4d9b-97c5-d20d6b356f63") ) + (wire + (pts + (xy 468.63 535.94) (xy 468.63 537.21) + ) + (stroke + (width 0) + (type default) + ) + (uuid "5b6446c7-78ac-4155-9abd-2e5b3ce82fb9") + ) (wire (pts (xy 330.2 505.46) (xy 336.55 505.46) @@ -13257,26 +13249,6 @@ ) (uuid "6b202dc2-b63b-453a-99cf-d34483dfd672") ) - (wire - (pts - (xy 400.05 527.05) (xy 396.24 527.05) - ) - (stroke - (width 0) - (type default) - ) - (uuid "6d716335-4a7d-41d3-9dc9-0ba195c48d5f") - ) - (wire - (pts - (xy 396.24 527.05) (xy 396.24 537.21) - ) - (stroke - (width 0) - (type default) - ) - (uuid "6d76ff3e-5cf8-43c9-abe4-9c585ba56935") - ) (wire (pts (xy 311.15 403.86) (xy 311.15 405.13) @@ -13297,6 +13269,16 @@ ) (uuid "6dd8ab4a-b6ee-4931-9278-1bb300c309de") ) + (wire + (pts + (xy 396.24 513.08) (xy 396.24 537.21) + ) + (stroke + (width 0) + (type default) + ) + (uuid "6e7e6080-ead4-43ea-9a9a-d463e4617905") + ) (wire (pts (xy 266.7 476.25) (xy 266.7 482.6) @@ -14339,7 +14321,7 @@ ) (wire (pts - (xy 396.24 487.68) (xy 396.24 515.62) + (xy 396.24 487.68) (xy 396.24 505.46) ) (stroke (width 0) @@ -16807,16 +16789,6 @@ ) (uuid "f3c38e30-f3c3-4495-9009-c4501c56511e") ) - (wire - (pts - (xy 400.05 519.43) (xy 400.05 527.05) - ) - (stroke - (width 0) - (type default) - ) - (uuid "f4ba49cb-64ac-4d0d-8f8a-e57afcab26ce") - ) (wire (pts (xy 396.24 537.21) (xy 396.24 541.02) @@ -17378,16 +17350,6 @@ ) (uuid "3279e749-d62b-45dc-920c-a4d4fc61f21f") ) - (text "use around 33k for 17.1v\nbe aware limit is 6v on input pin!" - (exclude_from_sim no) - (at 387.096 525.526 0) - (effects - (font - (size 1.27 1.27) - ) - ) - (uuid "3455ce77-4a9f-487a-85c9-d8775331bede") - ) (text "WaterTemp" (exclude_from_sim no) (at 74.93 194.31 0) @@ -44288,87 +44250,6 @@ ) ) ) - (symbol - (lib_id "Device:R_Potentiometer") - (at 396.24 519.43 0) - (unit 1) - (exclude_from_sim no) - (in_bom yes) - (on_board yes) - (dnp no) - (uuid "84b2b2be-2dbf-4c20-aa55-1957eb031b82") - (property "Reference" "RV2" - (at 393.7 518.16 0) - (effects - (font - (size 1.27 1.27) - ) - (justify right) - ) - ) - (property "Value" "50k" - (at 393.7 520.7 0) - (effects - (font - (size 1.27 1.27) - ) - (justify right) - ) - ) - (property "Footprint" "Potentiometer_THT:Potentiometer_Bourns_3299W_Vertical" - (at 396.24 519.43 0) - (effects - (font - (size 1.27 1.27) - ) - (hide yes) - ) - ) - (property "Datasheet" "~" - (at 396.24 519.43 0) - (effects - (font - (size 1.27 1.27) - ) - (hide yes) - ) - ) - (property "Description" "" - (at 396.24 519.43 0) - (effects - (font - (size 1.27 1.27) - ) - (hide yes) - ) - ) - (property "LCSC_PART_NUMBER" "C118911" - (at 396.24 519.43 0) - (effects - (font - (size 1.27 1.27) - ) - (hide yes) - ) - ) - (pin "1" - (uuid "eed82135-b2b2-4e54-bd28-10a7e16d3475") - ) - (pin "2" - (uuid "9568b812-3f8b-4083-8f2d-597e20f6d7ca") - ) - (pin "3" - (uuid "decf576a-9dba-4f35-b79f-af87ec95b2d1") - ) - (instances - (project "PlantCtrlESP32" - (path "/c26e8d55-0b6e-4c4e-b7c8-b1fed973201c" - (reference "RV2") - (unit 1) - ) - ) - ) - ) (symbol (lib_id "Device:R") (at 455.93 168.91 90) @@ -49331,88 +49212,6 @@ ) ) ) - (symbol - (lib_id "Device:R_Potentiometer") - (at 468.63 532.13 0) - (mirror y) - (unit 1) - (exclude_from_sim no) - (in_bom yes) - (on_board yes) - (dnp no) - (uuid "b332c31b-5371-4806-9189-268fb6732856") - (property "Reference" "RV3" - (at 471.17 530.86 0) - (effects - (font - (size 1.27 1.27) - ) - (justify right) - ) - ) - (property "Value" "50k" - (at 471.17 533.4 0) - (effects - (font - (size 1.27 1.27) - ) - (justify right) - ) - ) - (property "Footprint" "Potentiometer_THT:Potentiometer_Bourns_3299W_Vertical" - (at 468.63 532.13 0) - (effects - (font - (size 1.27 1.27) - ) - (hide yes) - ) - ) - (property "Datasheet" "~" - (at 468.63 532.13 0) - (effects - (font - (size 1.27 1.27) - ) - (hide yes) - ) - ) - (property "Description" "" - (at 468.63 532.13 0) - (effects - (font - (size 1.27 1.27) - ) - (hide yes) - ) - ) - (property "LCSC_PART_NUMBER" "C118911" - (at 468.63 532.13 0) - (effects - (font - (size 1.27 1.27) - ) - (hide yes) - ) - ) - (pin "1" - (uuid "7d4215e3-1540-4495-b06d-f0ce9c684265") - ) - (pin "2" - (uuid "ad14874f-5a05-4695-b1a8-1273fccc40e1") - ) - (pin "3" - (uuid "3d1aa074-5e83-4f3a-a188-1b671f6f6aaf") - ) - (instances - (project "PlantCtrlESP32" - (path "/c26e8d55-0b6e-4c4e-b7c8-b1fed973201c" - (reference "RV3") - (unit 1) - ) - ) - ) - ) (symbol (lib_id "Device:R") (at 425.45 97.79 180) @@ -51867,6 +51666,76 @@ ) ) ) + (symbol + (lib_id "Device:R") + (at 468.63 532.13 0) + (unit 1) + (exclude_from_sim no) + (in_bom yes) + (on_board yes) + (dnp no) + (fields_autoplaced yes) + (uuid "cb9bb05b-678c-4bc9-b5e7-565616fe994f") + (property "Reference" "R42" + (at 471.17 530.8599 0) + (effects + (font + (size 1.27 1.27) + ) + (justify left) + ) + ) + (property "Value" "~27K for 14.7v Bat V" + (at 471.17 533.3999 0) + (effects + (font + (size 1.27 1.27) + ) + (justify left) + ) + ) + (property "Footprint" "Resistor_THT:R_Axial_DIN0207_L6.3mm_D2.5mm_P2.54mm_Vertical" + (at 466.852 532.13 90) + (effects + (font + (size 1.27 1.27) + ) + (hide yes) + ) + ) + (property "Datasheet" "~" + (at 468.63 532.13 0) + (effects + (font + (size 1.27 1.27) + ) + (hide yes) + ) + ) + (property "Description" "Resistor" + (at 468.63 532.13 0) + (effects + (font + (size 1.27 1.27) + ) + (hide yes) + ) + ) + (pin "2" + (uuid "11d19adf-8b79-4b76-8c72-5a0b587fccb9") + ) + (pin "1" + (uuid "135bdf41-3993-41ad-aa61-26216fd8a4c7") + ) + (instances + (project "PlantCtrlESP32" + (path "/c26e8d55-0b6e-4c4e-b7c8-b1fed973201c" + (reference "R42") + (unit 1) + ) + ) + ) + ) (symbol (lib_id "ESP32-DEVKITC-32D:SL2300") (at 350.52 405.13 0) @@ -55152,6 +55021,76 @@ ) ) ) + (symbol + (lib_id "Device:R") + (at 396.24 509.27 0) + (unit 1) + (exclude_from_sim no) + (in_bom yes) + (on_board yes) + (dnp no) + (fields_autoplaced yes) + (uuid "f2f19577-b00b-42f7-98ed-238cf6ad418d") + (property "Reference" "R39" + (at 398.78 507.9999 0) + (effects + (font + (size 1.27 1.27) + ) + (justify left) + ) + ) + (property "Value" "~33K for 17.1v MPPT" + (at 398.78 510.5399 0) + (effects + (font + (size 1.27 1.27) + ) + (justify left) + ) + ) + (property "Footprint" "Resistor_THT:R_Axial_DIN0207_L6.3mm_D2.5mm_P2.54mm_Vertical" + (at 394.462 509.27 90) + (effects + (font + (size 1.27 1.27) + ) + (hide yes) + ) + ) + (property "Datasheet" "~" + (at 396.24 509.27 0) + (effects + (font + (size 1.27 1.27) + ) + (hide yes) + ) + ) + (property "Description" "Resistor" + (at 396.24 509.27 0) + (effects + (font + (size 1.27 1.27) + ) + (hide yes) + ) + ) + (pin "2" + (uuid "8568f007-2f46-4313-b905-dc9d5ce34576") + ) + (pin "1" + (uuid "81fdebab-ba58-4c97-8317-1a2dd42e8715") + ) + (instances + (project "" + (path "/c26e8d55-0b6e-4c4e-b7c8-b1fed973201c" + (reference "R39") + (unit 1) + ) + ) + ) + ) (symbol (lib_id "Diode:BAS40-04") (at 561.34 129.54 90) diff --git a/rust/src/log/mod.rs b/rust/src/log/mod.rs index ebe8e4d..be7b64f 100644 --- a/rust/src/log/mod.rs +++ b/rust/src/log/mod.rs @@ -1,4 +1,5 @@ use std::{collections::HashMap, sync::Mutex}; +use serde::Serialize; use strum_macros::IntoStaticStr; use esp_idf_svc::systime::EspSystemTime; @@ -17,6 +18,7 @@ static mut BUFFER:ConstGenericRingBuffer:: = ConstGeneric static BUFFER_ACCESS: Lazy>> = Lazy::new(|| unsafe { Mutex::new(&mut BUFFER) }); +#[derive(Serialize, Debug, Clone)] pub struct LogEntry { pub timestamp: u64, pub message_id: u32, @@ -52,6 +54,17 @@ fn limit_length (input: &str, target: &mut heapless::String< } } +pub fn get_log() -> Vec{ + let buffer = BUFFER_ACCESS.lock().unwrap(); + let mut read_copy = Vec::new(); + for entry in buffer.iter() { + let copy = entry.clone(); + read_copy.push(copy); + } + drop(buffer); + return read_copy; +} + pub fn log(message_key: LogMessage, number_a: u32, number_b: u32, txt_short:&str, txt_long:&str){ let mut txt_short_stack:heapless::String = heapless::String::new(); let mut txt_long_stack:heapless::String = heapless::String::new(); @@ -94,6 +107,8 @@ pub fn log(message_key: LogMessage, number_a: u32, number_b: u32, txt_short:&str } + + #[cfg(test)] mod tests { use super::*; diff --git a/rust/src/webserver/webserver.rs b/rust/src/webserver/webserver.rs index bde4b70..9245bb1 100644 --- a/rust/src/webserver/webserver.rs +++ b/rust/src/webserver/webserver.rs @@ -207,6 +207,13 @@ fn get_battery_state( anyhow::Ok(Some(battery_json)) } +fn get_log( + _request: &mut Request<&mut EspHttpConnection>, +) -> Result, anyhow::Error> { + let output = crate::log::get_log(); + anyhow::Ok(Some(serde_json::to_string(&output)?)) +} + fn get_version_web( _request: &mut Request<&mut EspHttpConnection>, ) -> Result, anyhow::Error> { @@ -354,6 +361,11 @@ pub fn httpd(reboot_now: Arc) -> Box> { handle_error_to500(request, get_version_web) }) .unwrap(); + server + .fn_handler("/log", Method::Get, |request| { + handle_error_to500(request, get_log) + }) + .unwrap(); server .fn_handler("/battery", Method::Get, |request| { handle_error_to500(request, get_battery_state)