Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
iLensMQTTDiverter
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
kiran.ak
iLensMQTTDiverter
Commits
36add0d9
Commit
36add0d9
authored
May 19, 2021
by
kiran.ak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
-mqtt publish structure changes, added extra logger statements
parent
0753042f
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
11 additions
and
28 deletions
+11
-28
conf/config.yml
conf/config.yml
+0
-23
conf/site_203.json
conf/site_203.json
+3
-3
main.py
main.py
+2
-1
scripts/mqtt_publisher.py
scripts/mqtt_publisher.py
+3
-0
scripts/mqtt_subscriber.py
scripts/mqtt_subscriber.py
+3
-1
No files found.
conf/config.yml
deleted
100644 → 0
View file @
0753042f
source
:
host
:
"
192.168.19.87"
port
:
1883
topic
:
"
ilens/monitor/live/site_143"
tag_old
:
"
site_214$line_490$equipment_301$tag_572"
tag
:
"
site_214$line_414$tag_155"
destination
:
host
:
"
iot-hub.ilens.io"
port
:
1883
topic
:
"
ilens/monitor/live/site_203"
tag_old
:
"
site_143$line_144$equipment_1050$tag_317"
tag
:
"
site_143$line_152$tag_5790"
site_id
:
"
site_143"
#To send the recieved json as it is just mapping the mapping as empty
mapping
:
site_143$line_140$equipment_181$tag_198
:
site_203$line_282$equipment_444$tag_423
site_143$line_140$equipment_178$tag_198
:
site_203$line_282$equipment_438$tag_423
site_143$line_141$equipment_182$tag_198
:
site_203$line_283$equipment_445$tag_423
site_143$line_141$equipment_183$tag_198
:
site_203$line_283$equipment_446$tag_423
site_143$line_164$equipment_230$tag_198
:
site_203$line_288$equipment_449$tag_423
\ No newline at end of file
conf/site_203.json
View file @
36add0d9
...
...
@@ -2,12 +2,12 @@
"source"
:
{
"ip"
:
"192.168.0.220"
,
"port"
:
1883
,
"topic"
:
"ilens/monitor/live/sit
e
_143"
"topic"
:
"ilens/monitor/live/sit_143"
},
"destination"
:
{
"ip"
:
"
iot-hub.ilens.io
"
,
"ip"
:
"
192.168.0.220
"
,
"port"
:
1883
,
"topic"
:
"ilens/monitor/live/sit
e
_203"
"topic"
:
"ilens/monitor/live/sit_203"
},
"mapper"
:
{
"site_143$line_140$equipment_181$tag_198"
:
"site_203$line_282$equipment_444$tag_423"
,
...
...
main.py
View file @
36add0d9
...
...
@@ -25,6 +25,7 @@ class myThread(threading.Thread):
if
tag
in
self
.
mapper
:
new_data
[
self
.
mapper
[
tag
]]
=
payload_data
[
'data'
][
tag
]
payload_data
[
"data"
]
=
new_data
if
payload_data
[
"data"
]:
self
.
mqtt_pub
.
publish_data
(
payload_data
)
...
...
scripts/mqtt_publisher.py
View file @
36add0d9
...
...
@@ -30,15 +30,18 @@ class MQTTPublisher(object):
def
publish_data
(
self
,
message
):
try
:
self
.
connect_to_destination
()
logger
.
debug
(
"MQTT Publish to :{}"
.
format
(
self
.
destination_topic
))
logger
.
debug
(
"MQTT DATA : {}"
.
format
(
str
(
message
)))
msg_info
=
self
.
mqtt_client
.
publish
(
self
.
destination_topic
,
json
.
dumps
(
message
),
qos
=
1
)
self
.
mqtt_client
.
disconnect
()
if
msg_info
[
0
]
==
4
:
logger
.
debug
(
"mqtt connection lost"
)
return
False
else
:
logger
.
info
(
"MQTT Message published successfully"
)
return
True
except
Exception
as
e
:
logger
.
exception
(
"Exception while publishing the message to topic:"
+
str
(
e
))
return
False
scripts/mqtt_subscriber.py
View file @
36add0d9
...
...
@@ -17,7 +17,9 @@ class MQTTSubscriber:
def
on_message
(
self
,
client
,
userdata
,
message
):
try
:
logger
.
info
(
"data arrived : {}"
.
format
(
str
(
time
.
time
())))
DATA_LIST
.
append
(
json
.
loads
(
message
.
payload
))
payload
=
json
.
loads
(
message
.
payload
)
logger
.
debug
(
"Payload DATA : {}"
.
format
(
payload
[
"data"
]))
DATA_LIST
.
append
(
payload
)
except
Exception
as
es
:
logger
.
error
(
"Exception in received data : {}"
.
format
(
str
(
es
)))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment