From 3fcd397fcbfc96f9bb76616bca1aae85ad195f6d Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 2 Nov 2016 17:13:04 +0100 Subject: [PATCH] Update receiver to use lorautil --- receiver/lorautil.py | 2 ++ receiver/ttn-receiver.py | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/receiver/lorautil.py b/receiver/lorautil.py index e490744..41101eb 100644 --- a/receiver/lorautil.py +++ b/receiver/lorautil.py @@ -3,6 +3,8 @@ # 2016-11-02 # GPLv3+ +import psycopg2 + dbname="lorawan" def db_notify(provider, payload='', deveui=''): diff --git a/receiver/ttn-receiver.py b/receiver/ttn-receiver.py index 937df07..84875e7 100644 --- a/receiver/ttn-receiver.py +++ b/receiver/ttn-receiver.py @@ -13,6 +13,8 @@ import json import base64 import os +import lorautil + #Call back functions # gives connection message @@ -29,14 +31,14 @@ def on_message(client,userdata,msg): payload = base64.b64decode(mydict['payload']).decode('utf-8') print("{}: {}".format(deveui, payload)) - insert_json("ttn", myjson, payload, deveui) + lorautil.db_insert_json("ttn", myjson, payload, deveui) + lorautil.db_notify("ttn", payload, deveui) def on_log(client,userdata,level,buf): print("message:" + msg) print("userdata:" + str(userdata)) - if __name__ == '__main__': mqttc= mqtt.Client() mqttc.on_connect=on_connect