fix cloudtopic msg proc
This commit is contained in:
@@ -2073,6 +2073,9 @@ void process_received_message(string mac, string id,const char* data, size_t len
|
||||
//设置装置对时(主动对时)
|
||||
if (udata[8] == static_cast<unsigned char>(MsgResponseType::Response_NewACK)) {
|
||||
std::cout << "set success" << mac << std::endl;
|
||||
|
||||
on_device_response_minimal(static_cast<int>(ResponseCode::OK), id, 0, static_cast<int>(DeviceState::SET_RIGHTTIME_2));
|
||||
|
||||
//对时设置成功,调整为空闲,处理后续工作。
|
||||
ClientManager::instance().change_device_state(id, DeviceState::IDLE);
|
||||
}
|
||||
@@ -2082,11 +2085,13 @@ void process_received_message(string mac, string id,const char* data, size_t len
|
||||
std::cout << "reason code: " << static_cast<int>(udata[8]) << "-" << static_cast<int>(udata[9]) << "-" << static_cast<int>(udata[10]) << "-" << static_cast<int>(udata[11]) << std::endl;
|
||||
|
||||
// 装置否定应答,对时设置失败
|
||||
on_device_response_minimal(static_cast<int>(ResponseCode::BAD_REQUEST), id, 0, static_cast<int>(DeviceState::SET_RIGHTTIME_2));
|
||||
// 设置对时失败,调整为空闲状态,处理下一项工作。
|
||||
ClientManager::instance().change_device_state(id, DeviceState::IDLE);
|
||||
}
|
||||
else {
|
||||
// 装置答非所问异常
|
||||
on_device_response_minimal(static_cast<int>(ResponseCode::INTERNAL_ERROR), id, 0, static_cast<int>(DeviceState::SET_RIGHTTIME_2));
|
||||
// 设置对时失败,调整为空闲状态,处理下一项工作。
|
||||
ClientManager::instance().change_device_state(id, DeviceState::IDLE);
|
||||
}
|
||||
@@ -2347,6 +2352,7 @@ void process_received_message(string mac, string id,const char* data, size_t len
|
||||
}
|
||||
else {
|
||||
std::cout << "***ctrl fail" << mac << std::endl;
|
||||
on_device_response_minimal(static_cast<int>(ResponseCode::UNAUTHORIZED), id, 0, static_cast<int>(DeviceState::SET_CTRL));
|
||||
//控制命令校验不合法,调整为空闲,处理后续工作。
|
||||
ClientManager::instance().change_device_state(id, DeviceState::IDLE);
|
||||
}
|
||||
@@ -2354,15 +2360,19 @@ void process_received_message(string mac, string id,const char* data, size_t len
|
||||
else if (udata[8] == static_cast<unsigned char>(MsgResponseType::Response_NewACK)) {
|
||||
std::cout << "***ctrl success" << mac << std::endl;
|
||||
//控制命令执行完毕,调整为空闲,处理后续工作。
|
||||
on_device_response_minimal(static_cast<int>(ResponseCode::OK), id, 0, static_cast<int>(DeviceState::SET_CTRL));
|
||||
|
||||
ClientManager::instance().change_device_state(id, DeviceState::IDLE);
|
||||
}
|
||||
else if (udata[8] == static_cast<unsigned char>(MsgResponseType::Response_NewNACK)) {
|
||||
std::cout << "***ctrl fail" << mac << std::endl;
|
||||
//控制命令执行失败,调整为空闲,处理后续工作。
|
||||
on_device_response_minimal(static_cast<int>(ResponseCode::BAD_REQUEST), id, 0, static_cast<int>(DeviceState::SET_CTRL));
|
||||
ClientManager::instance().change_device_state(id, DeviceState::IDLE);
|
||||
}
|
||||
else {
|
||||
// 装置答非所问异常
|
||||
on_device_response_minimal(static_cast<int>(ResponseCode::INTERNAL_ERROR), id, 0, static_cast<int>(DeviceState::SET_CTRL));
|
||||
// 控制命令失败,调整为空闲状态,处理下一项工作。
|
||||
ClientManager::instance().change_device_state(id, DeviceState::IDLE);
|
||||
}
|
||||
@@ -2445,15 +2455,19 @@ void process_received_message(string mac, string id,const char* data, size_t len
|
||||
if (generatedCrc != crc) {
|
||||
//crc 校验失败 后续升级停止!
|
||||
std::cerr << "CRC verify failed." << std::endl;
|
||||
on_device_response_minimal(static_cast<int>(ResponseCode::UNAUTHORIZED), id, 0, static_cast<int>(DeviceState::SET_PREUPGRADE));
|
||||
ClientManager::instance().change_device_state(id, DeviceState::IDLE);
|
||||
break;
|
||||
}
|
||||
|
||||
on_device_response_minimal(static_cast<int>(ResponseCode::OK), id, 0, static_cast<int>(DeviceState::SET_PREUPGRADE));
|
||||
|
||||
// 预升级校验结束成功,调整为空闲,处理后续工作。
|
||||
ClientManager::instance().change_device_state(id, DeviceState::IDLE);
|
||||
}
|
||||
else {
|
||||
// 装置答非所问异常
|
||||
on_device_response_minimal(static_cast<int>(ResponseCode::INTERNAL_ERROR), id, 0, static_cast<int>(DeviceState::SET_PREUPGRADE));
|
||||
// 预升级校验失败,调整为空闲状态,处理下一项工作。
|
||||
ClientManager::instance().change_device_state(id, DeviceState::IDLE);
|
||||
}
|
||||
@@ -2474,23 +2488,33 @@ void process_received_message(string mac, string id,const char* data, size_t len
|
||||
//接收文件错误!
|
||||
std::cout << "*** upgrade 0x02 fail ***!" << mac << std::endl;
|
||||
// 升级流程失败,调整为空闲状态,处理下一项工作。
|
||||
|
||||
on_device_response_minimal(static_cast<int>(ResponseCode::NOT_FOUND), id, 0, static_cast<int>(DeviceState::SET_PREUPGRADE));
|
||||
|
||||
ClientManager::instance().change_device_state(id, DeviceState::IDLE);
|
||||
}
|
||||
else if (udata[9] == 0x55) {
|
||||
//升级流程成功,等候装置重启
|
||||
std::cout << "*** upgrade 0x55 success ***!" << mac << std::endl;
|
||||
// 升级流程失败,调整为空闲状态,处理下一项工作。
|
||||
// 升级流程成功,调整为空闲状态,处理下一项工作。
|
||||
|
||||
on_device_response_minimal(static_cast<int>(ResponseCode::OK), id, 0, static_cast<int>(DeviceState::SET_PREUPGRADE));
|
||||
|
||||
ClientManager::instance().change_device_state(id, DeviceState::IDLE);
|
||||
}
|
||||
else if (udata[9] == 0xAA) {
|
||||
// 升级流程失败!
|
||||
std::cout << "*** upgrade 0xAA fail ***!" << mac << std::endl;
|
||||
// 升级流程失败,调整为空闲状态,处理下一项工作。
|
||||
|
||||
on_device_response_minimal(static_cast<int>(ResponseCode::BAD_REQUEST), id, 0, static_cast<int>(DeviceState::SET_PREUPGRADE));
|
||||
|
||||
ClientManager::instance().change_device_state(id, DeviceState::IDLE);
|
||||
}
|
||||
else {
|
||||
std::cout << "*** upgrade ?? error ***!" << mac << std::endl;
|
||||
// 升级流程失败,调整为空闲状态,处理下一项工作。
|
||||
on_device_response_minimal(static_cast<int>(ResponseCode::INTERNAL_ERROR), id, 0, static_cast<int>(DeviceState::SET_PREUPGRADE));
|
||||
ClientManager::instance().change_device_state(id, DeviceState::IDLE);
|
||||
}
|
||||
}
|
||||
@@ -2511,6 +2535,7 @@ void process_received_message(string mac, string id,const char* data, size_t len
|
||||
if (!ok) {
|
||||
//组装后续升级报文时出现异常,无法发送后续帧文件
|
||||
std::cout << "获取下一帧失败\n";
|
||||
on_device_response_minimal(static_cast<int>(ResponseCode::NOT_FOUND), id, 0, static_cast<int>(DeviceState::SET_UPGRADE));
|
||||
ClientManager::instance().change_device_state(id, DeviceState::IDLE);
|
||||
}
|
||||
else if (!packet.empty()) {
|
||||
@@ -2532,18 +2557,21 @@ void process_received_message(string mac, string id,const char* data, size_t len
|
||||
else {
|
||||
// 理论上不该走到这里,防御处理
|
||||
std::cout << "未获取到有效升级报文\n";
|
||||
on_device_response_minimal(static_cast<int>(ResponseCode::INTERNAL_ERROR), id, 0, static_cast<int>(DeviceState::SET_UPGRADE));
|
||||
ClientManager::instance().change_device_state(id, DeviceState::IDLE);
|
||||
}
|
||||
}
|
||||
else if (udata[8] == static_cast<unsigned char>(MsgResponseType::Response_NewNACK)) {
|
||||
std::cout << "*** upgrade 0x41 fail ***!" << mac << std::endl;
|
||||
// 升级流程失败,调整为空闲状态,处理下一项工作。
|
||||
on_device_response_minimal(static_cast<int>(ResponseCode::BAD_REQUEST), id, 0, static_cast<int>(DeviceState::SET_PREUPGRADE));
|
||||
ClientManager::instance().change_device_state(id, DeviceState::IDLE);
|
||||
}
|
||||
else {
|
||||
// 装置答非所问异常
|
||||
std::cout << "*** upgrade ?? fail ***!" << mac << std::endl;
|
||||
// 升级流程失败,调整为空闲状态,处理下一项工作。
|
||||
on_device_response_minimal(static_cast<int>(ResponseCode::INTERNAL_ERROR), id, 0, static_cast<int>(DeviceState::SET_UPGRADE));
|
||||
ClientManager::instance().change_device_state(id, DeviceState::IDLE);
|
||||
}
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user