{
  "schema_version": 1,
  "diagram_type": "sequence",
  "meta": {
    "title": "设备下行：App 控制到腾讯 IoT 受理",
    "locale": "zh-CN",
    "quality_profile": "showcase",
    "column_fit": "spread",
    "viewBox": [
      1360,
      600
    ]
  },
  "participants": [
    {
      "id": "app",
      "type": "frontend",
      "label": "App"
    },
    {
      "id": "gateway",
      "type": "backend",
      "label": "gateway"
    },
    {
      "id": "device",
      "type": "backend",
      "label": "device"
    },
    {
      "id": "redis",
      "type": "database",
      "label": "Redis"
    },
    {
      "id": "iot",
      "type": "cloud",
      "label": "腾讯 IoT"
    },
    {
      "id": "hardware",
      "type": "external",
      "label": "设备"
    }
  ],
  "messages": [
    {
      "id": "downlink-control_1",
      "from": "app",
      "to": "gateway",
      "y": 160,
      "label": "HTTP 控制请求",
      "variant": "emphasis"
    },
    {
      "id": "downlink-control_2",
      "from": "gateway",
      "to": "device",
      "y": 190,
      "label": "路由至控制接口",
      "variant": "default"
    },
    {
      "id": "downlink-control_3",
      "from": "device",
      "to": "redis",
      "y": 220,
      "label": "读取 JWT 登录态",
      "variant": "security"
    },
    {
      "id": "downlink-control_4",
      "from": "device",
      "to": "redis",
      "y": 250,
      "label": "接口多级限流",
      "variant": "default"
    },
    {
      "id": "downlink-control_5",
      "from": "device",
      "to": "redis",
      "y": 280,
      "label": "归属缓存（条件）",
      "variant": "security"
    },
    {
      "id": "downlink-control_6",
      "from": "device",
      "to": "redis",
      "y": 310,
      "label": "设备级令牌",
      "variant": "default"
    },
    {
      "id": "downlink-control_8",
      "from": "device",
      "to": "redis",
      "y": 340,
      "label": "IoT API 配额",
      "variant": "default"
    },
    {
      "id": "downlink-control_9",
      "from": "device",
      "to": "iot",
      "y": 370,
      "label": "编码协议帧 → PublishMessage",
      "variant": "emphasis"
    },
    {
      "id": "downlink-control_10",
      "from": "iot",
      "to": "device",
      "y": 400,
      "label": "云端受理返回",
      "variant": "return"
    },
    {
      "id": "downlink-control_11",
      "from": "device",
      "to": "gateway",
      "y": 430,
      "label": "AjaxResult",
      "variant": "return"
    },
    {
      "id": "downlink-control_12",
      "from": "gateway",
      "to": "app",
      "y": 460,
      "label": "HTTP 业务响应",
      "variant": "return"
    },
    {
      "id": "downlink-control_13",
      "from": "iot",
      "to": "hardware",
      "y": 490,
      "label": "QoS 1 下发",
      "variant": "dashed"
    }
  ],
  "cards": [
    {
      "dot": "cyan",
      "title": "调用与路由",
      "items": [
        "示例为 /api/hand/sitReminderSwitch；身份校验在 device 的公共过滤器，不逐次调用 identity。"
      ]
    },
    {
      "dot": "amber",
      "title": "成功的含义",
      "items": [
        "普通控制业务成功表示 SDK 发布正常返回；HTTP 200 还需检查业务码。云端受理不等于硬件执行完成。"
      ]
    },
    {
      "dot": "rose",
      "title": "现有边界",
      "items": [
        "归属校验可读缓存/数据库，也有旁路；设备令牌通过后校验编码。MQTT 与 HTTP 返回可并行，无下行 Stream。"
      ]
    }
  ]
}
