From e5b32a7546a93c005fe6f94ba2c7e1cf0bad02e8 Mon Sep 17 00:00:00 2001 From: giacomoaccursi <52125090+giacomoaccursi@users.noreply.github.com> Date: Tue, 30 May 2023 15:56:28 +0200 Subject: [PATCH 1/2] fix: add string terminator on serial message --- data/flows.json | 449 +++++++++++++++++++++++++----------------------- 1 file changed, 238 insertions(+), 211 deletions(-) diff --git a/data/flows.json b/data/flows.json index 9281958..a754948 100644 --- a/data/flows.json +++ b/data/flows.json @@ -232,7 +232,7 @@ "type": "function", "z": "09012e75c72a4968", "name": "UpdateActuatorState", - "func": "let jsonData = JSON.parse(msg.payload);\n\nmsg.payload = [\n {\n \"op\": \"add\",\n \"path\": \"/intensity_percentage\",\n \"value\": msg.intensity_percentage\n },\n {\n \"op\": \"add\",\n \"path\": \"/power_state\",\n \"value\": msg.state\n },\n {\n \"op\": \"add\",\n \"path\": \"/type\",\n \"value\": jsonData[msg.actuator_id][\"type\"]\n }\n]\n\nmsg.url = \"https://digital-twin-layer.api.neu.digitaltwins.azure.net/digitaltwins/\" + msg.actuator_id + \"?api-version=2023-02-27-preview\"\nmsg.method = \"patch\"\n\nreturn msg; \n", + "func": "let jsonData = JSON.parse(msg.payload);\n\nmsg.payload = [\n {\n \"op\": \"add\",\n \"path\": \"/intensity\",\n \"value\": msg.intensity_percentage\n },\n {\n \"op\": \"add\",\n \"path\": \"/power_state\",\n \"value\": msg.state\n },\n {\n \"op\": \"add\",\n \"path\": \"/type\",\n \"value\": jsonData[msg.actuator_id][\"type\"]\n }\n]\n\nmsg.url = \"https://digital-twin-layer.api.neu.digitaltwins.azure.net/digitaltwins/\" + msg.actuator_id + \"?api-version=2023-02-27-preview\"\nmsg.method = \"patch\"\n\nreturn msg; \n", "outputs": 1, "noerr": 0, "initialize": "", @@ -289,7 +289,7 @@ "type": "function", "z": "09012e75c72a4968", "name": "processAcutatorData", - "func": "msg.actuator_id = msg.serialData[\"actuator_id\"]\nmsg.state = msg.serialData[\"state\"]\nmsg.intensity_percentage = msg.serialData[\"intensity_percentage\"]\n\nreturn msg;", + "func": "msg.actuator_id = msg.serialData[\"actuator_id\"]\nmsg.state = msg.serialData[\"state\"]\nmsg.intensity_percentage = msg.serialData[\"intensity\"]\n\nreturn msg;", "outputs": 1, "noerr": 0, "initialize": "", @@ -476,23 +476,6 @@ ] ] }, - { - "id": "3a01a886905e5fed", - "type": "http in", - "z": "09012e75c72a4968", - "name": "ActuatorCommand", - "url": "/:actuator_id/:state", - "method": "post", - "upload": false, - "swaggerDoc": "", - "x": 90, - "y": 1300, - "wires": [ - [ - "d95b89b933ecab60" - ] - ] - }, { "id": "5c6d578149de144a", "type": "file", @@ -531,128 +514,6 @@ ] ] }, - { - "id": "8b23d4b6fc9ad1ef", - "type": "file in", - "z": "09012e75c72a4968", - "name": "read actuator_room_mapping", - "filename": "/data/configFiles/actuator_room_mapping.json", - "filenameType": "str", - "format": "utf8", - "chunk": false, - "sendError": false, - "encoding": "utf8", - "allProps": false, - "x": 730, - "y": 1300, - "wires": [ - [ - "4cadd432c4275bcf" - ] - ] - }, - { - "id": "d95b89b933ecab60", - "type": "function", - "z": "09012e75c72a4968", - "name": "getActuatorIDAndState", - "func": "msg.actuator_id = msg.req.params.actuator_id\nmsg.state = msg.req.params.state\n\nreturn msg;", - "outputs": 1, - "noerr": 0, - "initialize": "", - "finalize": "", - "libs": [], - "x": 300, - "y": 1300, - "wires": [ - [ - "d58bb8c70feab022" - ] - ] - }, - { - "id": "1107f97b9aa49722", - "type": "function", - "z": "09012e75c72a4968", - "name": "getRoomIDAndActuatorType", - "func": "let jsonData = JSON.parse(msg.payload);\nmsg.room_id = jsonData[msg.actuator_id][\"room\"]\nmsg.type = jsonData[msg.actuator_id][\"type\"]\nreturn msg;", - "outputs": 1, - "noerr": 0, - "initialize": "", - "finalize": "", - "libs": [], - "x": 1200, - "y": 1300, - "wires": [ - [ - "b091a6ca8e4cf197" - ] - ] - }, - { - "id": "19b43e1a0fb43f50", - "type": "file in", - "z": "09012e75c72a4968", - "name": "read room_arduino_mapping", - "filename": "/data/configFiles/arduino_room_mapping.json", - "filenameType": "str", - "format": "utf8", - "chunk": false, - "sendError": false, - "encoding": "utf8", - "allProps": false, - "x": 1640, - "y": 1300, - "wires": [ - [ - "d4e5b06fb8d61cd3" - ] - ] - }, - { - "id": "0bcfc84520ddafb2", - "type": "function", - "z": "09012e75c72a4968", - "name": "getSerial", - "func": "let jsonData = JSON.parse(msg.payload);\nmsg.serial = jsonData[msg.room_id]\nreturn msg;", - "outputs": 1, - "noerr": 0, - "initialize": "", - "finalize": "", - "libs": [], - "x": 2120, - "y": 1300, - "wires": [ - [ - "334dc786bd2b068a" - ] - ] - }, - { - "id": "c38d2690eac04451", - "type": "switch", - "z": "09012e75c72a4968", - "name": "SerialSwitch", - "property": "serial", - "propertyType": "global", - "rules": [ - { - "t": "eq", - "v": "/dev/ttyUSB0", - "vt": "str" - } - ], - "checkall": "true", - "repair": false, - "outputs": 1, - "x": 2550, - "y": 1300, - "wires": [ - [ - "ea1d80c07843fb89" - ] - ] - }, { "id": "5941b09a0ae77bc7", "type": "function", @@ -987,25 +848,6 @@ ] ] }, - { - "id": "334dc786bd2b068a", - "type": "function", - "z": "09012e75c72a4968", - "name": "setSerialMessage", - "func": "msg.state = isNaN(msg.state) ? msg.state : parseInt(msg.state)\nmsg.payload = {}\nmsg.payload[\"command\"] = msg.type\nmsg.payload[\"room_id\"] = msg.room_id\nmsg.payload[\"status\"] = msg.state\n\nreturn msg;", - "outputs": 1, - "noerr": 0, - "initialize": "", - "finalize": "", - "libs": [], - "x": 2350, - "y": 1300, - "wires": [ - [ - "c38d2690eac04451" - ] - ] - }, { "id": "f6e56c9200cdd690", "type": "file in", @@ -1051,7 +893,7 @@ "type": "function", "z": "09012e75c72a4968", "name": "setSerial", - "func": "msg.serial_id = \"/dev/tty/USB0\"\nmsg.payload = JSON.parse(msg.payload)\nreturn msg;", + "func": "msg.serial_id = \"/dev/ttyUSB0\"\nmsg.payload = JSON.parse(msg.payload)\nreturn msg;", "outputs": 1, "noerr": 0, "initialize": "", @@ -1213,8 +1055,7 @@ "y": 180, "wires": [ [ - "1453612b8d0a384b", - "ef9e572b7ecb3f6b" + "1453612b8d0a384b" ] ] }, @@ -1343,16 +1184,6 @@ ] ] }, - { - "id": "ea1d80c07843fb89", - "type": "serial out", - "z": "09012e75c72a4968", - "name": "", - "serial": "94b8abb47e4cb1f2", - "x": 2690, - "y": 1300, - "wires": [] - }, { "id": "745c5f5dda78248a", "type": "function", @@ -1679,8 +1510,7 @@ "y": 780, "wires": [ [ - "3e879afc64077b51", - "e2b6b538afd2a18f" + "3e879afc64077b51" ] ] }, @@ -1897,93 +1727,290 @@ ] }, { - "id": "d58bb8c70feab022", + "id": "17539151bcd56410", + "type": "http in", + "z": "09012e75c72a4968", + "name": "SwitchableCommand", + "url": "switchable/:actuator_id/:state", + "method": "post", + "upload": false, + "swaggerDoc": "", + "x": 120, + "y": 1440, + "wires": [ + [ + "ea86bcd644900a6a" + ] + ] + }, + { + "id": "ea86bcd644900a6a", + "type": "function", + "z": "09012e75c72a4968", + "name": "getActuatorIDAndState", + "func": "msg.actuator_id = msg.req.params.actuator_id\nmsg.state = msg.req.params.state\n\nreturn msg;", + "outputs": 1, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 380, + "y": 1440, + "wires": [ + [ + "76a96541c0093520" + ] + ] + }, + { + "id": "bd491d97528395bd", + "type": "file in", + "z": "09012e75c72a4968", + "name": "read actuator_room_mapping", + "filename": "/data/configFiles/actuator_room_mapping.json", + "filenameType": "str", + "format": "utf8", + "chunk": false, + "sendError": false, + "encoding": "utf8", + "allProps": false, + "x": 850, + "y": 1440, + "wires": [ + [ + "e2f669d1ba3b28ac" + ] + ] + }, + { + "id": "76a96541c0093520", "type": "semaphore-take", "z": "09012e75c72a4968", "config": "79c828b03c9c24ca", "name": "", - "x": 500, - "y": 1300, + "x": 620, + "y": 1440, "wires": [ [ - "8b23d4b6fc9ad1ef" + "bd491d97528395bd" ] ] }, { - "id": "4cadd432c4275bcf", + "id": "e2f669d1ba3b28ac", "type": "semaphore-leave", "z": "09012e75c72a4968", "config": "79c828b03c9c24ca", "name": "", - "x": 970, - "y": 1300, + "x": 1110, + "y": 1440, + "wires": [ + [ + "10b82578608764af" + ] + ] + }, + { + "id": "10b82578608764af", + "type": "function", + "z": "09012e75c72a4968", + "name": "getRoomIDAndActuatorType", + "func": "let jsonData = JSON.parse(msg.payload);\nmsg.room_id = jsonData[msg.actuator_id][\"room\"]\nmsg.type = jsonData[msg.actuator_id][\"type\"]\nreturn msg;", + "outputs": 1, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 1400, + "y": 1440, + "wires": [ + [ + "d34536b4b286bde0" + ] + ] + }, + { + "id": "0321c7f715ae71a9", + "type": "file in", + "z": "09012e75c72a4968", + "name": "read room_arduino_mapping", + "filename": "/data/configFiles/arduino_room_mapping.json", + "filenameType": "str", + "format": "utf8", + "chunk": false, + "sendError": false, + "encoding": "utf8", + "allProps": false, + "x": 1860, + "y": 1440, "wires": [ [ - "1107f97b9aa49722" + "1322d2a44999bebd" ] ] }, { - "id": "b091a6ca8e4cf197", + "id": "d34536b4b286bde0", "type": "semaphore-take", "z": "09012e75c72a4968", "config": "791ec7d75a1a4b22", "name": "", - "x": 1420, - "y": 1300, + "x": 1640, + "y": 1440, "wires": [ [ - "19b43e1a0fb43f50" + "0321c7f715ae71a9" ] ] }, { - "id": "d4e5b06fb8d61cd3", + "id": "1322d2a44999bebd", "type": "semaphore-leave", "z": "09012e75c72a4968", "config": "791ec7d75a1a4b22", "name": "", - "x": 1870, + "x": 2090, + "y": 1440, + "wires": [ + [ + "6521e5763736adb2" + ] + ] + }, + { + "id": "6521e5763736adb2", + "type": "function", + "z": "09012e75c72a4968", + "name": "getSerial", + "func": "let jsonData = JSON.parse(msg.payload);\nmsg.serial = jsonData[msg.room_id]\nreturn msg;", + "outputs": 1, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 2280, + "y": 1440, + "wires": [ + [ + "f8a973ba7af56764" + ] + ] + }, + { + "id": "d84f8fb891cfb581", + "type": "switch", + "z": "09012e75c72a4968", + "name": "SerialSwitch", + "property": "serial", + "propertyType": "msg", + "rules": [ + { + "t": "eq", + "v": "/dev/ttyUSB0", + "vt": "str" + } + ], + "checkall": "true", + "repair": false, + "outputs": 1, + "x": 2590, "y": 1300, + "wires": [ + [] + ] + }, + { + "id": "f8a973ba7af56764", + "type": "function", + "z": "09012e75c72a4968", + "name": "setSerialMessage", + "func": "msg.state = isNaN(msg.state) ? msg.state : parseInt(msg.state)\nmsg.payload = {}\nmsg.payload[\"command\"] = msg.type\nmsg.payload[\"room_id\"] = msg.room_id\nmsg.payload[\"status\"] = msg.state\n\nmsg.payload = JSON.stringify(msg.payload) + '\\n'\n\nreturn msg;", + "outputs": 1, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 2490, + "y": 1440, "wires": [ [ - "0bcfc84520ddafb2" + "ad7cbc939ce76248", + "2b915d11cb24c302", + "964af0e4e85941eb" ] ] }, { - "id": "ef9e572b7ecb3f6b", - "type": "debug", + "id": "964af0e4e85941eb", + "type": "serial out", "z": "09012e75c72a4968", - "name": "debug 1", - "active": true, - "tosidebar": true, - "console": false, - "tostatus": false, - "complete": "payload", - "targetType": "msg", - "statusVal": "", - "statusType": "auto", - "x": 1600, - "y": 80, + "name": "", + "serial": "94b8abb47e4cb1f2", + "x": 2870, + "y": 1440, "wires": [] }, { - "id": "e2b6b538afd2a18f", + "id": "a620b78341736b3a", + "type": "http in", + "z": "09012e75c72a4968", + "name": "DimmableCommand", + "url": "dimmable/:actuator_id", + "method": "post", + "upload": false, + "swaggerDoc": "", + "x": 110, + "y": 1520, + "wires": [ + [ + "d764c1e9370253e6" + ] + ] + }, + { + "id": "d764c1e9370253e6", + "type": "function", + "z": "09012e75c72a4968", + "name": "getActuatorIDAndIntensity", + "func": "msg.actuator_id = msg.req.params.actuator_id\nmsg.state = msg.req.body.intensity\n\nreturn msg;", + "outputs": 1, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 390, + "y": 1520, + "wires": [ + [ + "76a96541c0093520" + ] + ] + }, + { + "id": "ad7cbc939ce76248", + "type": "http response", + "z": "09012e75c72a4968", + "name": "OK", + "statusCode": "200", + "headers": {}, + "x": 2670, + "y": 1500, + "wires": [] + }, + { + "id": "2b915d11cb24c302", "type": "debug", "z": "09012e75c72a4968", - "name": "debug 2", - "active": false, + "name": "debug 3", + "active": true, "tosidebar": true, "console": false, "tostatus": false, - "complete": "url", - "targetType": "msg", + "complete": "false", "statusVal": "", "statusType": "auto", - "x": 3640, - "y": 680, + "x": 2760, + "y": 1340, "wires": [] } -] \ No newline at end of file +] From 32908f8d96303a3db5f539010016f6630bee6695 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Tue, 30 May 2023 13:56:55 +0000 Subject: [PATCH 2/2] chore(release)!: [skip ci] 1.1.2 released --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f0295de..d5fa88e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## [1.1.2](https://github.com/SmartOperatingBlock/operating-block-gateway/compare/1.1.1...1.1.2) (2023-05-30) + + +### Bug Fixes + +* add string terminator on serial message ([e5b32a7](https://github.com/SmartOperatingBlock/operating-block-gateway/commit/e5b32a7546a93c005fe6f94ba2c7e1cf0bad02e8)) + ## [1.1.1](https://github.com/SmartOperatingBlock/operating-block-gateway/compare/1.1.0...1.1.1) (2023-05-29)