diff --git a/Dev-Notes.md b/Dev-Notes.md index fa0a317..e2f12f9 100644 --- a/Dev-Notes.md +++ b/Dev-Notes.md @@ -1,3 +1,34 @@ +## 20240121 + +Got TBeam working with GPS. Downlink from gateway is not working; had to authenticate using ABP. + +Need to visualize it in QGIS now. Create a view, grant view permission to previously-created role. + +First create a `tbeam` view: + +```sql +CREATE OR REPLACE VIEW tbeam AS +WITH data(id, dev_eui, time, alt, lat, lon, rssi) AS + (SELECT + deduplication_id, + dev_eui, + time, + CAST (object -> 'gpsLocation' -> '3' ->> 'altitude' AS FLOAT), + CAST (object -> 'gpsLocation' -> '3' ->> 'latitude' AS FLOAT), + CAST (object -> 'gpsLocation' -> '3' ->> 'longitude' AS FLOAT), + CAST (rx_info -> 0 ->> 'rssi' AS INTEGER) + FROM event_up) +SELECT + id, + dev_eui, + time, + ST_SetSRID(ST_MakePoint(lon, lat, alt), 4326) AS location, + rssi +FROM data +WHERE dev_eui = 'fffe2002c855b594'; +GRANT SELECT ON tbeam TO qgis; +``` + ## 20240117 Example SQL query to create a `qgis_friendly` view that converts Cayenne GPS location into PostGIS point, includes unique ID, RSSI, time, and gatewayId, and filters on gatewayId: