node-red-contrib-sia-ultimate
Advanced tools
Comparing version 1.0.5 to 1.0.6
@@ -11,2 +11,6 @@ # node-red-contrib-sia-ultimate | ||
<p> | ||
<b>Version 1.0.6</b> - January 2022<br/> | ||
- FIX: fixed an issue preventing the TCP server to start.<br/> | ||
</p> | ||
<p> | ||
<b>Version 1.0.5</b> - December 2021<br/> | ||
@@ -13,0 +17,0 @@ - FIX: fix a possible crash if you have more than 1 server node with the same port.<br/> |
@@ -401,6 +401,57 @@ | ||
try { | ||
servertcp = net.createServer(onClientConnectedTCP(servertcp)); | ||
servertcp = net.createServer(function (sock) { | ||
let ack = null; | ||
// RED.log.info('siaendpointConfig: New client connected: ' + remoteAddress); | ||
var remoteAddress = sock.address().address + ':' + sock.address().port; | ||
sock.on('data', (data) => { | ||
// data = Buffer.from(data,'binary'); | ||
// data = new Buffer(data); | ||
RED.log.debug('siaendpointConfig: TCP received from ' + remoteAddress + ' following data: ' + JSON.stringify(data)); | ||
RED.log.debug('siaendpointConfig: TCP received from ' + remoteAddress + ' following message: ' + data.toString().trim()); | ||
let sia = parseSIA(data); | ||
if (sia) { | ||
ack = ackSIA(sia); | ||
if (ack) { | ||
// set states only if ACK okay | ||
setStatesSIA(sia); | ||
node.nodeClients.forEach(oClient => { | ||
oClient.sendPayload({ connection: "TCP", decoded: sia }); | ||
}) | ||
node.errorDescription = ""; // Reset the error | ||
startHeartBeat(); | ||
} else { | ||
let crcformat = getcrcFormat(data); | ||
ack = nackSIA(crcformat); | ||
} | ||
} else { | ||
let crcformat = getcrcFormat(data); | ||
ack = nackSIA(crcformat); | ||
} | ||
try { | ||
//sock.end(ack); | ||
// 23/12/2021 Fix for issue https://github.com/Supergiovane/node-red-contrib-sia-ultimate/issues/2 | ||
sock.write(ack); | ||
setTimeout(() => { | ||
sock.end(); | ||
}, 700); | ||
RED.log.info('siaendpointConfig: sending ACK VIA TCP to ' + remoteAddress + ' following message: ' + ack.toString().trim()); | ||
} catch (e) { | ||
// Error Message | ||
try { | ||
RED.log.error('siaendpointConfig: sending ACK VIA TCP to ' + remoteAddress + ' following message: ' + ack.toString().trim() + " Error:" + e.message); | ||
} catch (error) { } | ||
} | ||
}); | ||
sock.on('close', () => { | ||
RED.log.info('siaendpointConfig: TCP connection from ' + remoteAddress + ' closed'); | ||
}); | ||
sock.on('error', (err) => { | ||
RED.log.error('siaendpointConfig: TCP Connection ' + remoteAddress + ' error: ' + err.message); | ||
}); | ||
}); | ||
servertcp.listen(node.port, () => { | ||
try { | ||
let text = 'siaendpointConfig: SIA Server listening on IP-Adress (TCP): ' + servertcp.address().address || "" + ':' + servertcp.address().port; | ||
let text = 'siaendpointConfig: SIA Server listening on IP-Adress (TCP): ' + servertcp.address().address + ':' + servertcp.address().port; | ||
RED.log.info(text); | ||
@@ -619,6 +670,6 @@ } catch (error) { | ||
// delete sock._readableState.decoder; | ||
let remoteAddress = sock.remoteAddress + ':' + sock.remotePort; | ||
let ack = null; | ||
// RED.log.info('siaendpointConfig: New client connected: ' + remoteAddress); | ||
sock.on('data', (data) => { | ||
var remoteAddress = sock.address().address + ':' + sock.address().port; | ||
// data = Buffer.from(data,'binary'); | ||
@@ -836,8 +887,11 @@ // data = new Buffer(data); | ||
serverStartTCP(); | ||
} catch (error) { | ||
node.setAllClientsStatus({ fill: "red", shape: "dot", text: "Error instantiating server TCP " + error.message }); | ||
} | ||
try { | ||
serverStartUDP(); | ||
} catch (error) { | ||
node.setAllClientsStatus({ fill: "red", shape: "dot", text: "Error instantiating server " + error.message }); | ||
return; | ||
node.setAllClientsStatus({ fill: "red", shape: "dot", text: "Error instantiating server UDP " + error.message }); | ||
} | ||
startHeartBeat(); | ||
@@ -844,0 +898,0 @@ |
{ | ||
"name": "node-red-contrib-sia-ultimate", | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"description": "Connect your SIA-DCS compatible alarm system to node-red. It works with Ajax System too.", | ||
@@ -5,0 +5,0 @@ "author": "Supergiovane (https://github.com/Supergiovane)", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
123318
1034