From 8ecde78ac885b7b7d0c64c6c74640c6fa02c7bea Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20Bj=C3=B6rk?= <ddbjork@gmail.com>
Date: Mon, 2 Mar 2015 21:38:42 +0100
Subject: [PATCH] Added pymongo connect and insert of stability(+pos
 placeholder)

---
 UDP-client-server.py | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/UDP-client-server.py b/UDP-client-server.py
index 9b6d1d0..1e9ed8a 100755
--- a/UDP-client-server.py
+++ b/UDP-client-server.py
@@ -11,6 +11,16 @@ import pymongo
 # For timestamping in MongoDB
 import datetime
 
+#pymongo connect
+DBConHost = 'localhost'
+DBConPort = 27017
+DBName = 'matningar'
+DBTableName = 'stability'
+
+DBCon = MongoClient(DBConHost, DBConPort)
+DB = DBCon[DBName]
+DBTableStability = DB[DBTableName]
+
 
 #DEFINE INPUTS HERE
 #CLIENT - SENDER
@@ -223,6 +233,15 @@ def udp_client_send(UDP_DEST_IP,  UDP_DEST_PORT,
 
     print("MOS: ", mos)
 
+    post = {
+    	#"timestamp" : int(time.time()),
+    #Not needed since first 4bits of _id is timestamp
+    	"stability" : mos,
+    	"position"  : False # Position appended here
+    }
+
+    DBTableStability.insert(post);
+
 
 #START THE THREADS FOR SENDER AND RECEIVER
 if __name__ == "__main__":
-- 
GitLab