| 
									
										
										
										
											2025-04-27 10:05:00 +08:00
										 |  |  | #include "macconfig.h"
 | 
					
						
							|  |  |  | #include "ui_macconfig.h"
 | 
					
						
							|  |  |  | #include <QRegularExpression>
 | 
					
						
							|  |  |  | #include <QRegularExpressionValidator>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | MacConfig::MacConfig(QWidget *parent) : | 
					
						
							|  |  |  |     QWidget(parent), | 
					
						
							|  |  |  |     ui(new Ui::MacConfig) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     ui->setupUi(this); | 
					
						
							|  |  |  |     QRegularExpression macRegex("^([0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}$"); | 
					
						
							|  |  |  |     QRegularExpressionValidator *macValidator = new QRegularExpressionValidator(macRegex, this); | 
					
						
							|  |  |  |     ui->lineEdit_mac->setValidator(macValidator); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | MacConfig::~MacConfig() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     delete ui; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void MacConfig::on_pushButton_confirm_clicked() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2025-05-14 23:14:50 +08:00
										 |  |  |     ConfigMacReq config_mac = { {0xAA, 0x55, 0xAA}, kConfigMac, 1,0,{} }; | 
					
						
							| 
									
										
										
										
											2025-04-27 10:05:00 +08:00
										 |  |  |     memcpy(config_mac.mac,ui->lineEdit_mac->text().toStdString().c_str(),sizeof(config_mac.mac)); | 
					
						
							| 
									
										
										
										
											2025-05-14 23:14:50 +08:00
										 |  |  |     char send_buf[50] ={0}; | 
					
						
							|  |  |  |     memcpy(send_buf, (char*)&config_mac, sizeof(ConfigMacReq)); | 
					
						
							| 
									
										
										
										
											2025-04-27 10:05:00 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-05-14 23:14:50 +08:00
										 |  |  |     int length =  sizeof(ConfigMacReq); | 
					
						
							| 
									
										
										
										
											2025-04-27 10:05:00 +08:00
										 |  |  |     qint64 bytesWritten = m_tcpClient->sendData(send_buf, length); | 
					
						
							|  |  |  |     m_tcpClient->waitForRead(); | 
					
						
							|  |  |  |     qDebug() << "bytesWritten: " << bytesWritten; | 
					
						
							|  |  |  |     this->close(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void MacConfig::on_pushButton_cancel_clicked() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     this->close(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 |