node-red-contrib-hik-media-buffer 1.1.120 → 1.1.122
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 +20 -27
- package/package.json +1 -1
package/hik-media-buffer.js
CHANGED
|
@@ -62,52 +62,45 @@ module.exports = function(RED) {
|
|
|
62
62
|
if (isClosing || !nvrOnline) return;
|
|
63
63
|
const nvrAuth = new AxiosDigestAuth({ username: node.user, password: node.pass });
|
|
64
64
|
try {
|
|
65
|
+
// Chiamata all'endpoint specifico di status dei canali proxy (Pag. 322)
|
|
65
66
|
const res = await nvrAuth.request({
|
|
66
67
|
method: 'GET',
|
|
67
|
-
url: `${node.protocol}://${node.host}:${node.port}/ISAPI/ContentMgmt/InputProxy/channels`,
|
|
68
|
-
timeout:
|
|
68
|
+
url: `${node.protocol}://${node.host}:${node.port}/ISAPI/ContentMgmt/InputProxy/channels/status`,
|
|
69
|
+
timeout: 8000,
|
|
69
70
|
httpsAgent: node.protocol === "https" ? httpsAgent : undefined
|
|
70
71
|
});
|
|
71
72
|
|
|
72
73
|
const xml = res.data.toString();
|
|
73
|
-
//
|
|
74
|
-
const channelBlocks = xml.match(/<
|
|
74
|
+
// Separiamo i singoli blocchi <InputProxyChannelStatus>
|
|
75
|
+
const channelBlocks = xml.match(/<InputProxyChannelStatus>[\s\S]*?<\/InputProxyChannelStatus>/g) || [];
|
|
75
76
|
|
|
76
77
|
for (let block of channelBlocks) {
|
|
77
|
-
const idMatch = block.match(/<id>(\
|
|
78
|
+
const idMatch = block.match(/<id>([\s\S]*?)<\/id>/i);
|
|
79
|
+
const onlineMatch = block.match(/<online>[ \t]*(true|false)[ \t]*<\/online>/i);
|
|
80
|
+
const nameMatch = block.match(/<channelName>([^<]+)<\/channelName>/i);
|
|
78
81
|
|
|
79
82
|
if (idMatch) {
|
|
80
|
-
const ch = idMatch[1];
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
//
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
if (rawOnlineMatch && rawOnlineMatch[1]) {
|
|
89
|
-
const val = rawOnlineMatch[1].trim().toLowerCase();
|
|
90
|
-
// Se il testo contiene "true", la telecamera è online
|
|
91
|
-
if (val.includes("true")) {
|
|
92
|
-
isOnline = true;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
83
|
+
const ch = idMatch[1].trim();
|
|
84
|
+
// Estraiamo lo stato online nativo (true/false)
|
|
85
|
+
const isOnline = onlineMatch ? onlineMatch[1].trim().toLowerCase() === "true" : false;
|
|
86
|
+
// Estraiamo il nome reale configurato nell'NVR (se vuoto o "--", usiamo un fallback)
|
|
87
|
+
let nomeCameraReal = nameMatch ? nameMatch[1].trim() : `Camera ${ch}`;
|
|
88
|
+
if (nomeCameraReal === "--") nomeCameraReal = `Camera ${ch}`;
|
|
89
|
+
|
|
96
90
|
if (isOnline && statoCamera[ch] === false) {
|
|
97
|
-
|
|
98
|
-
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" } });
|
|
91
|
+
node.send({ payload: { tipo_messaggio: "status", stato_telecamera: "online", nome_cliente: node.name, nome_telecamera: nomeCameraReal, ip_telecamera: node.host, channel: ch, msg: "Camera ripristinata" } });
|
|
99
92
|
statoCamera[ch] = true;
|
|
100
|
-
} else if (!isOnline && statoCamera[ch]
|
|
101
|
-
node.send({ payload: { tipo_messaggio: "status", stato_telecamera: "offline", nome_cliente: node.name, nome_telecamera:
|
|
93
|
+
} else if (!isOnline && statoCamera[ch] === true) {
|
|
94
|
+
node.send({ payload: { tipo_messaggio: "status", stato_telecamera: "offline", nome_cliente: node.name, nome_telecamera: nomeCameraReal, ip_telecamera: node.host, channel: ch, msg: "Camera non raggiungibile" } });
|
|
102
95
|
statoCamera[ch] = false;
|
|
103
96
|
} else if (statoCamera[ch] === undefined) {
|
|
104
|
-
//
|
|
97
|
+
// Primo avvio: memorizza lo stato specchio dell'NVR
|
|
105
98
|
statoCamera[ch] = isOnline;
|
|
106
99
|
}
|
|
107
100
|
}
|
|
108
101
|
}
|
|
109
102
|
} catch (e) {
|
|
110
|
-
node.error(`Errore nel check diagnostico: ${e.message}`);
|
|
103
|
+
node.error(`Errore nel check diagnostico InputProxy: ${e.message}`);
|
|
111
104
|
}
|
|
112
105
|
updateNodeStatus();
|
|
113
106
|
}
|