Skip to content
Snippets Groups Projects
Commit dca68616 authored by Elisa Giglio's avatar Elisa Giglio
Browse files

update antifurto

parent 4b1ebba9
No related branches found
No related tags found
No related merge requests found
#!/bin/bash
if [ ! -d "/home/debian/hat_home" ]; then mkdir /home/debian/hat_home; fi
#!/bin/bash
status="OFF"
running=$(/usr/bin/pgrep code.Antifurto)
if [ -f "/home/debian/CONFIG/antifurtoMicroservizio/STATUS" ]; then status=$(cat /home/debian/CONFIG/antifurtoMicroservizio/STATUS); fi
if [ ! -z "$running" ]; then status="OFF"; fi
if [ $status == "ON" ]; then (java -classpath /home/debian/CONFIG/antifurtoMicroservizio:/home/debian/CONFIG/antifurtoMicroservizio/org.eclipse.paho.client.mqttv3_1.2.5.jar:/home/debian/CONFIG/antifurtoMicroservizio/org.json-1.0.0.v201011060100.jar:/home/debian/CONFIG/antifurtoMicroservizio/bcprov-jdk13-167.jar:/home/debian/CONFIG/antifurtoMicroservizio/bcpkix-jdk13-167.jar /home/debian/CONFIG/antifurtoMicroservizio/bin/code.Antifurto &>/dev/null&); fi
#!/bin/bash
status="NONE"
if [ -f "/home/debian/CONFIG/antifurtoMicroservizio/STATUS" ]; then status=$(cat /home/debian/CONFIG/antifurtoMicroservizio/STATUS); fi
if [ $status == "OFF" ]; then /home/debian/bin/stopag Antifurto; fi
{"soglia":30,"stato":1,"valore":0,"tempoAllarme":"2022-10-13T17:47:23.624881"}
\ No newline at end of file
{"soglia":30,"stato":0,"valore":0,"tempoAllarme":"2022-10-24T20:28:12.230820"}
\ No newline at end of file
......@@ -59,9 +59,7 @@ public class Esecutore extends Thread {
JSONObject statoJson = new JSONObject(Helper.leggiFile(Automa.FILE_STATO));
statoJson.put("valore", valore);
if(valore >= soglia && (!automa.allarme()) && (delta>0 || changedSoglia)) { // DA FARE: controlla se e' corretto: ho aggiunto un booleano che dice se la soglia e' appena stata settata.
// Questo per mandare il messaggio di accensione della luce dell'out del suono se si cambia la soglia abbassandola
// e facendo in modo che dopo la modifica della soglia si abbia subito valore>soglia
if(valore >= soglia && (!automa.allarme()) && (delta>0 || changedSoglia)) {
publisher.aggiungiComando("to/"+Antifurto.getMqttTree()+"/gpio/"+antifurto.getNomeOutputSuono(), "{cmd:1}");
tempoAllarme = LocalDateTime.now();
statoJson.put("tempoAllarme",tempoAllarme.toString());
......
......@@ -322,9 +322,9 @@ public class SubscribeCallback implements MqttCallback {
publisher.aggiungiComando("to/"+Antifurto.getMqttTree()+"/gpio/"+client.getNomeOutputSuono(), "{cmd:0}");
newSuonoConf = msgJson.getString("outputSuono");
}
else {
else
newConfigNomeOutputSuono(msgJson.getString("outputSuono"));
}
}
if(msgJson.has("nomeOutputAntifurto")) {
......@@ -332,9 +332,8 @@ public class SubscribeCallback implements MqttCallback {
publisher.aggiungiComando("to/"+Antifurto.getMqttTree()+"/gpio/"+client.getNomeOutputAntifurto(), "{cmd:0}");
newNomeOutputAntifurtoConf = msgJson.getString("nomeOutputAntifurto");
}
else {
else
newConfigNomeOutputAntifurto(msgJson.getString("nomeOutputAntifurto"));
}
}
sendResponseConf();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment