diff --git a/Cidn-SH b/Cidn-SH index fa597a9..22c3598 100644 Binary files a/Cidn-SH and b/Cidn-SH differ diff --git a/common/SH_global.h b/common/SH_global.h index c67b7d6..2c373c8 100644 --- a/common/SH_global.h +++ b/common/SH_global.h @@ -20,7 +20,7 @@ enum enumZigBeeTransmitStatus { //#define NR5G_MODULE -#define Q4G_MODULE +//#define Q4G_MODULE //#define WIFI_MODULE //#define NR5G_MEIGE //#define G2UL_GATEWAY diff --git a/dbaccess/SH_SqlDB.cpp b/dbaccess/SH_SqlDB.cpp index 140d911..390295c 100644 --- a/dbaccess/SH_SqlDB.cpp +++ b/dbaccess/SH_SqlDB.cpp @@ -861,7 +861,7 @@ int SqliteDB::CalculateBattery() vec_t vecResSig = sql_ctl->GetDataSingleLine(T_BATTERY_INFO(TNAME)," * ",whereCon); vector vParam; boost::split( vParam, vecRes[i][6], boost::is_any_of( "," ), boost::token_compress_on ); - if(vecResSig.size() <= 0 || vParam[0] == ""){//第一次计算 + if(vParam.size() <= 0 || vecResSig.size() <= 0){//第一次计算 memset(whereCon,0x00,sizeof(whereCon)); sprintf(whereCon,"dataNodeNo = '%s' ",vecRes[i][0].c_str()); string Dip = sql_ctl->GetData(T_DATASTATIC_INFO(TNAME)," dip ",whereCon); diff --git a/jsonparse/SH_JsonCmd.cpp b/jsonparse/SH_JsonCmd.cpp index e1c5b23..158d2f7 100644 --- a/jsonparse/SH_JsonCmd.cpp +++ b/jsonparse/SH_JsonCmd.cpp @@ -275,9 +275,11 @@ std::string JsonData::JsonCmd_26(Param_26 ¶m) jsSensorData["status"] = atoi(arrRes[j][37].c_str()); jsSensorData["timeStamp"] = arrRes[j][38]; jsSensorData["viff"] = atoi(arrRes[j][39].c_str()); - jsSensorData["RSSI"] = atoi(arrRes[j][40].c_str()); + jsSensorData["RSSI"] = arrRes[j][40]; jsSensorData["Update"] = atoi(arrRes[j][41].c_str()); - jsSensorData["Update"] = atoi(arrRes[j][41].c_str()); + jsSensorData["looseValue"] = arrRes[j][42]; + jsSensorData["battery"] = arrRes[j][43]; + jsSensorData["MeasurementID"] = arrRes[j][44]; jsArray.append(jsSensorData); } } else { diff --git a/localserver/SH_LocalServer.cpp b/localserver/SH_LocalServer.cpp index ba91296..8a1b061 100644 --- a/localserver/SH_LocalServer.cpp +++ b/localserver/SH_LocalServer.cpp @@ -12,6 +12,7 @@ LocalServer::LocalServer() LocalServer::~LocalServer() { print_info("~LocalServer is called!\n"); + LOG_INFO("~LocalServer is called!\n"); } void LocalServer::HandleFromServer(const char *pData_r, int pLen, const char *topic) diff --git a/main.cpp b/main.cpp index 05a71ff..83241af 100644 --- a/main.cpp +++ b/main.cpp @@ -28,7 +28,7 @@ int main(int argc, char *argv[]) { printf(" Firmware compile time:%s %s,version %s\n", __DATE__, __TIME__,GlobalConfig::Version.c_str()); // 初始化日志记录,日志缓存区,记录数,未使用,后期,命令启动 - log_init(SOFTWARE_RUN_LOG, 1380, 160 * 1024); + log_init(SOFTWARE_RUN_LOG, 1380, 160 * 1024 * 2); LOG_INFO("####CIDNSOFT start####\n"); // 查看版本信息 diff --git a/platform/SH_PlatformInit.cpp b/platform/SH_PlatformInit.cpp index a1be577..154fbb8 100644 --- a/platform/SH_PlatformInit.cpp +++ b/platform/SH_PlatformInit.cpp @@ -12,7 +12,7 @@ int GlobalConfig::LinkCount = 0; int GlobalConfig::net0Status = 1; -std::string GlobalConfig::Version = "3.2.2"; +std::string GlobalConfig::Version = "3.2.3"; std::string GlobalConfig::MacAddr_G = ""; std::string GlobalConfig::MacAddr_G2 = ""; std::string GlobalConfig::IpAddr_G = ""; diff --git a/threadfunc/SH_ThreadFunc.cpp b/threadfunc/SH_ThreadFunc.cpp index fa1ecef..202181e 100644 --- a/threadfunc/SH_ThreadFunc.cpp +++ b/threadfunc/SH_ThreadFunc.cpp @@ -317,7 +317,7 @@ void CheckThread() char localtimestamp[32] = { 0 }; GetTimeNet(localtimestamp, 1); char whereCon[1024] = {0}; - sprintf(whereCon," timestamp < '%ld' ",atol(localtimestamp) - 5097600); //删除2个月前的数据 + sprintf(whereCon," timestamp < '%ld' ",atol(localtimestamp) - 2592000); //删除1个月前的数据 sql_ctl->DeleteTableData(" t_battery_history ",whereCon); /*staticData = 0; Json::Value jsHeart; diff --git a/uart/SH_Uart.cpp b/uart/SH_Uart.cpp index 4eeb6e0..1d90c9e 100644 --- a/uart/SH_Uart.cpp +++ b/uart/SH_Uart.cpp @@ -47,9 +47,9 @@ int Uart::UartRecv(int fd, char srcshow,char* buffer) memset(buff, 0, sizeof(buff)); ret = read_data(fd, buff, BUF_LENGTH, 10); if (ret <= 0 ){ - if(!bUpdate && !bUpdateconfig && GlobalConfig::EnterZigBeeWaveTransmittingCnt_G > 15){ + if(!bUpdate && !bUpdateconfig){ timeoutflag ++; - if(timeoutflag > 300){ + if(timeoutflag > 1500){ LOG_DEBUG("===============0x9999 timeout= %d offSize = %d===============\n",timeoutflag,offSize); print_info("0x9999 timeout %d===============Size = %d\n",timeoutflag,offSize); FindRecvPackage(offSize, mUartRecvTmpBuf,head); @@ -69,9 +69,9 @@ int Uart::UartRecv(int fd, char srcshow,char* buffer) LOG_DEBUG("wave end\n"); } usleep(10000); - }else if(bUpdatePre || (bUpdateconfig && GlobalConfig::EnterZigBeeWaveTransmittingCnt_G > 15)){ + }else if(bUpdatePre || (bUpdateconfig)){ timeoutflag ++; - if(timeoutflag > 300){ + if(timeoutflag > 1500){ print_info("bUpdateconfig %d===============\n",timeoutflag); GlobalConfig::EnterZigBeeWaveTransmittingFlag_G = NO_ENTER_TRANSMITTING_STATUS; GlobalConfig::EnterZigBeeWaveTransmittingCnt_G = 0; @@ -84,10 +84,10 @@ int Uart::UartRecv(int fd, char srcshow,char* buffer) bModifyAddr = true; bSendTimeStamp = false; modify_LocalAddr(0x8888); - usleep(100000); + usleep(10000); GlobalConfig::Zigbee_G.MyAddr = 0x8888; } - usleep(100000); + usleep(10000); } } else if(ret > 0){ @@ -489,7 +489,7 @@ int Uart::FindRecvPackage(int bytesRead, char* mUartRecvBuf,char* head) } if(command == 32){ - LOG_INFO("bUpdateconfig command = %d ShortAddr :%s\n",command,strShortAddr.c_str()); + LOG_INFO("bUpdatepackge command = %d ShortAddr :%s\n",command,strShortAddr.c_str()); memcpy(RecvBuf,(char*)&UartRecvBuf[i],12); //for(int j = i; j < i+12;j++){ // print_info("%02X ",UartRecvBuf[j]&0xFF); @@ -504,7 +504,7 @@ int Uart::FindRecvPackage(int bytesRead, char* mUartRecvBuf,char* head) modify_LocalAddr(0x8888); sleep(1); bModifyAddr = true; - bSendTimeStamp = false; + bSendTimeStamp = false; GlobalConfig::EnterZigBeeWaveTransmittingFlag_G = NO_ENTER_TRANSMITTING_STATUS; GlobalConfig::EnterZigBeeWaveTransmittingCnt_G = 0; break; @@ -1268,6 +1268,7 @@ int Uart::UpdateConfig(unsigned char* pDestShortAddr) // WriteTranTimeout2Zigbee(0x0A); // } print_info("UpdateConfig\n"); + LOG_INFO("UpdateConfig\n"); bUpdateconfig = true; unsigned short localAddr = 0x9999; GlobalConfig::EnterZigBeeWaveTransmittingFlag_G = ENTER_TRANSMITTING_STATUS; @@ -2000,6 +2001,16 @@ void Uart::DealDataNodeFeature(const char *pData, int flag) bSendTimeStamp = true; modify_distaddr_info(0x9999,"",pRecvData->ShortAddr);//临时参数配置 usleep(10000); + + LOG_DEBUG("Zigbee Signal !\n"); + int Times = 0; + usleep(20000); + while(Times < 3 ){ + getZigbeeSignal(pRecvData->ShortAddr); + Times ++ ; + usleep(20000); + } + usleep(10000); UpdateWirelessNodeTime((unsigned char*)pRecvData->ShortAddr,0); }else { @@ -3427,20 +3438,7 @@ void Uart::DealDataNodeFeature(const char *pData, int flag) memset(selectCon,0x00,sizeof(selectCon)); sprintf(selectCon, "zigbeeSignal <> '' ORDER BY timeStamp desc LIMIT 0,1"); strTime = sql_ctl->GetData(szTableNameStatic, "timeStamp", selectCon); - if(/*(atol(nowTimetamp.c_str()) - atol(strTime.c_str()) > 3600)*/(1 == flag) && - (unsigned short)GlobalConfig::Zigbee_G.MyAddr == 0x9999)// 24h = 86400s ; 8h = 36000 ; 16h = 72000 - { - LOG_DEBUG("Zigbee Signal !\n"); - int Times = 0; - bZigbeeSinal = true; - usleep(20000); - while(Times < 3 && bZigbeeSinal){ - getZigbeeSignal(pRecvData->ShortAddr); - Times ++ ; - usleep(20000);; - } - bZigbeeSinal = false; - } + LOG_INFO("DealDataNodeFeature end %02x%02x\n",pRecvData->ShortAddr[0], pRecvData->ShortAddr[1]); } @@ -3834,7 +3832,7 @@ void Uart::DealWave() } }else{ - LOG_DEBUG("send data , filename %s\n", strFileName.c_str()); + LOG_DEBUG("send data , filename %s,size = %d\n", strFileName.c_str(),vecData.size()); } #ifdef G2UL_GATEWAY//存储6条波形数据 char whereCon[1024] = {0x00};