# edge-gateway+物联网iot+采集程序 **Repository Path**: thingsstack/edge-gateway ## Basic Information - **Project Name**: edge-gateway+物联网iot+采集程序 - **Description**: 基于go语言的跨平台物联网网关。通过可视化配置,轻松的连接到你的任何设备和系统(如串口设备、上位机、Mqtt Server等),从而与 Thingsboard或您自己的物联网平台进行双向数据通讯。提供简单的驱动开发接口;当然也可以进行边缘计算。 - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 13 - **Forks**: 2 - **Created**: 2024-07-15 - **Last Updated**: 2025-11-06 ## Categories & Tags **Categories**: Uncategorized **Tags**: Go语言 ## README > > 基于go语言的跨平台物联网网关。通过可视化配置,轻松的连接到你的任何设备和系统(如串口设备、上位机、Mqtt Server等),从而与 Thingsboard或您自己的物联网平台进行双向数据通讯。提供简单的驱动开发接口;当然也可以进行边缘计算。 ## 社区 |[QQ群:378374512](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=A47S-GZsVlRY2TWtin_JfBRQBsaFIyqi&authKey=EYgBJK0Zvw1QIqjTcz31%2Bngjzm1OQUFJcgOAShAEpzNF1z%2BGwYXf2cI9RVWHx%2FSW&noverify=0&group_code=378374512) | 公众号 | 微信扫我进群 | | ---- | ------ | ---- | |![qq](./images/qq.jpg)| ![wx](./images/wait.jpg) | ![qq](./images/wait.jpg) | # go-iot-gateway ## 初始化 ```shell go env -w GO111MODULE=on # 镜像 #go env -w GOPROXY=https://goproxy.cn,direct # 阿里云 go env -w GOPROXY=https://mirrors.aliyun.com/goproxy/,direct # 七牛 go env -w GOPROXY=https://goproxy.cn,direct #$env:GO111MODULE="on" #$env:GOPROXY="https://goproxy.cn,direct" go mod vendor ``` ## 依赖更新 ```shell go get -u github.com/eclipse/paho.mqtt.golang go get -u github.com/gin-gonic/gin go get -u github.com/ilyakaznacheev/cleanenv go get -u github.com/mattn/go-sqlite3 go get -u github.com/robfig/cron/v3 go get -u github.com/sirupsen/logrus go get -u github.com/spf13/cobra go get -u github.com/yuin/gopher-lua go get -u xorm.io/xorm go get -u go.bug.st/serial go get -u github.com/google/uuid go get -u github.com/panjf2000/ants/v2 #go get -u gitlab.xxx.com/project_name@dev ``` ## 编译 ```shell GOOS=linux CGO_ENABLED=1 go build -ldflags="-s -w" -o go-iot-gateway ./cmd/gateway ``` ## 其他 ```shell # go mod 初始化 go mod init go-iot-gateway # go mod 删除错误或者不使用的modules go mod tidy # go mod 生成vendor目录 go mod vendor # go mod 验证依赖是否正确 go mod verify # go mod 查找依赖 go mod why ``` # casbin 权限 https://www.jianshu.com/p/c0148bb6653f ```shell ``` ~~- mqtt 会发生panic 要捕获~~ ~~- kill 能不能关闭系统,验证~~ - 版本号添加 ~~- mqtt 当密码错误时,连接不上。要重新连接~~ ~~- modbus 写重试~~ - 启动脚本优化 - modbus 做rpc 时,要保证优先级最高 ~~- objectVal再增加一个 uint64 的类型~~ # 侍开发 - 优化modbus 采集, 分线程,提高吞吐量 - 界面显示, 调试发送 modbus 命令 , - 发送到tb 时。在tb 断开时,是否进行持久化。保存在队列中 - 日志模块:不同的模块配置不同的级别 - 启动时, 在后台运行 , 环境配置 - 读写锁抢占,做 20 个线程。 一个写线程看能否抢到 - things board 发送历史数据, 如果mqtt 断线,当恢复后数据依然上报 - modbus rtu 采集, 读取报文需要修改 - gin 的 logger 配置 - web 展示点表,要有地址栏 - 按位取值方法性能优化 - 设备状态表 - modbus rtu 对时功能,设备时间获取功能 - 通道协议补充 - modbus 批量写 - 系统出现panic 情况 - 存储中应该有一直写的操作, 不需要加入到队列中再批量写 - modbus 不按遥测 , 遥信 , 遥脉 , 摇控 , 摇调 分组, 查询按 可读 , 写按可写 1. 吕辉福 首航 ok 【苏绪兵】【苏进发】 2. 李孙达 固德威 【许新移】 【林清园】 - tb-gateway 死了 - 固德威 , 3. 辉旺石业 ~~- 数据采不上来~~ ~~- 数据采集慢~~ ~~- 多设备采集冲突~~ - 平台控制,调用成功,设备没有状态没有更改 - # 测试环境 > things board http://10.0.5.93:47004/entities/devices sysadmin@thingsboard.org sysadmin tenant@thingsboard.org 123456 mqtt 10.0.5.93 47003 http 47004 rpc http://10.0.5.93:47004/api/rpc/twoway/b2c6cc50-1fd6-11ef-9264-89961fe9a904 ```json { "method": "setTargetP", "params": 30, "persistent": false, "timeout": 500 } ``` 默认网关 go-iot-gateway 何挺强-benz-网关 vOC9mGr7ORH6xE10cB2P # 配置工具下载地址 http://www.linkqi.cn/html/downloadlist_388_1.html 参考地址: https://github.com/yjiong/iotgateway 插件 https://github.com/expr-lang/expr https://github.com/yuin/gopher-lua https://github.com/dop251/goja js 项目 https://github.com/emitter-io/emitter https://github.com/hybridgroup/gobot/ 事件驱动 https://github.com/tibcosoftware/flogo 协议 https://blog.51cto.com/transfer?https://github.com/zubairhamed/canopus https://github.com/jlaffaye/ftp https://github.com/asaskevich/EventBus https://github.com/DrmagicE/gmqtt https://github.com/googollee/go-socket.io https://github.com/google/gopacket https://github.com/gliderlabs/ssh https://github.com/quic-go/quic-go https://github.com/lesismal/nbio https://github.com/pkg/sftp github.com/google/gopacket https://github.com/bilibili/gengine https://github.com/thinkgos/go-iecp5 # 开源项目 https://gitee.com/rulego/rulego U16 无符号 16 位整形 U32 无符号 32 位整形 I16 有符号 16 位整形 I32 有符号 32 位整形 STR 字符串 MLD 多字节 Bitfield16 16 位宽度的按位表达数据 WO 只写数据 RW 可读可写数据 RO 只读数据