{"id":19411494,"url":"https://github.com/volcengine/vei-driver-sdk-go","last_synced_at":"2026-03-05T02:31:43.315Z","repository":{"id":194456882,"uuid":"690514951","full_name":"volcengine/vei-driver-sdk-go","owner":"volcengine","description":null,"archived":false,"fork":false,"pushed_at":"2024-07-05T06:35:13.000Z","size":261,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-02T05:28:07.262Z","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":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/volcengine.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-12T10:50:13.000Z","updated_at":"2024-07-05T06:35:08.000Z","dependencies_parsed_at":"2023-09-13T12:14:06.600Z","dependency_job_id":"ece179c2-ea0d-43b7-baf7-e6738d36953d","html_url":"https://github.com/volcengine/vei-driver-sdk-go","commit_stats":null,"previous_names":["volcengine/vei-driver-sdk-go"],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/volcengine/vei-driver-sdk-go","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/volcengine%2Fvei-driver-sdk-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/volcengine%2Fvei-driver-sdk-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/volcengine%2Fvei-driver-sdk-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/volcengine%2Fvei-driver-sdk-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/volcengine","download_url":"https://codeload.github.com/volcengine/vei-driver-sdk-go/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/volcengine%2Fvei-driver-sdk-go/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30107207,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-05T01:39:18.192Z","status":"online","status_checked_at":"2026-03-05T02:00:06.710Z","response_time":93,"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":[],"created_at":"2024-11-10T12:21:42.974Z","updated_at":"2026-03-05T02:31:43.293Z","avatar_url":"https://github.com/volcengine.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# vei-driver-sdk-go\n![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/volcengine/vei-driver-sdk-go/go.yml?branch=main\u0026logo=github)\n![GitHub go.mod Go version](https://img.shields.io/github/go-mod/go-version/volcengine/vei-driver-sdk-go?logo=go)\n![GitHub License](https://img.shields.io/github/license/volcengine/vei-driver-sdk-go)\n![GitHub Release](https://img.shields.io/github/v/release/volcengine/vei-driver-sdk-go)\n\n欢迎使用边缘智能驱动开发SDK for Golang，本文档为您介绍如何开发一个自定义驱动\n\n[边缘智能产品主页](https://www.volcengine.com/product/vei/mainpage)\n## 驱动开发步骤\n\n### 1. 程序入口\n```go\npackage main\n\nfunc main() {\n    d := \u0026driver.MinimalDriver{}\n    vei.Bootstrap(\"device-minimal\", \"0.0.1\", d)\n}\n```\n\n### 1. 必备接口\n```go\ntype MinimalDriver struct {\n    logger  logger.Logger\n    asyncCh chan\u003c- *contracts.AsyncValues\n}\n\n/**\n *  初始化接口: 程序启动时被调用一次\n *  @param lc:              logger客户端\n *  @param asyncCh:         原生的异步数据上报通道\n */\nfunc (m *MinimalDriver) Initialize(logger logger.Logger, asyncCh chan\u003c- *contracts.AsyncValues) error {\n    m.logger = logger\n    m.asyncCh = asyncCh\n    // 其他必要的初始化过程\n    ...\n    return nil\n}\n\n/**\n *  数据读取接口: 根据设置的采样周期定时调用，或通过在线调试主动调用\n *  @param device:          设备，包含了设备名称和通信协议内容\n *  @param reqs:            请求列表，每个请求中包含属性标识符和点表定义\n */\nfunc (m *MinimalDriver) ReadProperty(device *contracts.Device, reqs []contracts.ReadRequest) error {\n\t// 通过 device.Name 或 device.Protocols 和设备建立连接，如果连接失败，可手动更新设备状态。\n    if err := createConnectionWith(device);err != nil{\n        device.SetOperatingState(state, reason)\n    }\n\t\n    for _, req := range reqs {\n        // 根据请求中携带的模块、属性名、类型等参数访问设备获取数据\n        value, err := readProperty(device, req)\n        ...\n\t\t\n        if err != nil {\n            // 返回读取的结果\n            req.SetResult(contracts.NewSimpleResult(value))\n        } else {\n            // 或者返回失败内容\n            req.Failed(err)\t\t\t\n        }\n    }\n\treturn nil\n}\n\n/**\n *  数据写入接口: 通过在线调试主动调用\n *  @param device:          设备，包含了设备名称和通信协议内容\n *  @param reqs:            请求列表，每个请求中包含属性标识符和点表定义，以及写入的参数\n */\nfunc (m *MinimalDriver) WriteProperty(device *contracts.Device, reqs []contracts.WriteRequest) error {\n    for idx, req := range reqs {\n        param := req.Param()\n        // 根据 req 和 param 向设备写入数据\n        ...\n    }\n    return nil\n}\n\n/**\n *  服务调用接口: 通过在线调试主动调用\n *  @param device:          设备，包含了设备名称和通信协议内容\n *  @param reqs:            请求列表，每个请求中包含了服务的标识符和相关定义，以及调用的参数\n */\nfunc (m *MinimalDriver)  CallService(device *contracts.Device, reqs []contracts.CallRequest) error {\n    type Request struct {\n        X float32 `json:\"x\"`\n        Y float32 `json:\"y\"`\n    }\n    \n    type Response struct {\n        Result float32 `json:\"result\"`\n    }\n    \n    request, response := \u0026Request{}, \u0026Response{}\n    if err := json.Unmarshal(req.Payload(), request); err != nil {\n        return nil, err\n    }\n    \n    // 根据请求内容调用对应的Service\n    ...\n    \n    // 返回调用结果\n    req.SetResult(contracts.NewSimpleResult(response))\n\n    return nil\n}\n\n/**\n *  停止运行接口: 程序关闭前被调用一次\n *  @param force:           是否强制停止\n */\nfunc (m *MinimalDriver) Stop(force bool) error {\n    return nil\n}\n```\n\n### 2. 系统事件接口\n```go\n/**\n *  添加设备回调函数: 成功添加设备时调用一次\n *  @param device:      设备实例\n */\nfunc (m *MinimalDriver) AddDevice(device *contracts.Device) error error {}\n/**\n *  更新设备回调函数: 成功更新设备时调用一次\n *  @param device:      设备实例\n */\nfunc (m *MinimalDriver) UpdateDevice(device *contracts.Device) error {}\n/**\n *  删除设备回调函数: 成功删除设备时调用一次\n *  @param device:      设备实例\n */\nfunc (m *MinimalDriver) RemoveDevice(device *contracts.Device) error {}\n```\n\n## SDK功能规划\n- [x] 事件上报\n- [x] 设备发现\n- [ ] 点表在线调试功能\n\n\n## 许可证\n[Apache-2.0 License](LICENSE).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvolcengine%2Fvei-driver-sdk-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvolcengine%2Fvei-driver-sdk-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvolcengine%2Fvei-driver-sdk-go/lists"}