优化日志,mqtt,电池计算等接口信息3.2.3
This commit is contained in:
parent
a0b04aad09
commit
66b6164d93
@ -20,7 +20,7 @@ enum enumZigBeeTransmitStatus {
|
||||
|
||||
|
||||
//#define NR5G_MODULE
|
||||
#define Q4G_MODULE
|
||||
//#define Q4G_MODULE
|
||||
//#define WIFI_MODULE
|
||||
//#define NR5G_MEIGE
|
||||
//#define G2UL_GATEWAY
|
||||
|
@ -861,7 +861,7 @@ int SqliteDB::CalculateBattery()
|
||||
vec_t vecResSig = sql_ctl->GetDataSingleLine(T_BATTERY_INFO(TNAME)," * ",whereCon);
|
||||
vector<string> 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);
|
||||
|
@ -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["Update"] = atoi(arrRes[j][41].c_str());
|
||||
jsSensorData["RSSI"] = arrRes[j][40];
|
||||
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 {
|
||||
|
@ -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)
|
||||
|
2
main.cpp
2
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");
|
||||
|
||||
// 查看版本信息
|
||||
|
@ -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 = "";
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
@ -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};
|
||||
|
Loading…
x
Reference in New Issue
Block a user