This is the official standard HTTP Protocol Access Plugin, helping devices that do not support MQTT to send data to the ThingsPanel IoT platform via HTTP POST requests.
- Standard HTTP Access: Provides RESTful API to receive device telemetry data.
- Token Authentication: Supports device security authentication based on Access Token.
- Custom Forms:
- Protocol Config: No global configuration required (Empty).
- Connection Config: Provides Access Token input field.
- Health Check: Provides
/healthendpoint for platform status monitoring. - Docker Compatibility: Optimized instructions for containerized deployment environments.
Build
go mod tidy
go build -o tp-plugin-http cmd/main.goRun
Ensure configs/config.yaml exists and is configured correctly:
./tp-plugin-httpserver:
http_port: 8081 # Plugin listening port (Device uplink port)
platform:
url: "http://127.0.0.1:9999" # ThingsPanel Platform address (Modify for Docker environments)
mqtt_broker: "tcp://127.0.0.1:1883"
service_identifier: "HTTP" # Service IdentifierIf your ThingsPanel platform runs in a Docker container, while this plugin runs on the host machine:
-
HTTP Service Address:
- This is the address the Platform calls to reach the Plugin.
- Please use the Docker Gateway address:
http://172.17.0.1:8081 - Do NOT use
127.0.0.1, as that refers to the container itself.
-
Access Address:
- This is the address Devices use to report data.
- Please use the server's Public IP or LAN IP.
- Example:
http://10.147.17.226:8081/api/v1/uplink
After configuring the plugin and device, you can use curl to simulate device data reporting:
# Format: POST /api/v1/uplink
# Header: Access-Token: <Access Token configured on the platform>
curl -X POST http://localhost:8081/api/v1/uplink \
-H "Content-Type: application/json" \
-H "Access-Token: YOUR_DEVICE_TOKEN" \
-d '{
"temp": 25.5,
"hum": 60.2,
"status": "active"
}'.
├── cmd/main.go # Program Entry
├── configs/config.yaml # Configuration File
├── internal/
│ ├── bootstrap/ # Startup Initialization (HTTP Server defined here)
│ ├── handler/ # Business Logic (Uplink processing)
│ └── form_json/ # Form Definitions (Voucher/Config)
└── logs/ # Runtime Logs
- Plugin not started: Check if
http_portis occupied (netstat -tulpn | grep 8081). - Data not reported: Check
app.logfor errors, confirm if Access Token matches. - Platform Connection Failed: Ensure
platform.urlinconfig.yamlis accessible from the host.