{"id":19000105,"url":"https://github.com/dgiot/dgiot_dlink","last_synced_at":"2025-09-04T01:35:13.515Z","repository":{"id":103256302,"uuid":"446035646","full_name":"dgiot/dgiot_dlink","owner":"dgiot","description":"Dlink协议是针对物联网开发领域设计的一种数据交换规范，数据格式是JSON，用于设备端和物联网平台的双向通信，支持跨语言的grpc方式编解码,更便捷地实现和规范了设备端和物联网平台之间的业务数据交互。","archived":false,"fork":false,"pushed_at":"2022-01-29T13:07:33.000Z","size":62,"stargazers_count":12,"open_issues_count":1,"forks_count":6,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-06-02T05:15:23.104Z","etag":null,"topics":["dgiot","grpc","iot","mqtt"],"latest_commit_sha":null,"homepage":"","language":"Erlang","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dgiot.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,"zenodo":null}},"created_at":"2022-01-09T08:41:28.000Z","updated_at":"2023-11-11T09:46:19.000Z","dependencies_parsed_at":"2023-04-26T22:47:16.718Z","dependency_job_id":null,"html_url":"https://github.com/dgiot/dgiot_dlink","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dgiot/dgiot_dlink","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgiot%2Fdgiot_dlink","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgiot%2Fdgiot_dlink/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgiot%2Fdgiot_dlink/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgiot%2Fdgiot_dlink/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dgiot","download_url":"https://codeload.github.com/dgiot/dgiot_dlink/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgiot%2Fdgiot_dlink/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273539280,"owners_count":25123494,"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","status":"online","status_checked_at":"2025-09-03T02:00:09.631Z","response_time":76,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["dgiot","grpc","iot","mqtt"],"created_at":"2024-11-08T18:06:09.600Z","updated_at":"2025-09-04T01:35:13.492Z","avatar_url":"https://github.com/dgiot.png","language":"Erlang","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Dlink协议\n   Dlink协议是针对物联网开发领域设计的一种数据交换规范，数据格式是JSON，用于设备端和物联网平台的双向通信，更便捷地实现和规范了设备端和物联网平台之间的业务数据交互。\n\n## 协议框架\n![dlink proctol.png](http://dgiot-1253666439.cos.ap-shanghai-fsi.myqcloud.com/shuwa_tech/zh/backend/dgiot/dlink%20proctol.png)\n+ 设备层和用户层隔离，物理层和逻辑层隔离\n+ 用户层mqtt权限与openApi权限保持一致性\n+ 设备侧topic交互采用 {productId}/{deviceAddr}的组合来唯一标识设备, deviceAddr为设备物理地址\n+ 用户侧topic交互采用{deviceId}来唯一标识设备，用{userId}来唯一标识用户,deviceId为设备虚拟地址\n\n\n### 鉴权设计\n+ deviceId=md5(\"Device\" + {productId} + {devAddr}).subString(10)\n+ %u 表示用Username做ACL规则\n+ %c 表示用clientId做ACL规则\n - 用户侧clientId用Token做ACL规则, Token是dgiot用户登录权限系统的token,与API权限一致\n - 设备侧clientId可用deviceAddr或者deviceId,如果用deviceAddr需要用户自己保证唯一性\n\n| 客户端   | Username  |  Password |  ClientId  | 登录鉴权|  订阅ACL  | 发布ACL|\n| --------  | -------- | ------- | -------- |-------- | ------- | -------- |\n| Device |{productId}|{productSecret}|{clientId}| 一型一密 | $dg/device/%u/# | $dg/thing/%u/# |\n| Device |{productId}|{deviceSecret}|{clientId}| 一机一密 | $dg/device/%u/%d/# | $dg/thing/%u/%c/# |\n| Device |{productId}|{productSecret}|{clientId}| 证书加密 | $dg/device/%u/# | $dg/thing/%u/# |\n| User |{userId}|{Token}|{Token}| Token认证 | $dg/user/%c/# | $dg/thing/%c/# |\n\n## topic设计\n| 分类   | Topic  |  发布者 |  订阅者  |\n| --------  | -------- | ------- | -------- |\n| 双向消息 |$dg/device/{productId}/{deviceAddr}/messages| 平台 | 设备 |\n| 双向消息 |$dg/thing/{productId}/{deviceAddr}/messages| 设备 | 平台 |\n| 双向消息 |$dg/thing/{deviceId}/messages|用户|平台|\n| 双向消息 |$dg/user/{deviceId}/messages|平台|用户|\n| 双向命令 |$dg/device/{productId}/{deviceAddr}/commands/request_id={request_id}| 平台 | 设备 |\n| 双向命令 |$dg/thing/{productId}/{deviceAddr}/commands/request_id={request_id}| 设备 | 平台 |\n| 双向命令 |$dg/thing/{deviceId}/commands/request_id={request_id}|用户|平台|\n| 双向命令 |$dg/user/{deviceId}/commands/request_id={request_id}| 平台 | 用户 |\n| 属性上报 |$dg/thing/{productId}/{deviceAddr}/properties/report|设备|平台|\n| 属性上报 |$dg/user/{deviceId}/properties/report|平台|用户|\n| 子属性上报 |$dg/thing/{productId}/{deviceAddr}/gateway/sub_devices/properties/report|设备|平台|\n| 子属性上报 |$dg/user/{deviceId}/gateway/sub_devices/properties/report|平台|用户|\n| 属性设置 |$dg/thing/{deviceId}/properties/set/request_id={request_id}|用户|平台|\n| 属性设置 |$dg/device/{productId}/{deviceAddr}/properties/set/request_id={request_id}|平台|设备|\n| 属性设置 |$dg/thing/{productId}/{deviceAddr}/properties/set/request_id={request_id}|设备|平台|\n| 属性设置 |$dg/user/{deviceId}/properties/set/request_id={request_id}|平台|用户|\n| 属性获取 |$dg/thing/{deviceId}/properties/get/request_id={request_id}|用户|平台|\n| 属性获取 |$dg/device/{productId}/{deviceAddr}/properties/get/response/request_id={request_id}|平台|设备|\n| 属性获取 |$dg/thing/{productId}/{deviceAddr}/properties/get/response/request_id={request_id}|设备|平台|\n| 属性获取|$dg/{deviceId}/user/properties/get/request_id={request_id}|平台|用户|\n| 属性获取 |$dg/thing/{productId}/{deviceAddr}/shadow/get/request_id={request_id}|设备|平台|\n| 属性获取 |$dg/device/{productId}/{deviceAddr}/shadow/get/request_id={request_id}|平台|设备|\n| 事件上报 |$dg/thing/{productId}/{deviceAddr}/events|设备|平台|\n| 事件上报 |$dg/user/{deviceId}/events|平台|用户|\n\n## payload设计\n\n+ 支持grpc多语言编解码\n\n```\nDlink RunTime                             Third-party Decode/Encode\n+========================+                 +========+==========+\n|    Dlink              |                 |        |          |\n|   +----------------+   |      gRPC       | gRPC   |  User's  |\n|   |   gPRC Client  | ------------------\u003e | Server |  Codes   |\n|   +----------------+   |    (HTTP/2)     |        |          |\n|                        |                 |        |          |\n+========================+                 +========+==========+\n```\n### gRPC\n\nFor instructions on how to use the language-specific gRPC runtime for a project,\nplease refer to these documents\n\n- [C++](https://github.com/fastdgiot/grpc/tree/master/src/cpp): follow the instructions under the `src/cpp` directory\n- [C#](https://github.com/fastdgiot/grpc/tree/master/src/csharp): NuGet package `Grpc`\n- [Dart](https://github.com/grpc/grpc-dart): pub package `grpc`\n- [Go](https://github.com/grpc/grpc-go): `go get google.golang.org/grpc`\n- [Java](https://github.com/grpc/grpc-java): Use JARs from Maven Central\n  Repository\n- [Kotlin](https://github.com/grpc/grpc-kotlin): Use JARs from Maven Central\n  Repository\n- [Node](https://github.com/grpc/grpc-node): `npm install grpc`\n- [Objective-C](https://github.com/fastdgiot/grpc/tree/master/src/objective-c): Add `gRPC-ProtoRPC` dependency to podspec\n- [PHP](https://github.com/fastdgiot/grpc/tree/master/src/php): `pecl install grpc`\n- [Python](https://github.com/fastdgiot/grpc/tree/master/src/python/grpcio): `pip install grpcio`\n- [Ruby](https://github.com/fastdgiot/grpc/tree/master/src/ruby): `gem install grpc`\n- [WebJS](https://github.com/grpc/grpc-web): follow the grpc-web instructions\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdgiot%2Fdgiot_dlink","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdgiot%2Fdgiot_dlink","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdgiot%2Fdgiot_dlink/lists"}