Update receiver to use lorautil
This commit is contained in:
parent
5e122197da
commit
3fcd397fcb
2 changed files with 6 additions and 2 deletions
|
@ -3,6 +3,8 @@
|
|||
# 2016-11-02
|
||||
# GPLv3+
|
||||
|
||||
import psycopg2
|
||||
|
||||
dbname="lorawan"
|
||||
|
||||
def db_notify(provider, payload='', deveui=''):
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue