Merge branch 'dg101_feature_new_process' of http://192.168.0.10:3000/pandx/WLG into dg101_feature_new_process
This commit is contained in:
commit
a0f968ec41
125
uart/uart.cpp
125
uart/uart.cpp
@ -46,7 +46,7 @@ int Uart::UartRecv(int fd, char srcshow, char *buffer) {
|
|||||||
ret = read_data(fd, buff, BUF_LENGTH, 10);
|
ret = read_data(fd, buff, BUF_LENGTH, 10);
|
||||||
if (ret <= 0) {
|
if (ret <= 0) {
|
||||||
timeoutflag++;
|
timeoutflag++;
|
||||||
if (timeoutflag > 500) {
|
if (timeoutflag > 300) {
|
||||||
DealReviveDuration(wave_shortAddr);
|
DealReviveDuration(wave_shortAddr);
|
||||||
zlog_warn(zct, "===============0x9999 timeout= %d offSize = %d===============shortAddr = %02x%02x", timeoutflag, offSize,UINT16_HIGH(wave_shortAddr),UINT16_LOW(wave_shortAddr));
|
zlog_warn(zct, "===============0x9999 timeout= %d offSize = %d===============shortAddr = %02x%02x", timeoutflag, offSize,UINT16_HIGH(wave_shortAddr),UINT16_LOW(wave_shortAddr));
|
||||||
zlog_warn(zct, "0x9999 timeout %d===============Size = %d", timeoutflag, offSize);
|
zlog_warn(zct, "0x9999 timeout %d===============Size = %d", timeoutflag, offSize);
|
||||||
@ -75,7 +75,7 @@ int Uart::UartRecv(int fd, char srcshow, char *buffer) {
|
|||||||
maxSize = 0;
|
maxSize = 0;
|
||||||
tcflush(fd, TCIOFLUSH);
|
tcflush(fd, TCIOFLUSH);
|
||||||
}
|
}
|
||||||
|
zlog_info(zct, "0x8888 ===str_recv===,offSize = %d,ret = %d", offSize,ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -321,7 +321,9 @@ void Uart::GetLocalZigbeeRSSI(uint16_t ushortAdd){
|
|||||||
zlog_info(zct, "Local Zigbee Signal !\n");
|
zlog_info(zct, "Local Zigbee Signal !\n");
|
||||||
mssleep(20000);
|
mssleep(20000);
|
||||||
getZigbeeSignal(ushortAdd);
|
getZigbeeSignal(ushortAdd);
|
||||||
mssleep(10000);
|
mssleep(20000);
|
||||||
|
getZigbeeSignal(ushortAdd);
|
||||||
|
mssleep(20000);
|
||||||
}
|
}
|
||||||
int Uart::DealAskTask(uint16_t ushortAdd){
|
int Uart::DealAskTask(uint16_t ushortAdd){
|
||||||
char wherecon[50]={0};
|
char wherecon[50]={0};
|
||||||
@ -333,50 +335,63 @@ int Uart::DealAskTask(uint16_t ushortAdd){
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
ModifyDistAddr(ushortAdd);
|
ModifyDistAddr(ushortAdd);
|
||||||
int next_duration = 0;
|
int next_duration = 0,next_task_id = 0;
|
||||||
int taskID;
|
int taskID;
|
||||||
scheduler::instance().StartSchedule(ushortAdd,next_duration, taskID);
|
|
||||||
ScheduleTask scheduleTask;
|
ScheduleTask scheduleTask;
|
||||||
zlog_info(zct, "taskID = %d ", taskID);
|
taskID = scheduler::instance().StartSchedule(ushortAdd,next_duration, next_task_id);
|
||||||
if (taskID == kScheduleEigenValue) //1.特征值
|
zlog_info(zct, "taskID = %d next_duration = %d next_task_id = %d", taskID, next_duration, next_task_id);
|
||||||
{
|
if (taskID == kScheduleConfigSensor)
|
||||||
TaskResp(scheduleTask);
|
|
||||||
}
|
|
||||||
else if (taskID == kScheduleWaveForm) //2.波形
|
|
||||||
{
|
|
||||||
wave_shortAddr = ushortAdd;
|
|
||||||
GetLocalZigbeeRSSI(ushortAdd);
|
|
||||||
scheduleTask.cmd = SIGNAL_STRENGTH;
|
|
||||||
scheduleTask.shortAddr = ushortAdd;
|
|
||||||
scheduleTask.duration = next_duration;
|
|
||||||
TaskResp(scheduleTask);
|
|
||||||
|
|
||||||
}
|
|
||||||
else if (taskID == kScheduleUpgrade) //3.升级
|
|
||||||
{
|
|
||||||
UpdateWirelessNode(ushortAdd);
|
|
||||||
}else if (taskID == kScheduleConfigSensor) //4.更新配置
|
|
||||||
{
|
{
|
||||||
scheduleTask.cmd = CONFIG;
|
scheduleTask.cmd = CONFIG;
|
||||||
|
scheduleTask.duration = next_duration;
|
||||||
|
scheduleTask.next_taskID = next_task_id;
|
||||||
scheduleTask.shortAddr = ushortAdd;
|
scheduleTask.shortAddr = ushortAdd;
|
||||||
mssleep(50000);
|
mssleep(50000);
|
||||||
TaskResp(scheduleTask);
|
TaskResp(scheduleTask);
|
||||||
mssleep(50000);
|
mssleep(50000);
|
||||||
UpdateConfig(ushortAdd);
|
UpdateConfig(ushortAdd);
|
||||||
}else if (taskID == kScheduleWrongTime) //5.异常连接
|
}
|
||||||
{
|
if(next_task_id == kScheduleWaveForm){
|
||||||
scheduleTask.cmd = REVIVE_DURATION;
|
scheduleTask.cmd = REVIVE_DURATION;
|
||||||
scheduleTask.shortAddr = ushortAdd;
|
scheduleTask.shortAddr = ushortAdd;
|
||||||
scheduleTask.duration = next_duration;
|
scheduleTask.duration = next_duration;
|
||||||
zlog_info(zct, "next_duration = %d ", next_duration);
|
scheduleTask.next_taskID = WAVE_CMD;
|
||||||
TaskResp(scheduleTask);
|
TaskResp(scheduleTask);
|
||||||
}else if (taskID == 13) //6.RSSI
|
}else if (next_task_id == kScheduleEigenValue) {
|
||||||
{
|
scheduleTask.cmd = REVIVE_DURATION;
|
||||||
scheduleTask.cmd = SIGNAL_STRENGTH;
|
|
||||||
scheduleTask.shortAddr = ushortAdd;
|
scheduleTask.shortAddr = ushortAdd;
|
||||||
scheduleTask.duration = next_duration;
|
scheduleTask.duration = next_duration;
|
||||||
|
scheduleTask.next_taskID = next_task_id;
|
||||||
TaskResp(scheduleTask);
|
TaskResp(scheduleTask);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if (next_task_id == kScheduleEigenValue) //1.特征值
|
||||||
|
// {
|
||||||
|
|
||||||
|
// }
|
||||||
|
// else if (next_task_id == kScheduleWaveForm) //2.波形
|
||||||
|
// {
|
||||||
|
// DealReviveDuration(ushortAdd);
|
||||||
|
// }
|
||||||
|
// else if (next_task_id == kScheduleUpgrade) //3.升级
|
||||||
|
// {
|
||||||
|
// UpdateWirelessNode(ushortAdd);
|
||||||
|
// }else if (taskID == kScheduleConfigSensor) //4.更新配置
|
||||||
|
// {
|
||||||
|
// scheduleTask.cmd = CONFIG;
|
||||||
|
// scheduleTask.shortAddr = ushortAdd;
|
||||||
|
// mssleep(50000);
|
||||||
|
// TaskResp(scheduleTask);
|
||||||
|
// mssleep(50000);
|
||||||
|
// UpdateConfig(ushortAdd);
|
||||||
|
// }else if (taskID == kScheduleWrongTime) //5.异常连接
|
||||||
|
// {
|
||||||
|
// scheduleTask.cmd = REVIVE_DURATION;
|
||||||
|
// scheduleTask.shortAddr = ushortAdd;
|
||||||
|
// scheduleTask.duration = next_duration;
|
||||||
|
// zlog_info(zct, "next_duration = %d ", next_duration);
|
||||||
|
// TaskResp(scheduleTask);
|
||||||
|
// }
|
||||||
zlog_info(zct, " DealAskTask end" );
|
zlog_info(zct, " DealAskTask end" );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -386,21 +401,14 @@ int Uart::DealException(const char* pData){
|
|||||||
}
|
}
|
||||||
|
|
||||||
int Uart::DealReviveDuration(uint16_t ushortAdd){
|
int Uart::DealReviveDuration(uint16_t ushortAdd){
|
||||||
|
|
||||||
char localtimestamp[32] = {0x00};
|
|
||||||
ScheduleTask scheduleTask;
|
ScheduleTask scheduleTask;
|
||||||
int next_taskID = 0;
|
int next_taskID = 0;
|
||||||
uint16_t next_duration = scheduler::instance().GetNextDuration(ushortAdd,next_taskID);
|
uint16_t next_duration = scheduler::instance().GetNextDuration(ushortAdd,next_taskID);
|
||||||
next_taskID = MEAS_EVAL;
|
zlog_info(zct, "next_duration = %d next_taskID = %d", next_duration,next_taskID);
|
||||||
zlog_info(zct, "next_duration = %d ", next_duration);
|
|
||||||
scheduleTask.cmd = REVIVE_DURATION;
|
scheduleTask.cmd = REVIVE_DURATION;
|
||||||
scheduleTask.shortAddr = ushortAdd;
|
scheduleTask.shortAddr = ushortAdd;
|
||||||
scheduleTask.duration = next_duration;
|
scheduleTask.duration = next_duration;
|
||||||
scheduleTask.next_taskID = next_taskID & 0xFF;
|
scheduleTask.next_taskID = next_taskID & 0xFF;
|
||||||
int millisecond = 0;
|
|
||||||
std::string rtcTime = GetRTC(localtimestamp, millisecond);
|
|
||||||
scheduleTask.timeStamp = atoi(localtimestamp);
|
|
||||||
scheduleTask.millisecond = millisecond;
|
|
||||||
TaskResp(scheduleTask);
|
TaskResp(scheduleTask);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -419,6 +427,7 @@ int Uart::DealWaveCompress(const char *pData,uint16_t ushortAdd){
|
|||||||
|
|
||||||
zlog_info(zct, "DealWaveCompress ");
|
zlog_info(zct, "DealWaveCompress ");
|
||||||
now_task = WAVE_CMD;
|
now_task = WAVE_CMD;
|
||||||
|
WaveResp(ushortAdd);
|
||||||
char buf[20] = {0x00};
|
char buf[20] = {0x00};
|
||||||
sprintf(buf, "%02x%02x", (ushortAdd >> 8) & 0xFF, ushortAdd & 0xFF);
|
sprintf(buf, "%02x%02x", (ushortAdd >> 8) & 0xFF, ushortAdd & 0xFF);
|
||||||
std::string strShortAddr = std::string(buf);
|
std::string strShortAddr = std::string(buf);
|
||||||
@ -432,7 +441,7 @@ int Uart::DealWaveCompress(const char *pData,uint16_t ushortAdd){
|
|||||||
tempchannel.CountZ = BUILD_UINT32(pData[21], pData[20],pData[19],pData[18]);
|
tempchannel.CountZ = BUILD_UINT32(pData[21], pData[20],pData[19],pData[18]);
|
||||||
|
|
||||||
g_mapCompress[strShortAddr] = tempchannel;
|
g_mapCompress[strShortAddr] = tempchannel;
|
||||||
|
wave_shortAddr = ushortAdd;
|
||||||
char sensor_rssi[10] = {0x00};
|
char sensor_rssi[10] = {0x00};
|
||||||
sprintf(sensor_rssi, "%02d", pData[22] & 0xFF);
|
sprintf(sensor_rssi, "%02d", pData[22] & 0xFF);
|
||||||
if (!strcmp(sensor_rssi, "00") || !strcmp(sensor_rssi, "0")) {
|
if (!strcmp(sensor_rssi, "00") || !strcmp(sensor_rssi, "0")) {
|
||||||
@ -459,7 +468,7 @@ int Uart::DealWaveCompress(const char *pData,uint16_t ushortAdd){
|
|||||||
memset(updateSql,0,sizeof(updateSql));
|
memset(updateSql,0,sizeof(updateSql));
|
||||||
memset(whereCon,0,sizeof(whereCon));
|
memset(whereCon,0,sizeof(whereCon));
|
||||||
if (vParamRSSI.size() > 0) {
|
if (vParamRSSI.size() > 0) {
|
||||||
sprintf(updateSql, "RSSI = '%s,%02d' ", vParamRSSI[0].c_str(), pData[7] & 0xFF);
|
sprintf(updateSql, "RSSI = '%s,%02d' ", vParamRSSI[0].c_str(), pData[22] & 0xFF);
|
||||||
sprintf(whereCon, "dataNodeNo='%s'", (char *)vecDataNodeNo[0].c_str());
|
sprintf(whereCon, "dataNodeNo='%s'", (char *)vecDataNodeNo[0].c_str());
|
||||||
sqlite_db_ctrl::instance().UpdateTableData(T_SENSOR_INFO(TNAME), updateSql, whereCon);
|
sqlite_db_ctrl::instance().UpdateTableData(T_SENSOR_INFO(TNAME), updateSql, whereCon);
|
||||||
}
|
}
|
||||||
@ -542,7 +551,9 @@ void Uart::DealRecvData(const char *pData) {
|
|||||||
uint16_t ushortAdd = BUILD_UINT16(pData[3] & 0xFF, pData[4] & 0xFF);
|
uint16_t ushortAdd = BUILD_UINT16(pData[3] & 0xFF, pData[4] & 0xFF);
|
||||||
uint8_t command = pData[5] & 0xFF;
|
uint8_t command = pData[5] & 0xFF;
|
||||||
uint8_t recvcode = pData[7] & 0xFF;
|
uint8_t recvcode = pData[7] & 0xFF;
|
||||||
|
int next_duration = 0,next_task_id = 0;
|
||||||
|
int taskID = 0;
|
||||||
|
ScheduleTask scheduleTask;
|
||||||
zlog_info(zct, "shortAdd = %02x%02x,command = %d ",UINT16_HIGH(ushortAdd),UINT16_LOW(ushortAdd),command);
|
zlog_info(zct, "shortAdd = %02x%02x,command = %d ",UINT16_HIGH(ushortAdd),UINT16_LOW(ushortAdd),command);
|
||||||
switch (command) {
|
switch (command) {
|
||||||
case DEVICE_INF:
|
case DEVICE_INF:
|
||||||
@ -558,8 +569,10 @@ void Uart::DealRecvData(const char *pData) {
|
|||||||
DealException(pData);
|
DealException(pData);
|
||||||
break;
|
break;
|
||||||
case MEAS_EVAL:
|
case MEAS_EVAL:
|
||||||
DealReviveDuration(ushortAdd);
|
DealAskTask(ushortAdd);
|
||||||
DealDataNodeFeature(pData, 0);
|
DealDataNodeFeature(pData, 0);
|
||||||
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case UPGRADE:
|
case UPGRADE:
|
||||||
if (recvcode == 0){
|
if (recvcode == 0){
|
||||||
@ -586,10 +599,21 @@ void Uart::DealRecvData(const char *pData) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case WAVE_COMPRESS:
|
case WAVE_COMPRESS:
|
||||||
|
GetLocalZigbeeRSSI(ushortAdd);
|
||||||
DealWaveCompress(pData,ushortAdd);
|
DealWaveCompress(pData,ushortAdd);
|
||||||
break;
|
break;
|
||||||
case SIGNAL_STRENGTH:
|
case UPGRADE_ASK:
|
||||||
DealSensorRSSI(pData,ushortAdd);
|
taskID = scheduler::instance().StartSchedule(ushortAdd,next_duration, next_task_id);
|
||||||
|
if (taskID == kScheduleUpgrade){
|
||||||
|
UpdateWirelessNode(ushortAdd);
|
||||||
|
}else if(taskID == kScheduleResultNone){
|
||||||
|
scheduleTask.cmd = REVIVE_DURATION;
|
||||||
|
scheduleTask.shortAddr = ushortAdd;
|
||||||
|
scheduleTask.duration = next_duration;
|
||||||
|
scheduleTask.next_taskID = next_task_id;
|
||||||
|
TaskResp(scheduleTask);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
@ -697,6 +721,7 @@ void Uart::DealDataNodeInfo(const char *pData) {
|
|||||||
zlog_warn(zct, "recv remote zigbee module info shortAddr %02x%02x", pRecvData->Data[46], pRecvData->Data[47]);
|
zlog_warn(zct, "recv remote zigbee module info shortAddr %02x%02x", pRecvData->Data[46], pRecvData->Data[47]);
|
||||||
char buf[32] = {0};
|
char buf[32] = {0};
|
||||||
char whereCon[64] = {0};
|
char whereCon[64] = {0};
|
||||||
|
uint16_t ushortAdd = BUILD_UINT16(pData[3] & 0xFF, pData[4] & 0xFF);
|
||||||
char chTemp = pRecvData->Data[0]; //设备状态标志 1 byte
|
char chTemp = pRecvData->Data[0]; //设备状态标志 1 byte
|
||||||
DataNodeInfo dataNodeInfo;
|
DataNodeInfo dataNodeInfo;
|
||||||
dataNodeInfo.EquipSta = GET_BIT(chTemp, 2);
|
dataNodeInfo.EquipSta = GET_BIT(chTemp, 2);
|
||||||
@ -843,7 +868,6 @@ void Uart::DealDataNodeInfo(const char *pData) {
|
|||||||
zlog_info(zct, "upgrade = %d", upgrade);
|
zlog_info(zct, "upgrade = %d", upgrade);
|
||||||
if (upgrade == 1)
|
if (upgrade == 1)
|
||||||
{
|
{
|
||||||
uint16_t ushortAdd = BUILD_UINT16(pData[3] & 0xFF, pData[4] & 0xFF);
|
|
||||||
sprintf(whereCon, "dataNodeNo='%s'", dataNodeInfo.ZigbeeLongAddr.c_str());
|
sprintf(whereCon, "dataNodeNo='%s'", dataNodeInfo.ZigbeeLongAddr.c_str());
|
||||||
std::string soft_version = sqlite_db_ctrl::instance().GetData(T_SENSOR_INFO(TNAME), " softVersion ", whereCon);
|
std::string soft_version = sqlite_db_ctrl::instance().GetData(T_SENSOR_INFO(TNAME), " softVersion ", whereCon);
|
||||||
if (dataNodeInfo.SoftVersion != soft_version) {
|
if (dataNodeInfo.SoftVersion != soft_version) {
|
||||||
@ -1204,7 +1228,7 @@ int Uart::FindRecvPackage(int bytesRead, char *mUartRecvBuf, char *head) {
|
|||||||
memcpy(RecvBuf, (char *)&UartRecvBuf[i], 100);
|
memcpy(RecvBuf, (char *)&UartRecvBuf[i], 100);
|
||||||
DealDataNodeWave(RecvBuf, command);
|
DealDataNodeWave(RecvBuf, command);
|
||||||
mPackgeIndex = (unsigned int)UartRecvBuf[i + 6];
|
mPackgeIndex = (unsigned int)UartRecvBuf[i + 6];
|
||||||
} else if (now_task != WAVE_CMD && (command == ASK_TASK || command == DEVICE_INF || command == MEAS_EVAL || command == CONFIG || command == UPGRADE || command == DEVICE_INF2 || command == SIGNAL_STRENGTH || command == DEVICE_EXCEPTION || command == WAVE_COMPRESS)) {
|
} else if (now_task != WAVE_CMD && (command == ASK_TASK || command == DEVICE_INF || command == MEAS_EVAL || command == CONFIG || command == UPGRADE || command == DEVICE_INF2 || command == SIGNAL_STRENGTH || command == DEVICE_EXCEPTION)) {
|
||||||
char RecvBuf[100] = {0x00};
|
char RecvBuf[100] = {0x00};
|
||||||
if (command == ASK_TASK )
|
if (command == ASK_TASK )
|
||||||
{
|
{
|
||||||
@ -1214,7 +1238,7 @@ int Uart::FindRecvPackage(int bytesRead, char *mUartRecvBuf, char *head) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (command == CONFIG || command == CONFIG_INF2 || command == UPGRADE || command == SIGNAL_STRENGTH || command == DEVICE_EXCEPTION || command == WAVE_COMPRESS)
|
if (command == CONFIG || command == CONFIG_INF2 || command == UPGRADE || command == SIGNAL_STRENGTH || command == DEVICE_EXCEPTION)
|
||||||
{
|
{
|
||||||
memcpy(RecvBuf, &UartRecvBuf[i], 9);
|
memcpy(RecvBuf, &UartRecvBuf[i], 9);
|
||||||
if (!CheckCrc(RecvBuf, 8)) {
|
if (!CheckCrc(RecvBuf, 8)) {
|
||||||
@ -1232,9 +1256,9 @@ int Uart::FindRecvPackage(int bytesRead, char *mUartRecvBuf, char *head) {
|
|||||||
}
|
}
|
||||||
DealRecvData(RecvBuf);
|
DealRecvData(RecvBuf);
|
||||||
|
|
||||||
}else if(now_task == WAVE_CMD && command == WAVE_COMPRESS){
|
}else if( command == WAVE_COMPRESS && now_task != WAVE_CMD) {
|
||||||
memcpy(RecvBuf, &UartRecvBuf[i], 23);
|
memcpy(RecvBuf, &UartRecvBuf[i], 24);
|
||||||
if (!CheckCrc(RecvBuf, 22)) {
|
if (!CheckCrc(RecvBuf, 23)) {
|
||||||
zlog_warn(zct, "CheckCrc error ShortAddr :%s command = %d ", strShortAddr.c_str(), command);
|
zlog_warn(zct, "CheckCrc error ShortAddr :%s command = %d ", strShortAddr.c_str(), command);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1376,7 +1400,6 @@ bool Uart::CheckCrc(char *pCheckBuff, int No) {
|
|||||||
for (int i = 0; i < No; i++) {
|
for (int i = 0; i < No; i++) {
|
||||||
tmp += (unsigned char)pCheckBuff[i];
|
tmp += (unsigned char)pCheckBuff[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((unsigned char)pCheckBuff[No] != (unsigned char)tmp) return false;
|
if ((unsigned char)pCheckBuff[No] != (unsigned char)tmp) return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,10 +26,12 @@ enum InteractiveCommand {
|
|||||||
CONFIG_INF2 = 10, // 配置 只从无线网关发出 测点名称,测点编号
|
CONFIG_INF2 = 10, // 配置 只从无线网关发出 测点名称,测点编号
|
||||||
DEVICE_INF2 = 11, // 测点名称,测点编号
|
DEVICE_INF2 = 11, // 测点名称,测点编号
|
||||||
UPGRADE = 12, // 升级, 升级给这条信息
|
UPGRADE = 12, // 升级, 升级给这条信息
|
||||||
SIGNAL_STRENGTH = 13, // 信号强度
|
SIGNAL_STRENGTH = 13, // 信号强度 --不再使用
|
||||||
DEVICE_EXCEPTION = 14, // 异常: 外设
|
DEVICE_EXCEPTION = 14, // 异常: 外设
|
||||||
WAVE_COMPRESS = 15, // 波形数据压缩
|
WAVE_COMPRESS = 15, // 波形数据压缩
|
||||||
UPGRADE_FIRMWARE = 16 //固件升级内容
|
UPGRADE_FIRMWARE = 16, //固件升级内容
|
||||||
|
UPGRADE_ASK = 17, //固件升级请求
|
||||||
|
WAVE_RESP = 18 // 波形数据回复
|
||||||
};
|
};
|
||||||
|
|
||||||
// 无线传感器请求任务
|
// 无线传感器请求任务
|
||||||
@ -218,6 +220,7 @@ public:
|
|||||||
int UpdateConfig(uint16_t ushortAdd);
|
int UpdateConfig(uint16_t ushortAdd);
|
||||||
int TaskResp(ScheduleTask scheduleTask);
|
int TaskResp(ScheduleTask scheduleTask);
|
||||||
int SendReviveDuration(ReviveDuration recvDuration);
|
int SendReviveDuration(ReviveDuration recvDuration);
|
||||||
|
int WaveResp(uint16_t shortAddr);
|
||||||
void openSwitch();
|
void openSwitch();
|
||||||
int CheckZigbeeACK();
|
int CheckZigbeeACK();
|
||||||
|
|
||||||
|
|||||||
@ -143,17 +143,18 @@ void Uart::DealDataNodeFeature(const char *pData, int flag) {
|
|||||||
memcpy(szTableNameStatic, szTableName, sizeof(szTableNameStatic));
|
memcpy(szTableNameStatic, szTableName, sizeof(szTableNameStatic));
|
||||||
memset(whereCon, 0x00, sizeof(whereCon));
|
memset(whereCon, 0x00, sizeof(whereCon));
|
||||||
|
|
||||||
// sprintf(whereCon, "StaticIndex = %ld", staticIndex);
|
//时间戳判断,是否重包
|
||||||
// int count = sqlite_db_ctrl::instance().GetTableRows(szTableNameStatic, whereCon); //避免重复数据
|
sprintf(whereCon, "timeStamp = '%s'", localtimestamp);
|
||||||
// sprintf(szTableNameData, "t_data_%s", strMeasurementID.c_str());
|
int count = sqlite_db_ctrl::instance().GetTableRows(szTableNameStatic, whereCon); //避免重复数据
|
||||||
|
sprintf(szTableNameData, "t_data_%s", strMeasurementID.c_str());
|
||||||
|
|
||||||
// int count2 = sqlite_db_ctrl::instance().GetTableRows(szTableNameData, whereCon);
|
int count2 = sqlite_db_ctrl::instance().GetTableRows(szTableNameData, whereCon);
|
||||||
// if (count > 0 || count2 > 0) {
|
if (count > 0 || count2 > 0) {
|
||||||
// char logInfo[100] = {0x00};
|
char logInfo[100] = {0x00};
|
||||||
// sprintf(logInfo, "ShortAddr = %s,staticIndex = %ld,staticData = %d, data = %d", strShortAddr.c_str(), staticIndex, count, count2);
|
sprintf(logInfo, "ShortAddr = %s,localtimestamp = %s,staticData = %d, data = %d", strShortAddr.c_str(), localtimestamp, count, count2);
|
||||||
// zlog_info(zct, logInfo);
|
zlog_info(zct, logInfo);
|
||||||
// return;
|
return;
|
||||||
// }
|
}
|
||||||
memset(whereCon, 0x00, sizeof(whereCon));
|
memset(whereCon, 0x00, sizeof(whereCon));
|
||||||
sprintf(szTableNameData, "t_data_%s", strMeasurementID.c_str());
|
sprintf(szTableNameData, "t_data_%s", strMeasurementID.c_str());
|
||||||
///////////////////////////////////////////////////////////// for V2.0.3 upgrade to V3.0
|
///////////////////////////////////////////////////////////// for V2.0.3 upgrade to V3.0
|
||||||
@ -1040,9 +1041,7 @@ void Uart::WriteDatFile(int sampleRate, std::string &strMeasurementID, int iChan
|
|||||||
}
|
}
|
||||||
//传感器发来的数据包中的表示设备信息的数据转化为json格式后,通过调用data_publish将数据传给mqttclient : Topic:wireless/cmd/60294D203717
|
//传感器发来的数据包中的表示设备信息的数据转化为json格式后,通过调用data_publish将数据传给mqttclient : Topic:wireless/cmd/60294D203717
|
||||||
|
|
||||||
int iRet = data_publish(WaveData.c_str(
|
int iRet = data_publish(WaveData.c_str(), GlobalConfig::Topic_G.mPubWaveData.c_str());
|
||||||
|
|
||||||
), GlobalConfig::Topic_G.mPubWaveData.c_str());
|
|
||||||
if (iRet != 0) {
|
if (iRet != 0) {
|
||||||
char whereCon[1024] = {0x00};
|
char whereCon[1024] = {0x00};
|
||||||
char updateSql[1024] = {0x00};
|
char updateSql[1024] = {0x00};
|
||||||
|
|||||||
@ -558,20 +558,24 @@ int Uart::TaskResp(ScheduleTask scheduleTask){
|
|||||||
UpdateData[4] = scheduleTask.shortAddr & 0xFF;
|
UpdateData[4] = scheduleTask.shortAddr & 0xFF;
|
||||||
UpdateData[5] = scheduleTask.cmd & 0xFF;
|
UpdateData[5] = scheduleTask.cmd & 0xFF;
|
||||||
UpdateData[6] = 0x00;
|
UpdateData[6] = 0x00;
|
||||||
if (scheduleTask.cmd == MEAS_EVAL)
|
char localtimestamp[32] = {0x00};
|
||||||
{
|
int millisecond = 0;
|
||||||
|
std::string rtcTime = GetRTC(localtimestamp, millisecond);
|
||||||
|
scheduleTask.timeStamp = atoi(localtimestamp);
|
||||||
|
zlog_info(zct,"next taskID = %d\n",scheduleTask.next_taskID);
|
||||||
|
|
||||||
UpdateData[7] = UINT16_LOW(scheduleTask.duration);
|
UpdateData[7] = UINT16_LOW(scheduleTask.duration);
|
||||||
UpdateData[8] = UINT16_HIGH(scheduleTask.duration);
|
UpdateData[8] = UINT16_HIGH(scheduleTask.duration);
|
||||||
UpdateData[9] = UINT32_LOW_2(scheduleTask.timeStamp);
|
UpdateData[9] = UINT32_LOW_2(scheduleTask.timeStamp);
|
||||||
UpdateData[10] = UINT32_LOW_1(scheduleTask.timeStamp);
|
UpdateData[10] = UINT32_LOW_1(scheduleTask.timeStamp);
|
||||||
UpdateData[11] = UINT32_HIGH_2(scheduleTask.timeStamp);
|
UpdateData[11] = UINT32_HIGH_2(scheduleTask.timeStamp);
|
||||||
UpdateData[12] = UINT32_HIGH_1(scheduleTask.timeStamp);
|
UpdateData[12] = UINT32_HIGH_1(scheduleTask.timeStamp);
|
||||||
UpdateData[20] = UINT16_HIGH(scheduleTask.acc_z);
|
UpdateData[20] = scheduleTask.acc_z;
|
||||||
UpdateData[21] = UINT16_HIGH(scheduleTask.next_taskID);
|
UpdateData[21] = scheduleTask.next_taskID & 0xFF;
|
||||||
UpdateData[22] = UINT32_LOW_2(scheduleTask.millisecond);
|
UpdateData[22] = UINT16_LOW(scheduleTask.millisecond);
|
||||||
UpdateData[23] = UINT32_LOW_1(scheduleTask.millisecond);
|
UpdateData[23] = UINT16_HIGH(scheduleTask.millisecond);
|
||||||
|
|
||||||
}else if (scheduleTask.cmd == WAVE_CMD)
|
if (scheduleTask.next_taskID == WAVE_CMD)
|
||||||
{
|
{
|
||||||
uint8_t x,y,z;
|
uint8_t x,y,z;
|
||||||
wave_feature_set_inst::instance().GetWaveCfg(scheduleTask.shortAddr,x,y,z);
|
wave_feature_set_inst::instance().GetWaveCfg(scheduleTask.shortAddr,x,y,z);
|
||||||
@ -622,6 +626,29 @@ int Uart::SendReviveDuration(ReviveDuration recvDuration){
|
|||||||
}
|
}
|
||||||
return iRet;
|
return iRet;
|
||||||
}
|
}
|
||||||
|
int Uart::WaveResp(uint16_t shortAddr){
|
||||||
|
unsigned char sendData[8] = {0};
|
||||||
|
sendData[0] = 0xAA;
|
||||||
|
sendData[1] = 0x55;
|
||||||
|
sendData[2] = 0xAA;
|
||||||
|
sendData[3] = (shortAddr >> 8) & 0xFF;
|
||||||
|
sendData[4] = shortAddr & 0xFF;
|
||||||
|
sendData[5] = 0x12;
|
||||||
|
sendData[6] = 0x00;
|
||||||
|
unsigned char tmp = 0x00;
|
||||||
|
for (int k = 0; k < 7; k++) {
|
||||||
|
tmp += sendData[k];
|
||||||
|
}
|
||||||
|
sendData[7] = tmp;
|
||||||
|
WriteToUart((const char*)sendData, 8);
|
||||||
|
int iRet = CheckZigbeeACK();
|
||||||
|
if (iRet == 0) {
|
||||||
|
zlog_info(zct, "SendReviveDuration ACK send success,shortAddr = %d", shortAddr);
|
||||||
|
} else {
|
||||||
|
zlog_warn(zct, "SendReviveDuration ACK send failed,shortAddr = %d", shortAddr);
|
||||||
|
}
|
||||||
|
return iRet;
|
||||||
|
}
|
||||||
int Uart::CheckZigbeeACK() {
|
int Uart::CheckZigbeeACK() {
|
||||||
if (gpio_read(GlobalConfig::GPIO_G.zigAckrep) == 48) gpio_set(GlobalConfig::GPIO_G.zigAckreset, 1);
|
if (gpio_read(GlobalConfig::GPIO_G.zigAckrep) == 48) gpio_set(GlobalConfig::GPIO_G.zigAckreset, 1);
|
||||||
int time = 0, value = 0, iRet = -1;
|
int time = 0, value = 0, iRet = -1;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user