This commit is contained in:
flower_linux
2026-05-19 16:42:01 +08:00
parent 238b814057
commit fcafa81db1
21 changed files with 224 additions and 43 deletions

View File

@@ -80,6 +80,7 @@
| `list_edge_sessions` | 无 | `0` | - | 返回边缘 TCP 会话 `sessions``edgeId`/`helloOk`/`peer` |
| `get_edge_tree_revision` | 无 | `0` | - | 返回 `treeRevision`(与边缘 `CTRL_TREE_PROPOSE` 乐观锁对齐) |
| `push_edge_tree` | `edgeId` | `0` | `4000`/`4047`/`5003`/`5005` | 向已 HELLO 的会话下行 `TREE_FULL`;成功返回 `sent``treeRevision`;无在线会话 `no_active_session`ingress 未启用 `edge_ingress_disabled` |
| `edge_debug_send` | `edgeId`;可选 `debug`object若省略则将 `params` 去掉 `edgeId` 作为 body | `0` | `4000`/`4047`/`5003`/`5005` | 向已 HELLO 会话下行 **`DEBUG_TUNNEL`**UTF-8 JSON成功返回 `sent`;载荷过大 `debug_payload_too_large`;见 `docs/EDGE_UPLINK_PROTOCOL_v1.md` §10 |
| edge TCP`TREE_PROPOSE` | JSON`edgeId``baseTreeRevision``entries` | - | `CONFLICT`/`FORBIDDEN_SCOPE` 等 | 与 D-Bus 共用 `DeviceTreeModel::applyEdgePropose``entries` 支持 `op` 省略/`patch`**`op: upsert`**(边缘子树内新增或整节点合并),见 `docs/EDGE_UPLINK_PROTOCOL_v1.md` §6 |
| `get_plugins` | 无 | `0` | - | 合并 protocol/framer/mapper 插件列表 |
| `get_plugins_protocols` | 无 | `0` | - | `protocols` |

View File

@@ -406,6 +406,40 @@ DispatchResult CommandDispatcher::dispatch(const QString& action, const QJsonObj
{QStringLiteral("sent"), sent},
{QStringLiteral("treeRevision"), rev}}};
}
if (action == QStringLiteral("edge_debug_send")) {
const QString edgeId = params.value(QStringLiteral("edgeId")).toString();
if (edgeId.isEmpty()) {
return {4000, QStringLiteral("missing_edgeId"), {}};
}
QJsonObject dbg = params.value(QStringLiteral("debug")).toObject();
if (dbg.isEmpty()) {
dbg = params;
dbg.remove(QStringLiteral("edgeId"));
}
QJsonObject envelope;
envelope.insert(QStringLiteral("v"), 1);
envelope.insert(QStringLiteral("from"), QStringLiteral("host"));
envelope.insert(QStringLiteral("tsMs"), QDateTime::currentMSecsSinceEpoch());
envelope.insert(QStringLiteral("body"), dbg);
int sent = 0;
QString err;
const bool ok = softbus::device_bus::DeviceBus::instance().pushEdgeDebugDownlink(edgeId, envelope, &sent, &err);
if (!ok) {
int code = 5003;
if (err == QStringLiteral("no_active_session")) {
code = 4047;
} else if (err == QStringLiteral("missing_edgeId")) {
code = 4000;
} else if (err == QStringLiteral("edge_ingress_disabled") || err == QStringLiteral("edge_ingress_unavailable")) {
code = 5005;
} else if (err == QStringLiteral("debug_payload_too_large")) {
code = 4000;
}
return {code, err, QJsonObject{{QStringLiteral("edgeId"), edgeId}}};
}
return {0, QStringLiteral("ok"), QJsonObject{{QStringLiteral("edgeId"), edgeId}, {QStringLiteral("sent"), sent}}};
}
if (action == QStringLiteral("list_devices")) {
const auto devices = softbus::device_bus::DeviceBus::instance().listDevices();
QJsonArray arr;