From e5438a7476a330e3651966c35b9c7a3e50ef49bf Mon Sep 17 00:00:00 2001 From: GreenWizard Date: Fri, 2 Feb 2024 23:05:41 +0100 Subject: [PATCH] quick fix --- controller/tea_poor/lib/Arduino/RemoteControl.cpp | 9 ++++++++- ui/src/components/SystemControls.js | 5 +++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/controller/tea_poor/lib/Arduino/RemoteControl.cpp b/controller/tea_poor/lib/Arduino/RemoteControl.cpp index 5d9b1e7..c314d46 100644 --- a/controller/tea_poor/lib/Arduino/RemoteControl.cpp +++ b/controller/tea_poor/lib/Arduino/RemoteControl.cpp @@ -96,7 +96,14 @@ void RemoteControl::reconnect() { } void RemoteControl::process() { - if(WL_CONNECTED != WiFi.status()) { + const auto status = WiFi.status(); + // TODO: verify if this is the correct way to detect if we need to reconnect + const bool needsReconnect = ( + (WL_CONNECT_FAILED == status) || + (WL_CONNECTION_LOST == status) || + (WL_DISCONNECTED == status) + ); + if(needsReconnect) { reconnect(); return; // wait for next tick, just to be sure that all is ok } diff --git a/ui/src/components/SystemControls.js b/ui/src/components/SystemControls.js index b98b6e5..86b085f 100644 --- a/ui/src/components/SystemControls.js +++ b/ui/src/components/SystemControls.js @@ -6,11 +6,11 @@ import { useWaterPumpAPI } from '../contexts/WaterPumpAPIContext'; import { startPump, stopPump } from '../store/slices/SystemStatus.js'; export function SystemControlsComponent({ - pouringTime, systemStatus, startPump, stopPump + pouringTime, powerLevel, systemStatus, startPump, stopPump }) { const api = useWaterPumpAPI().API; const handleStart = async () => { - await startPump({ api , pouringTime }); + await startPump({ api, pouringTime, powerLevel }); }; const handleStop = async () => { @@ -33,6 +33,7 @@ export function SystemControlsComponent({ export default connect( state => ({ pouringTime: state.UI.pouringTime, + powerLevel: state.UI.powerLevelInPercents, systemStatus: state.systemStatus, }), { startPump, stopPump } )(SystemControlsComponent); \ No newline at end of file