add stdin handler (python)
Signed-off-by: Nico Schottelius <nico@wurzel.schottelius.org>
This commit is contained in:
parent
3a696ece0c
commit
f7f4fe6c91
3 changed files with 19 additions and 1 deletions
|
|
@ -10,6 +10,7 @@
|
|||
import binascii
|
||||
import lorautil
|
||||
import logging
|
||||
import sys
|
||||
|
||||
# L A T I T U D E L O N G I TU DE
|
||||
# status temp deg min sec +hem deg min min min
|
||||
|
|
@ -27,6 +28,12 @@ log.setLevel(logging.DEBUG)
|
|||
|
||||
known_devices = [ "0018B20000000C58", "0018B20000000C37", "0018B20000000C59", "0018B20000000CD0" ]
|
||||
|
||||
def convert_gps_from_stdin():
|
||||
for line in sys.stdin:
|
||||
res = get_gps("", line)
|
||||
if res:
|
||||
print(res[0][1:])
|
||||
|
||||
def get_gps(deveui, payload):
|
||||
res = []
|
||||
if not int(payload[0:2], 16) & (2**7):
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ import logging
|
|||
import select
|
||||
import psycopg2
|
||||
import psycopg2.extensions
|
||||
import sys
|
||||
import time
|
||||
import websocket
|
||||
|
||||
|
||||
|
|
@ -46,6 +48,13 @@ def db_insert_json(provider, data, payload='', deveui=''):
|
|||
def jsonToDict(data):
|
||||
return json.loads(data)
|
||||
|
||||
def nodered_from_stdin():
|
||||
provider = sys.argv[1]
|
||||
for line in sys.stdin:
|
||||
print("{} -> {}".format(provider, line))
|
||||
nodered_send(provider,line)
|
||||
time.sleep(0.1)
|
||||
|
||||
|
||||
def nodered_send(provider, data):
|
||||
ws = websocket.create_connection("ws://localhost:1880/{}".format(provider))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue