diff --git a/.gitignore b/.gitignore index 623b188..bafed9b 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ .idea/RFLinkGateway.iml .idea/vcs.xml .idea/workspace.xml +*.pyc diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..85773a5 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,125 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Python", + "type": "python", + "request": "launch", + "stopOnEntry": true, + "pythonPath": "${config.python.pythonPath}", + "program": "${file}", + "debugOptions": [ + "WaitOnAbnormalExit", + "WaitOnNormalExit", + "RedirectOutput" + ] + }, + { + "name": "Integrated Terminal/Console", + "type": "python", + "request": "launch", + "stopOnEntry": true, + "pythonPath": "${config.python.pythonPath}", + "program": "${file}", + "console": "integratedTerminal", + "debugOptions": [ + "WaitOnAbnormalExit", + "WaitOnNormalExit" + ] + }, + { + "name": "External Terminal/Console", + "type": "python", + "request": "launch", + "stopOnEntry": true, + "pythonPath": "${config.python.pythonPath}", + "program": "${file}", + "console": "externalTerminal", + "debugOptions": [ + "WaitOnAbnormalExit", + "WaitOnNormalExit" + ] + }, + { + "name": "Django", + "type": "python", + "request": "launch", + "stopOnEntry": true, + "pythonPath": "${config.python.pythonPath}", + "program": "${workspaceRoot}/manage.py", + "args": [ + "runserver", + "--noreload" + ], + "debugOptions": [ + "WaitOnAbnormalExit", + "WaitOnNormalExit", + "RedirectOutput", + "DjangoDebugging" + ] + }, + { + "name": "Flask", + "type": "python", + "request": "launch", + "stopOnEntry": false, + "pythonPath": "${config.python.pythonPath}", + "program": "fully qualified path fo 'flask' executable. Generally located along with python interpreter", + "env": { + "FLASK_APP": "${workspaceRoot}/quickstart/app.py" + }, + "args": [ + "run", + "--no-debugger", + "--no-reload" + ], + "debugOptions": [ + "WaitOnAbnormalExit", + "WaitOnNormalExit", + "RedirectOutput" + ] + }, + { + "name": "Flask (old)", + "type": "python", + "request": "launch", + "stopOnEntry": false, + "pythonPath": "${config.python.pythonPath}", + "program": "${workspaceRoot}/run.py", + "args": [], + "debugOptions": [ + "WaitOnAbnormalExit", + "WaitOnNormalExit", + "RedirectOutput" + ] + }, + { + "name": "Watson", + "type": "python", + "request": "launch", + "stopOnEntry": true, + "pythonPath": "${config.python.pythonPath}", + "program": "${workspaceRoot}/console.py", + "args": [ + "dev", + "runserver", + "--noreload=True" + ], + "debugOptions": [ + "WaitOnAbnormalExit", + "WaitOnNormalExit", + "RedirectOutput" + ] + }, + { + "name": "Attach (Remote Debug)", + "type": "python", + "request": "attach", + "localRoot": "${workspaceRoot}", + "remoteRoot": "${workspaceRoot}", + "port": 3000, + "secret": "my_secret", + "host": "localhost" + } + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..988937c --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "python.pythonPath": "/usr/local/bin/python3" +} \ No newline at end of file diff --git a/MQTTClient.py b/MQTTClient.py old mode 100755 new mode 100644 diff --git a/RFLinkGateway.py b/RFLinkGateway.py old mode 100755 new mode 100644 diff --git a/SerialProcess.py b/SerialProcess.py old mode 100755 new mode 100644 index ee3ed44..90cd75e --- a/SerialProcess.py +++ b/SerialProcess.py @@ -67,6 +67,7 @@ def connect(self): self.logger.info('Connecting to serial') while not self.sp.isOpen(): try: + time.sleep(1) self.sp = serial.Serial(self.gatewayPort, 57600, timeout=1) self.logger.debug('Serial connected') except Exception as e: diff --git a/config.json b/config.json index 1f712ab..947c03b 100644 --- a/config.json +++ b/config.json @@ -4,7 +4,7 @@ "mqtt_prefix": "/data/RFLINK", "mqtt_message_timeout": 60, "rflink_tty_device": "/dev/ttyUSB0", - "rflink_ignored_devices": [ + "rflink_direct_output_params": [ "BAT", "CMD", "SET_LEVEL", @@ -14,4 +14,4 @@ "PIR", "SMOKEALERT" ] -} \ No newline at end of file +} diff --git a/readme.md b/readme.md index cc92442..f65cdfb 100644 --- a/readme.md +++ b/readme.md @@ -1,9 +1,9 @@ -#RFLink Gateway to MQTT +# RFLink Gateway to MQTT -##Purpose +## Purpose Bridge between RFLink Gateway and MQTT broker. -##Current features +## Current features Forwarding messages received on TTY port from RFLink Gateway Arduino board to MQTT broker in both directions. @@ -27,7 +27,7 @@ Message: Every message received on particular MQTT topic is translated to RFLink Gateway and sent to 433 MHz. -##Configuration +## Configuration Whole configuration is located in config.json file. @@ -49,7 +49,7 @@ config param | meaning | rflink_tty_device | Arduino tty device | | rflink_ignored_devices | Parameters transferred to MQTT without any processing| -##Output data +## Output data Application pushes informations to MQTT broker in following format: [mqtt_prefix]/[device_type]/[device_id]/R/[parameter] @@ -61,6 +61,6 @@ Every change should be published to topic: `/data/RFLINK/TriState/8556a8/W/1 ON` -##References +## References - RFLink Gateway project http://www.nemcon.nl/blog2/ - RFLink Gateway protocol http://www.nemcon.nl/blog2/protref