#include "modulesystime.h" #include #include #include #include ModuleSysTime::ModuleSysTime(QObject *parent) : QObject(parent) { QTimer::singleShot(1000, this, SLOT(onTimerTimeOutPingNet())); } void ModuleSysTime::onTimerTimeOutPingNet() { qDebug("ping net: timeout 5s ping 202.108.22.5 > /home/net_check"); std::system("timeout 5s ping www.baidu.com -n > /home/net_check"); QTimer::singleShot(5000, this, SLOT(onTimerTimeOutCheckNet())); } void ModuleSysTime::onTimerTimeOutCheckNet() { qDebug("onTimerTimeOutCheckNet"); QFile file_read_net("/home/net_check"); QString net_check = ""; if(file_read_net.open(QIODevice::ReadOnly | QIODevice::Text)) { QTextStream in(&file_read_net);//创建一个对象让它去读文件 QString ping1=in.readLine(); QString ping2=in.readLine(); net_check=ping2.left(2); } file_read_net.close(); if (net_check=="64") { qDebug("file_write: /home/data/net_ok.txt success!"); QFile file_write("/home/data/net_ok.txt");//网络连接正常 if(file_write.open(QFile::WriteOnly)) { QTextStream setWIFI_data(&file_write); setWIFI_data<<"1"<