diff --git a/.cproject b/.cproject index 6205b59..56e898f 100644 --- a/.cproject +++ b/.cproject @@ -32,6 +32,8 @@ + + @@ -95,7 +97,7 @@ - + @@ -113,6 +115,8 @@ + + diff --git a/.settings/language.settings.xml b/.settings/language.settings.xml index 893d1b4..1d893ec 100644 --- a/.settings/language.settings.xml +++ b/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -16,7 +16,7 @@ - + diff --git a/.vscode/settings.json b/.vscode/settings.json index deaec24..8af08af 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -8,72 +8,68 @@ "**/Release": true }, "files.associations": { - "string": "cpp", + "*.tcc": "cpp", + "array": "cpp", + "atomic": "cpp", + "bit": "cpp", "cctype": "cpp", + "chrono": "cpp", "clocale": "cpp", "cmath": "cpp", - "csignal": "cpp", + "compare": "cpp", + "concepts": "cpp", + "condition_variable": "cpp", "cstdarg": "cpp", "cstddef": "cpp", + "cstdint": "cpp", "cstdio": "cpp", "cstdlib": "cpp", "cstring": "cpp", "ctime": "cpp", "cwchar": "cpp", "cwctype": "cpp", - "array": "cpp", - "atomic": "cpp", - "strstream": "cpp", - "*.tcc": "cpp", - "bitset": "cpp", - "cfenv": "cpp", - "chrono": "cpp", - "codecvt": "cpp", - "complex": "cpp", - "condition_variable": "cpp", - "cstdint": "cpp", "deque": "cpp", "list": "cpp", + "map": "cpp", + "set": "cpp", + "string": "cpp", "unordered_map": "cpp", + "unordered_set": "cpp", "vector": "cpp", "exception": "cpp", "algorithm": "cpp", - "any": "cpp", "functional": "cpp", + "iterator": "cpp", + "memory": "cpp", + "memory_resource": "cpp", + "numeric": "cpp", "optional": "cpp", + "random": "cpp", "ratio": "cpp", "string_view": "cpp", "system_error": "cpp", "tuple": "cpp", "type_traits": "cpp", + "utility": "cpp", "fstream": "cpp", - "future": "cpp", "initializer_list": "cpp", "iomanip": "cpp", "iosfwd": "cpp", "iostream": "cpp", "istream": "cpp", "limits": "cpp", - "memory": "cpp", "mutex": "cpp", "new": "cpp", + "numbers": "cpp", "ostream": "cpp", - "numeric": "cpp", + "semaphore": "cpp", "sstream": "cpp", "stdexcept": "cpp", + "stop_token": "cpp", "streambuf": "cpp", "thread": "cpp", "cinttypes": "cpp", - "utility": "cpp", - "typeindex": "cpp", - "typeinfo": "cpp", - "iterator": "cpp", - "map": "cpp", - "memory_resource": "cpp", - "random": "cpp", - "set": "cpp", - "*.ipp": "cpp", - "unordered_set": "cpp" + "typeinfo": "cpp" }, "C_Cpp.errorSquiggles": "disabled" } \ No newline at end of file diff --git a/common/parameter_defination.hpp b/common/parameter_defination.hpp index 81df061..7ca3eeb 100644 --- a/common/parameter_defination.hpp +++ b/common/parameter_defination.hpp @@ -301,18 +301,20 @@ struct Param_57 { }; struct Param_58 { + int mMode; int featureInterVal; int featureInterTime; int waveInterVal; int waveInterTime; int maxSensorNum; - Param_58() : featureInterVal(0),featureInterTime(0),waveInterVal(0),waveInterTime(0),maxSensorNum(0){}; + Param_58() : mMode(0),featureInterVal(0),featureInterTime(0),waveInterVal(0),waveInterTime(0),maxSensorNum(0){}; }; struct Param_59 { int mMode; std::string DataNodeNo; - Param_59() : mMode(0),DataNodeNo(""){}; + std::string straxis; + Param_59() : mMode(0),DataNodeNo(""),straxis(""){}; }; #endif // PARAMETER_DEFINATION_HPP_ diff --git a/scheduler/schedule.cpp b/scheduler/schedule.cpp index d2d3873..93a2345 100644 --- a/scheduler/schedule.cpp +++ b/scheduler/schedule.cpp @@ -109,11 +109,18 @@ SensorScheduler::SensorScheduler() { seconds_per_wave_slice_ = rest_duration / wave_slice_num_per_eigen_interval_; } else { zlog_info(zbt, "use default configuration"); - int eigen_value_send_interval = 300; - int wave_form_send_interval = 7200; + // int eigen_value_send_interval = 300; + // int wave_form_send_interval = 7200; + // int eigen_value_send_duration = 6; + // int wave_form_send_duration = 50; + // int max_sensor_num = 32; + + int eigen_value_send_interval = 120; + int wave_form_send_interval = 240; int eigen_value_send_duration = 6; - int wave_form_send_duration = 50; - int max_sensor_num = 32; + int wave_form_send_duration = 40; + int max_sensor_num = 4; + Config(eigen_value_send_interval, wave_form_send_interval, eigen_value_send_duration, diff --git a/uart/uart.cpp b/uart/uart.cpp index 808af67..ad57c1c 100644 --- a/uart/uart.cpp +++ b/uart/uart.cpp @@ -50,10 +50,8 @@ int Uart::UartRecv(int fd, char srcshow, char *buffer) { zlog_info(zct, "===============0x9999 timeout= %d offSize = %d===============", timeoutflag, offSize); zlog_info(zct, "0x9999 timeout %d===============Size = %d", timeoutflag, offSize); FindRecvPackage(offSize, mUartRecvTmpBuf, head); - GlobalConfig::Zigbee_G.MyAddr = 0x8888; now_task = -1; - wave_shortAddr = 0; timeoutflag = 0; offSize = 0; maxSize = 0; @@ -373,6 +371,7 @@ int Uart::DealAskTask(uint16_t ushortAdd){ ModifyDistAddr(ushortAdd); int next_duration = 0; int taskID = scheduler::instance().StartSchedule(ushortAdd,next_duration); + taskID = 4; ScheduleTask scheduleTask; zlog_info(zct, "taskID = %d ", taskID); if (taskID == kScheduleEigenValue) //1.特征值 @@ -429,10 +428,12 @@ int Uart::DealReviveDuration(uint16_t ushortAdd){ ScheduleTask scheduleTask; uint16_t next_duration = scheduler::instance().GetNextDuration(ushortAdd); + next_duration = 60; + zlog_info(zct, "next_duration = %d ", next_duration); scheduleTask.cmd = REVIVE_DURATION; scheduleTask.shortAddr = ushortAdd; scheduleTask.duration = next_duration; - zlog_info(zct, "next_duration = %d ", next_duration); + TaskResp(scheduleTask); return 0; } @@ -448,17 +449,18 @@ int Uart::DealConfig(uint16_t ushortAdd){ } int Uart::DealWaveCompress(const char *pData,uint16_t ushortAdd){ + zlog_info(zct, "DealWaveCompress "); char buf[20] = {0x00}; sprintf(buf, "%02x%02x", (ushortAdd >> 8) & 0xFF, ushortAdd & 0xFF); std::string strShortAddr = std::string(buf); compressWaveChannel tempchannel; - tempchannel.compressChannelX = pData[8]; - tempchannel.compressChannelY = pData[9]; - tempchannel.compressChannelZ = pData[10]; + tempchannel.compressChannelX = pData[7]; + tempchannel.compressChannelY = pData[8]; + tempchannel.compressChannelZ = pData[9]; - tempchannel.CountX = BUILD_UINT32(pData[14], pData[13],pData[12],pData[11]); - tempchannel.CountY = BUILD_UINT32(pData[18], pData[17],pData[16],pData[15]); - tempchannel.CountZ = BUILD_UINT32(pData[22], pData[21],pData[20],pData[19]); + tempchannel.CountX = BUILD_UINT32(pData[13], pData[12],pData[11],pData[10]); + tempchannel.CountY = BUILD_UINT32(pData[17], pData[16],pData[15],pData[14]); + tempchannel.CountZ = BUILD_UINT32(pData[21], pData[20],pData[19],pData[18]); g_mapCompress[strShortAddr] = tempchannel; @@ -952,7 +954,7 @@ int Uart::FindRecvPackage(int bytesRead, char *mUartRecvBuf, char *head) { char buf[8] = {0x00}; sprintf(buf, "%02d", UartRecvBuf[i + 5]); int command = atoi(buf); - zlog_info(zct, "command = %d ShortAddr :%s", command, strShortAddr.c_str()); + //zlog_info(zct, "command = %d ShortAddr :%s", command, strShortAddr.c_str()); if ((mPackgeIndex == -1 || (unsigned int)UartRecvBuf[i + 6] == 0) && (!bUpdatePre && !bUpdateconfig)) { mPackgeIndex = UartRecvBuf[i + 6] & 0xFF; } else if ((unsigned int)mPackgeIndex == (unsigned int)UartRecvBuf[i + 6] && mPackgeIndex != -1 && (!bUpdatePre && !bUpdateconfig) && command != 2) { @@ -1014,7 +1016,6 @@ int Uart::FindRecvPackage(int bytesRead, char *mUartRecvBuf, char *head) { g_VecWaveDataX.clear(); g_VecWaveDataY.clear(); g_VecWaveDataZ.clear(); - break; } mlastSize = 0; @@ -1037,14 +1038,6 @@ int Uart::FindRecvPackage(int bytesRead, char *mUartRecvBuf, char *head) { break; } } - if (command == WAVE_COMPRESS ) - { - memcpy(RecvBuf, &UartRecvBuf[i], 23); - if (!CheckCrc(RecvBuf, 22)) { - zlog_info(zct, "CheckCrc error ShortAddr :%s command = %d ", strShortAddr.c_str(), command); - break; - } - } if (command == CONFIG || command == CONFIG_INF2 || command == UPGRADE || command == SIGNAL_STRENGTH || command == DEVICE_EXCEPTION || command == WAVE_COMPRESS) { memcpy(RecvBuf, &UartRecvBuf[i], 9); @@ -1053,7 +1046,6 @@ int Uart::FindRecvPackage(int bytesRead, char *mUartRecvBuf, char *head) { break; } } - if (command == DEVICE_INF || command == MEAS_EVAL || command == DEVICE_INF2) { memcpy(RecvBuf, &UartRecvBuf[i], 100); @@ -1062,10 +1054,22 @@ int Uart::FindRecvPackage(int bytesRead, char *mUartRecvBuf, char *head) { break; } } - - DealRecvData(RecvBuf); + }else if(now_task == WAVE_CMD && command == WAVE_COMPRESS){ + memcpy(RecvBuf, &UartRecvBuf[i], 23); + if (!CheckCrc(RecvBuf, 22)) { + zlog_info(zct, "CheckCrc error ShortAddr :%s command = %d ", strShortAddr.c_str(), command); + break; + } + char tmp[23] = {0x00}; + char tmp2[23] = {0x00}; + for (int j = 0; j < 23; j++) { + sprintf(tmp, "%02x ", UartRecvBuf[i + j] & 0xff); + strcat(tmp2, tmp); + } + zlog_info(zct, "str = %s", tmp2); + DealRecvData(RecvBuf); } else if (command == 35) { char signalNode[10] = {0x00}; sprintf(signalNode, "%02d", UartRecvBuf[i + 14] & 0xFF); diff --git a/uart/uart_feature_parse.cpp b/uart/uart_feature_parse.cpp index 382c56f..80f9c7e 100644 --- a/uart/uart_feature_parse.cpp +++ b/uart/uart_feature_parse.cpp @@ -772,21 +772,21 @@ float Uart::ScaleConvert(int highbit) { return 0.0001f * pow(100.0f, highbit); } void Uart::DealDataNodeWave(const char *pData, int comand) { RecvData *pRecvData = (RecvData *)pData; if (wave_trans_) { - if (comand == 3) { + if (comand == WAVE_X) { VecWaveDataX.push_back(*pRecvData); - } else if (comand == 4) { + } else if (comand == WAVE_Y) { VecWaveDataY.push_back(*pRecvData); - } else if (comand == 5) { + } else if (comand == WAVE_Z) { VecWaveDataZ.push_back(*pRecvData); } } else { - if (comand == 3) { + if (comand == WAVE_X) { g_VecWaveDataX[m_waveCountX] = *pRecvData; m_waveCountX++; - } else if (comand == 4) { + } else if (comand == WAVE_Y) { g_VecWaveDataY[m_waveCountY] = *pRecvData; m_waveCountY++; - } else if (comand == 5) { + } else if (comand == WAVE_Z) { g_VecWaveDataZ[m_waveCountZ] = *pRecvData; m_waveCountZ++; } @@ -934,12 +934,18 @@ void Uart::DealWave() { std::vector vecData; if (wave_trans_) { //对每个传感器的每个通道进行遍历然后处理数据,例如:传感器1x轴的数据处理完后,再去处理y轴的。传感器1的所有数据处理完后,再处理传感器2的 char getLongAddr_sql[32] = {0}; - sprintf(getLongAddr_sql, "zigbeeShortAddr='%s'", m_strDestShortAddr.c_str()); + sprintf(getLongAddr_sql, "zigbeeShortAddr='%02x%02x'", (wave_shortAddr >> 8) & 0xFF,wave_shortAddr & 0xFF); vec_t res = sqlite_db_ctrl::instance().GetDataSingleLine(T_SENSOR_INFO(TNAME), " * ", getLongAddr_sql); + if (res.size() < 0) + { + wave_trans_ = false; + return; + } strLongAddr = res[0]; strMeasurementID = res[44]; if (0 == strLongAddr.length()) { sleep(1); + wave_trans_ = false; return; } std::string ran = ""; @@ -984,11 +990,6 @@ void Uart::DealWave() { g_VecWaveDataZ.clear(); VecWaveDataZ.clear(); } - char whereCon[1024] = {0x00}; - char updateSql[1024] = {0x00}; - sprintf(whereCon, "dataNodeNo='%s'", strLongAddr.c_str()); - sprintf(updateSql, "WaveTime = WaveTime + 1"); - sqlite_db_ctrl::instance().UpdateTableData(T_SENSOR_INFO(TNAME), updateSql, whereCon); wave_trans_ = false; } } diff --git a/uart/uart_parameter_config.cpp b/uart/uart_parameter_config.cpp index 4783266..16f68fc 100644 --- a/uart/uart_parameter_config.cpp +++ b/uart/uart_parameter_config.cpp @@ -528,8 +528,8 @@ int Uart::TaskResp(ScheduleTask scheduleTask){ UpdateData[6] = 0x00; if (scheduleTask.cmd == REVIVE_DURATION) { - UpdateData[7] = (scheduleTask.duration >> 8) & 0xFF; - UpdateData[8] = scheduleTask.duration & 0xFF; + UpdateData[7] = UINT16_LOW(scheduleTask.duration); + UpdateData[8] = UINT16_HIGH(scheduleTask.duration); } if (scheduleTask.cmd == MEAS_EVAL) {