guidosch / bikecounter

This repository contains the hardware and software components of a PIR based tracking device to monitor the usage of local bike trails. The data is sent over LoRaWAN to TTN and from there to a Google Cloud backend which stores the data and provides api endpoints for the data visualization web UI.
Creative Commons Zero v1.0 Universal
5 stars 0 forks source link

Payload formatter dev #98

Closed MeierTobias closed 7 months ago

MeierTobias commented 7 months ago

I added additional connection information to the database dump. (#97 and #81)

Further more I implemented a connection "table" that associates the device-eui to a trail collection. (#75)

Now we can register an end-device in the TTN console without specifying the trail it will be used. And later when the device gets mounted on the trail we just have to update the "internal-deviceId-trail-ct" collection with a new document.

Example "internal-deviceId-trail-ct" collection document.

{
  collectionID: "hoeckler-new-3",
  deviceEUI: "A8610A34343A7E19",
  validFrom: 25 November 2023 at 21:58:37.608 UTC+1 
}

The cloud function that stores the payload in the database looks up the corresponding trail from the "internal-deviceId-trail-ct" collection. It picks the entry with the most recent "validFrom" date. This allows to store a history of the device locations.