diff --git a/Firmware/src/main.cpp b/Firmware/src/main.cpp index 57d7053..b085407 100644 --- a/Firmware/src/main.cpp +++ b/Firmware/src/main.cpp @@ -63,18 +63,27 @@ void setup() websocket = new WebsocketCommunicator(ws, server, 50); connectWifi(); + server.begin(); registerTasks(); } +void computerCycle() +{ + light->updateState(computer->receiveMessage(), STEPS); + computer->sendMessage(light->getBjtState(), light->getBjtCount()); + computer->clearBuffer(); +} + +void phoneCycle() +{ + light->updateState(phone->receiveMessage(), STEPS); + phone->sendMessage(light->getBjtState(), light->getBjtCount()); + phone->clearBuffer(); +} + void loop() { - light->updateState(computer->receiveMessage(), STEPS); - light->updateState(phone->receiveMessage(), STEPS); - computer->sendMessage(light->getBjtState(), light->getBjtCount()); - computer->clearBuffer(); - phone->sendMessage(light->getBjtState(), light->getBjtCount()); - phone->clearBuffer(); - + computerCycle(); + phoneCycle(); ws.cleanupClients(); - server.begin(); } \ No newline at end of file