..
authorBernhard Tittelbach <xro@realraum.at>
Wed, 16 Oct 2013 17:19:09 +0000 (17:19 +0000)
committerBernhard Tittelbach <xro@realraum.at>
Wed, 16 Oct 2013 17:19:09 +0000 (17:19 +0000)
bridge-old-sensors-zmq.py
inject_presence.py [new file with mode: 0755]

index 65e5bc9..459d854 100755 (executable)
@@ -222,7 +222,7 @@ def exitHandler(signum, frame):
     pass
   time.sleep(0.1)
   try:
-    zmqsub.close()
+    zmqpub.close()
     zmqctx.destroy()
   except:
     pass
@@ -250,7 +250,7 @@ zmqpub.connect("tcp://wuzzler.realraum.at:4243")
 #listen for sensor data and forward them
 trackSensorStatus(uwscfg, zmqpub)
 
-zmqsub.close()
+zmqpub.close()
 zmqctx.destroy()
 
 
diff --git a/inject_presence.py b/inject_presence.py
new file mode 100755 (executable)
index 0000000..731469f
--- /dev/null
@@ -0,0 +1,25 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+from __future__ import with_statement
+import zmq.utils.jsonapi as json
+import zmq
+import time
+
+######## r3 ZMQ ############
+
+def sendR3Message(socket, structname, datadict):
+    socket.send_multipart([structname, json.dumps(datadict)])
+
+#Start zmq connection to publish / forward sensor data
+zmqctx = zmq.Context()
+zmqctx.linger = 0
+zmqpub = zmqctx.socket(zmq.PUB)
+zmqpub.connect("tcp://wuzzler.realraum.at:4243")
+
+#listen for sensor data and forward them
+sendR3Message(zmqpub,"PresenceUpdate",{"Presence":True,"Ts":int(time.time())})
+
+zmqpub.close()
+zmqctx.destroy()
+
+