49 lines
1.2 KiB
C++
49 lines
1.2 KiB
C++
#include "prot/prot_cmdline.h"
|
|
#include "base/mycfg.h"
|
|
#include "QNetworkConfigurationManager"
|
|
#include "QTimer"
|
|
#include "QtNetwork"
|
|
|
|
|
|
|
|
|
|
// 获取设备基本信息
|
|
static void whos(QList<myarray> args)
|
|
{
|
|
QString out;
|
|
QString name = "local_id:%1,name:%2";
|
|
QString hostName = QHostInfo::localHostName();
|
|
command *c=command_start();
|
|
mycfg *cfg_=syscfg();
|
|
name = name.arg(cfg_->local_id).arg(hostName);
|
|
out.append(name + "\n");
|
|
out.append("builed time:" + cfg_->build_date + "\n");
|
|
QList<QNetworkInterface> network = QNetworkInterface::allInterfaces();
|
|
foreach (QNetworkInterface net, network)
|
|
{
|
|
QString str = "net:%1";
|
|
QString netName = net.humanReadableName();
|
|
str = str.arg(netName);
|
|
out.append(str + "\n");
|
|
QList<QNetworkAddressEntry> list = net.addressEntries(); // 获取IP地址与子掩码等
|
|
foreach (QNetworkAddressEntry address, list)
|
|
{
|
|
QString str = "ip:%1";
|
|
if (address.ip().protocol() == QAbstractSocket::IPv4Protocol) // 获取IPv4的地址
|
|
{
|
|
out.append(str.arg(address.ip().toString()) + "\n");
|
|
}
|
|
}
|
|
}
|
|
out = "ack:1," + out;
|
|
c->send(out.toLocal8Bit());
|
|
}
|
|
|
|
cmdline_export(whos, whos, print device base info.);
|
|
|
|
|
|
|
|
|
|
|
|
|