1.添加图片注册和前后板主题图片上传;2.修改mdns连接方式

This commit is contained in:
2024-12-10 16:15:55 +08:00
parent 9d506e1cfc
commit d2bccd9c49
177 changed files with 4381 additions and 5709 deletions

View File

@@ -56,7 +56,7 @@
#define SET_LOG_LEVEL 0x0360
// 前板设备信息
// 前板设备信息
#define GET_FRONT_V851_VERSION 0x0400
#define GET_FRONT_MCU_VERSION 0x0401
#define GET_FRONT_HW_VERSION 0x0402
@@ -66,6 +66,7 @@
#define GET_FRONT_HW_INFO 0x0420
#define WRITE_FRONT_LICENSE 0x0421
// 后板设备信息
#define GET_BACK_V851_VERSION 0x0450
#define GET_BACK_806_VERSION 0x0451
#define GET_BACK_HW_VERSION 0x0452
@@ -77,4 +78,5 @@
#define VIDEO_TEST 0x050A
#endif

View File

@@ -108,8 +108,8 @@ void DataHandler::updateLineEdit(int msg_id, const QByteArray& actual_data) {
void DataHandler::clearAllRecvData() {
allRecvData = QByteArray();
remain = 0;
dataLen = 0;
remain = 0;
dataLen = 0;
}
// 处理接收到的数据
@@ -145,11 +145,20 @@ void DataHandler::handleData(const QString& client, const QByteArray& recv
(static_cast<unsigned char>(buffer->at(7)) << 8) |
(static_cast<unsigned char>(buffer->at(6)));
//qDebug() << "---Received dataSize:" << dataSize;
//qDebug() << "---Received buffer->size():" << buffer->size();
//qDebug() << "---msg_id:" << QString::number(msg_id, 16).toUpper();
// 第11字节为返回 OK/NG
bool success = (static_cast<unsigned char>(buffer->at(10)) == 0x00);
bool success = (static_cast<unsigned char>(buffer->at(10)) != 0x00);
int totalSize = 10 + dataSize; // 数据头大小(10字节) + 实际数据大小
if (CurrentCommand == "GET_BACK_MAC") {
//qDebug() << "--- getCommandNameFromValue:" << msg_id;
if (!getCommandNameFromValue(msg_id)) {
//qDebug() << "--- getCommandNameFromValue:" << msg_id;
buffer->remove(0, buffer->size());
emit commandError();
break;
}
}
if (buffer->size() >= totalSize) {
// 调试查看收到的前19个字节
/*for (int i = 0; i < 19; i++) {
@@ -158,7 +167,7 @@ void DataHandler::handleData(const QString& client, const QByteArray& recv
QByteArray data = buffer->mid(11, dataSize);
QString hexString = QString::fromUtf8(data.toHex().data());
QByteArray actual_data = hexStringToByteArray(hexString);
buffer->remove(0, totalSize); // 移除已处理的数据
buffer->remove(0, totalSize); // 移除已处理的数据
if(msg_id != 0x0040 && msg_id != START_VIDEO && msg_id != GET_IMG && msg_id != VIDEO_TEST &&
msg_id != STOP_VIDEO) {
qDebug() << "--- msg_id:" << msg_id;
@@ -167,7 +176,7 @@ void DataHandler::handleData(const QString& client, const QByteArray& recv
(msg_id != 0x0021 || clientLastMsgId.value(client, 0) != 0x0021) &&
(msg_id != START_VIDEO || clientLastMsgId.value(client, 0) != START_VIDEO)) {
//qDebug() << "Emitting statusUpdated for client:" << client << "with msg_id:" << QString::number(msg_id, 16).toUpper();
emit statusUpdated(client, true, jsonArray, itemJsonIndex);
emit statusUpdated(client, success, jsonArray, itemJsonIndex);
}
clientLastMsgId[client] = msg_id;
}
@@ -183,6 +192,68 @@ void DataHandler::handleData(const QString& client, const QByteArray& recv
}
}
void DataHandler::getCurrentSendItem(const QString& text) {
CurrentCommand = text;
}
// 初始化映射表
std::map<QString, int> commandValueMap = {
{"FACE_ENROLL_SINGLE", FACE_ENROLL_SINGLE},
{"FACE_ENROLL", FACE_ENROLL},
{"HAND_ENROLL", HAND_ENROLL},
{"FACE_VERIFY", FACE_VERIFY},
{"HAND_VERIFY", HAND_VERIFY},
{"DEL_USER", DEL_USER},
{"DEL_ALLUSER", DEL_ALLUSER},
{"GET_USER", GET_USER},
{"GET_ALLUSER", GET_ALLUSER},
{"PASSWD_ENROLL", PASSWD_ENROLL},
{"IMG_ENROLL", IMG_ENROLL},
{"GET_IMG", GET_IMG},
{"START_VIDEO", START_VIDEO},
{"STOP_VIDEO", STOP_VIDEO},
{"TOUCH_TEST", TOUCH_TEST},
{"MIC_TEST", MIC_TEST},
{"SPK_TEST", SPK_TEST},
{"RADAR_TEST", RADAR_TEST},
{"NFC_TEST", NFC_TEST},
{"PR_SWITCH", PR_SWITCH},
{"PS_TEST", PS_TEST},
{"BACKLIGHT", BACKLIGHT},
{"IR_LED", IR_LED},
{"UART_TEST", UART_TEST},
{"PIR_TEST", PIR_TEST},
{"FACE_VERIFY_THRES", FACE_VERIFY_THRES},
{"FACE_THRES_LEVEL", FACE_THRES_LEVEL},
{"FACE_LIVE_THRES", FACE_LIVE_THRES},
{"FACE_ACC_THRES", FACE_ACC_THRES},
{"FACE_ACC_LEVEL", FACE_ACC_LEVEL},
{"FACE_DIS_RANGE", FACE_DIS_RANGE},
{"FACE_ANGLE_RANGE", FACE_ANGLE_RANGE},
{"GET_BACK_MAC", GET_BACK_MAC},
{"WRITE_BACK_UID_SN", WRITE_BACK_UID_SN}
};
bool DataHandler::getCommandNameFromValue(int receivedValue) {
auto it = commandValueMap.find(CurrentCommand);
if (it != commandValueMap.end()) {
int expectedValue = it->second;
if (expectedValue == receivedValue) {
std::cout << "Match found: " << CurrentCommand.toStdString() << " corresponds to value " << std::hex << expectedValue << std::endl;
return true;
}
else {
std::cout << "Value mismatch: Expected " << std::hex << expectedValue << ", but received " << std::hex << receivedValue << std::endl;
return false;
}
}
else {
std::cout << "Unknown command: " << CurrentCommand.toStdString() << std::endl;
return false;
}
}
void DataHandler::initializeMsgIdToCmdMap() {
msgIdToCmdMap[GET_FRONT_V851_VERSION] = "GET_FRONT_V851_VERSION";
msgIdToCmdMap[GET_FRONT_MCU_VERSION] = "GET_FRONT_MCU_VERSION";

View File

@@ -28,7 +28,7 @@
#define YUV420 1
#define YUV422 2
#define BACK_MAC_ADDRESS_LEN 11
#define BACK_MAC_ADDRESS_LEN 17
class DataHandler : public QObject
{
@@ -48,6 +48,7 @@ public slots:
void handleData(const QString& client, const QByteArray& data, int msg_id, int currentRecvItemIndex,
int currentRecvFuncItemIndex, const QString& itemData, const QString& funcItemData,
const QJsonArray& jsonArray, int itemJsonIndex);
void getCurrentSendItem(const QString& text);
signals:
void statusUpdated(const QString& clientAddress, bool success, const QJsonArray& jsonArray, int itemJsonIndex);
void updateLicenseHwInfoEdit(const QString& text);
@@ -57,6 +58,7 @@ signals:
void updateVideoLabel(const QPixmap& pixmap);
void updateVideoResolution(const QString& resolutionText);
void picRecvFinished();
void commandError();
private:
QJsonArray frontBoardOneClickTest; // 前板一键功能测试 JSON
QJsonArray frontBoardTest; // 前板单项测试 JSON
@@ -91,8 +93,9 @@ private:
QMap<int, QString> msgIdToCmdMap;
QSize labelSize;
bool isStartVideo = false;
QString CurrentCommand = "";
// 如果接收十六进制数据,转为二进制
bool getCommandNameFromValue(int receivedValue);
QByteArray hexStringToByteArray(const QString& hexString);
void showVideo(const QString& client, const QByteArray& valData);
void clearAllRecvData();