board_type: "board_fpga"
description: "FPGA自组网模块 指令/接口映射（基于 HTTP /config 与 /status）"
version: "fpga_1.0"

# 说明：为了复用现有指令发送/同步框架，定义若干“伪命令”名称，
# 同步流程中会按 get_* 名称触发，我们在 DeviceCommService 中对 board_fpga 特殊处理，
# 经由 HTTP GET /config 和 /status 拉取配置与状态，并写回数据库。

commands:
  # 基本信息
  get_device_info:
    at_command: "HTTP_GET /version"
    description: "读取版本信息 (HTML 文本)"
    response_format: "text"

  # IP与网络配置（从 /config 读取/写入）
  get_network_config:
    at_command: "HTTP_GET /config"
    description: "读取配置参数（一次性返回全量配置）"
    response_format: "json"

  set_network_config:
    at_command: "HTTP_POST /config"
    description: "写入配置参数（可部分字段）"
    parameters:
      - name: "config_json"
        type: "json"

  # 状态信息（从 /status 读取）
  get_status:
    at_command: "HTTP_GET /status"
    description: "获取状态信息（一次性返回全量状态）"
    response_format: "json"

  # 高级状态（/statusadvanced）
  get_status_advanced:
    at_command: "HTTP_GET /statusadvanced"
    description: "获取高级状态参数（捕获数、误码率、频偏、各子带SNR、字节统计等）"
    response_format: "json"

  # 噪声强度（/spectrum）
  get_noise_spectrum:
    at_command: "HTTP_GET /spectrum"
    description: "获取当前环境噪声强度（与freqList对齐的rssi数据）"
    response_format: "json"

  # 版本（/version）
  get_version:
    at_command: "HTTP_GET /version"
    description: "获取软件版本，形如 X.X.X-rcXX-HQ-MXXXX"
    response_format: "text"

  # 设备升级（/upload + /update）
  upload_file:
    at_command: "HTTP_POST_MULTIPART /upload"
    description: "上传升级包、license或设备类型更新文件，成功返回OK"
    parameters:
      - name: "file"
        type: "file"
  trigger_update:
    at_command: "HTTP_GET /update"
    description: "触发升级，成功返回OK"
    response_format: "text"

  # 发现（UDP 7005 广播/应答）- 仅标注占位
  discover_broadcast:
    at_command: "UDP_BROADCAST 255.255.255.255:7005"
    description: "发送设备查找请求 {device:'mesh', method:'discover'}（占位，需外部实现UDP）"
    parameters:
      - name: "payload"
        type: "json"
  discover_response:
    at_command: "UDP_RESPONSE <client_ip>:<client_port>"
    description: "设备查找应答 {device:'mesh', method:'response', ipAddr, nwMask}（占位）"
    parameters:
      - name: "payload"
        type: "json"

  # 配置字段说明（通过 /config 读写，下列字段为常见关键项，写入时按需选择）
  set_config_fields:
    at_command: "HTTP_POST /config"
    description: "按需写入部分配置字段（将以下字段组合为JSON提交）"
    parameters:
      - name: "freqMode"
        type: "string"
        values: ["single", "roaming", "hop", "smart", "smartAdvanced", "adaptiveHopping"]
      - name: "freqList"
        type: "array:number"
        description: "工作频率列表，单位Hz，范围70000000~6000000000"
      - name: "freqDefault"
        type: "number"
        description: "freqList中的索引，作为缺省工作频率"
      - name: "span"
        type: "enum:number"
        values: [0,1,2,3,4,5,6,7,8,9,10,11]
        description: "带宽：0(2.5M),1(5M),2(10M),3(20M),4(10/20/40M),5(40M),6(300K),7(30M),8(1.25M),9(250K),10(500K),11(1M)"
      - name: "pwAtten1"
        type: "number"
        description: "天线1发射功率衰减 0~89 dB"
      - name: "pwAtten2"
        type: "number"
        description: "天线2发射功率衰减 0~89 dB"
      - name: "meshName"
        type: "string"
      - name: "id"
        type: "number"
      - name: "name"
        type: "string"
      - name: "ip"
        type: "string"
      - name: "nwMask"
        type: "string"
      - name: "rangeMode"
        type: "string"
        description: "字符串数值，表示公里数上限，例如 '10'"
      - name: "gateway"
        type: "string"
      - name: "infrastructureMode"
        type: "boolean"
      - name: "uartMode0"
        type: "enum:number"
        values: [0,1,2,3,4,5,6,7,8]
      - name: "uartBaudrate0"
        type: "number"
      - name: "uartIp0"
        type: "string"
      - name: "uartPort0"
        type: "number"
      - name: "uartMode1"
        type: "enum:number"
        values: [0,1,2,3,4,5,6,7,8]
      - name: "uartBaudrate1"
        type: "number"
      - name: "uartIp1"
        type: "string"
      - name: "uartMode2"
        type: "enum:number"
        values: [0,1,2,3,4,5,6,7,8]
      - name: "uartBaudrate2"
        type: "number"
      - name: "uartIp2"
        type: "string"
      - name: "ipBroadcastWhitelist"
        type: "array:object"
        description: "成员: {port:number, priority:0|1}"
      - name: "ipMulticastFilterMode"
        type: "number"
        values: [0,1,2]
      - name: "ipMulticastWhitelist"
        type: "array:object"
        description: "成员: {address:string, priority:number, dataRate:number, maxHopCount:number}"
      - name: "ipMulticastBlacklist"
        type: "array:object"
        description: "成员: {address:string}"
      - name: "rfDisable"
        type: "number"
        description: "射频通道禁用位图 0~3"
      - name: "linkSnrThreshold"
        type: "number"
        description: "链路SNR过滤门限 -10~30 dB"
      - name: "netIfConfig"
        type: "array:object"
        description: "网络接口配置，成员: {name, mode, ip, nwMask, gateway, hardwareChecksum}"
      - name: "bootSystemIndex"
        type: "number"
      - name: "stdmaMode"
        type: "number"
        values: [0,1]
      - name: "enableHeterogeneousNetwork"
        type: "boolean"
      - name: "configGlobal"
        type: "boolean"


