2 Commits

Author SHA1 Message Date
ishak jmilou.ishak
61651a9a02 try to see why sensor value doesnt show on website 2024-12-18 12:22:22 +01:00
ishak jmilou.ishak
e5881f1b37 making message print only once 2024-12-18 11:56:43 +01:00
3 changed files with 12 additions and 12 deletions

View File

@@ -36,9 +36,10 @@ int main()
std::thread sendMqtt([&]() { sendKobukiData(robot.parser.data); });
while(true){
parseMQTT(readMQTT());
std::this_thread::sleep_for(std::chrono::milliseconds(static_cast<int>(10)));
std::string message = readMQTT();
if (!message.empty()){
parseMQTT(message);
}
}
@@ -49,10 +50,13 @@ int main()
std::string readMQTT()
{
message = client.getLastMessage();
if (!message.empty())
static std::string lastMessage;
std::string message = client.getLastMessage();
if (!message.empty() && message != lastMessage)
{
std::cout << "MQTT Message: " << message << std::endl;
lastMessage = message;
}
// Add a small delay to avoid busy-waiting

View File

@@ -25,9 +25,12 @@ document.addEventListener("DOMContentLoaded", function() {
// Fetch data from the server
async function fetchData() {
try{
const response = await fetch("/data");
const data = await response.json();
return data;
} catch (error) {
console.error("Error:", error);
}
// Parse the data and show it on the website

View File

@@ -1,7 +0,0 @@
import sys
import logging
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0, "/home/ishak/rooziinuubii79/src/Python/flask/web")
from app import app as application