A The Things Network HTTP Integration for Azure IoT Hubs or Azure IoT Central instances
The repo has the source code for the series of blog posts written as I built this solution. There are also overviews of configuring the integration to work with Azure DPS + IoT Hubs and Azure IoT Central
- Infrastructure and payloads
- Basic JSON Deserialisation
- When Serialisation goes bad-payload_fields
- Out stupiding myself
- First TTN payload to the cloud
- Provisioning Devices on demand
- Queuing uplink messages
- Logging and the start of simplification
- Simplicating and securing the HTTP handler
- Assembling the components
Then depending on your target platform I have an overview of configuration required
The solution uses the Azure Device Provisioning Service(DPS) Group Enrollments with Symmetric Keys to "automagically" provision devices in Azure IoT Hus and Azure IoT Central instances.
The application has had some soak and stress testing
For more comple configuration scenarios the AzureIoTHubMessageV2Processor supports
- DPS EnrollmentGroup based on TTN Application ID
- DPS EnrollmentGroup based on TTN Application ID and port number
For example, a TTN solution has two Applications one for Smart Building sensors the other for tracking maintenance staff vehicles. The smart building sensor data could be routed to an Azure IoT hub for a room utilisation system. The vehicle position information could be routed to an Azure IoT Central instance for displaying on a dashboard. In the second scenario the maintenance vehicles e.g. John Deere Gator could be reporting location with messages with the port id set to 10 and usage data from built in sensors on port 15 for use in a predictive maintenance system.
The key projects are a pair of Azure Functions.
TTNHttpIntegrationUplinkEndpoint which places uplink messages from TTN into a Azure Storage Queue and AzureIoTHubUplinkMessageProcessor which processes the queue provisioning devices and sending telemetry events.