node-red-contrib-hik-media-buffer 1.1.10 → 1.1.12
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 +32 -7
- package/package.json +1 -1
package/hik-media-buffer.js
CHANGED
|
@@ -42,17 +42,42 @@ module.exports = function(RED) {
|
|
|
42
42
|
|
|
43
43
|
// --- PRENDE IL NOME DELLA TELECAMERA ---
|
|
44
44
|
async function getCameraName(cam) {
|
|
45
|
+
const camAuth = new AxiosDigestAuth({
|
|
46
|
+
username: node.user,
|
|
47
|
+
password: node.camPass
|
|
48
|
+
});
|
|
49
|
+
|
|
45
50
|
try {
|
|
46
|
-
|
|
51
|
+
console.log(`\n--- INIZIO RISPOSTA XML DA ${cam.ip} ---`);
|
|
52
|
+
|
|
53
|
+
const res = await camAuth.request({
|
|
47
54
|
method: 'GET',
|
|
48
|
-
url: `${node.protocol}://${cam.ip}:${node.port}/ISAPI/System/
|
|
49
|
-
|
|
50
|
-
|
|
55
|
+
url: `${node.protocol}://${cam.ip}:${node.port}/ISAPI/System/deviceInfo`,
|
|
56
|
+
timeout: 5000,
|
|
57
|
+
httpsAgent: node.protocol === "https" ? httpsAgent : undefined
|
|
51
58
|
});
|
|
52
|
-
|
|
53
|
-
|
|
59
|
+
|
|
60
|
+
// Stampiamo TUTTO l'XML ricevuto
|
|
61
|
+
const xmlCompleto = res.data.toString();
|
|
62
|
+
console.log(xmlCompleto);
|
|
63
|
+
console.log(`--- FINE RISPOSTA XML ---\n`);
|
|
64
|
+
|
|
65
|
+
// Proviamo a estrarre il nome (cambieremo la regex dopo aver visto il log)
|
|
66
|
+
const match = xmlCompleto.match(/<deviceName>([^<]+)<\/deviceName>/i);
|
|
67
|
+
|
|
68
|
+
if (match) {
|
|
69
|
+
return match[1];
|
|
70
|
+
} else {
|
|
71
|
+
return `Tag_Non_Trovato_${cam.ip}`;
|
|
72
|
+
}
|
|
73
|
+
|
|
54
74
|
} catch (e) {
|
|
55
|
-
|
|
75
|
+
console.log(`[ERRORE] Chiamata fallita a ${cam.ip}: ${e.message}`);
|
|
76
|
+
if (e.response) {
|
|
77
|
+
// Se la camera risponde con un errore (es. 401 Unauthorized) lo vediamo qui
|
|
78
|
+
console.log(`[ERRORE] Dati tecnici:`, e.response.data.toString());
|
|
79
|
+
}
|
|
80
|
+
return `Errore_Connessione_${cam.ip}`;
|
|
56
81
|
}
|
|
57
82
|
}
|
|
58
83
|
|