From d3212b70d98ff1b2cd74829deba5245f8596e73d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ali=20Burak=20Kulakl=C4=B1?= Date: Wed, 24 May 2023 12:51:00 +0300 Subject: [PATCH 1/7] send connection status to as a msg without payload --- ocpp/ocpp-server.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/ocpp/ocpp-server.js b/ocpp/ocpp-server.js index e2c4828..9f63444 100644 --- a/ocpp/ocpp-server.js +++ b/ocpp/ocpp-server.js @@ -436,6 +436,28 @@ module.exports = function(RED) { debug_csserver(`Websocket connection to : ${localcbid}`); + + msg = { + ocpp : { + websocket : 'ONLINE', + chargeBoxIdentity : localcbid + } + }; + node.send(msg); + + ws.on('close', function ws_close(code, reason) { + msg = { + ocpp : { + websocket : 'OFFLINE', + chargeBoxIdentity : localcbid, + code : code, + reason : reason, + } + }; + + node.send(msg); + }); + ws.on('message', function(msgIn) { let response = []; From ed991e5c4cf91f132e874e1207c30bd925c471f6 Mon Sep 17 00:00:00 2001 From: David D'Hauwe Date: Wed, 24 May 2023 19:55:43 +0200 Subject: [PATCH 2/7] added wsnoreconn in close to avoid reconnect --- ocpp/ocpp-cp-json.js | 1 + 1 file changed, 1 insertion(+) diff --git a/ocpp/ocpp-cp-json.js b/ocpp/ocpp-cp-json.js index 0eeae16..e3c71a0 100644 --- a/ocpp/ocpp-cp-json.js +++ b/ocpp/ocpp-cp-json.js @@ -457,6 +457,7 @@ module.exports = function(RED) { node.send(msg);//send update NetStatus = msg.ocpp.websocket; } + wsnoreconn = true; ws.close(); }); From aa95e92be58936d18c6eb2b07cf7943fd9960f9c Mon Sep 17 00:00:00 2001 From: caspar Date: Mon, 29 May 2023 17:43:55 +0800 Subject: [PATCH 3/7] Fix: When two CPs connect to the CS simultaneously, the second CP will not receive the "ONLINE" notification. --- ocpp/ocpp-cp-json.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ocpp/ocpp-cp-json.js b/ocpp/ocpp-cp-json.js index 0eeae16..07ecf59 100644 --- a/ocpp/ocpp-cp-json.js +++ b/ocpp/ocpp-cp-json.js @@ -12,7 +12,6 @@ const url = require('node:url'); const path = require('node:path'); let ee = new EventEmitter(); -let NetStatus = 'OFFLINE'; const WSTOMIN_DEF = 5; const WSTOMAX_DEF = 360; @@ -71,6 +70,7 @@ module.exports = function(RED) { let wstocur = parseInt(node.wstomin); let conto; let wsnoreconn = false; + let NetStatus = 'OFFLINE'; function reconn_debug() { debug(`wstomin: ${node.wstomin}`); From 5cdc6659e9a8e47594e1290e83c05b9ea9bdcf0c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 19 Jul 2023 02:53:17 +0000 Subject: [PATCH 4/7] Bump word-wrap from 1.2.3 to 1.2.4 Bumps [word-wrap](https://github.com/jonschlinkert/word-wrap) from 1.2.3 to 1.2.4. - [Release notes](https://github.com/jonschlinkert/word-wrap/releases) - [Commits](https://github.com/jonschlinkert/word-wrap/compare/1.2.3...1.2.4) --- updated-dependencies: - dependency-name: word-wrap dependency-type: indirect ... Signed-off-by: dependabot[bot] --- package-lock.json | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index fdd2c5a..2292bed 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "node-red-contrib-ocpp", - "version": "1.3.4", + "version": "1.3.5", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "node-red-contrib-ocpp", - "version": "1.3.4", + "version": "1.3.5", "license": "BSD-3-Clause", "dependencies": { "debug": "^4.3.1", @@ -3500,9 +3500,9 @@ } }, "node_modules/word-wrap": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", - "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==", + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.4.tgz", + "integrity": "sha512-2V81OA4ugVo5pRo46hAoD2ivUJx8jXmWXfUkY4KFNw0hEptvN0QfH3K4nHiwzGeKl5rFKedV48QVoqYavy4YpA==", "dev": true, "engines": { "node": ">=0.10.0" @@ -6114,9 +6114,9 @@ } }, "word-wrap": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", - "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==", + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.4.tgz", + "integrity": "sha512-2V81OA4ugVo5pRo46hAoD2ivUJx8jXmWXfUkY4KFNw0hEptvN0QfH3K4nHiwzGeKl5rFKedV48QVoqYavy4YpA==", "dev": true }, "wrappy": { From 78c51e0dae250b48d718978c66841a7e99bea8d9 Mon Sep 17 00:00:00 2001 From: Bryan Nystrom Date: Wed, 19 Jul 2023 12:12:52 -0500 Subject: [PATCH 5/7] Ignore connections without params --- ocpp/ocpp-server.js | 52 +++++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 25 deletions(-) diff --git a/ocpp/ocpp-server.js b/ocpp/ocpp-server.js index 9f63444..fc24528 100644 --- a/ocpp/ocpp-server.js +++ b/ocpp/ocpp-server.js @@ -223,38 +223,40 @@ module.exports = function(RED) { let wsrequest; x.on('connection', function connection(ws,req) { - debug_csserver(`Got a connection from ${req.params.cbid}...`); - const cbid = req.params.cbid; - let connname = cbid + CBIDCONPOSTFIX; - cb_map.set(cbid,ws); + debug_csserver(`Req: ${req}`); + if (req.params){ + debug_csserver(`Got a connection from ${req.params.cbid}...`); + const cbid = req.params.cbid; + let connname = cbid + CBIDCONPOSTFIX; + cb_map.set(cbid,ws); - node.status({ - fill: 'green', - shape: 'dot', - text: `Connection from ${cbid}`, - }); + node.status({ + fill: 'green', + shape: 'dot', + text: `Connection from ${cbid}`, + }); - // Announce connection + // Announce connection - ee.emit(connname,"connected"); + ee.emit(connname,"connected"); - // Remove cbid from map when it closes and emit a message - ws.on('close', function () { - cb_map.delete(cbid); - node.status({ - fill: 'gray', - shape: 'dot', - text: `Disconnected from ${cbid}`, + // Remove cbid from map when it closes and emit a message + ws.on('close', function () { + cb_map.delete(cbid); + node.status({ + fill: 'gray', + shape: 'dot', + text: `Disconnected from ${cbid}`, + }); + ee.emit(connname,"disconnected"); + debug_csserver(`Lost connection to ${cbid}`); }); - ee.emit(connname,"disconnected"); - debug_csserver(`Lost connection to ${cbid}`); - }); - - ws.on('message', function(msgIn) { - debug_csserver(msgIn); - }); + ws.on('message', function(msgIn) { + debug_csserver(msgIn); + }); + } }); let soapServer15, soapServer16; From 285276ea135c97ad6aca679c563c465a52f6af0d Mon Sep 17 00:00:00 2001 From: Bryan Nystrom Date: Wed, 19 Jul 2023 12:13:24 -0500 Subject: [PATCH 6/7] bump version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a50b8da..853268f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "node-red-contrib-ocpp", - "version": "1.3.5", + "version": "1.3.6", "description": "A set of nodes to communicate via OCPP to a compatible charge box or central system", "main": "ocpp-req.js", "scripts": { From 5bc32e7705f38e0ccfdd3b521705a9fe4fcbb2c1 Mon Sep 17 00:00:00 2001 From: Bryan Nystrom Date: Wed, 19 Jul 2023 12:15:54 -0500 Subject: [PATCH 7/7] remove debug statement --- ocpp/ocpp-server.js | 1 - 1 file changed, 1 deletion(-) diff --git a/ocpp/ocpp-server.js b/ocpp/ocpp-server.js index fc24528..aa69ca4 100644 --- a/ocpp/ocpp-server.js +++ b/ocpp/ocpp-server.js @@ -223,7 +223,6 @@ module.exports = function(RED) { let wsrequest; x.on('connection', function connection(ws,req) { - debug_csserver(`Req: ${req}`); if (req.params){ debug_csserver(`Got a connection from ${req.params.cbid}...`); const cbid = req.params.cbid;