Add nodered-receiver

This commit is contained in:
Nico Schottelius 2016-11-15 11:32:51 +01:00
parent d21bbdefef
commit 5a98367e43
5 changed files with 38 additions and 4 deletions

View File

@ -0,0 +1,32 @@
#!/usr/bin/env python3
# Nico Schottelius <nico.schottelius -at- ungleich.ch>
# 2016-11-15
# GPLv3+
import urllib
import psycopg2
import websocket
from http.server import BaseHTTPRequestHandler, HTTPServer
import re
import json
import lorautil
import logging
class RequestHandler(BaseHTTPRequestHandler):
def do_POST(self):
length = int(self.headers['Content-Length'])
post_data = self.rfile.read(length).decode('utf-8')
print(post_data)
# And insert into the db
#lorautil.db_insert_json("swisscom", post_data, payload, deveui)
#lorautil.db_notify("swisscom", payload, deveui)
if __name__ == '__main__':
server_address = ('0.0.0.0', 1900)
httpd = HTTPServer(server_address, RequestHandler)
httpd.serve_forever()

View File

@ -17,6 +17,7 @@ String gpsGetPostion(long waittime)
String res = "";
uint32_t timeout = waittime * 1000;
YELLOW();
debugSerial.println(String("waiting for fix ..., timeout=") + timeout + String("ms"));
uint32_t start = millis();
@ -31,6 +32,9 @@ String gpsGetPostion(long waittime)
} else {
debugSerial.println("GPS: No Fix");
}
CLEAR();
return res;
}

View File

@ -45,7 +45,6 @@ void blink(int length) {
YELLOW();
#elif LORADEV == 4
RED();
#else
GREEN();
#endif

View File

@ -49,6 +49,7 @@ void loraSetup()
void loraSend(String packet){
debugSerial.println("Trying to send: " + packet);
BLUE();
/* with ack */
//switch (LoRaBee.sendReqAck(1, (uint8_t*)packet.c_str(), packet.length(), 8))
@ -94,6 +95,7 @@ void loraSend(String packet){
/* Delay some time to give avoid keeping the device busy */
delay(2000);
CLEAR();
}
void sendIntAsString(String prefix, int value) {

View File

@ -76,9 +76,6 @@ void loop() {
loraSend(tmps);
}
/* if(cnt < LOUDNESS_AVG) { */
/* loudnesses[cnt] = readLoudness(LOUDNESS_PIN); */
/* debugSerial.println("temploudness=" + String(loudnesses[cnt])); */