feat(fpo): 新增全功率时间配置功能+修复跨天判断Bug+清理合并冲突残留
1. FPO全功率时间配置功能: - 新增COMM_UNIT_CMD_SET_FPO_TIME(0x0A)通讯单元命令和NET_COMM_CMD_FPO_CONFIG(0x0A)服务器下发命令 - CommUnitPara_t新增FPOTimeFlag/FPOTimeConfirmed/FPOTimeStart/FPOTime/CurFPOTimeStart/CurFPOTime字段 - 实现TrySendFullPowerCmd: 全功率时段直接下发配置/激光/校准/校时命令 - DebugCmd新增fpocfg命令,支持按MAC或all配置全功率时间 - lscomm命令显示FPO状态(Start/Dur/End/FullPower/LowPower/Pending) 2. 修复FPO跨天判断Bug: 显式处理全天(Dur>=24), endHour>24替代<=24, endHour-24替代%24 3. 新增传感器类型: EWS_7(0x0021)/MULTI_PARAMETER_FUSION(0x000D)/CRACK_DETECTION(0x000E)/ATTITUDE_MONITOR(0x0010) 4. 清理合并冲突残留: 删除8个README_BACKUP/BASE/LOCAL/REMOTE_*.md文件 5. 注释规范化: 统一Public.h结构体字段注释格式
This commit is contained in:
@@ -60,9 +60,9 @@ void Debug_Printf(char *format, ...)
|
||||
va_end(args);
|
||||
}
|
||||
/*****************************************************************************************
|
||||
* 函数名称: RS485Ch2_Thread_Entry
|
||||
* 功能描述: RS485通道1任务函数
|
||||
* 参 数: 任务参数入口
|
||||
* 函数名称: Debug_Thread_Entry
|
||||
* 功能描述: 调试线程入口
|
||||
* 参 数: parameter, 线程参数
|
||||
* 返 回 值: 无
|
||||
*****************************************************************************************/
|
||||
void Debug_Thread_Entry(void *parameter)
|
||||
@@ -127,10 +127,10 @@ void DebugOrCat1RxOverhandler(void)
|
||||
|
||||
/*****************************************************************************************
|
||||
* 函数名称: DebugAnalyze
|
||||
* 功能描述: 调试指令解析
|
||||
* 参 数: GateWay, 网关参数句柄
|
||||
rData,输入数据
|
||||
rLen, 输入数据长度
|
||||
* 功能描述: 解析调试指令
|
||||
* 参 数: GateWay, 网关参数
|
||||
rData, 接收数据
|
||||
rLen, 接收数据长度
|
||||
* 返 回 值: 无
|
||||
*****************************************************************************************/
|
||||
void DebugAnalyze(GateWayPara GateWay, uint8_t *rData, uint16_t rLen)
|
||||
@@ -164,16 +164,16 @@ void DebugAnalyze(GateWayPara GateWay, uint8_t *rData, uint16_t rLen)
|
||||
for(int i = 0; i < DEBUG_CMD_CNT; i++) {
|
||||
if(strcmp(argv[0], DebugFun[i].DBGCmd) == 0) {
|
||||
DebugFun[i].DBGExec(argc, argv);
|
||||
break; // 添加break避免继续匹配
|
||||
break; // 未匹配break跳出
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************************
|
||||
* 函数名称: DebugCmdMainOnOff
|
||||
* 功能描述: 主调试信息开关
|
||||
* 参 数: argc, 输入参数数量
|
||||
argv, 输入参数
|
||||
* 功能描述: 主通道消息控制
|
||||
* 参 数: argc, 参数个数
|
||||
argv, 参数列表
|
||||
* 返 回 值: 无
|
||||
*****************************************************************************************/
|
||||
void DebugCmdMainOnOff(int argc, char *argv[])
|
||||
@@ -199,9 +199,9 @@ void DebugCmdMainOnOff(int argc, char *argv[])
|
||||
|
||||
/*****************************************************************************************
|
||||
* 函数名称: DebugCmdCat1OnOff
|
||||
* 功能描述: CAT1调试信息开关
|
||||
* 参 数: argc, 输入参数数量
|
||||
argv, 输入参数
|
||||
* 功能描述: CAT1通道消息控制
|
||||
* 参 数: argc, 参数个数
|
||||
argv, 参数列表
|
||||
* 返 回 值: 无
|
||||
*****************************************************************************************/
|
||||
void DebugCmdCat1OnOff(int argc, char *argv[])
|
||||
@@ -248,9 +248,9 @@ void DebugCmdEthOnOff(int argc, char *argv[])
|
||||
|
||||
/*****************************************************************************************
|
||||
* 函数名称: DebugCmdCat1OnOff
|
||||
* 功能描述: CAT1调试信息开关
|
||||
* 参 数: argc, 输入参数数量
|
||||
argv, 输入参数
|
||||
* 功能描述: CAT1通道消息控制
|
||||
* 参 数: argc, 参数个数
|
||||
argv, 参数列表
|
||||
* 返 回 值: 无
|
||||
*****************************************************************************************/
|
||||
void DebugCmdRS485Ctrl(int argc, char *argv[])
|
||||
@@ -409,8 +409,8 @@ void DebugCmdRS485Ctrl(int argc, char *argv[])
|
||||
/*****************************************************************************************
|
||||
* 函数名称: DebugCmdDelCommUnit
|
||||
* 功能描述: 删除已注册的通讯单元
|
||||
* 参 数: argc, 输入参数数量
|
||||
argv, 输入参数
|
||||
* 参 数: argc, 参数个数
|
||||
argv, 参数列表
|
||||
* 返 回 值: 无
|
||||
*****************************************************************************************/
|
||||
void DebugCmdDelCommUnit(int argc, char *argv[])
|
||||
@@ -460,8 +460,8 @@ void DebugCmdDelCommUnit(int argc, char *argv[])
|
||||
/*****************************************************************************************
|
||||
* 函数名称: DebugCmdLsCommUnit
|
||||
* 功能描述: 查看通讯单元信息
|
||||
* 参 数: argc, 输入参数数量
|
||||
argv, 输入参数
|
||||
* 参 数: argc, 参数个数
|
||||
argv, 参数列表
|
||||
* 返 回 值: 无
|
||||
*****************************************************************************************/
|
||||
void DebugCmdLsCommUnit(int argc, char *argv[])
|
||||
@@ -508,11 +508,43 @@ void DebugCmdLsCommUnit(int argc, char *argv[])
|
||||
CU->Mac[j][3], CU->Mac[j][4], CU->Mac[j][5]);
|
||||
if(CU->SensorType[j] != 0x0000)
|
||||
DBG_LOG(" Type:%04X", CU->SensorType[j]);
|
||||
if(CU->SensorType[j] == 0x0009 || CU->SensorType[j] == 0x0011)
|
||||
if(CU->SensorType[j] == 0x0009)
|
||||
DBG_LOG(" Laser:%s", CU->LaserOnOff ? "On" : "Off");
|
||||
DBG_LOG("\r\n");
|
||||
}
|
||||
DBG_LOG(" Bat:%d%% Rssi:%d Snr:%d\r\n", CU->BatLevel, CU->RSSI, CU->Nsr);
|
||||
{
|
||||
const char *FPOStatus;
|
||||
if(CU->FPOTimeConfirmed == false) {
|
||||
//FPO配置已下发,等待传感器回应确认
|
||||
FPOStatus = "Pending";
|
||||
}
|
||||
else if(CU->CurFPOTime == 0) {
|
||||
FPOStatus = "LowPower";
|
||||
}
|
||||
else {
|
||||
//使用传感器当前已确认生效的FPO参数判断状态
|
||||
struct tm cTime;
|
||||
TimeGet(&cTime);
|
||||
int curHour = cTime.tm_hour;
|
||||
int endHour = CU->CurFPOTimeStart + CU->CurFPOTime;
|
||||
bool inFPO = false;
|
||||
if(CU->CurFPOTime >= 24) {
|
||||
inFPO = true; //全天全功率
|
||||
}
|
||||
else if(endHour > 24) {
|
||||
inFPO = (curHour >= CU->CurFPOTimeStart || curHour < endHour - 24);
|
||||
}
|
||||
else {
|
||||
inFPO = (curHour >= CU->CurFPOTimeStart && curHour < endHour);
|
||||
}
|
||||
FPOStatus = inFPO ? "FullPower" : "LowPower";
|
||||
}
|
||||
DBG_LOG(" FPO Start:%02d:00, Dur:%dh, End:%02d:00, %s\r\n",
|
||||
CU->FPOTimeStart, CU->FPOTime,
|
||||
(CU->FPOTimeStart + CU->FPOTime) % 24,
|
||||
FPOStatus);
|
||||
}
|
||||
DBG_LOG(" Online:%s\r\n\r\n", CU->CommStatus ? "Yes" : "No");
|
||||
}
|
||||
}
|
||||
@@ -523,8 +555,8 @@ void DebugCmdLsCommUnit(int argc, char *argv[])
|
||||
/*****************************************************************************************
|
||||
* 函数名称: DebugCmdExclCommUnit
|
||||
* 功能描述: 排除指定的通讯单元MAC
|
||||
* 参 数: argc, 输入参数数量
|
||||
argv, 输入参数
|
||||
* 参 数: argc, 参数个数
|
||||
argv, 参数列表
|
||||
* 返 回 值: 无
|
||||
*****************************************************************************************/
|
||||
void DebugCmdExclCommUnit(int argc, char *argv[])
|
||||
@@ -574,9 +606,9 @@ void DebugCmdExclCommUnit(int argc, char *argv[])
|
||||
}
|
||||
/*****************************************************************************************
|
||||
* 函数名称: DebugCmdDelExclCommUnit
|
||||
* 功能描述: 删除指定的被排除的通信单元MAC
|
||||
* 参 数: argc, 输入参数数量
|
||||
argv, 输入参数
|
||||
* 功能描述: 删除指定的被排除的通讯单元MAC
|
||||
* 参 数: argc, 参数个数
|
||||
argv, 参数列表
|
||||
* 返 回 值: 无
|
||||
*****************************************************************************************/
|
||||
void DebugCmdDelExclCommUnit(int argc, char *argv[])
|
||||
@@ -626,8 +658,8 @@ void DebugCmdDelExclCommUnit(int argc, char *argv[])
|
||||
/*****************************************************************************************
|
||||
* 函数名称: DebugCmdLsExclCommUnit
|
||||
* 功能描述: 查看被排除的通讯单元信息
|
||||
* 参 数: argc, 输入参数数量
|
||||
argv, 输入参数
|
||||
* 参 数: argc, 参数个数
|
||||
argv, 参数列表
|
||||
* 返 回 值: 无
|
||||
*****************************************************************************************/
|
||||
void DebugCmdLsExclCommUnit(int argc, char *argv[])
|
||||
@@ -678,8 +710,8 @@ static Channel_m ParseChannel(const char *str)
|
||||
/*****************************************************************************************
|
||||
* 函数名称: DebugCmdSetMuch
|
||||
* 功能描述: 设置主上报通道
|
||||
* 参 数: argc, 输入参数数量
|
||||
argv, 输入参数
|
||||
* 参 数: argc, 参数个数
|
||||
argv, 参数列表
|
||||
* 返 回 值: 无
|
||||
*****************************************************************************************/
|
||||
static void DebugCmdSetMuch(int argc, char *argv[])
|
||||
@@ -718,9 +750,9 @@ static void DebugCmdSetMuch(int argc, char *argv[])
|
||||
|
||||
/*****************************************************************************************
|
||||
* 函数名称: DebugCmdSetAuch
|
||||
* 功能描述: 设置辅助上报通道
|
||||
* 参 数: argc, 输入参数数量
|
||||
argv, 输入参数
|
||||
* 功能描述: 设置辅上报通道
|
||||
* 参 数: argc, 参数个数
|
||||
argv, 参数列表
|
||||
* 返 回 值: 无
|
||||
*****************************************************************************************/
|
||||
static void DebugCmdSetAuch(int argc, char *argv[])
|
||||
@@ -759,9 +791,9 @@ static void DebugCmdSetAuch(int argc, char *argv[])
|
||||
|
||||
/*****************************************************************************************
|
||||
* 函数名称: DebugCmdSetCuch
|
||||
* 功能描述: 通讯单元通道位掩码管理
|
||||
* 参 数: argc, 输入参数数量
|
||||
argv, 输入参数
|
||||
* 功能描述: 通讯单元通道位设置
|
||||
* 参 数: argc, 参数个数
|
||||
argv, 参数列表
|
||||
* 返 回 值: 无
|
||||
*****************************************************************************************/
|
||||
static void DebugCmdSetCuch(int argc, char *argv[])
|
||||
@@ -829,8 +861,8 @@ static void DebugCmdSetCuch(int argc, char *argv[])
|
||||
/*****************************************************************************************
|
||||
* 函数名称: DebugCmdReadHisData
|
||||
* 功能描述: 读取历史数据
|
||||
* 参 数: argc, 输入参数数量
|
||||
argv, 输入参数
|
||||
* 参 数: argc, 参数个数
|
||||
argv, 参数列表
|
||||
* 返 回 值: 无
|
||||
*****************************************************************************************/
|
||||
void DebugCmdReadHisData(int argc, char *argv[])
|
||||
@@ -908,8 +940,8 @@ void DebugCmdReadHisData(int argc, char *argv[])
|
||||
/*****************************************************************************************
|
||||
* 函数名称: DebugCmdDelHisData
|
||||
* 功能描述: 删除历史数据
|
||||
* 参 数: argc, 输入参数数量
|
||||
argv, 输入参数
|
||||
* 参 数: argc, 参数个数
|
||||
argv, 参数列表
|
||||
* 返 回 值: 无
|
||||
*****************************************************************************************/
|
||||
void DebugCmdDelHisData(int argc, char *argv[])
|
||||
@@ -928,8 +960,8 @@ void DebugCmdDelHisData(int argc, char *argv[])
|
||||
/*****************************************************************************************
|
||||
* 函数名称: DebugCmdGetHisInfo
|
||||
* 功能描述: 获取历史数据信息
|
||||
* 参 数: argc, 输入参数数量
|
||||
argv, 输入参数
|
||||
* 参 数: argc, 参数个数
|
||||
argv, 参数列表
|
||||
* 返 回 值: 无
|
||||
*****************************************************************************************/
|
||||
void DebugCmdGetHisInfo(int argc, char *argv[])
|
||||
@@ -969,8 +1001,8 @@ void DebugCmdGetHisInfo(int argc, char *argv[])
|
||||
/*****************************************************************************************
|
||||
* 函数名称: DebugCmdRestoreFactory
|
||||
* 功能描述: 恢复出厂设置
|
||||
* 参 数: argc, 输入参数数量
|
||||
argv, 输入参数
|
||||
* 参 数: argc, 参数个数
|
||||
argv, 参数列表
|
||||
* 返 回 值: 无
|
||||
*****************************************************************************************/
|
||||
void DebugCmdRestoreFactory(int argc, char *argv[])
|
||||
@@ -998,9 +1030,9 @@ void DebugCmdRestoreFactory(int argc, char *argv[])
|
||||
|
||||
/*****************************************************************************************
|
||||
* 函数名称: DebugCmdUpload
|
||||
* 功能描述: 上传当前网关状态
|
||||
* 参 数: argc, 输入参数数量
|
||||
argv, 输入参数
|
||||
* 功能描述: 上传当前设备状态
|
||||
* 参 数: argc, 参数个数
|
||||
argv, 参数列表
|
||||
* 返 回 值: 无
|
||||
*****************************************************************************************/
|
||||
static void DebugCmdUpload(int argc, char *argv[])
|
||||
@@ -1032,9 +1064,9 @@ static void DebugCmdUpload(int argc, char *argv[])
|
||||
|
||||
/*****************************************************************************************
|
||||
* 函数名称: DebugCmdRegister
|
||||
* 功能描述: 重新向上位机发起注册
|
||||
* 参 数: argc, 输入参数数量
|
||||
argv, 输入参数
|
||||
* 功能描述: 触发设备位置信息注册
|
||||
* 参 数: argc, 参数个数
|
||||
argv, 参数列表
|
||||
* 返 回 值: 无
|
||||
*****************************************************************************************/
|
||||
static void DebugCmdRegister(int argc, char *argv[])
|
||||
@@ -1069,8 +1101,8 @@ static void DebugCmdRegister(int argc, char *argv[])
|
||||
/*****************************************************************************************
|
||||
* 函数名称: DebugCmdRestoreFactory
|
||||
* 功能描述: 恢复出厂设置
|
||||
* 参 数: argc, 输入参数数量
|
||||
argv, 输入参数
|
||||
* 参 数: argc, 参数个数
|
||||
argv, 参数列表
|
||||
* 返 回 值: 无
|
||||
*****************************************************************************************/
|
||||
void DebugCmdReboot(int argc, char *argv[])
|
||||
@@ -1091,8 +1123,8 @@ void DebugCmdReboot(int argc, char *argv[])
|
||||
/*****************************************************************************************
|
||||
* 函数名称: DebugCmdSetSensorCollectTime
|
||||
* 功能描述: 设置采集时间
|
||||
* 参 数: argc, 输入参数数量
|
||||
argv, 输入参数
|
||||
* 参 数: argc, 参数个数
|
||||
argv, 参数列表
|
||||
* 返 回 值: 无
|
||||
*****************************************************************************************/
|
||||
void DebugCmdSetCollectTime(int argc, char *argv[])
|
||||
@@ -1157,8 +1189,8 @@ void DebugCmdSetCollectTime(int argc, char *argv[])
|
||||
/*****************************************************************************************
|
||||
* 函数名称: DebugCmdTimeSync
|
||||
* 功能描述: 时间同步
|
||||
* 参 数: argc, 输入参数数量
|
||||
argv, 输入参数
|
||||
* 参 数: argc, 参数个数
|
||||
argv, 参数列表
|
||||
* 返 回 值: 无
|
||||
*****************************************************************************************/
|
||||
void DebugCmdTimeSync(int argc, char *argv[])
|
||||
@@ -1198,9 +1230,9 @@ void DebugCmdTimeSync(int argc, char *argv[])
|
||||
|
||||
/*****************************************************************************************
|
||||
* 函数名称: DebugCmdTimeSync
|
||||
* 功能描述: 查询内置通讯单元传感器
|
||||
* 参 数: argc, 输入参数数量
|
||||
argv, 输入参数
|
||||
* 功能描述: 查询各通讯单元的版本号
|
||||
* 参 数: argc, 参数个数
|
||||
argv, 参数列表
|
||||
* 返 回 值: 无
|
||||
*****************************************************************************************/
|
||||
extern SensorCommPara_t SComm1Para;
|
||||
@@ -1233,9 +1265,9 @@ void DebugCmdQuerySensor(int argc, char *argv[])
|
||||
|
||||
/*****************************************************************************************
|
||||
* 函数名称: DebugCmdSelDebugChannel
|
||||
* 功能描述: 选择调试信息输出通道,
|
||||
* 参 数: argc, 输入参数数量
|
||||
argv, 输入参数
|
||||
* 功能描述: 选择调试信息输出通道号
|
||||
* 参 数: argc, 参数个数
|
||||
argv, 参数列表
|
||||
* 返 回 值: 无
|
||||
*****************************************************************************************/
|
||||
void DebugCmdSelDebugChannel(int argc, char *argv[])
|
||||
@@ -1291,9 +1323,9 @@ void DebugCmdSelDebugChannel(int argc, char *argv[])
|
||||
|
||||
/*****************************************************************************************
|
||||
* 函数名称: DebugCmdSetLTENet
|
||||
* 功能描述: 设置Cat1/4G服务器的地址和端口
|
||||
* 参 数: argc, 输入参数数量
|
||||
argv, 输入参数
|
||||
* 功能描述: 设置Cat1/4G网络服务器地址和端口
|
||||
* 参 数: argc, 参数个数
|
||||
argv, 参数列表
|
||||
* 返 回 值: 无
|
||||
*****************************************************************************************/
|
||||
static void DebugCmdSetLTENet(int argc, char *argv[])
|
||||
@@ -1343,8 +1375,8 @@ static void DebugCmdSetLTENet(int argc, char *argv[])
|
||||
/*****************************************************************************************
|
||||
* 函数名称: DebugCmdSetMac
|
||||
* 功能描述: 设置MAC地址
|
||||
* 参 数: argc, 输入参数数量
|
||||
argv, 输入参数
|
||||
* 参 数: argc, 参数个数
|
||||
argv, 参数列表
|
||||
* 返 回 值: 无
|
||||
*****************************************************************************************/
|
||||
static void DebugCmdSetMac(int argc, char *argv[])
|
||||
@@ -1385,8 +1417,8 @@ static void DebugCmdSetMac(int argc, char *argv[])
|
||||
/*****************************************************************************************
|
||||
* 函数名称: DebugCmdGetPara
|
||||
* 功能描述: 查看参数
|
||||
* 参 数: argc, 输入参数数量
|
||||
argv, 输入参数
|
||||
* 参 数: argc, 参数个数
|
||||
argv, 参数列表
|
||||
* 返 回 值: 无
|
||||
*****************************************************************************************/
|
||||
static void DebugCmdGetPara(int argc, char *argv[])
|
||||
@@ -1470,9 +1502,9 @@ static void DebugCmdGetPara(int argc, char *argv[])
|
||||
|
||||
/*****************************************************************************************
|
||||
* 函数名称: DebugCmdCali
|
||||
* 功能描述: 校准传感器
|
||||
* 参 数: argc, 输入参数数量
|
||||
argv, 输入参数
|
||||
* 功能描述: 校准命令
|
||||
* 参 数: argc, 参数个数
|
||||
argv, 参数列表
|
||||
* 返 回 值: 无
|
||||
*****************************************************************************************/
|
||||
static void DebugCmdCali(int argc, char *argv[])
|
||||
@@ -1526,12 +1558,14 @@ static void DebugCmdCali(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = 0; i < COMMUNIT_NUM_MAX; i++)//参数遍历
|
||||
for(int i = 0; i < COMMUNIT_NUM_MAX; i++)//遍历设备
|
||||
{
|
||||
if(GateWay->ConfigPara.CommUnitArray[i].RegFlag == true)
|
||||
GateWay->ConfigPara.CommUnitArray[i].CailFlag = true;//校准置位,等待下次此MAC主设备上传数据时下发校准指令(低功耗)
|
||||
if(GateWay->ConfigPara.CommUnitArray[i].RegFlag == true) {
|
||||
GateWay->ConfigPara.CommUnitArray[i].CailFlag = true;
|
||||
TrySendFullPowerCmd(GateWay, i);
|
||||
}
|
||||
}
|
||||
//Sx1276LoRaSendBuffer(CommUnitCmd, sizeof(CommUnitFrameHeader_t) + 2);//低功耗模式下不用下发
|
||||
//Sx1276LoRaSendBuffer(CommUnitCmd, sizeof(CommUnitFrameHeader_t) + 2);//
|
||||
|
||||
DBG_LOG("Calibrate all communication units.\r\n");
|
||||
return;
|
||||
@@ -1575,13 +1609,15 @@ static void DebugCmdCali(int argc, char *argv[])
|
||||
CommUnitCmd[sizeof(CommUnitFrameHeader_t) + 1] = (crc16 >> 8) & 0x00ff;
|
||||
|
||||
if(mac[2] == 0x01) { //LORA通讯
|
||||
if(GateWay->ConfigPara.CommUnitArray[ret].RegFlag == true)
|
||||
GateWay->ConfigPara.CommUnitArray[ret].CailFlag = true;//校准置位,等待下次此MAC主设备上传数据时下发校准指令(低功耗)
|
||||
if(GateWay->ConfigPara.CommUnitArray[ret].RegFlag == true) {
|
||||
GateWay->ConfigPara.CommUnitArray[ret].CailFlag = true;
|
||||
DBG_LOG("Wait for the device to respond. Mac:%02X-%02X-%02X-%02X-%02X-%02X\r\n",
|
||||
CUFrame->DevMac[0], CUFrame->DevMac[1], CUFrame->DevMac[2], CUFrame->DevMac[3], CUFrame->DevMac[4], CUFrame->DevMac[5]);
|
||||
//Sx1276LoRaSendBuffer(CommUnitCmd, sizeof(CommUnitFrameHeader_t) + 2);
|
||||
TrySendFullPowerCmd(GateWay, ret);
|
||||
}
|
||||
}
|
||||
else if(mac[2] == 0x02) { //RS485通讯
|
||||
else if(mac[2] == 0x02) { //RS485ͨѶ
|
||||
if(GateWay->ConfigPara.Rs485Ch1.Enable == true && !GateWay->ConfigPara.Rs485Ch1.CommUnitEnable) {
|
||||
GateWay->ConfigPara.Rs485Ch1.RS485Send(Rs485Cmd, sizeof(CommUnitFrameHeader_t) + 2);
|
||||
DBG_LOG("Calibrate CommUnit: %s!\r\n", argv[1]);
|
||||
@@ -1598,8 +1634,8 @@ static void DebugCmdCali(int argc, char *argv[])
|
||||
/*****************************************************************************************
|
||||
* 函数名称: DebugLaserConfig
|
||||
* 功能描述: 激光控制
|
||||
* 参 数: argc, 输入参数数量
|
||||
argv, 输入参数
|
||||
* 参 数: argc, 参数个数
|
||||
argv, 参数列表
|
||||
* 返 回 值: 无
|
||||
*****************************************************************************************/
|
||||
static void DebugLaserConfig(int argc, char *argv[])
|
||||
@@ -1691,25 +1727,26 @@ static void DebugLaserConfig(int argc, char *argv[])
|
||||
CommUnitCmd[len++] = crc16 & 0x00ff;
|
||||
CommUnitCmd[len++] = (crc16 >> 8) & 0x00ff;
|
||||
|
||||
if(mac[2] == 0x01) { //LORA通讯,低功耗模式不用主动下发
|
||||
if(mac[2] == 0x01) { //LORA通讯单元低功胀模式下直接下发
|
||||
if(GateWay->ConfigPara.CommUnitArray[ret].RegFlag == true)
|
||||
{
|
||||
if(onoff == true)
|
||||
{
|
||||
GateWay->ConfigPara.CommUnitArray[ret].ContLaser = true;//控制置位,等待下次此MAC主设备上传数据时下发校准指令(低功耗)
|
||||
GateWay->ConfigPara.CommUnitArray[ret].ContLaser = true;
|
||||
DBG_LOG("Wait for the device to respond. Mac:%02X-%02X-%02X-%02X-%02X-%02X\r\n",
|
||||
CUFrame->DevMac[0], CUFrame->DevMac[1], CUFrame->DevMac[2], CUFrame->DevMac[3], CUFrame->DevMac[4], CUFrame->DevMac[5]);
|
||||
GateWay->ConfigPara.CommUnitArray[ret].LaserOnOff = onoff;
|
||||
TrySendFullPowerCmd(GateWay, ret);
|
||||
}
|
||||
else if(onoff == false)
|
||||
{
|
||||
GateWay->ConfigPara.CommUnitArray[ret].ContLaser = false;
|
||||
GateWay->ConfigPara.CommUnitArray[ret].LaserOnOff = onoff;
|
||||
Sx1276LoRaSendBuffer(CommUnitCmd, len);//直接发
|
||||
Sx1276LoRaSendBuffer(CommUnitCmd, len);//直接发送
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(mac[2] == 0x02) { //RS485通讯
|
||||
else if(mac[2] == 0x02) { //RS485ͨѶ
|
||||
if(GateWay->ConfigPara.Rs485Ch1.Enable == true && !GateWay->ConfigPara.Rs485Ch1.CommUnitEnable) {
|
||||
GateWay->ConfigPara.Rs485Ch1.RS485Send(Rs485Cmd, len);
|
||||
DBG_LOG("Control RS485 laser CommUnit: %s!\r\n", argv[1]);
|
||||
@@ -1726,9 +1763,9 @@ static void DebugLaserConfig(int argc, char *argv[])
|
||||
|
||||
/*****************************************************************************************
|
||||
* 函数名称: DebugCmdLPConfig
|
||||
* 功能描述: 低功耗参数配置
|
||||
* 参 数: argc, 输入参数数量
|
||||
argv, 输入参数
|
||||
* 功能描述: 低功胀参数配置
|
||||
* 参 数: argc, 参数个数
|
||||
argv, 参数列表
|
||||
* 返 回 值: 无
|
||||
*****************************************************************************************/
|
||||
static void DebugCmdLPConfig(int argc, char *argv[])
|
||||
@@ -1737,7 +1774,7 @@ static void DebugCmdLPConfig(int argc, char *argv[])
|
||||
uint16_t CollectInterval; //采集时间间隔
|
||||
uint16_t ReportInterval; //上报时间间隔
|
||||
uint8_t ERInterval; //紧急上报时间间隔
|
||||
uint8_t ERTime; //紧急上报时长
|
||||
uint8_t ERTime; //紧急上报时间
|
||||
|
||||
if(strcmp(argv[1], "?") == 0) {
|
||||
DBG_LOG("Debug Cmd: lpcfg arg1 arg2 arg3 arg4\r\n");
|
||||
@@ -1784,6 +1821,7 @@ static void DebugCmdLPConfig(int argc, char *argv[])
|
||||
GateWay->ConfigPara.CommUnitArray[i].ERInterval = ERInterval;
|
||||
GateWay->ConfigPara.CommUnitArray[i].ERTime = ERTime;
|
||||
GateWay->ConfigPara.CommUnitArray[i].ConfigFlag = true;
|
||||
TrySendFullPowerCmd(GateWay, i);
|
||||
}
|
||||
}
|
||||
WritePara((uint8_t *)&GateWay->ConfigPara, sizeof(GWConfigPara_t));
|
||||
@@ -1791,10 +1829,87 @@ static void DebugCmdLPConfig(int argc, char *argv[])
|
||||
}
|
||||
|
||||
/*****************************************************************************************
|
||||
* 函数名称: DebugCmdLPConfig
|
||||
* 函数名称: DebugCmdFPOConfig
|
||||
* 功能描述: 全功率时间配置
|
||||
* 参 数: argc, 参数个数
|
||||
argv, 参数列表
|
||||
* 返 回 值: 无
|
||||
*****************************************************************************************/
|
||||
static void DebugCmdFPOConfig(int argc, char *argv[])
|
||||
{
|
||||
DBG_LOG("\r\n");
|
||||
uint8_t FPOTimeStart;
|
||||
uint8_t FPOTime;
|
||||
uint8_t Mac[6];
|
||||
bool ConfigAll = false;
|
||||
|
||||
if(strcmp(argv[1], "?") == 0) {
|
||||
DBG_LOG("Debug Cmd: fpocfg arg1 arg2 arg3\r\n");
|
||||
DBG_LOG(" brief --> Configure full-power operation time.\r\n");
|
||||
DBG_LOG(" arg1 --> Mac(xx-xx-xx-xx-xx-xx) or \"all\"\r\n");
|
||||
DBG_LOG(" arg2 --> FPO time start hour(0~23)\r\n");
|
||||
DBG_LOG(" arg3 --> FPO time duration(0~24 hour)\r\n\r\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if(argc < 4)
|
||||
return;
|
||||
|
||||
if(strcmp(argv[1], "all") == 0) {
|
||||
ConfigAll = true;
|
||||
}
|
||||
else {
|
||||
int ret = sscanf(argv[1], "%02X-%02X-%02X-%02X-%02X-%02X",
|
||||
(int *)&Mac[0], (int *)&Mac[1], (int *)&Mac[2], (int *)&Mac[3], (int *)&Mac[4], (int *)&Mac[5]);
|
||||
if(ret != 6) {
|
||||
DBG_LOG("Mac Para Error! (xx-xx-xx-xx-xx-xx or all)\r\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
FPOTimeStart = atoi(argv[2]);
|
||||
if(FPOTimeStart > 23) {
|
||||
DBG_LOG("FPOTimeStart Para Error! (0~23)\r\n");
|
||||
return;
|
||||
}
|
||||
|
||||
FPOTime = atoi(argv[3]);
|
||||
if(FPOTime > 24) {
|
||||
DBG_LOG("FPOTime Para Error! (0~24)\r\n");
|
||||
return;
|
||||
}
|
||||
|
||||
bool Found = false;
|
||||
for(int i = 0; i < COMMUNIT_NUM_MAX; i++) {
|
||||
if(GateWay->ConfigPara.CommUnitArray[i].RegFlag) {
|
||||
if(ConfigAll || memcmp(GateWay->ConfigPara.CommUnitArray[i].Mac[0], Mac, 6) == 0) {
|
||||
GateWay->ConfigPara.CommUnitArray[i].FPOTimeStart = FPOTimeStart;
|
||||
GateWay->ConfigPara.CommUnitArray[i].FPOTime = FPOTime;
|
||||
GateWay->ConfigPara.CommUnitArray[i].FPOTimeFlag = true;
|
||||
GateWay->ConfigPara.CommUnitArray[i].FPOTimeConfirmed = false;
|
||||
Found = true;
|
||||
DBG_LOG("Mac:%02X-%02X-%02X-%02X-%02X-%02X FPO set.\r\n",
|
||||
GateWay->ConfigPara.CommUnitArray[i].Mac[0][0], GateWay->ConfigPara.CommUnitArray[i].Mac[0][1],
|
||||
GateWay->ConfigPara.CommUnitArray[i].Mac[0][2], GateWay->ConfigPara.CommUnitArray[i].Mac[0][3],
|
||||
GateWay->ConfigPara.CommUnitArray[i].Mac[0][4], GateWay->ConfigPara.CommUnitArray[i].Mac[0][5]);
|
||||
TrySendFullPowerCmd(GateWay, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!Found) {
|
||||
DBG_LOG("Device not found.\r\n");
|
||||
return;
|
||||
}
|
||||
WritePara((uint8_t *)&GateWay->ConfigPara, sizeof(GWConfigPara_t));
|
||||
DBG_LOG("FPO time configured. Start:%02d:00, Dur:%dh, End:%02d:00\r\n",
|
||||
FPOTimeStart, FPOTime, (FPOTimeStart + FPOTime) % 24);
|
||||
}
|
||||
|
||||
/*****************************************************************************************
|
||||
* 函数名称: DebugLoraConfig
|
||||
* 功能描述: Lora参数配置
|
||||
* 参 数: argc, 输入参数数量
|
||||
argv, 输入参数
|
||||
* 参 数: argc, 参数个数
|
||||
argv, 参数列表
|
||||
* 返 回 值: 无
|
||||
*****************************************************************************************/
|
||||
static void DebugLoraConfig(int argc, char *argv[])
|
||||
@@ -1923,9 +2038,9 @@ static void DebugLoraConfig(int argc, char *argv[])
|
||||
|
||||
/*****************************************************************************************
|
||||
* 函数名称: DebugCmdHelp
|
||||
* 功能描述: 调试命令帮助信息
|
||||
* 参 数: argc, 输入参数数量
|
||||
argv, 输入参数
|
||||
* 功能描述: 打印调试帮助信息
|
||||
* 参 数: argc, 参数个数
|
||||
argv, 参数列表
|
||||
* 返 回 值: 无
|
||||
*****************************************************************************************/
|
||||
void DebugCmdHelp(int argc, char *argv[])
|
||||
@@ -2083,6 +2198,7 @@ const DBGFunType DebugFun[DEBUG_CMD_CNT] = {
|
||||
"cali", DebugCmdCali,
|
||||
"laser", DebugLaserConfig,
|
||||
"lpcfg", DebugCmdLPConfig,
|
||||
"fpocfg", DebugCmdFPOConfig,
|
||||
"lora", DebugLoraConfig,
|
||||
"reboot", DebugCmdReboot,
|
||||
"up", DebugCmdUpload,
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
#include "bsp.h"
|
||||
|
||||
#define LORA_LOWPOWER //LORA低功耗设备,采用主动上报方式
|
||||
#define LORA_LOWPOWER //LORA低功耗模式支持
|
||||
|
||||
#define SENSOR_DATA_LEN_MAX 50
|
||||
#define SENSOR_NUM_MAX 16
|
||||
@@ -12,8 +12,8 @@
|
||||
#define REGISTER_INTERVAL_MAX (2 * 60)
|
||||
#define COMMUNIT_READ_SENSOR_INTERVAL_MAX (1 * 60)
|
||||
|
||||
#define LORA_ERR_RESET_DLY_MAX (10 * 60) //LORA接收超时复位延时,单位秒
|
||||
#define CAT1_ERR_RESET_DLY_MAX (60 * 60) //CAT1接收超时复位延时,单位秒
|
||||
#define LORA_ERR_RESET_DLY_MAX (10 * 60) //LORA通信异常复位延迟时间
|
||||
#define CAT1_ERR_RESET_DLY_MAX (60 * 60) //CAT1通信异常复位延迟时间
|
||||
|
||||
typedef struct GateWay_t GateWayPara_t, *GateWayPara;
|
||||
|
||||
@@ -61,13 +61,14 @@ typedef enum {
|
||||
|
||||
|
||||
typedef enum {
|
||||
COMM_UNIT_CMD_REG,
|
||||
COMM_UNIT_CMD_CAIL,
|
||||
COMM_UNIT_CMD_READ,
|
||||
COMM_UNIT_CMD_SET_SENSOR_COLL_TIME = 5,
|
||||
COMM_UNIT_CMD_TIME_SYNC,
|
||||
COMM_UNIT_CMD_CONT_LASER = 8,//激光独有指令
|
||||
COMM_UNIT_CMD_GET_SIGNAL, //0x09 查询Lora信号质量
|
||||
COMM_UNIT_CMD_REG = 0x00,
|
||||
COMM_UNIT_CMD_CAIL = 0x01,
|
||||
COMM_UNIT_CMD_READ = 0x02,
|
||||
COMM_UNIT_CMD_SET_SENSOR_COLL_TIME = 0x05,
|
||||
COMM_UNIT_CMD_TIME_SYNC = 0x06,
|
||||
COMM_UNIT_CMD_CONT_LASER = 0x08,//连续激光控制
|
||||
COMM_UNIT_CMD_GET_SIGNAL = 0x09, //0x09 获取Lora信号质量
|
||||
COMM_UNIT_CMD_SET_FPO_TIME = 0x0A, //0x0A 全功率时间配置
|
||||
COMM_UNIT_CMD_END,
|
||||
}CommUnitCmd_m;
|
||||
|
||||
@@ -82,38 +83,40 @@ typedef enum {
|
||||
NET_COMM_CMD_ADD_UNIT,
|
||||
NET_COMM_CMD_LP_DEV_CONFIG,
|
||||
NET_COMM_CMD_ALARM,
|
||||
NET_COMM_CMD_CONT_LASER,//激光独有指令
|
||||
NET_COMM_CMD_CONT_LASER,//连续激光控制
|
||||
NET_COMM_CMD_FPO_CONFIG = 0x0A,//0x0A 全功率时间配置
|
||||
NET_COMM_CMD_END,
|
||||
}NetCommCmd_m;
|
||||
|
||||
typedef enum {
|
||||
SENSOR_TYPE_NULL, //0x0000 空设备
|
||||
FORCE_6D, //0x0001 六维应力
|
||||
SENSOR_TYPE_NULL, //0x0000 空类型
|
||||
FORCE_6D, //0x0001 六维力
|
||||
OSMOTIC_PRESSURE, //0x0002 渗透压
|
||||
ELASTIC_WAVEGUIDE, //0x0003 弹性波导
|
||||
DIELECTRIC_MASS, //0x0004 介电质普
|
||||
VIBRATE_SENSOR, //0x0005 微振动传感器
|
||||
CONT_DEFOR_3D, //0x0006 三维连续变形
|
||||
DIELECTRIC_MASS, //0x0004 介电质
|
||||
VIBRATE_SENSOR, //0x0005 振动传感器
|
||||
CONT_DEFOR_3D, //0x0006 三向连续变形
|
||||
COMM_UNIT, //0x0007 通讯单元
|
||||
FORCE_3D, //0x0008 三维应力
|
||||
LASER_TRACING, //0x0009 激光示踪
|
||||
WATER_LEVEL, //0x000A 水位计
|
||||
_0x000B, //0x000B 保留
|
||||
_0x000C, //0x000C 保留
|
||||
MULTI_PARAMETER_FUSION, //0x000D 多参数融合
|
||||
CRACK_DETECTION, //0x000E 裂缝仪
|
||||
_0x000F, //0x000F 保留
|
||||
ATTITUDE_MONITOR, //0x0010 姿态检测
|
||||
FORCE_3D, //0x0008 三维力
|
||||
LASER_TRACING, //0x0009 激光追踪
|
||||
WATER_LEVEL, //0x000A 水位
|
||||
_0x000B, //0x000B 位移
|
||||
_0x000C, //0x000C 流量
|
||||
MULTI_PARAMETER_FUSION, //0x000D 多参融合
|
||||
CRACK_DETECTION, //0x000E 裂缝
|
||||
_0x000F, //0x000F 应变
|
||||
ATTITUDE_MONITOR, //0x0010 姿态监测
|
||||
LASER_DISPLACE, //0x0011 激光位移
|
||||
REBAR_STRESS, //0x0012 钢筋应力
|
||||
ANCHOR_ROD_STRESS, //0x0013 锚杆轴力
|
||||
ANCHOR_ROD_STRESS, //0x0013 锚杆应力
|
||||
SURFACE_STRESS, //0x0014 表面应力
|
||||
PRESSURE, //0x0015 压力
|
||||
MICROWAVE_DISPLACE, //0x0016 微波位移
|
||||
DISPLACEMENT = 0x0020, //0x0020 位移监测传感器
|
||||
DISPLACEMENT = 0x0020, //0x0020 位移变形传感器
|
||||
EWS_7 = 0x0021, //0x0021 七要素气象站,含温度湿度气压风速风向降雨光照
|
||||
}SensorType_m;
|
||||
|
||||
typedef struct {//主设备固定包头
|
||||
typedef struct {//主设备信息
|
||||
uint8_t BatLevel; //电池电量
|
||||
int8_t RSSI; //信号强度
|
||||
int8_t Nsr; //信噪比
|
||||
@@ -133,33 +136,56 @@ typedef struct {
|
||||
|
||||
typedef struct {
|
||||
MasterDev_T MasterDev;
|
||||
int16_t PitchAngle; //俯仰角偏斜 (范围±900)单位0.1°
|
||||
int16_t RollAngle; //横滚角偏斜 (范围±900)单位0.1°
|
||||
int16_t YawAngle; //偏航角偏斜 (范围0~3600)单位0.1°
|
||||
int16_t PitchAngle; //俯仰角 范围-900~900,精度0.1度
|
||||
int16_t RollAngle; //横滚角 范围-900~900,精度0.1度
|
||||
int16_t YawAngle; //航向角 范围0~3600,精度0.1度
|
||||
}__attribute__((packed))LaserTracingType_T;
|
||||
|
||||
typedef struct {//0x0020 位移计
|
||||
typedef struct {//0x0020 位移
|
||||
MasterDev_T MasterDev;
|
||||
int16_t PitchAngle; //俯仰角偏斜(范围±900)单位0.1°
|
||||
int16_t RollAngle; //横滚角偏斜(范围±900)单位0.1°
|
||||
int16_t YawAngle; //偏航角偏斜(范围0~3600)单位0.1°
|
||||
int16_t PitchAngle; //俯仰角范围-900~900,精度0.1度
|
||||
int16_t RollAngle; //横滚角范围-900~900,精度0.1度
|
||||
int16_t YawAngle; //航向角范围0~3600,精度0.1度
|
||||
float Temp; //温度
|
||||
float Altitude; //海拔()单位cm
|
||||
int16_t Distance; //1轴应力值转位移(范围±300,单位0.1mm)
|
||||
float Altitude; //高程变化值,单位cm
|
||||
int16_t Distance; //1次测量相对基准值偏差,范围-300,精度0.1mm
|
||||
}__attribute__ ((packed))Displacement_T,*DisplacementDp;
|
||||
|
||||
typedef struct {//0x0021 七要素气象站数据
|
||||
uint8_t Time[7]; //"时间24小时制,Byte[0]*100+Byte[1]为年份,Byte[2]为月份,Byte[3]为日期,Byte[4]为时,Byte[5]为分,Byte[6]"
|
||||
int16_t Temperature; //温度
|
||||
uint16_t Humidity; //湿度
|
||||
uint16_t Pressure; //气压
|
||||
uint16_t WindSpeed; //平均风速
|
||||
uint16_t WindDirection; //平均风向
|
||||
uint16_t WindSpeed1m; //过去1分钟风速
|
||||
uint16_t WindDirection1m; //过去1分钟风向
|
||||
uint16_t WindSpeed10m; //过去10分钟风速
|
||||
uint16_t WindDirection10m; //过去10分钟风向
|
||||
uint16_t MinRainfall; //最小降雨量
|
||||
uint16_t HourRainfall; //小时降雨量
|
||||
uint16_t DayRainfall; //日降雨量
|
||||
uint32_t Light; //光照强度
|
||||
}__attribute__ ((packed))EWS_7_T,*EWS_7_Dp;
|
||||
|
||||
typedef struct {
|
||||
int Distance;
|
||||
}__attribute__((packed))LaserDistanceSensorType_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t CommDevAddr[6]; //通讯单元地址
|
||||
uint8_t CommDevAddr[6]; //通讯设备地址
|
||||
uint16_t CollectInterval; //采集时间间隔
|
||||
uint16_t ReportInterval; //上报时间间隔
|
||||
uint8_t ERInterval; //紧急上报时间间隔
|
||||
uint8_t ERTime; //紧急上报时长
|
||||
}__attribute__((packed))SvrDownLPDevConfigPara_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t CommDevAddr[6]; //通讯设备地址
|
||||
uint8_t FPOTimeStart; //全功率工作时间起始点(0~23)
|
||||
uint8_t FPOTime; //全功率工作时间时长(0~24)
|
||||
}__attribute__((packed))SvrDownFPOConfigPara_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t AlarmType;
|
||||
uint8_t AlarmState;
|
||||
@@ -170,6 +196,8 @@ typedef struct {
|
||||
#define LW_DEV_REPORT_INTERVAL_MAX 20//20分钟
|
||||
#define LW_DEV_ER_INTERVAL_MAX 2//2分钟
|
||||
#define LW_DEV_ER_TIME_MAX 20//20分钟
|
||||
#define LW_DEV_FPO_TIME_START_DEFAULT 0//默认0点开始
|
||||
#define LW_DEV_FPO_TIME_DEFAULT 0//默认0小时
|
||||
|
||||
typedef struct {
|
||||
uint16_t CollectInterval; //采集时间间隔
|
||||
@@ -182,31 +210,37 @@ typedef struct {
|
||||
typedef struct {
|
||||
bool RegFlag;
|
||||
bool RevNewDataFlag;
|
||||
bool CommStatus; //通讯状态,1-在线,0-离线
|
||||
bool CailFlag; //校准标志(低功耗)
|
||||
bool TimeSyncFlag; //时间同步标志(低功耗)
|
||||
bool ContLaser; //激光控制标志(低功耗)
|
||||
bool LaserOnOff; //激光状态(低功耗)
|
||||
bool CommStatus; //通讯状态1-在线0-离线
|
||||
bool CailFlag; //校准标志,需要校准
|
||||
bool TimeSyncFlag; //时间同步标志,需要同步时间
|
||||
bool ContLaser; //连续激光控制标志,需要控制
|
||||
bool LaserOnOff; //激光开关状态,开关状态
|
||||
bool FPOTimeFlag; //全功率时间配置等待下发标志
|
||||
bool FPOTimeConfirmed; //全功率时间配置已确认标志(传感器回应后置true)
|
||||
uint32_t CommErrCnt;
|
||||
uint8_t MasterMac[6];
|
||||
uint8_t Mac[SENSOR_NUM_MAX][6];//第一位是主设备,后面全是子设备
|
||||
uint8_t Mac[SENSOR_NUM_MAX][6];//主设备MAC,传感器MAC列表
|
||||
uint8_t BatLevel;
|
||||
int8_t RSSI; //信号强度
|
||||
int8_t Nsr; //信噪比
|
||||
uint16_t CUType;
|
||||
uint8_t SensorN;
|
||||
uint16_t SensorType[SENSOR_NUM_MAX];
|
||||
//低功耗设备配置信息
|
||||
bool ConfigFlag; //配置标志,为1表示有新配置,应答低功耗设备时需要附带发送
|
||||
//低功耗设备相关参数
|
||||
bool ConfigFlag; //配置标志位1表示需要配置,传感器上报数据时检查此标志并下发配置参数
|
||||
uint16_t CollectInterval; //采集时间间隔
|
||||
uint16_t ReportInterval; //上报时间间隔
|
||||
uint8_t ERInterval; //紧急上报时间间隔
|
||||
uint8_t ERTime; //紧急上报时长
|
||||
uint8_t FPOTimeStart; //全功率工作时间起始点(0~23)(待配置/已配置)
|
||||
uint8_t FPOTime; //全功率工作时间时长(0~24)(待配置/已配置)
|
||||
uint8_t CurFPOTimeStart; //传感器当前已确认生效的全功率起始点(0~23)
|
||||
uint8_t CurFPOTime; //传感器当前已确认生效的全功率时长(0~24)
|
||||
}__attribute__((packed))CommUnitPara_t, *CommUnitPara;
|
||||
|
||||
typedef struct {
|
||||
bool ExclFlag;
|
||||
uint8_t ExclMac[6];//需要排除的通讯单元MAC
|
||||
uint8_t ExclMac[6];//排除的通讯单元MAC
|
||||
}__attribute__((packed))ExclCommUnit_t, *ExclCommUnit;
|
||||
|
||||
typedef struct {
|
||||
@@ -218,10 +252,10 @@ typedef struct {
|
||||
}__attribute__((packed))CommUnit_t, *CommUnit;
|
||||
|
||||
typedef struct {
|
||||
bool Enable; //串口使能
|
||||
bool CommUnitEnable; //通讯单元使能,开启(使用内部通讯单元功能,直接和传感器通讯),关闭(直接和RS485类型的通讯单元通讯)
|
||||
bool Enable; //通道使能
|
||||
bool CommUnitEnable; //通讯单元使能,用于RS485通道挂载通讯单元时使用,主设备为RS485传感器时此标志无效
|
||||
bool QuerySensorFlag; //查询传感器标志
|
||||
bool UpgradeEnable;//升级功能使能
|
||||
bool UpgradeEnable;//升级使能标志
|
||||
uint8_t Power;
|
||||
uint32_t BaudRate;
|
||||
SendData RS485Send;
|
||||
@@ -263,61 +297,61 @@ typedef struct {
|
||||
}LoraPara_t, *pLoraPara;
|
||||
|
||||
typedef struct {
|
||||
uint8_t DestAddr[4]; //目的服务器地址
|
||||
uint16_t DestPort; //目的服务器端口
|
||||
uint8_t LocalAddr[4]; //本地客户端地址(预留)
|
||||
uint16_t LocalPort; //本地客户端端口(预留)
|
||||
uint8_t DestAddr[4]; //目标服务器地址
|
||||
uint16_t DestPort; //目标服务器端口
|
||||
uint8_t LocalAddr[4]; //本地地址(备用)
|
||||
uint16_t LocalPort; //本地端口(备用)
|
||||
}LTENetPara_t, *pLTENetPara;
|
||||
|
||||
typedef struct {
|
||||
uint8_t IpMode; //IP模式:DHCP/静态
|
||||
uint8_t IpMode; //IP模式DHCP/静态
|
||||
uint8_t IpAddr[4]; //本地IP地址
|
||||
uint16_t IpPort; //本地端口
|
||||
uint8_t WorkMode; //工作模式
|
||||
uint8_t SubnetMask[4]; //子网掩码
|
||||
uint8_t Gateway[4]; //网关
|
||||
uint8_t DestIp[4]; //目的IP地址
|
||||
uint16_t DestPort; //目的端口
|
||||
uint8_t DestIp[4]; //目标IP地址
|
||||
uint16_t DestPort; //目标端口
|
||||
}EthNetPara_t, *pEthNetPara;
|
||||
|
||||
typedef struct {
|
||||
uint32_t SavFlag; //存储标志
|
||||
Channel_m Much; //主上报通道
|
||||
Channel_m Auch; //辅助上报通道
|
||||
Channel_m Duch; //调试打印/上送通道
|
||||
uint8_t CuchMask; //通讯单元通道位掩码
|
||||
Channel_m Much; //主上传通道
|
||||
Channel_m Auch; //辅助上传通道
|
||||
Channel_m Duch; //调试通道/升级通道
|
||||
uint8_t CuchMask; //通讯单元通道掩码
|
||||
uint8_t GwMac[6]; //网关mac
|
||||
LTENetPara_t LTENet; //Cat1/4G服务器参数
|
||||
EthNetPara_t EthNet; //以太网网络参数
|
||||
uint32_t CommUnitReadInterval; //通讯单元读取时间间隔,单位S
|
||||
CommUnitPara_t CommUnitArray[COMMUNIT_NUM_MAX]; //注册的通讯单元信息
|
||||
ExclCommUnit_t ExclCommUnit[COMMUNIT_NUM_MAX]; //排除的通讯单元信息
|
||||
RS485Para_t Rs485Ch1; //RS485通道1配置
|
||||
RS485Para_t Rs485Ch2; //RS485通道2配置
|
||||
LoraPara_t Lora; //Lora配置
|
||||
bool OutageFlag; //断电报警标志
|
||||
LTENetPara_t LTENet; //Cat1/4G网络参数配置
|
||||
EthNetPara_t EthNet; //以太网网络参数配置
|
||||
uint32_t CommUnitReadInterval; //通讯单元读取间隔,单位S
|
||||
CommUnitPara_t CommUnitArray[COMMUNIT_NUM_MAX]; //通讯单元参数数组
|
||||
ExclCommUnit_t ExclCommUnit[COMMUNIT_NUM_MAX]; //排除的通讯单元列表
|
||||
RS485Para_t Rs485Ch1; //RS485通道1参数
|
||||
RS485Para_t Rs485Ch2; //RS485通道2参数
|
||||
LoraPara_t Lora; //Lora参数
|
||||
bool OutageFlag; //断电标志
|
||||
uint16_t crc16;
|
||||
}__attribute__((packed))GWConfigPara_t, *GWConfigPara;
|
||||
|
||||
struct GateWay_t{
|
||||
bool TimeSyncFlag; //时间同步标志
|
||||
bool MuchRegFlag; //主上报注册标志
|
||||
bool AuchRegFlag; //辅助上报注册标志
|
||||
bool MuchRegFlag; //主通道注册标志
|
||||
bool AuchRegFlag; //辅助通道注册标志
|
||||
uint8_t SvrMac[6]; //服务器mac
|
||||
GWConfigPara_t ConfigPara; //配置参数
|
||||
GWConfigPara_t ConfigPara; //网关配置参数
|
||||
CommUnitData_t CUDataArray[COMMUNIT_NUM_MAX];
|
||||
uint8_t Battery; //电池电量
|
||||
uint16_t UploadInterval; //上传间隔
|
||||
uint32_t HistoryNum; //历史数据数量
|
||||
DataRevCallBack MuchRevCallBack; //主上报接收回调
|
||||
DataRevCallBack AuchRevCallBack; //辅上报接收回调
|
||||
DataRevCallBack MuchRevCallBack; //主通道接收回调
|
||||
DataRevCallBack AuchRevCallBack; //辅助通道接收回调
|
||||
DataRevResCallBack CommUnitRevCallBack; //通讯单元接收回调
|
||||
rt_mq_t ChMQ[6]; //每个通道独立队列,索引=Channel_m
|
||||
rt_mq_t LoraRev_MQ; //Lora接收消息队列,第一个字节用于存储消息长度,后为数据
|
||||
rt_mq_t ChMQ[6]; //各通道消息队列,索引=Channel_m
|
||||
rt_mq_t LoraRev_MQ; //Lora接收消息队列,用于缓存接收数据避免丢失
|
||||
rt_mutex_t UartRevMutex;
|
||||
rt_mutex_t EthTxMutex;
|
||||
|
||||
uint8_t BatteryReadDlyCnt; //读取电压延时,单位秒,防止4G发送拉低电池电压,造成断电误报
|
||||
uint8_t BatteryReadDlyCnt; //电池读取延迟计数,开机后延时读取,4G模块上电需要时间稳定
|
||||
};
|
||||
|
||||
int MuchRevCallBack(GateWayPara GateWay, uint8_t *rData, uint16_t rLen);
|
||||
@@ -329,9 +363,9 @@ int NetCommOrgData(GateWayPara GateWay, uint8_t *MegData, uint8_t *OutData);
|
||||
int CommUnitAnalyze(GateWayPara GateWay, uint8_t *rData, uint16_t rLen, SendData Response);
|
||||
void DebugAnalyze(GateWayPara GateWay, uint8_t *rData, uint16_t rLen);
|
||||
void CommUnitCmdSend(GateWayPara GateWay, uint8_t *CommUnitMac, CommUnitCmd_m Cmd, uint8_t *Payload, uint16_t PayloadLen, SendData Send);
|
||||
void TrySendFullPowerCmd(GateWayPara GateWay, int CommUnitIdx);
|
||||
int CheckCommUnitReg(GateWayPara GateWay, uint8_t *CommUnitMac);
|
||||
int CheckCommUnitExcl(GateWayPara GateWay, uint8_t *CommUnitMac);
|
||||
int CommUintOrgData(GateWayPara GateWay, CommUnitPara CUPara, CommUnitData CUData, uint8_t *sData);
|
||||
void DebugDisplaySensorData(int SensorIdx, uint16_t SensorType, uint8_t *SensorData);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -292,6 +292,87 @@ void CommUnitCmdSend(GateWayPara GateWay, uint8_t *CommUnitMac, CommUnitCmd_m Cm
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************************
|
||||
* 函数名称: TrySendFullPowerCmd
|
||||
* 功能描述: 当传感器处于FullPower状态时,直接下发待处理配置命令,无需等待传感器上报
|
||||
* 参 数: GateWay, 网关参数
|
||||
CommUnitIdx, 通讯单元索引
|
||||
* 返 回 值: 无
|
||||
*****************************************************************************************/
|
||||
void TrySendFullPowerCmd(GateWayPara GateWay, int CommUnitIdx)
|
||||
{
|
||||
if(CommUnitIdx < 0 || CommUnitIdx >= COMMUNIT_NUM_MAX)
|
||||
return;
|
||||
if(GateWay->ConfigPara.CommUnitArray[CommUnitIdx].RegFlag != true)
|
||||
return;
|
||||
if(GateWay->ConfigPara.CommUnitArray[CommUnitIdx].CUType != DEV_TYPE_EXT_COMMUNIT)
|
||||
return;
|
||||
|
||||
//使用传感器当前已确认生效的FPO参数判断是否处于全功率时段
|
||||
uint8_t FPOStart = GateWay->ConfigPara.CommUnitArray[CommUnitIdx].CurFPOTimeStart;
|
||||
uint8_t FPODur = GateWay->ConfigPara.CommUnitArray[CommUnitIdx].CurFPOTime;
|
||||
if(FPODur == 0)
|
||||
return; //传感器当前未配置全功率时段,不能直接下发,需等待上报回应
|
||||
struct tm cTime;
|
||||
TimeGet(&cTime);
|
||||
int curHour = cTime.tm_hour;
|
||||
int endHour = FPOStart + FPODur;
|
||||
bool inFPO = false;
|
||||
if(FPODur >= 24) {
|
||||
inFPO = true; //全天全功率
|
||||
}
|
||||
else if(endHour > 24) {
|
||||
//跨天:如 Start=22, Dur=4,则 22~23 和 0~1 为全功率
|
||||
inFPO = (curHour >= FPOStart || curHour < endHour - 24);
|
||||
}
|
||||
else {
|
||||
//同天:如 Start=8, Dur=10,则 8~17 为全功率
|
||||
inFPO = (curHour >= FPOStart && curHour < endHour);
|
||||
}
|
||||
if(!inFPO)
|
||||
return;
|
||||
|
||||
uint8_t *Mac = GateWay->ConfigPara.CommUnitArray[CommUnitIdx].Mac[0];
|
||||
uint32_t ctime = TimeTs();
|
||||
|
||||
if(GateWay->ConfigPara.CommUnitArray[CommUnitIdx].ConfigFlag == true) {
|
||||
GateWay->ConfigPara.CommUnitArray[CommUnitIdx].ConfigFlag = false;
|
||||
LPDevConfigPara_t Config;
|
||||
Config.CollectInterval = GateWay->ConfigPara.CommUnitArray[CommUnitIdx].CollectInterval;
|
||||
Config.ReportInterval = GateWay->ConfigPara.CommUnitArray[CommUnitIdx].ReportInterval;
|
||||
Config.ERInterval = GateWay->ConfigPara.CommUnitArray[CommUnitIdx].ERInterval;
|
||||
Config.ERTime = GateWay->ConfigPara.CommUnitArray[CommUnitIdx].ERTime;
|
||||
Config.TimeStamp = ctime;
|
||||
CommUnitCmdSend(GateWay, Mac, COMM_UNIT_CMD_READ, (uint8_t *)&Config, sizeof(LPDevConfigPara_t), Sx1276LoRaSendBuffer);
|
||||
MAIN_DBG_LOG("FullPower direct send config. Mac:%02X-%02X-%02X-%02X-%02X-%02X\r\n",
|
||||
Mac[0], Mac[1], Mac[2], Mac[3], Mac[4], Mac[5]);
|
||||
}
|
||||
else if(GateWay->ConfigPara.CommUnitArray[CommUnitIdx].ContLaser == true) {
|
||||
if(GateWay->ConfigPara.CommUnitArray[CommUnitIdx].LaserOnOff == true) {
|
||||
CommUnitCmdSend(GateWay, Mac, COMM_UNIT_CMD_CONT_LASER, (uint8_t *)&GateWay->ConfigPara.CommUnitArray[CommUnitIdx].LaserOnOff, 1, Sx1276LoRaSendBuffer);
|
||||
}
|
||||
MAIN_DBG_LOG("FullPower direct send laser cmd.\r\n");
|
||||
}
|
||||
else if(GateWay->ConfigPara.CommUnitArray[CommUnitIdx].CailFlag == true) {
|
||||
CommUnitCmdSend(GateWay, Mac, COMM_UNIT_CMD_CAIL, 0, 0, Sx1276LoRaSendBuffer);
|
||||
MAIN_DBG_LOG("FullPower direct send calibrate cmd.\r\n");
|
||||
}
|
||||
else if(GateWay->ConfigPara.CommUnitArray[CommUnitIdx].TimeSyncFlag == true) {
|
||||
CommUnitCmdSend(GateWay, Mac, COMM_UNIT_CMD_TIME_SYNC, (uint8_t *)&ctime, 4, Sx1276LoRaSendBuffer);
|
||||
MAIN_DBG_LOG("FullPower direct send time sync cmd.\r\n");
|
||||
}
|
||||
else if(GateWay->ConfigPara.CommUnitArray[CommUnitIdx].FPOTimeFlag == true) {
|
||||
GateWay->ConfigPara.CommUnitArray[CommUnitIdx].FPOTimeFlag = false;
|
||||
GateWay->ConfigPara.CommUnitArray[CommUnitIdx].FPOTimeConfirmed = false;
|
||||
uint8_t FPOData[2];
|
||||
FPOData[0] = GateWay->ConfigPara.CommUnitArray[CommUnitIdx].FPOTimeStart;
|
||||
FPOData[1] = GateWay->ConfigPara.CommUnitArray[CommUnitIdx].FPOTime;
|
||||
CommUnitCmdSend(GateWay, Mac, COMM_UNIT_CMD_SET_FPO_TIME, FPOData, 2, Sx1276LoRaSendBuffer);
|
||||
MAIN_DBG_LOG("FullPower direct send FPO config. Start:%d, Duration:%d\r\n", FPOData[0], FPOData[1]);
|
||||
}
|
||||
WritePara((uint8_t *)&GateWay->ConfigPara, sizeof(GWConfigPara_t));
|
||||
}
|
||||
|
||||
/*****************************************************************************************
|
||||
* 函数名称: CommUintOrgData
|
||||
* 功能描述: 上传传感器数据函数
|
||||
@@ -544,9 +625,11 @@ int CommUnitAnalyze(GateWayPara GateWay, uint8_t *rData, uint16_t rLen, SendData
|
||||
GateWay->ConfigPara.CommUnitArray[CommUnitIdx].TimeSyncFlag = false;
|
||||
GateWay->ConfigPara.CommUnitArray[CommUnitIdx].ContLaser = false;
|
||||
GateWay->ConfigPara.CommUnitArray[CommUnitIdx].LaserOnOff = false;
|
||||
CommUnitCmdSend(GateWay, CUHeader->DevMac, COMM_UNIT_CMD_REG, &ret, 1, Response);
|
||||
WritePara((uint8_t *)&GateWay->ConfigPara, sizeof(GWConfigPara_t));
|
||||
return CommUnitIdx;
|
||||
GateWay->ConfigPara.CommUnitArray[CommUnitIdx].FPOTimeFlag = false;
|
||||
GateWay->ConfigPara.CommUnitArray[CommUnitIdx].FPOTimeConfirmed = true;
|
||||
CommUnitCmdSend(GateWay, CUHeader->DevMac, COMM_UNIT_CMD_REG, &ret, 1, Response);
|
||||
WritePara((uint8_t *)&GateWay->ConfigPara, sizeof(GWConfigPara_t));
|
||||
return CommUnitIdx;
|
||||
}
|
||||
for(int i = 0; i < COMMUNIT_NUM_MAX; i++) {
|
||||
if(GateWay->ConfigPara.CommUnitArray[i].RegFlag == false) {
|
||||
@@ -580,9 +663,15 @@ int CommUnitAnalyze(GateWayPara GateWay, uint8_t *rData, uint16_t rLen, SendData
|
||||
GateWay->ConfigPara.CommUnitArray[i].ReportInterval = LW_DEV_REPORT_INTERVAL_MAX;
|
||||
GateWay->ConfigPara.CommUnitArray[i].ERInterval = LW_DEV_ER_INTERVAL_MAX;
|
||||
GateWay->ConfigPara.CommUnitArray[i].ERTime = LW_DEV_ER_TIME_MAX;
|
||||
WritePara((uint8_t *)&GateWay->ConfigPara, sizeof(GWConfigPara_t));
|
||||
uint8_t ret = 1;
|
||||
CommUnitCmdSend(GateWay, CUHeader->DevMac, COMM_UNIT_CMD_REG, &ret, 1, Response);
|
||||
GateWay->ConfigPara.CommUnitArray[i].FPOTimeStart = LW_DEV_FPO_TIME_START_DEFAULT;
|
||||
GateWay->ConfigPara.CommUnitArray[i].FPOTime = LW_DEV_FPO_TIME_DEFAULT;
|
||||
GateWay->ConfigPara.CommUnitArray[i].CurFPOTimeStart = LW_DEV_FPO_TIME_START_DEFAULT;
|
||||
GateWay->ConfigPara.CommUnitArray[i].CurFPOTime = LW_DEV_FPO_TIME_DEFAULT;
|
||||
GateWay->ConfigPara.CommUnitArray[i].FPOTimeFlag = false;
|
||||
GateWay->ConfigPara.CommUnitArray[i].FPOTimeConfirmed = true;
|
||||
WritePara((uint8_t *)&GateWay->ConfigPara, sizeof(GWConfigPara_t));
|
||||
uint8_t ret = 1;
|
||||
CommUnitCmdSend(GateWay, CUHeader->DevMac, COMM_UNIT_CMD_REG, &ret, 1, Response);
|
||||
|
||||
if(GateWay->MuchRegFlag) { //网关已注册,向服务发送新设备添加指令
|
||||
PayLoadLen = (GateWay->ConfigPara.CommUnitArray[i].SensorN * 6) + 2;
|
||||
@@ -647,6 +736,16 @@ int CommUnitAnalyze(GateWayPara GateWay, uint8_t *rData, uint16_t rLen, SendData
|
||||
CommUnitCmdSend(GateWay, CUHeader->DevMac, COMM_UNIT_CMD_TIME_SYNC, (uint8_t *)&ctime, 4, Response);
|
||||
MAIN_DBG_LOG("Issue a time synchronization command.\r\n");
|
||||
}
|
||||
else if(GateWay->ConfigPara.CommUnitArray[CommUnitIdx].FPOTimeFlag == true)
|
||||
{
|
||||
GateWay->ConfigPara.CommUnitArray[CommUnitIdx].FPOTimeFlag = false;
|
||||
GateWay->ConfigPara.CommUnitArray[CommUnitIdx].FPOTimeConfirmed = false;
|
||||
uint8_t FPOData[2];
|
||||
FPOData[0] = GateWay->ConfigPara.CommUnitArray[CommUnitIdx].FPOTimeStart;
|
||||
FPOData[1] = GateWay->ConfigPara.CommUnitArray[CommUnitIdx].FPOTime;
|
||||
CommUnitCmdSend(GateWay, CUHeader->DevMac, COMM_UNIT_CMD_SET_FPO_TIME, FPOData, 2, Response);
|
||||
MAIN_DBG_LOG("Issue FPO time config command. Start:%d, Duration:%d\r\n", FPOData[0], FPOData[1]);
|
||||
}
|
||||
WritePara((uint8_t *)&GateWay->ConfigPara, sizeof(GWConfigPara_t));
|
||||
break;}
|
||||
|
||||
@@ -730,6 +829,16 @@ int CommUnitAnalyze(GateWayPara GateWay, uint8_t *rData, uint16_t rLen, SendData
|
||||
CommUnitCmdSend(GateWay, CUHeader->DevMac, COMM_UNIT_CMD_TIME_SYNC, (uint8_t *)&ctime, 4, Response);
|
||||
MAIN_DBG_LOG("Issue a time synchronization command.\r\n");
|
||||
}
|
||||
else if(GateWay->ConfigPara.CommUnitArray[CommUnitIdx].FPOTimeFlag == true)
|
||||
{
|
||||
GateWay->ConfigPara.CommUnitArray[CommUnitIdx].FPOTimeFlag = false;
|
||||
GateWay->ConfigPara.CommUnitArray[CommUnitIdx].FPOTimeConfirmed = false;
|
||||
uint8_t FPOData[2];
|
||||
FPOData[0] = GateWay->ConfigPara.CommUnitArray[CommUnitIdx].FPOTimeStart;
|
||||
FPOData[1] = GateWay->ConfigPara.CommUnitArray[CommUnitIdx].FPOTime;
|
||||
CommUnitCmdSend(GateWay, CUHeader->DevMac, COMM_UNIT_CMD_SET_FPO_TIME, FPOData, 2, Response);
|
||||
MAIN_DBG_LOG("Issue FPO time config command. Start:%d, Duration:%d\r\n", FPOData[0], FPOData[1]);
|
||||
}
|
||||
else
|
||||
CommUnitCmdSend(GateWay, CUHeader->DevMac, COMM_UNIT_CMD_READ, (uint8_t *)&ctime, 4, Response);
|
||||
#endif
|
||||
@@ -782,6 +891,16 @@ int CommUnitAnalyze(GateWayPara GateWay, uint8_t *rData, uint16_t rLen, SendData
|
||||
CommUnitCmdSend(GateWay, CUHeader->DevMac, COMM_UNIT_CMD_TIME_SYNC, (uint8_t *)&ctime, 4, Response);
|
||||
MAIN_DBG_LOG("Issue a time synchronization command.\r\n");
|
||||
}
|
||||
else if(GateWay->ConfigPara.CommUnitArray[CommUnitIdx].FPOTimeFlag == true)
|
||||
{
|
||||
GateWay->ConfigPara.CommUnitArray[CommUnitIdx].FPOTimeFlag = false;
|
||||
GateWay->ConfigPara.CommUnitArray[CommUnitIdx].FPOTimeConfirmed = false;
|
||||
uint8_t FPOData2[2];
|
||||
FPOData2[0] = GateWay->ConfigPara.CommUnitArray[CommUnitIdx].FPOTimeStart;
|
||||
FPOData2[1] = GateWay->ConfigPara.CommUnitArray[CommUnitIdx].FPOTime;
|
||||
CommUnitCmdSend(GateWay, CUHeader->DevMac, COMM_UNIT_CMD_SET_FPO_TIME, FPOData2, 2, Response);
|
||||
MAIN_DBG_LOG("Issue FPO time config command. Start:%d, Duration:%d\r\n", FPOData2[0], FPOData2[1]);
|
||||
}
|
||||
WritePara((uint8_t *)&GateWay->ConfigPara, sizeof(GWConfigPara_t));
|
||||
break;}
|
||||
|
||||
@@ -856,10 +975,20 @@ int CommUnitAnalyze(GateWayPara GateWay, uint8_t *rData, uint16_t rLen, SendData
|
||||
CommUnitCmdSend(GateWay, CUHeader->DevMac, COMM_UNIT_CMD_TIME_SYNC, (uint8_t *)&ctime, 4, Response);
|
||||
MAIN_DBG_LOG("Issue a time synchronization command.\r\n");
|
||||
}
|
||||
else if(GateWay->ConfigPara.CommUnitArray[CommUnitIdx].FPOTimeFlag == true)
|
||||
{
|
||||
GateWay->ConfigPara.CommUnitArray[CommUnitIdx].FPOTimeFlag = false;
|
||||
GateWay->ConfigPara.CommUnitArray[CommUnitIdx].FPOTimeConfirmed = false;
|
||||
uint8_t FPOData3[2];
|
||||
FPOData3[0] = GateWay->ConfigPara.CommUnitArray[CommUnitIdx].FPOTimeStart;
|
||||
FPOData3[1] = GateWay->ConfigPara.CommUnitArray[CommUnitIdx].FPOTime;
|
||||
CommUnitCmdSend(GateWay, CUHeader->DevMac, COMM_UNIT_CMD_SET_FPO_TIME, FPOData3, 2, Response);
|
||||
MAIN_DBG_LOG("Issue FPO time config command. Start:%d, Duration:%d\r\n", FPOData3[0], FPOData3[1]);
|
||||
}
|
||||
WritePara((uint8_t *)&GateWay->ConfigPara, sizeof(GWConfigPara_t));
|
||||
break;}
|
||||
|
||||
case COMM_UNIT_CMD_GET_SIGNAL:{
|
||||
case COMM_UNIT_CMD_GET_SIGNAL:{
|
||||
int16_t Rssi;
|
||||
int8_t Snr;
|
||||
uint8_t SignalPayload[2];
|
||||
@@ -872,6 +1001,35 @@ int CommUnitAnalyze(GateWayPara GateWay, uint8_t *rData, uint16_t rLen, SendData
|
||||
Snr, Rssi);
|
||||
break;}
|
||||
|
||||
case COMM_UNIT_CMD_SET_FPO_TIME:{
|
||||
//传感器回应0x0A命令,携带配置参数
|
||||
uint8_t FPOResponse = 0;
|
||||
if(PayLoad[0] <= 23 && PayLoad[1] <= 24) {
|
||||
GateWay->ConfigPara.CommUnitArray[CommUnitIdx].FPOTimeStart = PayLoad[0];
|
||||
GateWay->ConfigPara.CommUnitArray[CommUnitIdx].FPOTime = PayLoad[1];
|
||||
GateWay->ConfigPara.CommUnitArray[CommUnitIdx].CurFPOTimeStart = PayLoad[0];
|
||||
GateWay->ConfigPara.CommUnitArray[CommUnitIdx].CurFPOTime = PayLoad[1];
|
||||
GateWay->ConfigPara.CommUnitArray[CommUnitIdx].FPOTimeConfirmed = true;
|
||||
FPOResponse = 1;
|
||||
MAIN_DBG_LOG("FPO time confirmed. Mac:%02X-%02X-%02X-%02X-%02X-%02X, Start:%d, Duration:%d\r\n",
|
||||
CUHeader->DevMac[0], CUHeader->DevMac[1], CUHeader->DevMac[2], CUHeader->DevMac[3], CUHeader->DevMac[4], CUHeader->DevMac[5],
|
||||
PayLoad[0], PayLoad[1]);
|
||||
WritePara((uint8_t *)&GateWay->ConfigPara, sizeof(GWConfigPara_t));
|
||||
}
|
||||
else {
|
||||
MAIN_DBG_LOG("FPO time config invalid. Start:%d, Duration:%d\r\n", PayLoad[0], PayLoad[1]);
|
||||
}
|
||||
//回应服务器0x0A命令:DevAddr(6) + Response(1)
|
||||
MegData = rt_malloc(10);
|
||||
MegData[0] = 7;
|
||||
MegData[1] = 0;
|
||||
MegData[2] = NET_COMM_CMD_FPO_CONFIG;
|
||||
memcpy(&MegData[3], CUHeader->DevMac, 6);
|
||||
MegData[9] = FPOResponse;
|
||||
UploadSend(MegData, 10);
|
||||
rt_free(MegData);
|
||||
break;}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -939,8 +1097,10 @@ static int _NetRevCallBack(GateWayPara GateWay, uint8_t *rData, uint16_t rLen, b
|
||||
}
|
||||
for(int i = 0; i < COMMUNIT_NUM_MAX; i++)//参数遍历
|
||||
{
|
||||
if(GateWay->ConfigPara.CommUnitArray[i].RegFlag == true)
|
||||
if(GateWay->ConfigPara.CommUnitArray[i].RegFlag == true) {
|
||||
GateWay->ConfigPara.CommUnitArray[i].TimeSyncFlag = true;//校时置位,等待下次此MAC主设备上传数据时下发校准指令(低功耗)
|
||||
TrySendFullPowerCmd(GateWay, i);
|
||||
}
|
||||
}
|
||||
//校准其他通讯网关
|
||||
//CommUnitCmdSend(GateWay, CommUintMac, COMM_UNIT_CMD_TIME_SYNC, &rData[14], 4, Sx1276LoRaSendBuffer);
|
||||
@@ -997,8 +1157,10 @@ static int _NetRevCallBack(GateWayPara GateWay, uint8_t *rData, uint16_t rLen, b
|
||||
|
||||
for(int i = 0; i < COMMUNIT_NUM_MAX; i++)//参数遍历
|
||||
{
|
||||
if(GateWay->ConfigPara.CommUnitArray[i].RegFlag == true)
|
||||
if(GateWay->ConfigPara.CommUnitArray[i].RegFlag == true) {
|
||||
GateWay->ConfigPara.CommUnitArray[i].CailFlag = true;//校准置位,等待下次此MAC主设备上传数据时下发校准指令(低功耗)
|
||||
TrySendFullPowerCmd(GateWay, i);
|
||||
}
|
||||
}
|
||||
//校准其他通讯网关
|
||||
//CommUnitCmdSend(GateWay, CommUintMac, COMM_UNIT_CMD_CAIL, NULL, 0, Sx1276LoRaSendBuffer);
|
||||
@@ -1017,6 +1179,7 @@ static int _NetRevCallBack(GateWayPara GateWay, uint8_t *rData, uint16_t rLen, b
|
||||
//CommUnitCmdSend(GateWay, CommUintMac, COMM_UNIT_CMD_CAIL, NULL, 0, Sx1276LoRaSendBuffer);//查询模式
|
||||
MAIN_DBG_LOG("Calibrate Mac:%02X-%02X-%02X-%02X-%02X-%02X\r\n",
|
||||
CommUintMac[0], CommUintMac[1], CommUintMac[2], CommUintMac[3], CommUintMac[4], CommUintMac[5]);
|
||||
TrySendFullPowerCmd(GateWay, ret);
|
||||
}
|
||||
else if(GateWay->ConfigPara.CommUnitArray[ret].Mac[0][2] == 2)//判断通讯类型
|
||||
{
|
||||
@@ -1141,7 +1304,7 @@ static int _NetRevCallBack(GateWayPara GateWay, uint8_t *rData, uint16_t rLen, b
|
||||
break;}
|
||||
|
||||
case NET_COMM_CMD_LP_DEV_CONFIG: {
|
||||
//开始配置
|
||||
//13字节:DevAddr(6) + CollectInterval(2) + ReportInterval(2) + ERInterval(1) + ERTime(1)
|
||||
SvrDownLPDevConfigPara_t *LPDevConfig;
|
||||
LPDevConfig = (SvrDownLPDevConfigPara_t *)Data;
|
||||
int ret = memcmp(CommUintMac, LPDevConfig->CommDevAddr, 6);
|
||||
@@ -1153,6 +1316,7 @@ static int _NetRevCallBack(GateWayPara GateWay, uint8_t *rData, uint16_t rLen, b
|
||||
GateWay->ConfigPara.CommUnitArray[i].ERInterval = LPDevConfig->ERInterval;
|
||||
GateWay->ConfigPara.CommUnitArray[i].ERTime = LPDevConfig->ERTime;
|
||||
GateWay->ConfigPara.CommUnitArray[i].ConfigFlag = true;
|
||||
TrySendFullPowerCmd(GateWay, i);
|
||||
}
|
||||
}
|
||||
MAIN_DBG_LOG("Configure all the parameters of the main devices.\r\n");
|
||||
@@ -1171,6 +1335,7 @@ static int _NetRevCallBack(GateWayPara GateWay, uint8_t *rData, uint16_t rLen, b
|
||||
WritePara((uint8_t *)&GateWay->ConfigPara, sizeof(GWConfigPara_t));
|
||||
MAIN_DBG_LOG("Main equipment parameter configuration. Mac:%02X-%02X-%02X-%02X-%02X-%02X\r\n",
|
||||
CommUintMac[0], CommUintMac[1], CommUintMac[2], CommUintMac[3], CommUintMac[4], CommUintMac[5]);
|
||||
TrySendFullPowerCmd(GateWay, ret);
|
||||
}
|
||||
//应答服务器
|
||||
MegData = rt_malloc(4);
|
||||
@@ -1182,6 +1347,24 @@ static int _NetRevCallBack(GateWayPara GateWay, uint8_t *rData, uint16_t rLen, b
|
||||
UploadSend(MegData, sLen);
|
||||
rt_free(MegData);
|
||||
break;}
|
||||
case NET_COMM_CMD_FPO_CONFIG: {
|
||||
//8字节:DevAddr(6) + FPOTimeStart(1) + FPOTime(1),全功率时间配置
|
||||
SvrDownFPOConfigPara_t *FPOConfig;
|
||||
FPOConfig = (SvrDownFPOConfigPara_t *)Data;
|
||||
memcpy(&CommUintMac[0], Data, 6);
|
||||
int ret = CheckCommUnitReg(GateWay, CommUintMac);
|
||||
if(ret < 0)
|
||||
return -1;
|
||||
GateWay->ConfigPara.CommUnitArray[ret].FPOTimeStart = FPOConfig->FPOTimeStart;
|
||||
GateWay->ConfigPara.CommUnitArray[ret].FPOTime = FPOConfig->FPOTime;
|
||||
GateWay->ConfigPara.CommUnitArray[ret].FPOTimeFlag = true;
|
||||
GateWay->ConfigPara.CommUnitArray[ret].FPOTimeConfirmed = false;
|
||||
WritePara((uint8_t *)&GateWay->ConfigPara, sizeof(GWConfigPara_t));
|
||||
MAIN_DBG_LOG("FPO time config. Mac:%02X-%02X-%02X-%02X-%02X-%02X, Start:%d, Duration:%d\r\n",
|
||||
CommUintMac[0], CommUintMac[1], CommUintMac[2], CommUintMac[3], CommUintMac[4], CommUintMac[5],
|
||||
FPOConfig->FPOTimeStart, FPOConfig->FPOTime);
|
||||
TrySendFullPowerCmd(GateWay, ret);
|
||||
break;}
|
||||
case NET_COMM_CMD_ALARM:{
|
||||
MAIN_DBG_LOG("Received server response.....\r\n");
|
||||
break;}
|
||||
@@ -1202,6 +1385,7 @@ static int _NetRevCallBack(GateWayPara GateWay, uint8_t *rData, uint16_t rLen, b
|
||||
GateWay->ConfigPara.CommUnitArray[ret].ContLaser = true;//控制激光,等待下次此MAC主设备上传数据时下发打开激光指令(低功耗)
|
||||
MAIN_DBG_LOG("Waiting for the laser response. Mac:%02X-%02X-%02X-%02X-%02X-%02X\r\n",
|
||||
CommUintMac[0], CommUintMac[1], CommUintMac[2], CommUintMac[3], CommUintMac[4], CommUintMac[5]);
|
||||
TrySendFullPowerCmd(GateWay, ret);
|
||||
}
|
||||
else if(GateWay->ConfigPara.CommUnitArray[ret].LaserOnOff == false)
|
||||
{//直接发送
|
||||
|
||||
@@ -76,6 +76,7 @@ void RS485Analyze(GateWayPara GateWay, SensorCommPara SCPara, CommUnit Para, uin
|
||||
else {
|
||||
MAIN_DBG_LOG("Sensor%d Addr Set failed!\r\n", Header->SlvAddr);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case RS485_SENSOR_CMD_CAIL:
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
<<<<<<< HEAD
|
||||
# GateWay
|
||||
|
||||
一代网关
|
||||
=======
|
||||
# LaserTracing_Debug
|
||||
|
||||
>>>>>>> aaff1aeec5ea03de83eee8888e10da1bf6a62ded
|
||||
@@ -1,8 +0,0 @@
|
||||
<<<<<<< HEAD
|
||||
# GateWay
|
||||
|
||||
一代网关
|
||||
=======
|
||||
# LaserTracing_Debug
|
||||
|
||||
>>>>>>> aaff1aeec5ea03de83eee8888e10da1bf6a62ded
|
||||
@@ -1,3 +0,0 @@
|
||||
# GateWay
|
||||
|
||||
一代网关
|
||||
@@ -1,3 +0,0 @@
|
||||
# GateWay
|
||||
|
||||
一代网关
|
||||
@@ -1,2 +0,0 @@
|
||||
# LaserTracing_Debug
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
# LaserTracing_Debug
|
||||
|
||||
Reference in New Issue
Block a user