diff --git a/send_and_blink/send_and_blink.ino b/send_and_blink/send_and_blink.ino index 4a26460..f25b4dd 100644 --- a/send_and_blink/send_and_blink.ino +++ b/send_and_blink/send_and_blink.ino @@ -252,23 +252,24 @@ void loop() { String data_water; if(hasWater()) { - data_water = String("water=true"); + data_water = String("water=1"); } else { - data_water = String("water=false"); + data_water = String("water=0"); } debugSerial.println(data_water); String data_magnet; if(isMagnetic()) { - data_magnet = String("magnet=true"); + data_magnet = String("magnet=1"); } else { - data_magnet = String("magnet=false"); + data_magnet = String("magnet=0"); } debugSerial.println(data_magnet); /* Blink long after sending packet */ if(counter >= 10) { - // beep(20); + sendPacket("Teststring"); + // Beep(20); blink(20); delay(10); blink(20); diff --git a/web-to-db.py b/web-to-db.py index 79cf2aa..901b4c7 100644 --- a/web-to-db.py +++ b/web-to-db.py @@ -5,6 +5,7 @@ import psycopg2 import websocket import xml.etree.ElementTree as ET from http.server import BaseHTTPRequestHandler, HTTPServer +import re from websocket import create_connection @@ -48,12 +49,17 @@ class testHTTPServer_RequestHandler(BaseHTTPRequestHandler): self.to_dashboard(post_data) def to_dashboard(self, data): - ws = websocket.create_connection("wss://home-safety-visual.eu-gb.mybluemix.net/alarmsocket") + dev = self.devEUI(data) text = self.payload(data) - ws.send("%s:%s" % (dev, text)) - ws.close() + # Working lora node + if dev == "9CD90BB52B6A1D01": + key, value = text.split("=") + ws = websocket.create_connection("wss://home-safety-visual.eu-gb.mybluemix.net/%s" % (key)) + + ws.send("%s:%s" % (dev, text)) + ws.close() def devEUI(self, data): root = ET.fromstring(data)