first commit
This commit is contained in:
@@ -26,6 +26,17 @@ public class Main {
|
||||
}, pinStatus -> {
|
||||
// TODO Handle pin status updates here
|
||||
Logger.info("Gpio {}, Description {}, status updated to {}", pinStatus.getGpioNumber(), pinStatus.getDescription(), pinStatus.getStatus());
|
||||
// MQTT publish pin status update
|
||||
if (mqttClient != null && mqttClient.isConnected()) mqttClient.Publish(config.getMQTT_Topic(), config.getMQTT_ClientID(),
|
||||
String.format("Gpio %d, Description %s, Status %d", pinStatus.getGpioNumber(), pinStatus.getDescription(), pinStatus.getStatus()),
|
||||
published -> {
|
||||
if (published) {
|
||||
Logger.info("Pin status update published successfully.");
|
||||
} else {
|
||||
Logger.error("Failed to publish pin status update.");
|
||||
}
|
||||
});
|
||||
// Email notification can be added here
|
||||
|
||||
|
||||
},
|
||||
@@ -57,6 +68,7 @@ public class Main {
|
||||
|
||||
// Add a shutdown hook to disconnect all services
|
||||
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
|
||||
if (gpio!=null && gpio.IsOpened()) gpio.Close();
|
||||
if (mqttClient!=null && mqttClient.isConnected()) mqttClient.Disconnect();
|
||||
}));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user