适配新协议。

This commit is contained in:
luocai 2024-07-23 20:03:19 +08:00
parent 59281e3a75
commit 5c2440c32c
5 changed files with 15 additions and 79 deletions

View File

@ -1,4 +1,4 @@
project(Analyser VERSION 0.2 LANGUAGES C CXX)
project(Analyser VERSION 0.3 LANGUAGES C CXX)
set(APPLICATION_NAME "掌静脉测试工具")
set(CMAKE_AUTOMOC ON)

View File

@ -110,42 +110,6 @@ void ModuleCommunication::requestEnrolledImage(uint32_t offset, uint32_t size) {
// LOG_CAT(info, GUI) << Separator;
}
void ModuleCommunication::requestPalmFeature(uint16_t userid) {
uint16_t n = htons(userid);
auto [frameData, frameSize] = generateFrame(RequestPalmFeature, reinterpret_cast<const uint8_t *>(&n), sizeof(n));
m_serialPort->write(reinterpret_cast<const char *>(frameData), frameSize);
LOG_CAT(info, GUI) << "发送获取掌静脉特征值指令: " << protocolDataFormatString(frameData, frameSize);
LOG_CAT(info, GUI) << "获取特征值用户ID: " << userid;
LOG_CAT(info, GUI) << Separator;
}
void ModuleCommunication::enrollPalmFeature(uint16_t userid, const PalmFeature &feature) {
auto buffer = new uint8_t[sizeof(PalmFeatureHeader) + feature.feature.size()];
auto header = reinterpret_cast<PalmFeatureHeader *>(buffer);
header->userid = htons(userid);
header->featureTotalSize = htons(static_cast<uint16_t>(feature.feature.size()));
strncpy(reinterpret_cast<char *>(header->username), feature.username.c_str(), sizeof(header->username));
mbedtls_md5_context context;
mbedtls_md5_init(&context);
mbedtls_md5_starts(&context);
uint8_t md5[16];
mbedtls_md5_update(&context, feature.feature.data(), feature.feature.size());
mbedtls_md5_finish(&context, md5);
mbedtls_md5_free(&context);
memcpy(header->featureDataMd5, md5, sizeof(header->featureDataMd5));
memcpy(buffer + sizeof(PalmFeatureHeader), feature.feature.data(), feature.feature.size());
auto [frameData, frameSize] = generateFrame(
RegisterPalmFeature, buffer, static_cast<uint16_t>(sizeof(PalmFeatureHeader) + feature.feature.size()));
m_serialPort->write(reinterpret_cast<const char *>(frameData), frameSize);
LOG_CAT(info, GUI) << "发送注册掌静脉特征指令: " << protocolDataFormatString(frameData, frameSize);
LOG_CAT(info, GUI) << Separator;
if (buffer != nullptr) delete[] buffer;
}
void ModuleCommunication::uploadImageInfo(const UploadImageInformation &info) {
UploadImageInformation request;
request.operation = info.operation;
@ -288,29 +252,6 @@ void ModuleCommunication::processPackage(const uint8_t *data, uint16_t size) {
}
break;
}
case RequestPalmFeature: {
LOG_CAT(info, GUI) << "模组: " << protocolDataFormatString(data, size);
if (result == Success) {
auto info = reinterpret_cast<const PalmFeatureHeader *>(data + 7);
LOG_CAT(info, GUI) << "用户ID: " << ntohs(info->userid)
<< ", 用户名: " << std::string_view(reinterpret_cast<const char *>(info->username))
<< ", 特征值长度: " << ntohs(info->featureTotalSize);
PalmFeature feature;
feature.username = std::string_view(reinterpret_cast<const char *>(info->username));
feature.feature = std::vector<uint8_t>(info->feature, info->feature + ntohs(info->featureTotalSize));
emit newPalmFeature(feature);
}
LOG_CAT(info, GUI) << Separator;
break;
}
case RegisterPalmFeature: {
LOG_CAT(info, GUI) << "模组: " << protocolDataFormatString(data, size);
if (result == Success) {
LOG_CAT(info, GUI) << "掌静脉特征值注册成功。";
}
LOG_CAT(info, GUI) << Separator;
break;
}
case UploadImageInfo: {
break;
}

View File

@ -30,8 +30,6 @@ public:
GetUniqueID = 0xAC,
UploadImageInfo = 0xF6,
UploadImageData = 0xF7,
RegisterPalmFeature = 0xF9,
RequestPalmFeature = 0xFA,
Idle = 0xFF,
};
Q_ENUM(MessageId)
@ -80,7 +78,6 @@ public:
};
struct EnrollData {
uint8_t admin = 0;
uint8_t username[32];
uint8_t skipSave = 0;
uint8_t timeout;
@ -112,19 +109,9 @@ public:
struct VerifyDataReply {
uint16_t userid;
uint8_t username[UsernameSize]; // 32Bytes
uint8_t admin;
uint16_t elapsed; // 此时识别耗时时间
};
struct PalmFeatureHeader {
uint16_t userid; // 用户ID
uint8_t username[32]; // 用户姓名
uint8_t admin; // 是否管理员YES1 NO:0
uint8_t featureDataMd5[16]; // 整体特征数据的MD5值
uint16_t featureTotalSize; // 特征数据总长度
uint8_t feature[0];
};
struct UploadImageInformation {
uint8_t operation; // 0:图片录入掌静脉
uint8_t format; // 0: 灰度图(纯Y分量)
@ -159,9 +146,6 @@ public:
Q_INVOKABLE void requestUniqueId();
void requestEnrolledImage(uint32_t offset, uint32_t size);
void requestPalmFeature(uint16_t userid);
void enrollPalmFeature(uint16_t userid, const PalmFeature &feature);
void uploadImageInfo(const UploadImageInformation &info);
void uploadImageData(uint32_t offset, const uint8_t *data, uint32_t size);
Q_INVOKABLE void requestCurrentStatus();

View File

@ -264,7 +264,6 @@ void Widget::onRequestPalmFeatureButtonClicked() {
auto module = Amass::Singleton<Application>::instance()->module();
if (!module) return;
auto id = m_palmFeatureEdit->text().toInt();
module->requestPalmFeature(id);
}
void Widget::onRegisterPalmFeatureButtonClicked() {
@ -275,7 +274,6 @@ void Widget::onRegisterPalmFeatureButtonClicked() {
// LOG(error) << "feature is empty.";
// return;
// }
// module->enrollPalmFeature(264, features.at(0));
}
void Widget::onResetButtonClicked() {

View File

@ -57,7 +57,20 @@ HOST_TOOLS := /opt/Xuantie-900-gcc-elf-newlib-x86_64-V2.6.1/bin
```shell
./rebuild-app.sh y L015 V200 R002 # 编译烧录固件
./rebuild-app-ota.sh y L015 V200 R002 13 # 编译OTA固件11为OTA版本号
./rebuild-app-ota.sh y L015 V200 R002 14 # 编译OTA固件11为OTA版本号
600X800
```
# Flash设置
```
__FLASH_16MB__
cv181x_alios/boards/cv181xc_qfn/configs/config.yaml
cv181x_alios/boards/cv181xc_qfn/configs/partition_alios_spinor.xml
cv181x_alios/solutions/smart_doorbell/face_lock_app/flash-part.h
```