Commit 5a98367e authored by Nico Schottelius's avatar Nico Schottelius

Add nodered-receiver

parent d21bbdef
#!/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()
......@@ -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;
}
......
......@@ -45,7 +45,6 @@ void blink(int length) {
YELLOW();
#elif LORADEV == 4
RED();
#else
GREEN();
#endif
......
......@@ -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) {
......
......@@ -76,9 +76,6 @@ void loop() {
loraSend(tmps);
}
/* if(cnt < LOUDNESS_AVG) { */
/* loudnesses[cnt] = readLoudness(LOUDNESS_PIN); */
/* debugSerial.println("temploudness=" + String(loudnesses[cnt])); */
......
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