Intro
After testing the ZTP API via Swagger, this guide walks you through automating the provisioning of GNSS devices using curl or a Python script. This approach is ideal for integrating into a production fleet, providing a streamlined and scalable solution for device setup and key retrieval.
Pre-requisite: You must already have a PointPerfect Device Profile Token. If not, please follow the PointPerfect ZTP setup guide first.
Overview
This guide covers:
- Collecting the required parameters
- Creating a script to send POST requests to the ZTP API
- Parse the JSON response and forward credentials to a u-blox receiver or NTRIP-Client
Required Parameters
The POST body (data):
{
"token": "your_device_profile_token",
"givenName": "device-001",
"tags": ["optional_tag1", "optional_tag2"],
"hardwareId": "123456789012345"
}
Headers:
-
Content-Type: application/json
-
Accept: application/json
The API endpoint is:
https://api.thingstream.io/ztp/pointperfect/credentials
Example curl Command
Use this curl command to send the POST request:
curl -X POST "https://api.thingstream.io/ztp/pointperfect/credentials" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{
"token": "your_device_profile_token",
"givenName": "device-001",
"tags": ["optional_tag1"],
"hardwareId": "123456789012345"
}' \
-o response.json
Automating with Python
For better automation, use this Python example script:
import requests
import json
ZTP_ENDPOINT = "https://api.thingstream.io/ztp/pointperfect/credentials"
DEVICE_PROFILE_TOKEN = "your_device_profile_token"
HARDWARE_ID = "123456789012345"
GIVEN_NAME = "device-001"
TAGS = ["optional_tag1"]
payload = {
"token": DEVICE_PROFILE_TOKEN,
"givenName": GIVEN_NAME,
"tags": TAGS,
"hardwareId": HARDWARE_ID
}
response = requests.post(ZTP_ENDPOINT, headers={"Content-Type": "application/json", "Accept": "application/json"}, data=json.dumps(payload))
if response.status_code == 200:
with open("response.json", "w") as f:
f.write(response.text)
print("Response saved to response.json")
else:
print(f"Request failed with status {response.status_code}")
IP: Parse and Send Credentials to NTRIP Client
L-band: Parse and Send Credentials to u-blox Receiver
Once you have the response json, you can refer to Section 2 of the guide, Managing SPARTN Dynamic Keys for PointPerfect L-band Corrections.
Comments
0 comments
Article is closed for comments.