添加广播命令的解析和回复指令
This commit is contained in:
@@ -277,4 +277,5 @@
|
||||
地址线使用下拉,app中也使用断言,线程栈默认填充0x23+pro,malloc失败直接进断言
|
||||
2023.12.4
|
||||
只在初次进入检测命令时清除检测结果,检测结束时获取检测结果加入有效性判断
|
||||
添加广播命令的解析和回复指令
|
||||
|
||||
|
@@ -247,13 +247,24 @@ array_def *protm_decode(protu_def *p,array_def *data)
|
||||
str_set(p->str_err,"crc check err.");
|
||||
}
|
||||
p->cmd=arr_get(data,6);
|
||||
arr_delete(r);
|
||||
r=arr_mid(data,9,len-10);
|
||||
if(dst==0x1f){
|
||||
p->silent=1;
|
||||
// 广播命令需判断额外字节
|
||||
int self_addr=elec_local_addr();
|
||||
int dst_addrs=arr_get(r,0)|(arr_get(r,1)<<8)|(arr_get(r,2)<<16);
|
||||
if((dst_addrs&(1<<(self_addr-1)))!=0){
|
||||
p->silent=1;
|
||||
arr_remove(r,0,3);
|
||||
}else{
|
||||
arr_delete(r);
|
||||
r=arr_creat();
|
||||
str_set(p->str_err,"bordcast without this.");
|
||||
}
|
||||
}else{
|
||||
p->silent=0;
|
||||
}
|
||||
arr_delete(r);
|
||||
return arr_mid(data,9,len-10);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
@@ -262,18 +273,23 @@ array_def *protm_encode(protu_def *p,array_def *data)
|
||||
{
|
||||
array_def *t=arr_creat();
|
||||
param_check(t);
|
||||
uint16_t len=arr_length(data)+10;
|
||||
arr_append(t,'Y');
|
||||
arr_append(t,'e');
|
||||
arr_append(t,len&0xff);
|
||||
arr_append(t,len>>8);
|
||||
arr_append(t,elec_local_addr());// 源地址
|
||||
arr_append(t,0);// 目标地址
|
||||
arr_append(t,p->cmd);// 命令码
|
||||
arr_append(t,p->cmd_no&0xff);
|
||||
arr_append(t,p->cmd_no>>8);
|
||||
arr_appends_from(t,data);
|
||||
arr_append(t,crc_crc8(arr_data(t),arr_length(t)));
|
||||
if(p->silent==0){
|
||||
uint16_t len=arr_length(data)+10;
|
||||
arr_append(t,'Y');
|
||||
arr_append(t,'e');
|
||||
arr_append(t,len&0xff);
|
||||
arr_append(t,len>>8);
|
||||
arr_append(t,elec_local_addr());// 源地址
|
||||
arr_append(t,0);// 目标地址
|
||||
arr_append(t,p->cmd);// 命令码
|
||||
arr_append(t,p->cmd_no&0xff);
|
||||
arr_append(t,p->cmd_no>>8);
|
||||
arr_appends_from(t,data);
|
||||
arr_append(t,crc_crc8(arr_data(t),arr_length(t)));
|
||||
}else{
|
||||
// 广播命令只需回复本机地址
|
||||
arr_append(t,elec_local_addr());
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
|
@@ -6,7 +6,7 @@
|
||||
|
||||
|
||||
|
||||
#define BUILD_DATE "2023-12-04 10:52:51"
|
||||
#define BUILD_DATE "2023-12-04 17:01:27"
|
||||
#define SOFT_VERSION "2.07"
|
||||
|
||||
|
||||
|
@@ -280,8 +280,8 @@ void protu_reply_call(protu_def *p,array_def *data)
|
||||
{
|
||||
param_check(p);
|
||||
array_def *t=0;
|
||||
if(p->silent)
|
||||
return;
|
||||
// if(p->silent)
|
||||
// return;
|
||||
if(p->codec)
|
||||
t=p->codec->encode(p,data);
|
||||
// DBG_LOG("send encode:%s",arr_string(t));
|
||||
@@ -296,8 +296,8 @@ void protu_reply_call(protu_def *p,array_def *data)
|
||||
void protu_send_call(protu_def *p,uint8_t cmd,array_def *data)
|
||||
{
|
||||
array_def *t=0;
|
||||
if(p->silent)
|
||||
return;
|
||||
// if(p->silent)
|
||||
// return;
|
||||
if(cmd!=0){
|
||||
p->cmd=cmd;
|
||||
// 上报数据不增加流水号 2023.7.14
|
||||
|
Reference in New Issue
Block a user