i-things / ithings Goto Github PK
View Code? Open in Web Editor NEW物联网设备接入平台
Home Page: http://ithings.net.cn/
License: GNU Affero General Public License v3.0
物联网设备接入平台
Home Page: http://ithings.net.cn/
License: GNU Affero General Public License v3.0
提供modbus等自定义协议能够在云端配置好就可以直接使用,避免重复开发
直接抄: http://doc.jetlinks.cn/
参考:https://www.thingspanel.cn/Pc
首先实现从nats中获取设备上报数据,及nats下发数据,这里需要前后端一起协作
参考: https://console.thingscloud.xyz/region/bj-3/project/fe5ffe5b-1dc6-4ee9-9005-df5a730ea51f/rules
参考: https://iot.console.aliyun.com/rule/simple
向apisvr发送POST json数据时,如下json的数据格式会出现解析异常。
{ "api.apiDebug" : "1", "api.secret" : "035c73f7-bb6b-4889-a715-d9eb2d1925cc", "ffmpeg.bin" : "/usr/local/bin/ffmpeg", "ffmpeg.cmd" : "%s -re -i %s -c:a aac -strict -2 -ar 44100 -ab 48k -c:v libx264 -f flv %s", "ffmpeg.log" : "./ffmpeg/ffmpeg.log", "general.mediaServerId" : "your_server_id", "general.addMuteAudio" : "1", "general.enableVhost" : "1", "general.flowThreshold" : "1024", }
带点的json名无法正常被解析。
测试示例见附件
post接收json数据异常.txt
umi:4.x
react:18.x
ant:5.0
node:16.x以上,建议18.x
设备密码生成代码参考:
https://ithings.net.cn/iThings/%E4%BA%91%E7%AB%AF%E5%BC%80%E5%8F%91%E6%8C%87%E5%8D%97/password%E7%94%9F%E6%88%90%E5%B7%A5%E5%85%B7.html
源码: https://github.com/i4de/ithings-doc/edit/master/src/iThings/%E4%BA%91%E7%AB%AF%E5%BC%80%E5%8F%91%E6%8C%87%E5%8D%97/password%E7%94%9F%E6%88%90%E5%B7%A5%E5%85%B7.md
参考腾讯云: https://cloud.tencent.com/document/product/1081/34916
需要把gps信息加上
后端使用包引用的方式,前端使用微前端的方式
改造为后台版本
模仿设备tag
latest image run error
./init.db.sh
docker-compose logs --tail 100 ithings
ithings | 2023-04-03T15:51:52.537+08:00 info auth.(*LoginLogic).Login req=&{Username:ddsvr Password:iThings ClientID:dd.rpc/e4756ba1-088c-c289-8853-845b49d3e3ca Ip:172.19.0.8 Certificate:} caller
=auth/loginLogic.go:31 trace=13e6e546367c3a04d4e00cfc93f8c582 span=51c6ef7dc8b2d497
ithings | 2023-04-03T15:51:52.538+08:00 info deviceauth.(*LoginAuthLogic).LoginAuth req=username:"ddsvr" password:"iThings" clientID:"dd.rpc/e4756ba1-088c-c289-8853-845b49d3e3ca" ip:"172.19.0.8"c
aller=deviceauth/loginAuthLogic.go:103 trace=13e6e546367c3a04d4e00cfc93f8c582 span=51c6ef7dc8b2d497
ithings | 2023-04-03T15:51:52.538+08:00 error auth.(*LoginLogic).Login.rpc.ManageDevice req=&{ddsvr iThings dd.rpc/e4756ba1-088c-c289-8853-845b49d3e3ca 172.19.0.8 } err={"code":100006,"msg":"参数
错误","details":["userName not right"]} caller=auth/loginLogic.go:52 trace=13e6e546367c3a04d4e00cfc93f8c582 span=51c6ef7dc8b2d497
ithings | 2023-04-03T15:51:52.538+08:00 error 【http handle err】router:/api/v1/things/device/auth/login err: {"code":100006,"msg":"参数错误","details":["userName not right"]} caller=result/
httpResult.go:29 trace=13e6e546367c3a04d4e00cfc93f8c582 span=51c6ef7dc8b2d497
ithings | 2023-04-03T15:51:52.538+08:00 info [HTTP] 400 - POST /api/v1/things/device/auth/login - 172.19.0.7:41456 - duration=0.7ms caller=handler/loghandler.go:160 trace=13e6e546
367c3a04d4e00cfc93f8c582 span=51c6ef7dc8b2d497
ithings | 2023-04-03T15:51:52.538+08:00 info mqtt client connect attempt broker:tcp://172.19.0.7:1883 caller=clients/mqtt.go:45
ithings | 2023-04-03T15:51:52.539+08:00 info auth.(*LoginLogic).Login req=&{Username:ddsvr Password:iThings ClientID:dd.rpc/e4756ba1-088c-c289-8853-845b49d3e3ca Ip:172.19.0.8 Certificate:} caller
=auth/loginLogic.go:31 trace=beff4ceedfdfaa02e847c9efd898a262 span=1a3d4901d4b72dc3
ithings | 2023-04-03T15:51:52.539+08:00 info deviceauth.(*LoginAuthLogic).LoginAuth req=username:"ddsvr" password:"iThings" clientID:"dd.rpc/e4756ba1-088c-c289-8853-845b49d3e3ca" ip:"172.19.0.8"c
aller=deviceauth/loginAuthLogic.go:103 trace=beff4ceedfdfaa02e847c9efd898a262 span=1a3d4901d4b72dc3
ithings | 2023-04-03T15:51:52.539+08:00 info [HTTP] 400 - POST /api/v1/things/device/auth/login - 172.19.0.7:43627 - duration=0.3ms caller=handler/loghandler.go:160 trace=beff4cee
dfdfaa02e847c9efd898a262 span=1a3d4901d4b72dc3
ithings | 2023-04-03T15:51:52.539+08:00 error auth.(*LoginLogic).Login.rpc.ManageDevice req=&{ddsvr iThings dd.rpc/e4756ba1-088c-c289-8853-845b49d3e3ca 172.19.0.8 } err={"code":100006,"msg":"参数
错误","details":["userName not right"]} caller=auth/loginLogic.go:52 trace=beff4ceedfdfaa02e847c9efd898a262 span=1a3d4901d4b72dc3
ithings | 2023-04-03T15:51:52.539+08:00 error 【http handle err】router:/api/v1/things/device/auth/login err: {"code":100006,"msg":"参数错误","details":["userName not right"]} caller=result/
httpResult.go:29 trace=beff4ceedfdfaa02e847c9efd898a262 span=1a3d4901d4b72dc3
ithings | 2023-04-03T15:51:56.534+08:00 info mqtt Connect failure caller=clients/mqtt.go:54
ithings | 2023-04-03T15:51:56.534+08:00 error NewDevClient errmqtt client connect failure caller=svc/serviceContext.go:20
image version:
docker pull ghcr.io/i4de/ithings:sha256-daf2e7b10b71be69584c44808099437c29ce915a5cd70e773e0428daad2e055b.sig
参考阿里云和jetlinks
设备可以上传标签到云平台
注意设备的位置需要可以修改,设备位置记录在设备信息表里即可
设备日志主要用于平台远程查看设备运行日志,平台可通过下发消息,通知设备进行日志上报,日志级别包括错误、警告、信息和调试。
功能概述
设备使用场景中,对于需要更新系统参数(如:设备的 IP、端口号和串口参数等)的设备,可采用远程配置功能对设备系统参数进行更新。
功能详情
设备远程配置分为物联网平台主动下发和设备端主动请求两种配置更新方式。对于同一产品下所有设备均需更新配置的场景,可采用物联网平台主动下发的形式,将配置信息通过远程配置 Topic 下发到同一产品下的所有设备中。对于部分设备更新配置信息的场景,可采用设备端主动请求远程配置 Topic 的方式来完成。
远程配置请求 Topic:$config/up/get/${productid}/${devicename}
远程配置订阅回复 Topic:$config/down/get/${productid}/${devicename}
远程配置订阅通知 Topic:$config/down/push/${productid}
设备影子充当中介,支持设备和用户应用程序查看和更新设备状态。设备、用户应用程序、设备影子三者之间通过两个特殊的 Topic 来实现通信:
$shadow/operation/up/${productId}/${deviceName}:用于发布(上行)消息,可实现对设备影子数据的 get/update 操作。
$shadow/operation/down/${productId}/${deviceName}:用于订阅(下行)消息,影子服务端通过此 Topic 发送应答和推送消息。
目的: 提供能够在插入数据的时候就根据规则计算好数据插入到表中
参考:https://docs.taosdata.com/taos-sql/stream/
$ota/up/report/${productID}/${deviceName} 设备上报版本号(上行)
$ota/up/progress/${productID}/${deviceName} 设备上报下载进度(上行)
$ota/down/update/${productID}/${deviceName} 服务器端推送ota信息(下行)
可以对产品进行分类
地图和编辑器太慢了,可以预加载就好了
问题原因:
tdengine在针对select * 最新数据的时候优化不够好,后续版本会优化
td优化方案:切换成last_row,并执行: alter database ithings cachemodel 'both' cachesize 200;
打开td缓存: 测试后查询速度0.036秒
解决方案:
需要做第三点
可以看到设备发上来的告警记录及告警的通知
参考:
主要参考:https://demo.jetlinks.cn/#/iot/Alarm/Configuration
顺带可以参考: https://console.thingscloud.xyz/region/bj-3/project/fe5ffe5b-1dc6-4ee9-9005-df5a730ea51f/alarm_logs
版本:master
报错信息:
2023-02-22T18:44:19.963+08:00 info sql taosQuery: insert into `device_property_25Mjq9jn0je_Test-Device_test` (ts, param) values ('2023-02-22T18:44:19.959+08:00',1); duration=0.0ms caller=taosRestful/connection.go:180
2023-02-22T18:44:19.963+08:00 error deviceMsgEvent.(*ThingLogic).HandlePropertyReport.InsertPropertyData err={"code":100008,"msg":"数据库错误","details":["SchemaDataRepo.InsertPropertiesData.InsertPropertyData identifier:test param:1 err:[0x2603] Table does not exist"]} caller=deviceMsgEvent/thing.go:97 trace=ec6cf1ad8c1f9fea48e762b9c40ed616 span=c9befb34de400012
2023-02-22T18:44:19.965+08:00 info sql taosQuery: insert into `device_hublog_25Mjq9jn0je_Test-Device` using `model_common_hublog` tags('25Mjq9jn0je','Test-Device')(`ts`, `content`, `topic`, `action`, `requestID`, `trance_id`, `result_type`) values ('2023-02-22T18:44:19.959+08:00','{
"method": "report",
"clientToken": "afwegafeegfa",
"params": {
"test": 1
}
}
','$thing/up/property/25Mjq9jn0je/Test-Device','property','afwegafeegfa','ec6cf1ad8c1f9fea48e762b9c40ed616',100008); duration=0.0ms caller=taosRestful/connection.go:180
2023-02-22T18:44:19.965+08:00 info DeviceMsgHandle.deviceResp.PublishToDev msg:{"DeviceNames":"","Payload":"{\"method\":\"reportReply\",\"clientToken\":\"afwegafeegfa\",\"timestamp\":1677062659963,\"code\":100008,\"status\":\"数据库错误\"}","ProductID":"","Timestamp":"2023-02-22T18:44:19.963140843+08:00","Topic":"$thing/down/property/25Mjq9jn0je/Test-Device"} caller=deviceMsgEvent/deviceMsg.go:92 trace=ec6cf1ad8c1f9fea48e762b9c40ed616 span=c9befb34de400012
2023-02-22T18:44:19.965+08:00 info deviceMsgEvent.(*DeviceMsgHandle).Thing req:{"DeviceNames":"Test-Device","Payload":"{ \n \"method\": \"report\", \n \"clientToken\": \"afwegafeegfa\", \n \"params\": { \n \"test\": 1\n }\n}\n","ProductID":"25Mjq9jn0je","Timestamp":"2023-02-22T18:44:19.959+08:00","Topic":"$thing/up/property/25Mjq9jn0je/Test-Device"} resp:{"DeviceNames":"","Payload":"{\"method\":\"reportReply\",\"clientToken\":\"afwegafeegfa\",\"timestamp\":1677062659963,\"code\":100008,\"status\":\"数据库错误\"}","ProductID":"","Timestamp":"2023-02-22T18:44:19.963140843+08:00","Topic":"$thing/down/property/25Mjq9jn0je/Test-Device"} err:{"code":100008,"msg":"数据库错误","details":["SchemaDataRepo.InsertPropertiesData.InsertPropertyData identifier:test param:1 err:[0x2603] Table does not exist"]} caller=deviceMsgEvent/deviceMsg.go:39 trace=ec6cf1ad8c1f9fea48e762b9c40ed616 span=c9befb34de400012
2023-02-22T18:44:19.965+08:00 error nats subscription|subject:device.up.thing.25Mjq9jn0je.Test-Device,body:{"timestamp":1677062659959,"productID":"25Mjq9jn0je","deviceName":"Test-Device","topic":"$thing/up/property/25Mjq9jn0je/Test-Device","payload":"eyAgICAgICAgICAgICAgICAgICAgIAogICAgIm1ldGhvZCI6ICJyZXBvcnQiLCAgICAgICAgICAgIAogICAgImNsaWVudFRva2VuIjogImFmd2VnYWZlZWdmYSIsICAgCiAgICAicGFyYW1zIjogeyAKICAgICAgInRlc3QiOiAxCiAgICB9Cn0K"},err:{"code":100008,"msg":"数据库错误","details":["SchemaDataRepo.InsertPropertiesData.InsertPropertyData identifier:test param:1 err:[0x2603] Table does not exist"]} duration=0.0ms caller=events/nats.go:28 trace=ec6cf1ad8c1f9fea48e762b9c40ed616 span=c9befb34de400012
默认情况下不需要验证码
需要进行以下维度的安全控制:
project
功能如题
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.