KubeEdge设备接入应用的调试
创始人
2025-05-29 14:27:55

kubeedge的设备接入采用的是mapper,

用mapper去适配不同的协议类型。

已经实现的协议在这个地方: 

GitHub - kubeedge/mappers-go: KubeEdge Device Mappers written in go

包括modbus, opcua, 蓝牙等。

运行的时候mapper是运行在容器中,会根据云端下发的设备数据,与设备建立连接。

但是在容器中调试非常不便。

其实在容器外面也是可以运行的,只不过需要把云端下发的.json准备好。

以opcua mapper为例。

https://github.com/kubeedge/mappers-go/blob/main/mappers/opcua/config.yaml

这个文件定义configmap: /opt/kubeedge/deviceProfile.json的位置

改成configmap: ./deviceProfile.json

deviceProfile.json的内容从云端拿

kubectl get cm XXXXXXX  -o json

就导出了这个边缘节点上的设备信息。

 保存到deviceProfile.json中, deviceProfile.json中最后面有几个关于证书的配置,需要修改成本地的证书(mappers-go项目中有)。

以及opcua的参数修改成需要的,就可以运行这个mapper了。

{"deviceInstances": [{"id": "plc-instance-sl1-8g-108","name": "plc-instance-sl1-8g-108","protocol": "opcua-plc-instance-sl1-8g-108","model": "plc-model","twins": [{"propertyName": "status","desired": {"value": ""},"reported": {"value": "0","metadata": {"timestamp": "1678938009371","type": "int"}}}]}],"deviceModels": [{"name": "plc-model","properties": [{"name": "status","dataType": "int","description": "status","accessMode": "ReadOnly","defaultValue": 0,"minimum": 0,"maximum": 0}]}],"protocols": [{"name": "opcua-plc-instance-sl1-8g-108","protocol": "opcua","protocolConfig": {"url": "opc.tcp://127.0.0.1:4840/","userName": "testuser","password": "./ca/pass","securityMode": "None","certificate": "./ca/clientcert.pem","privateKey": "./ca/clientkey.pem"},"protocolCommonConfig": {"customizedValues": {"remoteCertificate": "./ca/servercert.pem"}}}]
}

make  mapper 后, 生成的程序在bin/目录下。

./bin/opcua   --v 5

相关内容

热门资讯

吃一斤胜过10斤牛羊肉!中老年... 1️⃣黑豆党参炖猪尾巴! 2️⃣黑豆苦瓜排骨汤! 3️⃣黑豆鲫鱼汤!
办法总比困难多! 咱妈就没有体面点的方式了吗
新疆驼奶首获香港“优质正印” ... 2025年岁末,新疆源西域品牌迎来发展里程碑。该品牌不仅携旗下纯驼奶粉、鲜驼奶、纯驼奶片等代表性产品...
冬季旅游火热 贵州黔南到成都揽... 封面新闻记者 杨金祝12月30日,“川黔同心·冬游黔南——2025这就是黔南”冬季推介会亮相成都,全...
有一种叫云南的生活·自在昭通 ... 当北国寒风呼啸,云南东北部的巧家县却浸润在21℃的温润暖阳中。这座金沙江畔的“水上天堂”,不仅是备受...