Compare commits
4 Commits
3143f166d5
...
a31550c604
| Author | SHA1 | Date | |
|---|---|---|---|
| a31550c604 | |||
| 04c8983442 | |||
| 44d96b6db3 | |||
| 2354a60390 |
@ -1481,7 +1481,7 @@ std::string JsonData::JsonCmd_Cgi_67(Param_67 ¶m){
|
||||
char whereCon[512] = {0};
|
||||
char updateSql[256] = {0};
|
||||
sprintf(whereCon, " MeasurementID = '%s' ", param.measurementID[i].c_str());
|
||||
sprintf(updateSql, " status = '%d' ", 1);// 0 未调试,1 调试中,2 调试完成
|
||||
sprintf(updateSql, " status = '%d' ", 1);// 0 未调试,1 调试中,2 调试完成,3停止调试
|
||||
sqlite_db_ctrl::instance().UpdateTableData("t_debug_info", updateSql, whereCon);
|
||||
uint16_t short_addr;
|
||||
char *end_ptr = NULL;
|
||||
@ -1495,7 +1495,7 @@ std::string JsonData::JsonCmd_Cgi_67(Param_67 ¶m){
|
||||
char whereCon[512] = {0};
|
||||
char updateSql[256] = {0};
|
||||
sprintf(whereCon, " status = '1' ");
|
||||
sprintf(updateSql, " status = '%d' ", 0);// 0 未调试,1 调试中,2 调试完成
|
||||
sprintf(updateSql, " status = '%d' ", 3);// 0 未调试,1 调试中,2 调试完成,3停止调试
|
||||
sqlite_db_ctrl::instance().UpdateTableData("t_debug_info", updateSql, whereCon);
|
||||
scheduler::instance().CloseDebugMode();
|
||||
}
|
||||
@ -1581,7 +1581,7 @@ std::string JsonData::JsonCmd_Cgi_69(Param_69 ¶m){
|
||||
memset(updateSql,0,sizeof(updateSql));
|
||||
sprintf(whereCon, " MeasurementID = '%s' ", param.vecParam69[i].measurementID.c_str());
|
||||
sprintf(updateSql, " status = '%d',trigerType = '%d',statisticType = '%d', threshold = '%f'",param.vecParam69[i].status,param.vecParam69[i].trigerType,param.vecParam69[i].statisticType,param.vecParam69[i].threshold);
|
||||
sqlite_db_ctrl::instance().UpdateTableData(" t_waveTriger_info ", updateSql, whereCon);
|
||||
sqlite_db_ctrl::instance().UpdateTableData(" t_wave_triger_info ", updateSql, whereCon);
|
||||
}
|
||||
}
|
||||
} else if (param.mMode == 0) {
|
||||
|
||||
@ -516,7 +516,7 @@ int Uart::DealWaveCompress(const char *pData,uint16_t ushortAdd){
|
||||
std::string productNo = res[17];
|
||||
compressWaveChannel tempchannel;
|
||||
if ((compareVersions(softVersion, "2.6") == -1 && productNo == "02") || productNo == "01"){ // DN101所有版本和DN102 2.6以前版本
|
||||
ScheduleStatus schedule_status = scheduler::instance().GetScheduleStatus();
|
||||
schedule_status = scheduler::instance().GetScheduleStatus();
|
||||
if(schedule_status == kScheduleStatusDebug || schedule_status == kScheduleStatusUpgrade){
|
||||
zlog_warn(zct, "ScheduleStatus not meet condition ,shortAddr = %s,schedule_status = %d",shortAdd,schedule_status);
|
||||
scheduler::instance().WaveSuccess(ushortAdd,true);
|
||||
@ -531,14 +531,15 @@ int Uart::DealWaveCompress(const char *pData,uint16_t ushortAdd){
|
||||
tempchannel.CountY = BUILD_UINT32(pData[17], pData[16],pData[15],pData[14]);
|
||||
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);
|
||||
}else
|
||||
{
|
||||
int ret = WaveSendCondition(shortAdd);
|
||||
if(ret == 1){
|
||||
zlog_warn(zct, "WaveSendCondition not meet condition ,shortAddr = %s",shortAdd);
|
||||
scheduler::instance().WaveSuccess(ushortAdd,true);
|
||||
return 1;
|
||||
}else{
|
||||
ScheduleStatus schedule_status = scheduler::instance().GetScheduleStatus();
|
||||
schedule_status = scheduler::instance().GetScheduleStatus();
|
||||
if(schedule_status == kScheduleStatusUpgrade){
|
||||
zlog_warn(zct, "ScheduleStatus not meet condition ,shortAddr = %s,schedule_status = %d",shortAdd,schedule_status);
|
||||
scheduler::instance().WaveSuccess(ushortAdd,true);
|
||||
@ -590,6 +591,15 @@ int Uart::DealWaveCompress(const char *pData,uint16_t ushortAdd){
|
||||
memset(whereCon,0,sizeof(whereCon));
|
||||
sprintf(whereCon, "dataNodeNo='%s' and timeStamp = '%s'", (char*)vecDataNodeNo[0].c_str(),timestamp_last.c_str());
|
||||
sqlite_db_ctrl::instance().UpdateTableData(tableName, updateSql, whereCon);
|
||||
if(schedule_status == kScheduleStatusDebug){
|
||||
memset(whereCon,0,sizeof(whereCon));
|
||||
memset(updateSql,0,sizeof(updateSql));
|
||||
memset(tableName,0,sizeof(tableName));
|
||||
sprintf(tableName, "t_debug_info");
|
||||
sprintf(updateSql, " datanodeRSSI = '%s' ", sensor_rssi);
|
||||
sprintf(whereCon, "shortAddr = '%02x%02x' ",UINT16_HIGH(ushortAdd),UINT16_LOW(ushortAdd));
|
||||
sqlite_db_ctrl::instance().UpdateTableData(tableName, updateSql, whereCon);
|
||||
}
|
||||
|
||||
}
|
||||
zlog_warn(zct, "count X = %d,Y = %d,Z = %d,vol X = %d,vol Y = %d,vol Z = %d short_add = %s", tempchannel.CountX, tempchannel.CountY, tempchannel.CountZ,tempchannel.CountVolX,tempchannel.CountVolY,tempchannel.CountVolZ,strShortAddr.c_str());
|
||||
@ -599,43 +609,7 @@ int Uart::DealWaveCompress(const char *pData,uint16_t ushortAdd){
|
||||
zlog_info(zct, "samplerate vol X = %d,vol Y = %d,vol Z = %d ", tempchannel.samplerateVolX, tempchannel.samplerateVolY, tempchannel.samplerateVolZ);
|
||||
return 0;
|
||||
}
|
||||
int Uart::DealSensorRSSI(const char *pData,uint16_t ushortAdd){
|
||||
|
||||
//传感器获取网关信号强度
|
||||
zlog_info(zct, "DealSensorRSSI ushortAdd = %02x%02x",UINT16_HIGH(ushortAdd),UINT16_LOW(ushortAdd));
|
||||
mssleep(200000);
|
||||
ScheduleTask scheduleTask;
|
||||
now_task = WAVE_CMD;
|
||||
scheduleTask.cmd = WAVE_CMD;
|
||||
scheduleTask.shortAddr = ushortAdd;
|
||||
|
||||
TaskResp(scheduleTask);
|
||||
|
||||
char localtimestamp[32] = {0};
|
||||
GetTimeNet(localtimestamp, 1);
|
||||
char sensor_rssi[10] = {0x00};
|
||||
sprintf(sensor_rssi, "%02d", pData[7] & 0xFF);
|
||||
if (!strcmp(sensor_rssi, "00") || !strcmp(sensor_rssi, "0")) {
|
||||
char errorInfo[100] = {0x00};
|
||||
sprintf(errorInfo, "No RSSI %s", sensor_rssi);
|
||||
zlog_error(zct, errorInfo);
|
||||
} else {
|
||||
char tableName[100] = {0x00};
|
||||
char whereCon[100] = {0};
|
||||
char updateSql[100] = {0};
|
||||
sprintf(whereCon, "zigbeeShortAddr='%02x%02x'", UINT16_HIGH(ushortAdd),UINT16_LOW(ushortAdd));
|
||||
vec_t vecDataNodeNo = sqlite_db_ctrl::instance().GetDataSingleLine(T_SENSOR_INFO(TNAME), " MeasurementID,RSSI ", whereCon);
|
||||
sprintf(tableName, "t_dataStatic_%s", (char *)vecDataNodeNo[0].c_str());
|
||||
memset(whereCon,0,sizeof(whereCon));
|
||||
sprintf(whereCon, "dataNodeNo='%s' order by timeStamp desc limit 1", vecDataNodeNo[0].c_str());
|
||||
std::string timestamp_last = sqlite_db_ctrl::instance().GetData(tableName, " timeStamp ", whereCon);
|
||||
sprintf(updateSql, "zigbeeSignalNode = '%02d' ",atoi(sensor_rssi));
|
||||
memset(whereCon,0,sizeof(whereCon));
|
||||
sprintf(whereCon, "dataNodeNo='%s' and timeStamp = '%s'", (char*)vecDataNodeNo[0].c_str(),timestamp_last.c_str());
|
||||
sqlite_db_ctrl::instance().UpdateTableData(tableName, updateSql, whereCon);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
int Uart::DealUpgrade(uint16_t ushortAdd,int status){
|
||||
|
||||
char updateSql[100] = {0};
|
||||
@ -1584,6 +1558,15 @@ int Uart::FindRecvPackage(int bytesRead, char *mUartRecvBuf, char *head) {
|
||||
sprintf(whereCon, "dataNodeNo='%s' and timeStamp = '%s'", (char*)vecDataNodeNo[0].c_str(),timestamp_last.c_str());
|
||||
|
||||
sqlite_db_ctrl::instance().UpdateTableData(tableName, updateSql, whereCon);
|
||||
if(schedule_status == kScheduleStatusDebug){
|
||||
memset(whereCon,0,sizeof(whereCon));
|
||||
memset(updateSql,0,sizeof(updateSql));
|
||||
memset(tableName,0,sizeof(tableName));
|
||||
sprintf(tableName, "t_debug_info");
|
||||
sprintf(updateSql, " gatewayRSSI = '%02d' ", UartRecvBuf[i+6]&0xFF);
|
||||
sprintf(whereCon, "MeasurementID = '%s' ",(char*)vecDataNodeNo[0].c_str());
|
||||
sqlite_db_ctrl::instance().UpdateTableData(tableName, updateSql, whereCon);
|
||||
}
|
||||
|
||||
// zigbeeRSSIType = 1 网关获取传感器信号强度
|
||||
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
#include "common/global.hpp"
|
||||
#include "dbaccess/sql_db.hpp"
|
||||
#include "utility/calculation.hpp"
|
||||
#include "scheduler/status_mgr.hpp"
|
||||
|
||||
typedef void (*pTestRecvCallBack)(int Status);
|
||||
|
||||
@ -187,7 +188,6 @@ public:
|
||||
int DealReviveDuration(uint16_t ushortAdd);
|
||||
int DealConfig(uint16_t ushortAdd);
|
||||
int DealWaveCompress(const char *pData,uint16_t ushortAdd);
|
||||
int DealSensorRSSI(const char *pData,uint16_t ushortAdd);
|
||||
int DealUpgrade(uint16_t ushortAdd,int status);
|
||||
void GetLocalZigbeeRSSI(uint16_t ushortAdd);
|
||||
int WaveSendCondition(char* shortAddr);
|
||||
@ -285,6 +285,8 @@ private:
|
||||
long last_time;
|
||||
bool current_z;
|
||||
std::map<uint16_t, std::vector<uint8_t>> map_send_data;
|
||||
|
||||
ScheduleStatus schedule_status;
|
||||
};
|
||||
|
||||
typedef boost::container::dtl::singleton_default<Uart> uart_inst;
|
||||
|
||||
@ -63,7 +63,7 @@ void Uart::RecordBattery(std::string &strLongAddr, DataRecvStatic &dataStatic, s
|
||||
if (res_static.size() > 0){
|
||||
int zigbeeSignal = atoi(res_static[6].c_str());
|
||||
int zigbeeSignalNode = atoi(res_static[11].c_str());
|
||||
float standardRate = 5000.0f; //5kB/s
|
||||
float standardRate = 5.0f; //5kB/s
|
||||
float actualRate = 0.0f;
|
||||
if (dataStatic.nodeSendTime > 0){
|
||||
actualRate = (wave_dataLen / 1024.0f) / (dataStatic.nodeSendTime / 1000.0f); //单位:KB/s
|
||||
@ -73,7 +73,8 @@ void Uart::RecordBattery(std::string &strLongAddr, DataRecvStatic &dataStatic, s
|
||||
comprehensiveRSSI = 1.0f; //综合信号强度最大为1
|
||||
}
|
||||
|
||||
zlog_info(zct, "dataNodeNo='%s',wave_dataLen=%d,nodeSendTime=%f,actualRate=%f", strLongAddr.c_str(), wave_dataLen, dataStatic.nodeSendTime, actualRate);
|
||||
zlog_info(zct, "dataNodeNo='%s',zigbeeSignal = '%d',zigbeeSignalNode = '%d',wave_dataLen=%d,nodeSendTime=%f,actualRate=%f",
|
||||
strLongAddr.c_str(),zigbeeSignal, zigbeeSignalNode,wave_dataLen, dataStatic.nodeSendTime, actualRate);
|
||||
//更新综合信号强度到数据库
|
||||
char updateSql[256] = {0};
|
||||
memset(whereCon, 0x00, sizeof(whereCon));
|
||||
@ -86,6 +87,17 @@ void Uart::RecordBattery(std::string &strLongAddr, DataRecvStatic &dataStatic, s
|
||||
sprintf(updateSql,"RSSI = '%f'", comprehensiveRSSI);
|
||||
sqlite_db_ctrl::instance().UpdateTableData(T_SENSOR_INFO(TNAME), updateSql, whereCon);
|
||||
zlog_info(zct, "dataNodeNo='%s',zigbeeSignal=%d,zigbeeSignalNode=%d,actualRate=%f,comprehensiveRSSI=%f", strLongAddr.c_str(), zigbeeSignal, zigbeeSignalNode, actualRate, comprehensiveRSSI);
|
||||
if (schedule_status == kScheduleStatusDebug)
|
||||
{
|
||||
char localtimestamp[32] = { 0 };
|
||||
GetTimeNet(localtimestamp, 1);
|
||||
memset(updateSql,0,sizeof(updateSql));
|
||||
memset(tableName,0,sizeof(tableName));
|
||||
sprintf(tableName, "t_debug_info");
|
||||
sprintf(updateSql, " comprehensiveRSSI = '%f',minnumVoltage = '%d',status = '2',timeStamp = '%s' ", comprehensiveRSSI,dataStatic.instantaneousBatteryVoltage,localtimestamp);
|
||||
sqlite_db_ctrl::instance().UpdateTableData(tableName, updateSql, whereCon);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
void Uart::DealTriger(uint16_t ushortAdd,std::string & measurementID){
|
||||
@ -271,6 +283,9 @@ int Uart::DealDataNodeFeature(const char *pData, int flag) {
|
||||
iTemp = (int)strtol(buf, NULL, 16);
|
||||
dataStatic.instantaneousBatteryVoltage = iTemp;
|
||||
|
||||
if(schedule_status == kScheduleStatusDebug){
|
||||
|
||||
}
|
||||
char szTableName[50] = {0x00}, szTableNameStatic[50] = {0x00}, szTableNameData[50] = {0x00};
|
||||
sprintf(szTableName, "t_dataStatic_%s", strMeasurementID.c_str());
|
||||
memcpy(szTableNameStatic, szTableName, sizeof(szTableNameStatic));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user