{"id":37087290,"url":"https://github.com/mkrainbow/rtio-device-sdk-go","last_synced_at":"2026-01-14T10:44:33.202Z","repository":{"id":270293468,"uuid":"904175127","full_name":"mkrainbow/rtio-device-sdk-go","owner":"mkrainbow","description":"IoT device SDK in Go for RTIO service connectivity.","archived":false,"fork":false,"pushed_at":"2025-01-13T08:32:31.000Z","size":41,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-13T09:35:47.265Z","etag":null,"topics":["embedded","iot","iot-device","remote-control","rtio"],"latest_commit_sha":null,"homepage":"https://mkrainbow.com","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/mkrainbow.png","metadata":{"files":{"readme":"README-CN.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":"2024-12-16T11:46:44.000Z","updated_at":"2025-01-13T08:41:21.000Z","dependencies_parsed_at":"2024-12-30T04:28:30.805Z","dependency_job_id":"11207f14-96d5-4af5-a552-8dbc40453d97","html_url":"https://github.com/mkrainbow/rtio-device-sdk-go","commit_stats":null,"previous_names":["mkrainbow/rtio-device-sdk-go"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/mkrainbow/rtio-device-sdk-go","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkrainbow%2Frtio-device-sdk-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkrainbow%2Frtio-device-sdk-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkrainbow%2Frtio-device-sdk-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkrainbow%2Frtio-device-sdk-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mkrainbow","download_url":"https://codeload.github.com/mkrainbow/rtio-device-sdk-go/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkrainbow%2Frtio-device-sdk-go/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28417710,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T10:25:19.714Z","status":"ssl_error","status_checked_at":"2026-01-14T10:22:49.371Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["embedded","iot","iot-device","remote-control","rtio"],"created_at":"2026-01-14T10:44:32.561Z","updated_at":"2026-01-14T10:44:33.198Z","avatar_url":"https://github.com/mkrainbow.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RTIO设备SDK-Go语言\n\n\u003e 简体中文 | [English](./README.md)\n\nGolang版的物联网设备端SDK，用于连接RTIO服务。\n\n设备也是服务资源的提供者，RTIO采取REST-Like模型，使设备端开发高效和有趣。\n\n## 运行Demo\n\n目前仅在Linux环境下测试。\n\n### 运行RTIO服务端\n\n可通过“Docker”或者“编译源码”方式运行RTIO服务。\n\n#### 编译源码运行RTIO\n\n工具：\n\n- Golang：版本1.21.0或以上。\n- GNU Make：建议版本4.3或以上。\n- Git.\n\n获取代码。\n\n```sh\ngit clone https://github.com/mkrainbow/rtio.git\ncd rtio\nmake\n```\n\n通过以下命令运行服务，可通过`./out/rtio -h`查看帮助。\n\n```sh\n$ ./out/rtio -disable.deviceverify -disable.hubconfiger -log.level info\n2024-12-19 17:07:14.198 INF rtio starting ...\n```\n\n#### 通过Docker运行RTIO\n\n```sh\n$ sudo docker pull registry.cn-guangzhou.aliyuncs.com/rtio/rtio:v0.8.0\nv0.8.0: Pulling from rtio/rtio\n...\nDigest: sha256:...\n\n$ sudo docker run  --rm -p 17017:17017 -p 17917:17917 registry.cn-guangzhou.aliyuncs.com/rtio/rtio:v0.8.0\n2024-06-03 13:12:23.264 INF rtio starting ...\n```\n\n通过以下命令登录容器中，比如查看命令帮助。\n\n```sh\n$ sudo docker run -it --rm --entrypoint /bin/sh  -p 17017:17017 -p 17917:17917 registry.cn-guangzhou.aliyuncs.com/rtio/rtio:v0.8.0\n/home/rainbow $ ./rtio -h\nUsage of ./rtio: \n...\n```\n\n#### 运行设备端Demo\n\n编译Demo。\n\n```sh\ngit clone https://github.com/mkrainbow/rtio-device-sdk-go.git\nmkdir -p out \ngo build -o out/ github.com/mkrainbow/rtio-device-sdk-go/...\n```\n\n```sh\n$ ls out/\nsimple_device  simple_device_copost_to_server  simple_device_obget  simple_device_tls\n```\n\n运行`simple_device`。\n\n```sh\n./out/simple_device\n```\n\n打开另一终端运行`curl`模拟请求到设备。\n\n```sh\n$  curl http://localhost:17917/cfa09baa-4913-4ad7-a936-3e26f9671b09 -d '{\"method\":\"copost\", \"uri\":\"/rainbow\",\"id\":12667,\"data\":\"aGVsbG8=\"}'\n{\"id\":12667,\"fid\":0,\"code\":\"OK\",\"data\":\"d29ybGQ=\"}\n```\n\n其中，\"aGVsbG8=\"为\"hello\"的base64编码，\"d29ybGQ=\"为\"world\"的base64编码。可通过以下命令在终端里编解码。\n\n```sh\n$ echo -n \"hello\" | base64       # Encode\naGVsbG8=\n$ echo -n \"d29ybGQ=\" | base64 -d # Decode\nworld\n```\n\n设备端输出：\n\n```sh\n$ ./out/simple_device\nreceived [hello] and reply [world]\n```\n\n## SDK集成\n\n添加库：\n\n```sh  \ngo get github.com/mkrainbow/rtio-device-sdk-go\n```\n\n使用库：\n\n```go\nimport (\n    \"github.com/mkrainbow/rtio-device-sdk-go/rtio\"\n)\n\nfunc main() {\n\n    // Connect to rtio service.\n    session, err := rtio.Connect(context.Background(), *deviceID, *deviceSecret, *serverAddr)\n\n    // ...\n    \n    // Register handler for URI.\n    session.RegisterPostHandler(\"/rainbow\", func(req []byte) ([]byte, error) {\n        log.Printf(\"received [%s] and reply [world]\", string(req))\n        return []byte(\"world\"), nil\n    })\n\n    // Session serve in the background.\n    session.Serve(context.Background())\n\n    // Do other things.\n    time.Sleep(time.Hour * 8760)\n}\n```\n\n## API列表\n\n```go\n// Connect establishes a connection to a server with the provided device credentials.\nfunc Connect(ctx context.Context, deviceID, deviceSecret, serverAddr string) (*DeviceSession, error) \n// ConnectWithLocalAddr establishes a connection with a specified local address. Usually for testing.\nfunc ConnectWithLocalAddr(ctx context.Context, deviceID, deviceSecret, localAddr, serverAddr string) (*DeviceSession, error) \n// ConnectWithTLS establishes a TLS-encrypted connection to the server.\nfunc ConnectWithTLS(ctx context.Context, deviceID, deviceSecret, serverAddr, caFile string) (*DeviceSession, error) \n// ConnectWithTLSSkipVerify establishes a TLS-encrypted connection, skipping certificate verification.\nfunc ConnectWithTLSSkipVerify(ctx context.Context, deviceID, deviceSecret, serverAddr string) (*DeviceSession, error) \n\n// SetLogConfigs sets the logging configuration (text, json) and log Level (debug, info, warn, error)\nfunc SetLogConfigs(format, level string) \n\n// SetHeartbeatSeconds sets the heartbeat interval in seconds for the device session.\nfunc (*DeviceSession) SetHeartbeatSeconds(n uint16) \n// Serve starts the device session and serves requests in background until the context is canceled.\nfunc (*DeviceSession) Serve(ctx context.Context) \n// RegisterCoPostHandler registers a handler for CoPOST requests to the specified URI.Not Thread-safe.\nfunc (*DeviceSession) RegisterCoPostHandler(uri string, handler func(req []byte) ([]byte, error)) error \n// RegisterObGetHandler registers a handler for ObGET requests to the specified URI.Not Thread-safe.\nfunc (*DeviceSession) RegisterObGetHandler(uri string, handler func(ctx context.Context, req []byte) (\u003c-chan []byte, error)) error \n// CoPost Sends a CoPost request to the specified URI with the given payload and timeout.\nfunc (*DeviceSession) CoPost(ctx context.Context, uri string, Req []byte, timeout time.Duration) ([]byte, error) \n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmkrainbow%2Frtio-device-sdk-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmkrainbow%2Frtio-device-sdk-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmkrainbow%2Frtio-device-sdk-go/lists"}