fix web bugs
This commit is contained in:
parent
2ece225952
commit
bf26028791
@ -113,7 +113,6 @@ std::string JsonData::JsonCmd_Cgi_26(Param_26 ¶m) {
|
||||
jsSensorData["RSSI"] = arrRes[j][40];
|
||||
rssi = arrRes[j][40];
|
||||
}
|
||||
zlog_info(zct,"1arrRes[j][43] = %s",arrRes[j][43].c_str());
|
||||
batteryPower = arrRes[j][43];
|
||||
std::vector<std::string> vParamBatteryPower;
|
||||
float fBatteryPower = 100.0;
|
||||
@ -123,7 +122,6 @@ std::string JsonData::JsonCmd_Cgi_26(Param_26 ¶m) {
|
||||
fBatteryPower = atof(vParamBatteryPower[1].c_str())/atof(vParamBatteryPower[0].c_str());
|
||||
}
|
||||
}
|
||||
zlog_info(zct,"2arrRes[j][43] = %s",arrRes[j][43].c_str());
|
||||
memset(whereCon,0x00,sizeof(whereCon));
|
||||
sprintf(whereCon,"shortAddr = '%s' ",arrRes[j][30].c_str());
|
||||
vec_t vecResult = sqlite_db_ctrl::instance().GetDataSingleLine("t_shutdown_info","*",whereCon);
|
||||
|
||||
@ -705,6 +705,9 @@ std::string JsonData::JsonCmd_Cgi_60(Param_60 ¶m){
|
||||
jsonVal[JSON_FIELD_CMD] = "60";
|
||||
jsonVal["success"] = true;
|
||||
jsonVal["message"] = "";
|
||||
char wherecon[100] = {0};
|
||||
char insertSql[200] = {0};
|
||||
char updateSql[100] = {0};
|
||||
if(param.mMode == 0){
|
||||
char file_path[64]={0};
|
||||
char cmd[128]={0};
|
||||
@ -790,9 +793,7 @@ std::string JsonData::JsonCmd_Cgi_60(Param_60 ¶m){
|
||||
char localtimestamp[32] = {0};
|
||||
GetTimeNet(localtimestamp, 1);
|
||||
std::vector<UpgradeParameter> param_list;
|
||||
char wherecon[100] = {0};
|
||||
char insertSql[200] = {0};
|
||||
char updateSql[100] = {0};
|
||||
|
||||
for (size_t i = 0; i < param.dataNodeNo.size(); i++)
|
||||
{
|
||||
UpgradeParameter upgrade_parameter;
|
||||
@ -810,7 +811,7 @@ std::string JsonData::JsonCmd_Cgi_60(Param_60 ¶m){
|
||||
}
|
||||
sprintf(insertSql, " '%s','%s','','','','','%d.%d','%s',1,'%s'",vecResult[3].c_str(),localtimestamp,sf_ver_m,sf_ver_s,vecResult[1].c_str(),param.fileName.c_str());
|
||||
sqlite_db_ctrl::instance().InsertData(" firmware_upgrade ", insertSql);
|
||||
//0 默认状态,1 升级中,2 升级成功,3 升级失败
|
||||
//0 默认状态,1 升级中,2 升级成功,3 升级失败 4,停止升级
|
||||
memset(wherecon,0,sizeof(wherecon));
|
||||
memset(updateSql,0,sizeof(updateSql));
|
||||
sprintf(wherecon," zigbeeShortAddr = '%s'",vecResult[3].c_str());
|
||||
@ -836,10 +837,28 @@ std::string JsonData::JsonCmd_Cgi_60(Param_60 ¶m){
|
||||
}
|
||||
free(buffer);
|
||||
}else if(param.mMode == 1){
|
||||
std::vector<uint16_t> short_addr_list;
|
||||
for (size_t i = 0; i < param.dataNodeNo.size(); i++)
|
||||
{
|
||||
|
||||
UpgradeParameter upgrade_parameter;
|
||||
memset(wherecon,0,sizeof(wherecon));
|
||||
memset(insertSql,0,sizeof(insertSql));
|
||||
sprintf(wherecon," dataNodeNo = '%s' ",param.dataNodeNo[i].c_str());
|
||||
vec_t vecResult = sqlite_db_ctrl::instance().GetDataSingleLine(T_SENSOR_INFO(TNAME), " hardVersion,softVersion,ProductNo,zigbeeShortAddr ", wherecon);
|
||||
|
||||
uint16_t short_addr;
|
||||
char *end_ptr = NULL;
|
||||
short_addr = strtol(vecResult[3].c_str(), &end_ptr, 16);
|
||||
short_addr_list.push_back(short_addr);
|
||||
memset(wherecon,0,sizeof(wherecon));
|
||||
memset(updateSql,0,sizeof(updateSql));
|
||||
sprintf(wherecon," zigbeeShortAddr = '%s'",vecResult[3].c_str());
|
||||
sprintf(updateSql, " upgradeStatus = %d ", 4);
|
||||
sqlite_db_ctrl::instance().UpdateTableData(T_SENSOR_INFO(TNAME), updateSql,wherecon);
|
||||
|
||||
}
|
||||
scheduler::instance().CancelUpgradeSensor(short_addr_list);
|
||||
}
|
||||
|
||||
return show_value_.write(jsonVal);
|
||||
|
||||
@ -98,12 +98,45 @@ void PlatformInit::Init() {
|
||||
zlog_error(zbt, "PlatFormInit exception happend.");
|
||||
std::string errorinfo = "系统初始化异常";
|
||||
}
|
||||
char whereCon[128] = {0};
|
||||
char insertSql[128] = {0};
|
||||
int rows = 0;
|
||||
std::string MeasurementID = "0";
|
||||
std::string ShortAdd = "0";
|
||||
array_t arrResult = sqlite_db_ctrl::instance().GetDataMultiLineTransaction(T_SENSOR_INFO(TNAME), " MeasurementID,zigbeeShortAddr ", NULL);
|
||||
for (size_t i = 0; i < arrResult.size(); i++) {
|
||||
compressWaveChannel tempchannel;
|
||||
WaveChannel tempwavechannel;
|
||||
g_mapCompress.insert(std::make_pair(arrResult[i][1], tempchannel));
|
||||
g_mapWaveChannel.insert(std::make_pair(arrResult[i][0], tempwavechannel));
|
||||
if (arrResult.size() > 1)
|
||||
{
|
||||
for (size_t i = 0; i < arrResult.size(); i++) {
|
||||
compressWaveChannel tempchannel;
|
||||
WaveChannel tempwavechannel;
|
||||
g_mapCompress.insert(std::make_pair(arrResult[i][1], tempchannel));
|
||||
g_mapWaveChannel.insert(std::make_pair(arrResult[i][0], tempwavechannel));
|
||||
MeasurementID = arrResult[i][0];
|
||||
ShortAdd = arrResult[i][1];
|
||||
sprintf(whereCon, "MeasurementID = '%s' ", arrResult[i][0].c_str());
|
||||
rows = sqlite_db_ctrl::instance().GetTableRows("t_shutdown_info",whereCon);
|
||||
zlog_info(zbt, "MeasurementID = %s,ShortAdd = %s,rows = %d", MeasurementID.c_str(), ShortAdd.c_str(), rows);
|
||||
if(rows < 1){
|
||||
memset(insertSql,0,sizeof(insertSql));
|
||||
sprintf(insertSql, " '%s','%s','0','0','0','0'",
|
||||
MeasurementID.c_str(), ShortAdd.c_str());
|
||||
sqlite_db_ctrl::instance().InsertData("t_shutdown_info", insertSql);
|
||||
}
|
||||
rows = sqlite_db_ctrl::instance().GetTableRows("t_debug_info",whereCon);
|
||||
if(rows < 1){
|
||||
memset(insertSql,0,sizeof(insertSql));
|
||||
sprintf(insertSql, " '%s','%s','','','','','','0',''",
|
||||
MeasurementID.c_str(), ShortAdd.c_str());
|
||||
sqlite_db_ctrl::instance().InsertData("t_debug_info", insertSql);
|
||||
}
|
||||
rows = sqlite_db_ctrl::instance().GetTableRows("t_wave_triger_info",whereCon);
|
||||
if(rows < 1){
|
||||
memset(insertSql,0,sizeof(insertSql));
|
||||
sprintf(insertSql, " '%s','%s','0','0','0','0','0'",
|
||||
MeasurementID.c_str(), ShortAdd.c_str());
|
||||
sqlite_db_ctrl::instance().InsertData("t_wave_triger_info", insertSql);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -92,10 +92,10 @@ int SensorScheduler::StartSchedule(uint16_t short_addr, int &next_duration, bool
|
||||
long nxt_ts = current_wave_start_ts_ + nth_eigen_value_slice_ * eigen_value_send_interval_ + 60 + (i-nth_wave_slice)*60;
|
||||
next_duration = nxt_ts - current_ts_;
|
||||
if (next_duration < 10) {
|
||||
zlog_debug(zbt, "[%d:%x] [Nxt] debug exception duration:%d, adjust to 25", id, short_addr);
|
||||
zlog_debug(zbt, "[%d:%x] [Nxt] debug exception duration:%d, adjust to 25", id, short_addr,next_duration);
|
||||
next_duration = 25;
|
||||
} else if (next_duration > eigen_value_send_interval_) {
|
||||
zlog_debug(zbt, "[%d:%x] [Nxt] debug exception duration:%d, adjust to 120", id, short_addr);
|
||||
zlog_debug(zbt, "[%d:%x] [Nxt] debug exception duration:%d, adjust to 120", id, short_addr,next_duration);
|
||||
next_duration = 120;
|
||||
}
|
||||
z = true;
|
||||
@ -460,11 +460,11 @@ int SensorScheduler::GetNextDuration(uint16_t short_addr, bool &z, int &next_tas
|
||||
long next_ts = CalcNextTimestamp(id, short_addr, z, next_task_id);
|
||||
int duration = next_ts - current_ts;
|
||||
if (duration < 10) {
|
||||
zlog_debug(zbt, "[%d:%x] [Nxt] exception duration:%d, adjust to 25", id, short_addr);
|
||||
zlog_debug(zbt, "[%d:%x] [Nxt] exception duration:%d, adjust to 25", id, short_addr,duration);
|
||||
duration = 25;
|
||||
return duration;
|
||||
} else if (duration > eigen_value_send_interval_) {
|
||||
zlog_debug(zbt, "[%d:%x] [Nxt] exception duration:%d, adjust to 120", id, short_addr);
|
||||
zlog_debug(zbt, "[%d:%x] [Nxt] exception duration:%d, adjust to 120", id, short_addr,duration);
|
||||
duration = 120;
|
||||
return duration;
|
||||
}
|
||||
@ -499,11 +499,11 @@ int SensorScheduler::GetDebugUpgradeNextDuration(uint16_t short_addr) {
|
||||
|
||||
int duration = available_ts - current_ts;
|
||||
if (duration < 10) {
|
||||
zlog_debug(zbt, "[%d:%x] [Nxt] exception duration:%d, adjust to 25", id, short_addr);
|
||||
zlog_debug(zbt, "[%d:%x] [Nxt] exception duration:%d, adjust to 25", id, short_addr,duration);
|
||||
duration = 25;
|
||||
return duration;
|
||||
} else if (duration > eigen_value_send_interval_) {
|
||||
zlog_debug(zbt, "[%d:%x] [Nxt] exception duration:%d, adjust to 120", id, short_addr);
|
||||
zlog_debug(zbt, "[%d:%x] [Nxt] exception duration:%d, adjust to 120", id, short_addr,duration);
|
||||
duration = 120;
|
||||
return duration;
|
||||
}
|
||||
@ -1375,7 +1375,7 @@ void SensorScheduler::GenerateUpgradeSchedule() {
|
||||
long nth_eigen_value_slice = seconds_in_current_wave_slice / eigen_value_send_interval_;
|
||||
long seconds_in_current_eigen_slice = seconds_in_current_wave_slice % eigen_value_send_interval_;
|
||||
int previous_wave_slice = wave_slice_num_per_eigen_interval_ * (nth_eigen_value_slice + 1);
|
||||
zlog_debug(zbt, "seconds_in_current_wave_slice:%d, nth_eigen_value_slice:%d, seconds_in_current_eigen_slice:%d, previous_wave_slice: %d",
|
||||
zlog_debug(zbt, "seconds_in_current_wave_slice:%ld, nth_eigen_value_slice:%ld, seconds_in_current_eigen_slice:%ld, previous_wave_slice: %d",
|
||||
seconds_in_current_wave_slice, nth_eigen_value_slice, seconds_in_current_eigen_slice, previous_wave_slice);
|
||||
// if (previous_wave_slice < 0) {
|
||||
// zlog_error(zbt, "previous_wave_slice: %d", previous_wave_slice);
|
||||
|
||||
@ -527,7 +527,7 @@ int Uart::DealWaveCompress(const char *pData,uint16_t ushortAdd){
|
||||
tempchannel.CountZ = BUILD_UINT32(pData[21], pData[20],pData[19],pData[18]);
|
||||
sprintf(sensor_rssi, "%02d", pData[22] & 0xFF);
|
||||
}else{
|
||||
int ret = 0;//WaveSendCondition(shortAdd);
|
||||
int ret = WaveSendCondition(shortAdd);
|
||||
if(ret == 1){
|
||||
zlog_warn(zct, "WaveSendCondition not meet condition ,shortAddr = %s",shortAdd);
|
||||
scheduler::instance().WaveSuccess(ushortAdd,true);
|
||||
@ -580,15 +580,6 @@ int Uart::DealWaveCompress(const char *pData,uint16_t ushortAdd){
|
||||
sprintf(whereCon, "dataNodeNo='%s' and timeStamp = '%s'", (char*)vecDataNodeNo[0].c_str(),timestamp_last.c_str());
|
||||
sqlite_db_ctrl::instance().UpdateTableData(tableName, updateSql, whereCon);
|
||||
|
||||
std::vector<std::string> vParamRSSI;
|
||||
boost::split(vParamRSSI, vecDataNodeNo[1], boost::is_any_of(","), boost::token_compress_on);
|
||||
memset(updateSql,0,sizeof(updateSql));
|
||||
memset(whereCon,0,sizeof(whereCon));
|
||||
if (vParamRSSI.size() > 0) {
|
||||
sprintf(updateSql, "RSSI = '%s,%02d' ", vParamRSSI[0].c_str(), pData[22] & 0xFF);
|
||||
sprintf(whereCon, "dataNodeNo='%s'", (char *)vecDataNodeNo[0].c_str());
|
||||
sqlite_db_ctrl::instance().UpdateTableData(T_SENSOR_INFO(TNAME), updateSql, whereCon);
|
||||
}
|
||||
}
|
||||
zlog_info(zct, "count X = %d,Y = %d,Z = %d,vol X = %d,vol Y = %d,vol Z = %d ", tempchannel.CountX, tempchannel.CountY, tempchannel.CountZ,tempchannel.CountVolX,tempchannel.CountVolY,tempchannel.CountVolZ);
|
||||
zlog_info(zct, "compress X = %d,Y = %d,Z = %d ", tempchannel.compressChannelX, tempchannel.compressChannelY, tempchannel.compressChannelZ);
|
||||
@ -669,7 +660,14 @@ int Uart::DealFeatureValue(const char *pData,uint16_t ushortAdd){
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
DealAskTask(ushortAdd);
|
||||
// char logInfo[100] = {0x00};
|
||||
// std::vector<uint8_t>& data_vec = map_send_data[ushortAdd];
|
||||
// const uint8_t* send_data = data_vec.data();
|
||||
// WriteToUart((const char*)send_data, 100);
|
||||
// mssleep(50000);
|
||||
// WriteToUart((const char*)send_data, 100);
|
||||
// mssleep(50000);
|
||||
// WriteToUart((const char*)send_data, 100);
|
||||
}else {
|
||||
DealAskTask(ushortAdd);
|
||||
DealDataNodeFeature(pData, 0);
|
||||
|
||||
@ -277,23 +277,23 @@ int Uart::DealDataNodeFeature(const char *pData, int flag) {
|
||||
memset(whereCon, 0x00, sizeof(whereCon));
|
||||
|
||||
//时间戳判断,是否重包
|
||||
sprintf(whereCon, "timeStamp = '%s'", localtimestamp);
|
||||
int count = sqlite_db_ctrl::instance().GetTableRows(szTableNameStatic, whereCon); //避免重复数据
|
||||
sprintf(szTableNameData, "t_data_%s", strMeasurementID.c_str());
|
||||
// sprintf(whereCon, "timeStamp = '%s'", localtimestamp);
|
||||
// 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);
|
||||
if (count > 0 || count2 > 0) {
|
||||
char logInfo[100] = {0x00};
|
||||
sprintf(logInfo, "ShortAddr = %s,localtimestamp = %s,staticData = %d, data = %d", strShortAddr.c_str(), localtimestamp, count, count2);
|
||||
zlog_info(zct, logInfo);
|
||||
std::vector<uint8_t>& data_vec = map_send_data[u_short_addr];
|
||||
const uint8_t* send_data = data_vec.data();
|
||||
WriteToUart((const char*)send_data, 100);
|
||||
mssleep(50000);
|
||||
WriteToUart((const char*)send_data, 100);
|
||||
mssleep(50000);
|
||||
WriteToUart((const char*)send_data, 100);
|
||||
}
|
||||
// int count2 = sqlite_db_ctrl::instance().GetTableRows(szTableNameData, whereCon);
|
||||
// if (count > 0 || count2 > 0) {
|
||||
// char logInfo[100] = {0x00};
|
||||
// sprintf(logInfo, "ShortAddr = %s,localtimestamp = %s,staticData = %d, data = %d", strShortAddr.c_str(), localtimestamp, count, count2);
|
||||
// zlog_info(zct, logInfo);
|
||||
// std::vector<uint8_t>& data_vec = map_send_data[u_short_addr];
|
||||
// const uint8_t* send_data = data_vec.data();
|
||||
// WriteToUart((const char*)send_data, 100);
|
||||
// mssleep(50000);
|
||||
// WriteToUart((const char*)send_data, 100);
|
||||
// mssleep(50000);
|
||||
// WriteToUart((const char*)send_data, 100);
|
||||
// }
|
||||
memset(whereCon, 0x00, sizeof(whereCon));
|
||||
sprintf(szTableNameData, "t_data_%s", strMeasurementID.c_str());
|
||||
///////////////////////////////////////////////////////////// for V2.0.3 upgrade to V3.0
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user