feat: 完善机巢任务安全控制与状态诊断
同步新版飞控与 WebSocket 回执合同,完善独立指令等待、暂停继续和返航状态;增加真机诊断并优化倒计时与素材库展示。
This commit is contained in:
@@ -10,6 +10,7 @@ enum DroneDockShootingSocketMessage {
|
||||
case opened
|
||||
case subscribed(taskID: Int, hasSnapshot: Bool)
|
||||
case snapshot(DroneDockShootingResponse)
|
||||
case subscriptionRejected(code: Int, message: String)
|
||||
case rejected(code: Int, message: String)
|
||||
case unrelated
|
||||
|
||||
@@ -24,9 +25,16 @@ enum DroneDockShootingSocketMessage {
|
||||
guard let root = json as? [String: Any],
|
||||
let code = root["code"] as? Int else { throw APIError.invalidResponse }
|
||||
if code != 100000 {
|
||||
return .rejected(code: code, message: root["msg"] as? String ?? "任务订阅失败")
|
||||
let message = root["msg"] as? String ?? "任务订阅失败"
|
||||
if let body = root["data"] as? [String: Any],
|
||||
body["type"] as? Int == 310, body["subscribed"] as? Bool == false {
|
||||
return .subscriptionRejected(code: code, message: message)
|
||||
}
|
||||
return .rejected(code: code, message: message)
|
||||
}
|
||||
guard let body = root["data"] as? [String: Any] else { throw APIError.invalidResponse }
|
||||
// 链路就绪和 310 已入站仅供诊断,不能替代正式订阅结果,即使误带了订阅字段。
|
||||
if let ack = body["ack"] as? String, ack == "ready" || ack == "received" { return .unrelated }
|
||||
if let subscribed = body["subscribed"] as? Bool, subscribed {
|
||||
guard let id = body["order_flight_task_id"] as? Int,
|
||||
let hasSnapshot = body["has_snapshot"] as? Bool else { throw APIError.invalidResponse }
|
||||
|
||||
Reference in New Issue
Block a user