First Proof-of-concept meshtastic integration #404
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
First attempt at supporting infrastructure for meshtastic ingestion (as outlined in #398 ) for the Fab25 hackday.
Data model changes
This adds a few new fields:
meshtastic_idmeshtastic_idmeshtastic_default_sensor_id, which should point to the ID of a sensor for that measurementThese can all be updated through the API in the usual way, by device owners /admins as appropriate
New internal endpoints
The meshtastic ingestion script being developed elsewhere needs to be able to resovle meshtastic node IDs and telemetry keys to smartcitizen device tokens and sensor IDs, so we create a couple of internal endpoints to enable that:
/meshtastic/device_token?meshtastic_id=MESHTASTIC_ID&ingest_token=SECRET_INGEST_TOKEN- this returns the device token for a given meshtastic ID./meshtastic/sensor_id?device_meshtastic_id=DEVICE_MESHTASTIC_ID&measurement_meshtastic_id=MEASUREMENT_MESHTASTIC_ID&ingest_token=SECRET_INGEST_TOKEN- this returns the sensor id for the sensor on that device which senses that measurement if one exists, or themeshtastic_default_sensor_idfor the measurement otherwise.In both cases, the SECRET_INGEST_TOKEN is a shared secret, provided in the MESHTASTIC_INGEST_TOKEN environment variable, to ensure that only our ingestor script can access these endpoints.
Onboarding meshtastic devices
The "legacy" device registration page, when accessed by "researchers" and "admins" now includes the option to select a "Smartcitizen Meshtastic Prototype" hardware version, leave the MAC address field blank, and add a meshtastic node ID in the "researcher options" section.