Commit 6602000c authored by Nico Schottelius's avatar Nico Schottelius

add support for sending to ttn2prom

parent d4349fa8
......@@ -13,7 +13,7 @@ import psycopg2.extensions
import sys
import time
import websocket
import requests
logging.basicConfig(format='%(levelname)s: %(message)s')
log = logging.getLogger(__name__)
......@@ -60,6 +60,16 @@ def nodered_send(path, data):
ws.send("%s" % data)
ws.close()
myobj = {'somekey': 'somevalue'}
def ttn2prom_send(path, data):
url = 'http://localhost:8047/'
x = requests.post(url, data = data)
channels = [ "loriot", "swisscom", "ttn" ]
def pg_conn_notify():
......
......@@ -16,4 +16,5 @@ if __name__ == '__main__':
conns = lorautil.pg_conn_notify()
while True:
lorautil.pg_wait_for_pkg(conns, lorautil.nodered_send)
# lorautil.pg_wait_for_pkg(conns, lorautil.nodered_send)
lorautil.pg_wait_for_pkg(conns, lorautil.ttn2prom_send)
......@@ -60,5 +60,4 @@ if __name__ == '__main__':
print(get_temperature(payload_hex))
print(get_humidity(payload_hex))
# print("{} {}".format(payload_raw, payload_hex))
import time
import ttn
import os
app_id = os.environ['ttn_app_id'] # f.i. "datacenterlight"
access_key = os.environ['ttn_access_key'] # f.i. "ttn-account..."
def uplink_callback(msg, client):
print("Received uplink from ", msg.dev_id)
print(msg)
handler = ttn.HandlerClient(app_id, access_key)
# using mqtt client
mqtt_client = handler.data()
mqtt_client.set_uplink_callback(uplink_callback)
mqtt_client.connect()
time.sleep(60)
mqtt_client.close()
# using application manager client
app_client = handler.application()
my_app = app_client.get()
print(my_app)
my_devices = app_client.devices()
print(my_devices)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment