Ribbit-Network / ribbit-network-frog-software

The software for the Ribbit Network Frog Sensor
https://www.ribbitnetwork.org/
MIT License
9 stars 8 forks source link

Simplify sensor data export #55

Closed damz closed 7 months ago

damz commented 7 months ago

The original idea was to use the export() method on each sensor class to generate the export data, but with the introduction of the backwards-compatible "aggregate" data, that method became unused.

Refactor and clean-up:

Data format change

Here are the changes to the "aggregate" data payload after this change. Nothing has changed that I expect the import lambda to care about.

--- old.json    2024-01-26 18:35:34.109195913 -0800
+++ new.json    2024-01-26 18:35:54.739721486 -0800
@@ -1,4 +1,9 @@
 {
+  "board": {
+    "board": "Ribbit Frog Sensor v4 with ESP32-S3",
+    "t": "2024-01-27T02:27:48Z",
+    "version": "v0.4.0-4-ga3ac41d",
+  },
   "dps310": {
     "pressure": 1010.583,
     "t": "2024-01-27T02:27:32Z",
@@ -6,25 +11,29 @@
   },
   "gps": {
     "altitude": null,
+    "geoid_height": null,
     "has_fix": false,
     "latitude": null,
     "longitude": null,
+    "satellites_count": 0,
     "t": "2024-01-27T02:31:38Z",
   },
   "memory": {
     "allocated": 41552,
     "free": 2021296,
+    "t": "2024-01-27T02:27:48Z",
   },
   "scd30": {
     "co2": 0.0,
     "humidity": 56.98547,
     "t": "2024-01-27T02:31:36Z",
     "temperature": 21.22949,
+    "temperature_offset": 0.0,
   },
   "time_manager": {
     "boot_time": "2024-01-27T02:30:36Z",
     "has_valid_time": true,
-    "last_update": "2024-01-27T02:30:36Z",
     "source": "ntp",
+    "t": "2024-01-27T02:22:31Z",
   },
 }
damz commented 7 months ago

It looks like code size went down ~2.7 kB, which is a nice side effect.

keenanjohnson commented 7 months ago

The cloud function that converts the JSON into influx DB is here for reference: https://github.com/Ribbit-Network/SensorDataToInfluxDB/blob/main/main.py

Looking at the JSON diff, it seems that everything should be fine to me.

Have you tested this on hardware yet @damz ?

damz commented 7 months ago

@keenanjohnson I confirmed that the UI still works and that the "aggregate" payload logged in the serial console is OK. I haven't confirmed that it works end-to-end.

keenanjohnson commented 7 months ago

Looks good to me!