修改台账更新和添加升级接口

This commit is contained in:
lnk
2026-05-08 09:55:34 +08:00
parent 10a24450c7
commit f879978e62
7 changed files with 128 additions and 16 deletions

View File

@@ -103,6 +103,10 @@ static std::map<std::string, RunningInformation> g_runninginfo_cache;
static std::mutex g_versioninfo_cache_mtx;
static std::map<std::string, DeviceVersionInfo> g_versioninfo_cache;
//装置升级
std::map<std::string, std::string> g_upgrade_file_map;
std::mutex g_upgrade_file_mutex;
//补招
std::list<JournalRecall> g_StatisticLackList; //日志补招结构类链表
std::mutex g_StatisticLackList_list_mutex; //补招队列数据锁
@@ -1641,12 +1645,12 @@ void parse_terminal_from_data(trigger_update_xml_t& trigger_update_xml,
//work_terminal.dev_key = get_value("devKey");
//work_terminal.dev_series = get_value("series");
work_terminal.processNo = get_value("processNo");
//work_terminal.addr_str = get_value("ip");
work_terminal.addr_str = get_value("ip");
//work_terminal.port = get_value("port");
//work_terminal.timestamp = get_value("updateTime");
work_terminal.Righttime = get_value("Righttime");
work_terminal.mac = get_value("mac");
work_terminal.mac = get_value("ip");
for (tinyxml2::XMLElement* monitor = root->FirstChildElement("monitorData");
monitor;
@@ -6594,8 +6598,43 @@ void on_device_response_minimal(int response_code,
try {
if(dev->isbusy == 2){
//获取升级文件
std::string file_path;
{
std::lock_guard<std::mutex> lk(g_upgrade_file_mutex);
auto it = g_upgrade_file_map.find(dev->terminal_id);
if (it != g_upgrade_file_map.end()) {
file_path = it->second;
}
}
if (file_path.empty()) {
std::cerr << "upgrade file not found for devid=" << dev->terminal_id << std::endl;
send_reply_to_cloud(static_cast<int>(ResponseCode::NOT_FOUND), id, device_state_int, dev->guid, dev->mac);
dev->guid.clear();
dev->busytype = 0;
dev->isbusy = 0;
dev->busytimecount = 0;
return;
}
std::cout << "upgrade file path=" << file_path << std::endl;
// 读取升级文件
std::vector<unsigned char> file_data = read_file_as_bytes("pqs_arm2.bin");
std::vector<unsigned char> file_data = read_file_as_bytes(file_path);
if (file_data.empty()) {
std::cerr << "read file failed: " << file_path << std::endl;
send_reply_to_cloud(static_cast<int>(ResponseCode::NOT_FOUND), id, device_state_int, dev->guid, dev->mac);
dev->guid.clear();
dev->busytype = 0;
dev->isbusy = 0;
dev->busytimecount = 0;
return;
}
std::cout << "file size=" << file_data.size() << std::endl;
// 下发升级指令
ClientManager::instance().send_upgrade_action_to_device(id, file_data, 10240);