node-red-contrib-hik-media-buffer 1.1.118 → 1.1.119
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/hik-media-buffer.js +10 -9
- package/package.json +1 -1
package/hik-media-buffer.js
CHANGED
|
@@ -57,40 +57,41 @@ module.exports = function(RED) {
|
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
// --- 2. CONTROLLO STATUS CAMERE AUTOMATICO
|
|
60
|
+
// --- 2. CONTROLLO STATUS CAMERE AUTOMATICO ---
|
|
61
61
|
async function checkCameras() {
|
|
62
62
|
if (isClosing || !nvrOnline) return;
|
|
63
63
|
const nvrAuth = new AxiosDigestAuth({ username: node.user, password: node.pass });
|
|
64
64
|
try {
|
|
65
|
-
// Interroghiamo l'elenco proxy
|
|
65
|
+
// Interroghiamo l'elenco proxy centralizzato dell'NVR
|
|
66
66
|
const res = await nvrAuth.request({
|
|
67
67
|
method: 'GET',
|
|
68
68
|
url: `${node.protocol}://${node.host}:${node.port}/ISAPI/ContentMgmt/InputProxy/channels`,
|
|
69
|
-
timeout:
|
|
69
|
+
timeout: 6000,
|
|
70
70
|
httpsAgent: node.protocol === "https" ? httpsAgent : undefined
|
|
71
71
|
});
|
|
72
72
|
|
|
73
73
|
const xml = res.data.toString();
|
|
74
|
-
// Estraiamo i singoli blocchi di canali digitali
|
|
74
|
+
// Estraiamo i singoli blocchi di canali digitali
|
|
75
75
|
const channelBlocks = xml.match(/<InputProxyChannel>[\s\S]*?<\/InputProxyChannel>/g) || [];
|
|
76
76
|
|
|
77
77
|
for (let block of channelBlocks) {
|
|
78
78
|
const idMatch = block.match(/<id>(\d+)<\/id>/i);
|
|
79
|
-
//
|
|
80
|
-
const onlineMatch = block.match(/<online
|
|
79
|
+
// Questa regex cerca la parola "true" o "false" dentro il tag online, sia esso <online>, <onLine> o <ONLINE>
|
|
80
|
+
const onlineMatch = block.match(/<onLine[^>]*>(true|false)<\/onLine>/i) || block.match(/<online[^>]*>(true|false)<\/online>/i);
|
|
81
81
|
|
|
82
82
|
if (idMatch) {
|
|
83
83
|
const ch = idMatch[1];
|
|
84
|
-
const isOnline = onlineMatch ? onlineMatch[1].
|
|
84
|
+
const isOnline = onlineMatch ? onlineMatch[1].toLowerCase() === "true" : false;
|
|
85
85
|
|
|
86
86
|
if (isOnline && statoCamera[ch] === false) {
|
|
87
87
|
const nomeOnline = await getCameraNameFromNVR(ch);
|
|
88
88
|
node.send({ payload: { tipo_messaggio: "status", stato_telecamera: "online", nome_cliente: node.name, nome_telecamera: nomeOnline, ip_telecamera: node.host, channel: ch, msg: "Camera ripristinata" } });
|
|
89
89
|
statoCamera[ch] = true;
|
|
90
|
-
} else if (!isOnline && statoCamera[ch] !== false) {
|
|
90
|
+
} else if (!isOnline && statoCamera[ch] !== false && statoCamera[ch] !== undefined) {
|
|
91
91
|
node.send({ payload: { tipo_messaggio: "status", stato_telecamera: "offline", nome_cliente: node.name, nome_telecamera: `Camera ${ch}`, ip_telecamera: node.host, channel: ch, msg: "Camera non raggiungibile" } });
|
|
92
92
|
statoCamera[ch] = false;
|
|
93
93
|
} else if (statoCamera[ch] === undefined) {
|
|
94
|
+
// Configurazione iniziale dello stato al boot
|
|
94
95
|
statoCamera[ch] = isOnline;
|
|
95
96
|
}
|
|
96
97
|
}
|
|
@@ -112,7 +113,7 @@ module.exports = function(RED) {
|
|
|
112
113
|
}
|
|
113
114
|
}
|
|
114
115
|
|
|
115
|
-
const heartbeatInterval = setInterval(checkCameras,
|
|
116
|
+
const heartbeatInterval = setInterval(checkCameras, 15000);
|
|
116
117
|
|
|
117
118
|
// --- 3. DOWNLOAD MEDIA CON DELAY E FORMATO STRINGA CORRETTO ---
|
|
118
119
|
async function downloadMedia(evento, channelID) {
|