以太网_DTU
<p>短连接:tcpClient或tcpServer模式涉及,连接超过设置时间后,设备主动断开连接。单位:秒,取值范围2~255秒;
web登录默认账号:admin/admiN,默认端口80.鉴权基于客户端ip,ip鉴权通过后有效时间xx秒,最后一次访问超时后再次访问需要重新登录;
tcp最大连接数4,超过后续连接无法建立。(注意:web配置页面需要2个tcp连接,tcpserver模式连接超过2个连接后再访问web可能无法访问)
串口分包超时时间20毫秒,超过该值数据将被分包发送。数据包最大400byte,超过也会分包发送,2个串口接收缓存,连续发包长度不能超过2个缓冲长度;
串口发送频率高导致未及时转发会丢包,连续发送数据超过2个缓冲长度会丢包;
无连接自动重启:单位秒,0为不启用,取值范围0,1~3600;
支持u盘方式OTA【升级时需将当前u盘内除conf.ini外所有文件备份到电脑后删除,以释放空间存储升级文件,升级完成后再拷贝回来】;
⭐用户配置错乱,导致设备无法启动时,可按下“RST”按钮同时设备上电开机,系统将跳过u盘内用户配置,开机后用户可重新配置设备;</p>
<p>支持功能模式:
tcpServer:设备是服务端,最多支持4个客户端连接;
tcpClient:设备是客户端,开机自动连接服务端;
udpServer:设备是服务端,无连接客户端数量不限,但只能接收,无法发送;
udpClient:设备是客户端,只能向服务端发送数据;
mqttClient:仅支持不加密通信,支持注册包、心跳包、离线包、数据包发送;
迅鸣网关:仅用于连接迅鸣自有设备,如十六路锁控板;</p>
<p>设备配置方式:web界面、配置文件、串口配置;
<strong>从迅鸣网关或迅鸣云模式修改为其他模式时,必须先修改模式保存后再修改相关配置,否则相关配置无法被修改!</strong></p>
<p>自动重启最小值为60s;
注册包配置为”数据携带“时,不支持十六进制模式;
mqtt client模式,发布、订阅用的透传topic使用全局替换,因为使用频率高;
tcp包长度536,到mqtt client有效载荷不能超过400byte,否则会触发”tcp windows full“影响后续数据通信;
串口2个buf总缓冲800byte,所以串口配置包总长度不能超过800byte,否则多余数据无法接收;
通过串口、网络发送配置json时,【注册包、心跳包、遗嘱包】内如果有["],则需要用转义符[]修饰,web配置则无需转义;
web配置种【发送topic、接收topic、遗嘱topic、遗嘱包】使用变量配置时,反显为变量更换后值,但仅限显示,配置文件内仍存放变量配置方式;</p>
<p>性能参数:
文件传输时,115200波特率下,tcp client上传下载、tcp server四客户端上传下载、udp client上传、udp server下载测试正常;</p>
<p>发送topic、接收topic、遗嘱topic、注册包、心跳包、遗嘱包支持使用变量:
#modname:模块名称
#sn:设备序列号
#ip:当前IP地址,十六进制显示【"%02x%02x%02x%02x",IPAddr[0],IPAddr[1],IPAddr[2],IPAddr[3]】
#mac:设备mac,十六进制显示【"%02x%02x%02x%02x%02x%02x",MACAddr[0],MACAddr[1],MACAddr[2],MACAddr[3],MACAddr[4],MACAddr[5]】</p>
<p><strong>json配置示例:</strong></p>
<pre><code>//通过串口json读取设备配置
+comm,{&quot;header&quot;:{&quot;timeStamp&quot;:&quot;&quot;},&quot;payload&quot;:{&quot;devices&quot;:[{&quot;devicesn&quot;:&quot;&quot;,&quot;action&quot;:&quot;get_info&quot;,&quot;params&quot;:null}]}}
//设备返回数据
{&quot;header&quot;:{&quot;timeStamp&quot;:&quot;4&quot;},&quot;payload&quot;:{&quot;devices&quot;:[{&quot;nodeid&quot;:&quot;000&quot;,&quot;action&quot;:&quot;get_info&quot;,&quot;params&quot;:{&quot;device_id&quot;:&quot;45846123578945&quot;,&quot;version&quot;:&quot;1.0.0&quot;,&quot;mode&quot;:4,&quot;server&quot;:&quot;csmq.xunmingiot.com&quot;,&quot;port&quot;:1883,&quot;hea_dir&quot;:2,&quot;reg_type&quot;:1,&quot;hea_type&quot;:1,&quot;reg_pak&quot;:&quot;onli:#sn&quot;,&quot;hea_pak&quot;:&quot;{\&quot;ip\&quot;:\&quot;#ip\&quot;}&quot;,&quot;heart_time&quot;:600,&quot;tout_time&quot;:0,&quot;ip_type&quot;:1,&quot;ip&quot;:&quot;192.168.137.100&quot;,&quot;netmask&quot;:&quot;255.255.255.0&quot;,&quot;gateway&quot;:&quot;192.168.137.1&quot;,&quot;dns&quot;:&quot;8.8.8.8&quot;,&quot;mac&quot;:&quot;38:3b:26:11:97:1e&quot;,&quot;mqtt_user&quot;:&quot;45846123578945&quot;,&quot;mqtt_pass&quot;:&quot;****&quot;,&quot;mqtt_keepalive&quot;:120,&quot;sub_topic&quot;:&quot;/test/sub/45846123578945/v1&quot;,&quot;pub_topic&quot;:&quot;/test/pub/45846123578945/v1&quot;,&quot;qos&quot;:0,&quot;is_will&quot;:1,&quot;wil_topic&quot;:&quot;/test/wil/45846123578945/v1&quot;,&quot;wil_pak&quot;:&quot;wil&quot;,&quot;rate&quot;:115200,&quot;parity&quot;:1,&quot;stopb&quot;:1,&quot;datab&quot;:8,&quot;modeid&quot;:&quot;2009&quot;}}]}}
//通过串口配置设备为mqtt client模式,并配置相关参数【mode在前后不影响】
+comm,{&quot;header&quot;:{&quot;timeStamp&quot;:&quot;4&quot;},&quot;payload&quot;:{&quot;devices&quot;:[{&quot;nodeid&quot;:&quot;000&quot;,&quot;action&quot;:&quot;writeconfig&quot;,&quot;params&quot;:{&quot;mode&quot;:4,&quot;server&quot;:&quot;csmq.xunmingiot.com&quot;,&quot;port&quot;:1883,&quot;hea_dir&quot;:2,&quot;reg_type&quot;:1,&quot;hea_type&quot;:1,&quot;reg_pak&quot;:&quot;onli:#sn&quot;,&quot;hea_pak&quot;:&quot;{\&quot;ip\&quot;:\&quot;#ip\&quot;}&quot;,&quot;heart_time&quot;:600,&quot;tout_time&quot;:0,&quot;ip_type&quot;:1,&quot;ip&quot;:&quot;192.168.137.100&quot;,&quot;netmask&quot;:&quot;255.255.255.0&quot;,&quot;gateway&quot;:&quot;192.168.137.1&quot;,&quot;dns&quot;:&quot;8.8.8.8&quot;,&quot;mqtt_user&quot;:&quot;45846123578945&quot;,&quot;mqtt_pass&quot;:&quot;545786456123&quot;,&quot;mqtt_keepalive&quot;:120,&quot;sub_topic&quot;:&quot;/test/sub/#sn/v1&quot;,&quot;pub_topic&quot;:&quot;/test/pub/#sn/v1&quot;,&quot;qos&quot;:0,&quot;is_will&quot;:1,&quot;wil_topic&quot;:&quot;/test/wil/#sn/v1&quot;,&quot;wil_pak&quot;:&quot;wil&quot;}}]}}
//mqttclient模式时,通过“get_info”读取当前系统配置,返回
{&quot;header&quot;:{&quot;timeStamp&quot;:&quot;132&quot;},&quot;payload&quot;:{&quot;devices&quot;:[{&quot;nodeid&quot;:&quot;000&quot;,&quot;action&quot;:&quot;get_info&quot;,&quot;params&quot;:{&quot;device_id&quot;:&quot;1510100110126924&quot;,&quot;version&quot;:&quot;1.0.0&quot;,&quot;mode&quot;:4,&quot;server&quot;:&quot;csmq.xunmingiot.com&quot;,&quot;port&quot;:1883,&quot;hea_dir&quot;:2,&quot;reg_type&quot;:1,&quot;hea_type&quot;:1,&quot;reg_pak&quot;:&quot;onli:#sn&quot;,&quot;hea_pak&quot;:&quot;{\&quot;ip\&quot;:\&quot;#ip\&quot;}&quot;,&quot;heart_time&quot;:60,&quot;tout_time&quot;:0,&quot;ip_type&quot;:1,&quot;ip&quot;:&quot;192.168.137.100&quot;,&quot;netmask&quot;:&quot;255.255.255.0&quot;,&quot;gateway&quot;:&quot;192.168.137.1&quot;,&quot;dns&quot;:&quot;8.8.8.8&quot;,&quot;mac&quot;:&quot;38:3b:26:11:97:1e&quot;,&quot;mqtt_user&quot;:&quot;45846123578945&quot;,&quot;mqtt_pass&quot;:&quot;****&quot;,&quot;mqtt_keepalive&quot;:120,&quot;sub_topic&quot;:&quot;/test/sub/45846123578945/v1&quot;,&quot;pub_topic&quot;:&quot;/test/pub/45846123578945/v1&quot;,&quot;qos&quot;:0,&quot;is_will&quot;:1,&quot;wil_topic&quot;:&quot;/test/wil/45846123578945/v1&quot;,&quot;wil_pak&quot;:&quot;wil&quot;,&quot;rate&quot;:115200,&quot;parity&quot;:1,&quot;stopb&quot;:1,&quot;datab&quot;:8,&quot;modeid&quot;:&quot;2009&quot;}}]}}</code></pre>
<p><strong>用户输入字段空间长度限制:</strong>
注意:
1、使用变量时务必保证替换后总长度不能超过限制值!
2、web配置时url提交最大长度600byte,含请求路径及携带参数;
3、实际可用长度-1,因为最后一位存放字符串结束符!</p>
<pre><code>char serv_url[51-1]; //服务器域名最大长度
char mqtt_user[21-1] ; //mqtt用户名
char mqtt_pass[21-1] ; //mqtt密码
char sub_topic[51-1] ; //订阅的topic
char pub_topic[51-1]; //发布的topic
char mqtt_id[21-1]; //mqtt id
UINT16 mqtt_keepalive; //注意:发给服务器的keeplive值必须是实际发送的1.5倍以上
char will_str[101-1]; //遗嘱数据包
char will_topic[51-1]; //遗嘱topic
char modname[15-1]; //系统名称
char user[7-1]; //web登录用户名
char pass[7-1]; /web登录/密码
char hearhb[101-1]; //串口心跳包内容
char reghex[101-1]; //注册包内容</code></pre>