更新与前板的使用串口连接
This commit is contained in:
@@ -4,12 +4,13 @@
|
||||
|
||||
#include "mdns.h"
|
||||
|
||||
// 添加一个类来运行 mDNS 服务
|
||||
// 运行 mDNS 服务
|
||||
class MdnsServiceThread : public QThread {
|
||||
Q_OBJECT
|
||||
public:
|
||||
MdnsServiceThread(const QString& hostname, const QString& serviceName, int servicePort, QObject* parent = nullptr)
|
||||
MdnsServiceThread(const QString& hostname, const QString& serviceName, int servicePort, char* select_ip, QObject* parent = nullptr)
|
||||
: QThread(parent),
|
||||
m_select_ip(select_ip),
|
||||
m_hostname(hostname),
|
||||
m_serviceName(serviceName),
|
||||
m_servicePort(servicePort) {}
|
||||
@@ -26,8 +27,9 @@ protected:
|
||||
extern volatile sig_atomic_t running; // 使用全局变量控制运行状态
|
||||
running = 1;
|
||||
|
||||
// 调用阻塞的 service_mdns 方法
|
||||
int result = service_mdns(m_hostname.toStdString().c_str(), m_serviceName.toStdString().c_str(), m_servicePort);
|
||||
//int result = service_mdns(m_hostname.toStdString().c_str(), m_serviceName.toStdString().c_str(), m_servicePort, "192.168.1.170");
|
||||
//int result = service_mdns(m_hostname.toStdString().c_str(), m_serviceName.toStdString().c_str(), m_servicePort, "172.17.128.1");
|
||||
int result = service_mdns(m_hostname.toStdString().c_str(), m_serviceName.toStdString().c_str(), m_servicePort, m_select_ip);
|
||||
if (result < 0) {
|
||||
qDebug() << "Failed to start mDNS service";
|
||||
}
|
||||
@@ -37,6 +39,7 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
char* m_select_ip;
|
||||
QString m_hostname;
|
||||
QString m_serviceName;
|
||||
int m_servicePort;
|
||||
|
||||
Reference in New Issue
Block a user