{"id":21043544,"url":"https://github.com/thingspanel/tp-protocol-sdk-go","last_synced_at":"2026-03-17T15:11:29.413Z","repository":{"id":195655704,"uuid":"693443993","full_name":"ThingsPanel/tp-protocol-sdk-go","owner":"ThingsPanel","description":"Development of ThingsPanel protocol plug-in GO language SDK package","archived":false,"fork":false,"pushed_at":"2025-04-27T09:17:50.000Z","size":57,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-29T09:54:41.076Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ThingsPanel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-09-19T03:34:58.000Z","updated_at":"2025-04-27T09:11:37.000Z","dependencies_parsed_at":"2024-06-27T07:25:25.300Z","dependency_job_id":"6fc0d6f7-7353-4d19-87ff-77f1b8b849da","html_url":"https://github.com/ThingsPanel/tp-protocol-sdk-go","commit_stats":null,"previous_names":["thingspanel/tp-protocol-sdk-go"],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThingsPanel%2Ftp-protocol-sdk-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThingsPanel%2Ftp-protocol-sdk-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThingsPanel%2Ftp-protocol-sdk-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThingsPanel%2Ftp-protocol-sdk-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ThingsPanel","download_url":"https://codeload.github.com/ThingsPanel/tp-protocol-sdk-go/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251480069,"owners_count":21596016,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-19T14:13:12.381Z","updated_at":"2026-03-17T15:11:29.358Z","avatar_url":"https://github.com/ThingsPanel.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TP Protocol SDK Go\n\nThingsPanel Protocol SDK for Go，用于快速开发ThingsPanel插件。\n\n## 功能特性\n\n- 设备配置管理\n- 服务接入管理\n- MQTT消息通信\n- HTTP回调处理\n\n## 安装\n\n```bash\ngo get github.com/ThingsPanel/tp-protocol-sdk-go\n```\n\n## 快速开始\n\n### HTTP回调服务\n\n```go\npackage main\n\nimport (\n    \"log\"\n    \"os\"\n\n    \"github.com/ThingsPanel/tp-protocol-sdk-go/handler\"\n)\n\nfunc main() {\n    // 创建处理器\n    h := handler.NewHandler(handler.HandlerConfig{\n        Logger: log.New(os.Stdout, \"[TP] \", log.LstdFlags),\n    })\n\n    // 设置表单配置处理函数\n    h.SetFormConfigHandler(func(req *handler.GetFormConfigRequest) (interface{}, error) {\n        return map[string]interface{}{\n            \"fields\": []map[string]interface{}{\n                {\n                    \"name\":  \"host\",\n                    \"type\":  \"string\",\n                    \"label\": \"服务器地址\",\n                },\n            },\n        }, nil\n    })\n\n    // 启动HTTP服务\n    h.Start(\":8080\")\n}\n```\n\n### MQTT客户端\n\n```go\npackage main\n\nimport (\n    \"log\"\n\n    tp \"github.com/ThingsPanel/tp-protocol-sdk-go/client\"\n)\n\nfunc main() {\n    // 创建客户端\n    client := tp.NewClient(\"tcp://localhost:1883\")\n\n    // 连接MQTT服务器\n    err := client.Connect()\n    if err != nil {\n        log.Fatal(err)\n    }\n\n    // 发送设备状态\n    client.SendStatus(\"device-001\", \"1\")\n}\n```\n\n## API说明\n\n### HTTP回调接口\n\n- `/api/v1/form/config` - 获取表单配置\n- `/api/v1/device/disconnect` - 设备断开通知\n- `/api/v1/plugin/notification` - 事件通知\n- `/api/v1/plugin/device/list` - 获取设备列表\n\n### MQTT主题\n\n- `devices/status/{device_id}` - 设备状态上报\n- `plugin/{服务标识符}/` - 设备数据上报主题前缀，后面跟平台规范的直连设备主题\n- `plugin/{服务标识符}/#` - 订阅平台数据主题，# 位置会是平台规范的直连设备订阅主题\n\n## 目录结构\n\n```text\ntp-protocol-sdk-go/\n├── client/       - 客户端实现\n├── handler/      - HTTP回调处理\n├── types/        - 数据类型定义\n└── examples/     - 使用示例\n```\n\n## 开发文档\n\n更多详细信息请参考[开发文档](https://docs.thingspanel.cn/docs/protocol-sdk-go/)\n\n## License\n\nThis project is licensed under the GNU Affero General Public License v3.0 - see the [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthingspanel%2Ftp-protocol-sdk-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthingspanel%2Ftp-protocol-sdk-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthingspanel%2Ftp-protocol-sdk-go/lists"}