Compare commits

...

3 Commits

Author SHA1 Message Date
c06fa6af06 add code 2026-02-28 22:29:46 +08:00
7df0cad3d3 add code 2026-02-28 14:11:23 +08:00
4d4c31944f add code 2026-02-28 10:34:05 +08:00
6 changed files with 52 additions and 48 deletions

View File

@ -18,7 +18,7 @@ enum enumZigBeeTransmitStatus {
//#define NR5G_MODULE
#define Q4G_MODULE
//#define Q4G_MODULE
//#define WIFI_MODULE
//#define NR5G_MEIGE
//#define BLUETEETH_MODULE

View File

@ -78,8 +78,8 @@ int main(int argc, char *argv[]) {
boost::thread uartWaveReadTh(UartStartWave);
uartWaveReadTh.detach();
//启动 RUN LED
boost::thread startRunLED(RunLED);
startRunLED.detach();
// boost::thread startRunLED(RunLED);
// startRunLED.detach();
#ifdef NR5G_MODULE
@ -119,7 +119,6 @@ int main(int argc, char *argv[]) {
uart_inst::instance().ZigbeeParameterConfig();
sleep(1);
uart_inst::instance().UpdateZigbeeInfoCtrl();
//启动 mqtt客户端
boost::thread startMqtt(StartMqttClient);
startMqtt.detach();
@ -144,13 +143,10 @@ int main(int argc, char *argv[]) {
zlog_error(zbt, "(this usually indicates a compiler bug - try recompiling\nwithout optimizations, and enable '-DLZO_DEBUG' for diagnostics)");
}
int fd = OpenWatchDog();
//int fd = OpenWatchDog();
int count = 0;
while (GlobalConfig::QuitFlag_G) {
gpio_set(GlobalConfig::GPIO_G.hardWatchDog, 1);
usleep(20000);
gpio_set(GlobalConfig::GPIO_G.hardWatchDog, 0);
WriteWatchDog(fd);
//WriteWatchDog(fd);
sleep(20);
if (GlobalConfig::threadStatus == 0) {
count++;

View File

@ -69,22 +69,22 @@ void HeartRep() {
zlog_info(zct, "heart = %s,iRet = %d", strJson.c_str(), iRet);
}
if (iRet != 0) {
gpio_set(GlobalConfig::GPIO_G.errorLed, 1);
sleep(1);
gpio_set(GlobalConfig::GPIO_G.errorLed, 0);
sleep(1);
gpio_set(GlobalConfig::GPIO_G.errorLed, 1);
sleep(1);
gpio_set(GlobalConfig::GPIO_G.errorLed, 0);
sleep(1);
gpio_set(GlobalConfig::GPIO_G.errorLed, 1);
sleep(1);
GlobalConfig::serverStatus = 1;
} else {
GlobalConfig::serverStatus = 0;
gpio_set(GlobalConfig::GPIO_G.errorLed, 0);
}
// if (iRet != 0) {
// gpio_set(GlobalConfig::GPIO_G.errorLed, 1);
// sleep(1);
// gpio_set(GlobalConfig::GPIO_G.errorLed, 0);
// sleep(1);
// gpio_set(GlobalConfig::GPIO_G.errorLed, 1);
// sleep(1);
// gpio_set(GlobalConfig::GPIO_G.errorLed, 0);
// sleep(1);
// gpio_set(GlobalConfig::GPIO_G.errorLed, 1);
// sleep(1);
// GlobalConfig::serverStatus = 1;
// } else {
// GlobalConfig::serverStatus = 0;
// gpio_set(GlobalConfig::GPIO_G.errorLed, 0);
// }
sleep(30);
count ++;
}

View File

@ -157,7 +157,7 @@ Uart::~Uart() {
}
void Uart::InitUart(speed_t speed) {
fd = config_uart("/dev/ttySC2", speed);
fd = config_uart("/dev/ttyS3", speed);
zlog_info(zct, "InitUart fd = %d", fd);
if (fd < 0) {
@ -654,7 +654,8 @@ void Uart::DealRecvData(const char *pData) {
nowTimetamp = std::string(localtimestamp);
last_time = atol(nowTimetamp.c_str());
}
if (ushortAdd != last_short_addr){
//if (ushortAdd != last_short_addr)
{
mssleep(50000);
ModifyDistAddr(ushortAdd);
mssleep(50000);

View File

@ -705,10 +705,17 @@ std::vector<float> Uart::DealData(int iChannel, float coe, unsigned int sampleRa
waveCount = VecWaveDataZ.size();
}
waveCount = m_waveCountZ;
printf("\n");
for (; j < waveCount; j++) {
RecvData recvData = g_VecWaveDataZ[j];
memcpy(data + j * 92, recvData.Data, 92);
if (j + 3 > waveCount)
{
printf("%02x ",recvData.Order);
}
}
printf("\n");
memset(buf, 0x00, sizeof(buf));
sprintf(buf, "%02x%02x", g_VecWaveDataZ[0].ShortAddr[0], g_VecWaveDataZ[0].ShortAddr[1]);
strShortAddr = std::string(buf);

View File

@ -599,13 +599,13 @@ int Uart::TaskResp(ScheduleTask scheduleTask){
mssleep(50000);
WriteToUart((const char*)send_data, 100);
int iRet = CheckZigbeeACK();
if (iRet == 0) {
zlog_info(zct, "TaskResp ACK send success,shortAddr = %02x%02x", UINT16_HIGH(scheduleTask.shortAddr),UINT16_LOW(scheduleTask.shortAddr));
} else {
zlog_warn(zct, "TaskResp ACK send failed,shortAddr = %02x%02x", UINT16_HIGH(scheduleTask.shortAddr),UINT16_LOW(scheduleTask.shortAddr));
}
return iRet;
// int iRet = CheckZigbeeACK();
// if (iRet == 0) {
// zlog_info(zct, "TaskResp ACK send success,shortAddr = %02x%02x", UINT16_HIGH(scheduleTask.shortAddr),UINT16_LOW(scheduleTask.shortAddr));
// } else {
// zlog_warn(zct, "TaskResp ACK send failed,shortAddr = %02x%02x", UINT16_HIGH(scheduleTask.shortAddr),UINT16_LOW(scheduleTask.shortAddr));
// }
return 0;
}
int Uart::SendReviveDuration(ReviveDuration recvDuration){
@ -626,13 +626,13 @@ int Uart::SendReviveDuration(ReviveDuration recvDuration){
}
UpdateData[99] = tmp;
WriteToUart((const char*)UpdateData, 100);
int iRet = CheckZigbeeACK();
if (iRet == 0) {
zlog_info(zct, "SendReviveDuration ACK send success,shortAddr = %d", recvDuration.shortAddr);
} else {
zlog_warn(zct, "SendReviveDuration ACK send failed,shortAddr = %d", recvDuration.shortAddr);
}
return iRet;
// int iRet = CheckZigbeeACK();
// if (iRet == 0) {
// zlog_info(zct, "SendReviveDuration ACK send success,shortAddr = %d", recvDuration.shortAddr);
// } else {
// zlog_warn(zct, "SendReviveDuration ACK send failed,shortAddr = %d", recvDuration.shortAddr);
// }
return 0;
}
int Uart::WaveResp(uint16_t shortAddr){
unsigned char sendData[8] = {0};
@ -653,13 +653,13 @@ int Uart::WaveResp(uint16_t shortAddr){
WriteToUart((const char*)sendData, 8);
mssleep(50000);
WriteToUart((const char*)sendData, 8);
int iRet = CheckZigbeeACK();
if (iRet == 0) {
zlog_info(zct, "WaveResp ACK send success,shortAddr = %x", shortAddr);
} else {
zlog_warn(zct, "WaveResp ACK send failed,shortAddr = %x", shortAddr);
}
return iRet;
// int iRet = CheckZigbeeACK();
// if (iRet == 0) {
// zlog_info(zct, "WaveResp ACK send success,shortAddr = %x", shortAddr);
// } else {
// zlog_warn(zct, "WaveResp ACK send failed,shortAddr = %x", shortAddr);
// }
return 0;
}
int Uart::CheckZigbeeACK() {
if (gpio_read(GlobalConfig::GPIO_G.zigAckrep) == 48) gpio_set(GlobalConfig::GPIO_G.zigAckreset, 1);