|
|
|
|
@ -113,6 +113,32 @@ mqttClient.on("message", (topic, message, packet) => {
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case "display/passwordEntered": {
|
|
|
|
|
const data = JSON.parse(message);
|
|
|
|
|
console.log(data);
|
|
|
|
|
|
|
|
|
|
const pins = ["1234", "112233"];
|
|
|
|
|
if (pins.includes(data.password.join(""))) {
|
|
|
|
|
mqttClient.emit("display/passwordResponse", {
|
|
|
|
|
deviceId: data.deviceId,
|
|
|
|
|
correct: true,
|
|
|
|
|
password: data.password
|
|
|
|
|
});
|
|
|
|
|
if (StateManager.alarmStatus != Disarmed) {
|
|
|
|
|
disarmAlarm();
|
|
|
|
|
} else {
|
|
|
|
|
armAlarm();
|
|
|
|
|
}
|
|
|
|
|
unlockDoor();
|
|
|
|
|
} else {
|
|
|
|
|
mqttClient.emit("display/passwordResponse", {
|
|
|
|
|
deviceId: data.deviceId,
|
|
|
|
|
correct: false,
|
|
|
|
|
password: data.password
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
console.log("Unsupported topic received: " + topic);
|
|
|
|
|
break;
|
|
|
|
|
|