Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-red-contrib-hikvision-ultimate

Package Overview
Dependencies
Maintainers
1
Versions
119
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-red-contrib-hikvision-ultimate - npm Package Compare versions

Comparing version 0.0.19 to 0.0.20

4

CHANGELOG.md

@@ -5,2 +5,6 @@ # node-red-contrib-hikvision-ultimate

<p>
<b>Version 0.0.20 GA VERSION WITH STABLE BEHAVOUR</b> December 2020<br/>
- NEW: added the PIN 2 for signalling errors.<br/>
</p>
<p>
<b>Version 0.0.19 LAST BETA BEFORE STABLE RELEASE</b> December 2020<br/>

@@ -7,0 +11,0 @@ - Better handling of status messages.<br/>

39

nodes/ANPR-config.js

@@ -15,4 +15,5 @@

node.nodeClients = []; // Stores the registered clients
node.isConnected = false;
node.isConnected = true; // Assume it's connected, to signal the disconnection on start
node.lastPicName = "";
node.errorDescription = ""; // Contains the error description in case of connection error.
var controller = null; // Abortcontroller

@@ -70,5 +71,5 @@

} else {
node.setAllClientsStatus({ fill: "red", shape: "ring", text: response.statusText });
console.log("BANANA Error response " + response.statusText);
throw ("Error response: " + response.statusText);
node.setAllClientsStatus({ fill: "red", shape: "ring", text: response.statusText || " unknown response code" });
//console.log("BANANA Error response " + response.statusText);
throw new Error("Error response: " + response.statusText || " unknown response code");
}

@@ -99,3 +100,3 @@ //#region "BODY"

// console.log("BANANA ANPR-config: DecodingBody: Invalid Json " + sRet);
throw ("Error Invalid Json: " + sRet);
throw new Error("Error Invalid Json: " + sRet);
}

@@ -106,8 +107,12 @@ }

if (oPlates.Plates !== null && oPlates.Plates !== undefined) {
// Send connection OK
if (!node.isConnected) {
node.nodeClients.forEach(oClient => {
oClient.sendPayload({ topic: oClient.topic || "", payload: null, connected: true });
oClient.sendPayload({ topic: oClient.topic || "", errorDescription: "", payload: false });
})
}
node.errorDescription = ""; // Reset the error message
node.isConnected = true;
//console.log("BANANA JSON PLATES: " + JSON.stringify(oPlates));

@@ -125,11 +130,13 @@ if (oPlates.Plates.hasOwnProperty("Plate")) {

}
} else {
// Error in parsing XML
throw ("Error: oPlates.Plates is null");
RED.log.info("ANPR-config: Error: oPlates.Plates is null");
throw new Error("Error: oPlates.Plates is null");
}
} catch (error) {
RED.log.error("ANPR-config: ERRORE CATCHATO initPlateReader:" + error);
RED.log.warn("ANPR-config: ERRORE CATCHATO initPlateReader:" + (error.message || ""));
// console.log("BANANA ANPR-config: ERRORE CATCHATO initPlateReader: " + error);
throw ("Error initPlateReader: " + error);
throw new Error("Error initPlateReader: " + (error.message || ""));
}

@@ -140,3 +147,9 @@ }

// Main Error
// console.log("BANANA MAIN ERROR: " + err);
node.errorDescription = err.message || " unknown error";
node.setAllClientsStatus({ fill: "grey", shape: "ring", text: "Server unreachable: " + node.errorDescription + " Retry..." });
if (node.isConnected) {
node.nodeClients.forEach(oClient => {
oClient.sendPayload({ topic: oClient.topic || "", errorDescription: node.errorDescription, payload: true });
})
}
// Abort request

@@ -146,8 +159,2 @@ try {

} catch (error) { }
node.setAllClientsStatus({ fill: "grey", shape: "ring", text: "Server unreachable: " + err + " Retry..." });
if (node.isConnected) {
node.nodeClients.forEach(oClient => {
oClient.sendPayload({ topic: oClient.topic || "", payload: null, connected: false });
})
}
node.isConnected = false;

@@ -154,0 +161,0 @@ return null;

@@ -16,4 +16,5 @@

node.nodeClients = []; // Stores the registered clients
node.isConnected = false;
node.isConnected = true; // Assumes, that is already connected.
node.timerCheckHeartBeat = null;
node.errorDescription = ""; // Contains the error description in case of connection error.
var controller = null; // AbortController

@@ -28,2 +29,4 @@

// This function starts the heartbeat timer, to detect the disconnection from the server

@@ -34,15 +37,15 @@ node.resetHeartBeatTimer = () => {

node.timerCheckHeartBeat = setTimeout(() => {
try {
if (controller !== null) controller.abort();
} catch (error) { }
if (node.isConnected) {
if (node.errorDescription === "") node.errorDescription = "Timeout waiting heartbeat"; // In case of timeout of a stream, there is no error throwed.
node.nodeClients.forEach(oClient => {
oClient.sendPayload({ topic: oClient.topic || "", payload: null, connected: false });
oClient.sendPayload({ topic: oClient.topic || "", errorDescription: node.errorDescription, payload: true });
});
node.setAllClientsStatus({ fill: "red", shape: "ring", text: "Lost connection...Retry..." });
node.setAllClientsStatus({ fill: "red", shape: "ring", text: "Lost connection...Retry... " + node.errorDescription });
}
try {
if (controller !== null) controller.abort();
} catch (error) { }
node.isConnected = false;
setTimeout(startAlarmStream, 5000); // Reconnect
}, 40000);
setTimeout(startAlarmStream, 2000); // Reconnect
}, 26000);
}

@@ -102,3 +105,3 @@

node.nodeClients.forEach(oClient => {
if (result !== undefined) oClient.sendPayload({ topic: oClient.topic || "", payload: result.EventNotificationAlert, connected: true });
if (result !== undefined) oClient.sendPayload({ topic: oClient.topic || "", payload: result.EventNotificationAlert });
})

@@ -113,3 +116,3 @@ });

node.nodeClients.forEach(oClient => {
oClient.sendPayload({ topic: oClient.topic || "", payload: JSON.parse(sRet), connected: true });
oClient.sendPayload({ topic: oClient.topic || "", payload: JSON.parse(sRet) });
})

@@ -127,3 +130,4 @@ } else {

// console.log("BANANA startAlarmStream decodifica body: " + error);
RED.log.error("Hikvision-config: DecodingBody error: " + error);
RED.log.warn("Hikvision-config: DecodingBody error: " + (error.message || " unknown error"));
throw (error);
}

@@ -133,4 +137,6 @@ }

} catch (error) {
// console.log("BANANA NEL BODY errore " + error);
return;
RED.log.info("Hikvision-config: readStream error: " + (error.message || " unknown error"));
node.errorDescription = "readStream error " + (error.message || " unknown error");
throw (error);
}

@@ -142,10 +148,19 @@ }

const response = await client.fetch("http://" + node.host + "/ISAPI/Event/notification/alertStream", options);
if (response.status >= 200 && response.status <= 300) {
node.setAllClientsStatus({ fill: "green", shape: "ring", text: "Waiting for Alarm." });
} else {
node.setAllClientsStatus({ fill: "red", shape: "ring", text: response.statusText });
node.setAllClientsStatus({ fill: "red", shape: "ring", text: response.statusText || " unknown response code"});
// console.log("BANANA Error response " + response.statusText);
throw ("Error response: " + response.statusText);
node.errorDescription = "StatusResponse problem " + (response.statusText || " unknown status response code");
throw new Error("StatusResponse " + (response.statusText || " unknown response code"));
}
if (response.ok) {
if (!node.isConnected) {
node.setAllClientsStatus({ fill: "green", shape: "ring", text: "Connected." });
node.nodeClients.forEach(oClient => {
oClient.sendPayload({ topic: oClient.topic || "", errorDescription: "", payload: false });
})
node.errorDescription = ""; // Reset the error
}
node.isConnected = true;

@@ -155,19 +170,8 @@ streamPipeline(response.body, readStream);

} catch (err) {
} catch (error) {
// Main Error
// console.log("BANANA MAIN ERROR: " + err);
// Abort request
try {
if (controller !== null) controller.abort();
} catch (error) { }
node.setAllClientsStatus({ fill: "grey", shape: "ring", text: "Server unreachable: " + err + " Retry..." });
if (node.isConnected) {
try {
node.nodeClients.forEach(oClient => {
oClient.sendPayload({ topic: oClient.topic || "", payload: null, connected: false });
})
} catch (error) { }
}
node.isConnected = false;
//node.errorDescription = "Fetch error " + JSON.stringify(error, Object.getOwnPropertyNames(error));
node.errorDescription = "Fetch error " + (error.message || " unknown error");
RED.log.error("Hikvision-config: FETCH ERROR: " + (error.message || " unknown error"));
};

@@ -177,3 +181,3 @@

setTimeout(startAlarmStream, 5000); // First connection.
setTimeout(startAlarmStream, 10000); // First connection.

@@ -180,0 +184,0 @@

@@ -16,3 +16,4 @@

node.sendPayload = (_msg) => {
if (_msg.payload === null) { node.send(_msg); return; }; // If null, then it's disconnected. Avoid processing the event
if (_msg.hasOwnProperty("errorDescription")) { node.send([null,_msg]); return; }; // It's a connection error/restore comunication.
if (_msg.payload.hasOwnProperty("eventType")

@@ -27,3 +28,3 @@ && _msg.payload.eventType.toString().toLowerCase() === "videoloss"

node.setNodeStatus({ fill: "green", shape: "dot", text: "Alert received" });
node.send(_msg);
node.send([_msg,null]);
}

@@ -30,0 +31,0 @@

@@ -20,3 +20,3 @@

node.sendPayload = (_msg) => {
if (_msg.payload === null) { node.send(_msg); return; }; // If null, then it's disconnected. Avoid processing the event
if (_msg.hasOwnProperty("errorDescription")) { node.send([null,_msg]); return; }; // It's a connection error/restore comunication.

@@ -40,3 +40,3 @@ if (node.currentPlate === _msg.payload) {

node.currentPlate = _msg.payload;
node.send(_msg);
node.send([_msg,null]);
try {

@@ -54,3 +54,3 @@ node.setNodeStatus({ fill: "green", shape: "dot", text: "Plate " + _msg.payload });

this.on('input', function (msg) {
node.sendPayload(msg);
});

@@ -57,0 +57,0 @@

@@ -17,3 +17,3 @@

node.sendPayload = (_msg) => {
if (_msg.payload === null) { node.send(_msg); return; }; // If null, then it's disconnected. Avoid processing the event
if (_msg.hasOwnProperty("errorDescription")) { node.send([null,_msg]); return; }; // It's a connection error/restore comunication.
// Radar alarm JSON

@@ -75,3 +75,3 @@ /* {

}
node.send(oRetMsg);
node.send([oRetMsg,null]);
}

@@ -88,3 +88,3 @@ }

this.on('input', function (msg) {
node.sendPayload(msg);
});

@@ -91,0 +91,0 @@

{
"name": "node-red-contrib-hikvision-ultimate",
"version": "0.0.19",
"version": "0.0.20",
"description": "A native set of node for Hikvision Cameras, Alarms, Radars etc.",

@@ -5,0 +5,0 @@ "author": "Supergiovane (https://github.com/Supergiovane)",

@@ -39,6 +39,8 @@ # node-red-contrib-hikvision-ultimate

The node outputs a payload that can vary, depending from the alarm type sent by the connected device.</br>
The node outputs a payload on **PIN 1** that can vary, depending from the alarm type sent by the connected device.</br>
The node outputs a payload on **PIN 2**, representing a connection error. ***TRUE*** if error, otherwise ***FALSE***</br>
This below, is only an example (in this case, a movement detected from a radar)</br>
**Caution**: the node actively checks if the device is connected to the network. In case of disconnection/reconnection, the nodes will output a message with **msg.connected = false** with a ***null*** payload if disconnected, and **msg.connected = true** if connected.<br/>
**Output PIN 1**
```javascript

@@ -75,3 +77,2 @@ msg.payload = {

},
"connected": true,
"_msgid": "dba1850a.2dc5e8"

@@ -81,2 +82,11 @@ }

**Output PIN 2 (connection error)**
```javascript
msg = {
"topic": "",
"errorDescription": "", // This will contain the error rescription, in case of errors.
"payload": false, // Or TRUE if error
"_msgid": "dd5b3622.884a78"
}
```
<br/>

@@ -92,4 +102,4 @@ <br/>

The payload contains the license plate number and the property "plate" contains other useful informations.</br>
**Caution**: the node actively checks if the ANPR camera is connected to the network. In case of disconnection/reconnection, the nodes will output a message with **msg.connected = false** with a ***null*** payload if disconnected, and **msg.connected = true** if connected.<br/>
**Output PIN 1**
```javascript

@@ -99,3 +109,2 @@ msg.payload = {

"payload":"AB123CD", // This is the license plate
"connected":true, // true if the connection is OK, otherwise false if the connection is lost.
"plate":{

@@ -113,2 +122,11 @@ "captureTime":"20201130T114200+0100",

**Output PIN 2 (connection error)**
```javascript
msg = {
"topic": "",
"errorDescription": "", // This will contain the error rescription, in case of errors.
"payload": false, // Or TRUE if error
"_msgid": "dd5b3622.884a78"
}
```
<br/>

@@ -127,8 +145,7 @@ <br/>

In an **unknown CID event** arrives from the Radar, the node will output a message containing the CID code, the full alarm and a null payload.</br>
**Caution**: the node actively checks if the radar is connected to the network. In case of disconnection/reconnection, the nodes will output a message with **msg.connected = false** with a ***null*** payload if disconnected, and **msg.connected = true** if connected.<br/>
**Output PIN 1**
```javascript
msg.payload = {
{
"connected": true, // true if the connection is OK, otherwise false if the connection is lost.
"zone": 1, // This is the zone number that fired the alarm

@@ -170,2 +187,11 @@ "payload": true, // true if alarm, otherwise false if alarm ended.

**Output PIN 2 (connection error)**
```javascript
msg = {
"topic": "",
"errorDescription": "", // This will contain the error rescription, in case of errors.
"payload": false, // Or TRUE if error
"_msgid": "dd5b3622.884a78"
}
```

@@ -172,0 +198,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc