# 2.0版本mesh单板AT指令配置
# 注意：HW2.0 MESH设备的AT指令集与其他板子类型（如HW2.0 Star、HW2.0 Star 2W600）不同
# 请勿混用不同板子类型的AT指令
# 主要区别：
# 1. AT^DSONSCAP命令格式不同：
#    - HW2.0 MESH: 查询返回 ^DSONSCAP: <mode>,<type>，设置格式 AT^DSONSCAP=<mode> [,<type>]
#    - HW2.0 Star: 查询返回单参数，设置格式 AT^DSONSCAP=<mode>
# 2. HW2.0 MESH设备不支持AT^DSONSCF和AT^DSONMIMOF命令
# 3. 其他命令格式可能也有差异，请参考各板子类型的专用配置
board_type: "2.0_mesh"
description: "2.0版本mesh单板AT指令集（HW2.0 MESH专用，与其他板子类型不兼容）"
version: "2.0"

commands:
  # 基础功能命令
  get_device_info:
    at_command: "AT^DGMR?"
    description: "查询本端版本信息"
    response_format: "text"

  get_ip_address:
    at_command: "AT^DUIP?"
    description: "查询本端IP地址信息"
    response_format: "text"

  # 设备功能控制
  set_phone_functionality:
    at_command: "AT+CFUN=%d"
    description: "设置MT功能等级"
    parameters:
      - name: "fun"
        type: "int"
        values: [0, 1]
        description: "0:关机, 1:开机"

  get_phone_functionality:
    at_command: "AT+CFUN?"
    description: "查询MT功能等级"
    response_format: "text"

  # 接入状态配置
  get_access_state:
    at_command: "AT^DACS?"
    description: "获取接入状态上报开关"
    response_format: "text"

  set_access_state:
    at_command: "AT^DACS=%d"
    description: "设置接入状态上报"
    parameters:
      - name: "n"
        type: "int"
        values: [0, 1, 2]
        description: "0:关闭, 1:开启, 2:WEBUI上报"

  # 无线参数配置
  get_radio_params:
    at_command: "AT^DRPS?"
    description: "获取无线参数配置（非Accessed状态使用）"
    response_format: "text"

  get_radio_params_current:
    at_command: "AT^DRPC?"
    description: "获取当前无线参数配置（Accessed状态使用）"
    response_format: "text"

  set_radio_params:
    at_command: "AT^DRPC=%s,%s,%s"
    description: "设置无线参数（实时配置，不持久化）"
    parameters:
      - name: "freq"
        type: "string"
        description: "频点频率(100KHz)，留空表示不修改：','"
        optional: true
      - name: "bandwidth"
        type: "string"
        description: "带宽(0:1.4M, 1:3M, 2:5M, 3:10M, 4:15M, 5:20M)，留空表示不修改"
        optional: true
      - name: "cellid"
        type: "string"
        description: "物理小区ID(0:主小区, 1:辅小区)，仅在CA模式下需要，留空表示不指定"
        optional: true

  # 网络接口配置
  get_network_config:
    at_command: "AT^NETIFCFG?"
    description: "获取网络接口配置"
    response_format: "text"

  set_network_config:
    at_command: "AT^NETIFCFG=%d,\"%s\",\"%s\",\"%s\""
    description: "设置网络接口配置"
    parameters:
      - name: "type"
        type: "int"
        values: [2, 3, 4]
        description: "2:IP, 3:IP+MASK, 4:IP+MASK+GATEWAY"
      - name: "master_ip"
        type: "string"
        description: "主IP地址"
      - name: "sub_mask"
        type: "string"
        description: "子网掩码"
      - name: "gateway"
        type: "string"
        description: "网关地址"

  # 接入密钥配置
  get_access_password:
    at_command: "AT^DAPI?"
    description: "获取接入密钥"
    response_format: "text"

  set_encryption_key:
    at_command: "AT^DAPI=\"%s\""
    description: "设置加密密钥"
    parameters:
      - name: "key"
        type: "string"
        description: "加密密钥(十六进制格式, 最长64字符)"

  # 无线参数存储
  get_radio_params_store:
    at_command: "AT^DRPS?"
    description: "获取存储的无线参数"
    response_format: "text"

  set_radio_params_store:
    at_command: "AT^DRPS=%d,%d,\"%s\",%d"
    description: "存储无线参数到NVRAM"
    parameters:
      - name: "freq"
        type: "int"
        description: "频点频率(100KHz)"
      - name: "bandwidth"
        type: "int"
        description: "带宽(0:1.4M, 1:3M, 2:5M, 3:10M, 4:15M, 5:20M)"
      - name: "power"
        type: "string"
        description: "发射功率(dBm), 范围-40到40"
      - name: "cellid"
        type: "int"
        values: [0, 1]
        description: "物理小区ID(0:主小区, 1:辅小区)"

  # 无线参数上报
  get_radio_param_report:
    at_command: "AT^DRPR?"
    description: "获取无线参数上报状态"
    response_format: "text"

  set_radio_param_report:
    at_command: "AT^DRPR=%d"
    description: "设置无线参数上报"
    parameters:
      - name: "n"
        type: "int"
        values: [0, 1, 2]
        description: "0:关闭, 1:开启, 2:WEBUI上报"

  # 频段配置
  get_band_config:
    at_command: "AT^DAOCNDI?"
    description: "获取用户频段配置"
    response_format: "text"

  set_band_config:
    at_command: "AT^DAOCNDI=%s,%s"
    description: "设置用户频段配置"
    parameters:
      - name: "pcell_band_bitmap"
        type: "string"
        description: "主小区频段位图(十六进制)"
      - name: "scell_band_bitmap"
        type: "string"
        description: "辅小区频段位图(十六进制)"

  # MIMO模式频段配置
  set_band_config_mimo:
    at_command: "AT^DAOCNDI=%s;+CFUN=0;+CFUN=1"
    description: "设置MIMO模式频段配置（单通道）"
    parameters:
      - name: "band_bitmap"
        type: "string"
        description: "频段位图(十六进制)，MIMO模式下主辅通道使用相同配置"

  # 设备类型配置
  get_device_type:
    at_command: "AT^DDTC?"
    description: "获取设备类型配置"
    response_format: "text"

  set_device_type:
    at_command: "AT^DDTC=%d"
    description: "设置设备类型"
    parameters:
      - name: "type"
        type: "int"
        values: [0, 1, 2]
        description: "0:自组网节点, 1:中心节点, 2:接入节点"

  # 加密算法配置
  get_encryption_algorithm:
    at_command: "AT^DCIAC?"
    description: "获取加密算法配置"
    response_format: "text"

  set_encryption_algorithm:
    at_command: "AT^DCIAC=%d"
    description: "设置加密算法"
    parameters:
      - name: "algorithm"
        type: "int"
        values: [0, 1, 2, 3]
        description: "加密算法(0:无加密, 1:SNOW, 2:AES, 3:ZUC)"

  # 跳频控制
  get_frequency_hopping:
    at_command: "AT^DFHC?"
    description: "获取跳频控制状态"
    response_format: "text"

  set_frequency_hopping:
    at_command: "AT^DFHC=%d"
    description: "设置跳频控制"
    parameters:
      - name: "n"
        type: "int"
        values: [0, 1]
        description: "0:关闭跳频, 1:开启跳频"

  # 可达节点查询
  get_accessible_nodes:
    at_command: "AT^DIPAN"
    description: "获取所有可达节点IP地址列表"
    response_format: "text"

  # UART波特率配置
  get_uart_baud_rate:
    at_command: "AT^DUBR?"
    description: "获取UART波特率配置"
    response_format: "text"

  set_uart_baud_rate:
    at_command: "AT^DUBR=%d"
    description: "设置UART波特率"
    parameters:
      - name: "rate"
        type: "int"
        values: [1200, 2400, 4800, 9600, 19200, 28800, 38400, 57600, 76800, 115200, 230400, 460800, 921600, 1152000, 2304000, 3750000, 4000000]
        description: "波特率"

  # 路由信息上报
  get_route_info_report:
    at_command: "AT^DSONRIRPT?"
    description: "获取路由信息上报开关"
    response_format: "text"

  set_route_info_report:
    at_command: "AT^DSONRIRPT=%d"
    description: "设置路由信息上报"
    parameters:
      - name: "operation_type"
        type: "int"
        values: [0, 1, 2]
        description: "0:关闭, 1:开启, 2:查询"

  # 固定路由管理
  set_fixed_route:
    at_command: "AT^DSONRICFG=%d,%s,%s"
    description: "设置固定路由"
    parameters:
      - name: "op"
        type: "int"
        values: [0, 1, 2, 3]
        description: "0:增加路由, 1:删除路由, 2:删除全部路由, 3:删除全部路由并清空"
      - name: "dst_sn"
        type: "string"
        description: "目的节点SN(7位16进制)"
      - name: "nxt_sn"
        type: "string"
        description: "下一跳节点SN(7位16进制)"

  # 主控节点信息
  get_master_node_info:
    at_command: "AT^DSONMIRPT?"
    description: "获取主控节点信息上报开关"
    response_format: "text"

  set_master_node_info:
    at_command: "AT^DSONMIRPT=%d"
    description: "设置主控节点信息上报"
    parameters:
      - name: "n"
        type: "int"
        values: [0, 1, 2]
        description: "0:关闭, 1:开启, 2:查询"

  # 在网节点IP查询
  get_network_nodes_ip:
    at_command: "AT^DSONIPNN?"
    description: "获取在网节点IP查询开关"
    response_format: "text"

  set_network_nodes_ip:
    at_command: "AT^DSONIPNN=%d"
    description: "设置在网节点IP查询"
    parameters:
      - name: "mode"
        type: "int"
        values: [0, 1, 2, 3]
        description: "查询模式"

  # CA MIMO能力配置
  # 注意：HW2.0 MESH设备的AT^DSONSCAP命令格式与其他板子类型不同
  # 查询命令返回格式：^DSONSCAP: <mode>,<type>
  #   <mode>: 0=不支持CA MIMO, 1=支持CA, 2=支持MIMO
  #   <type>: 0=本节点, 1=全网
  # 设置命令格式：AT^DSONSCAP=<mode> [,<type>]
  #   如果省略type参数，默认为本节点(0)
  #   设置后需要重启生效（进出飞行设置生效）
  get_ca_mimo_capability:
    at_command: "AT^DSONSCAP?"
    description: "获取CA MIMO能力配置（HW2.0 MESH专用格式：返回mode,type）"
    response_format: "text"
    response_parser: "mesh_2.0_ca_mimo"
    notes: "响应格式：^DSONSCAP: <mode>,<type>，mode=0不支持, mode=1支持CA, mode=2支持MIMO"

  set_ca_mimo_capability:
    at_command: "AT^DSONSCAP=%d,%d;+CFUN=0;+CFUN=1"
    description: "设置CA/MIMO能力配置（HW2.0 MESH专用格式：需要mode和type参数，设置后重启生效）"
    parameters:
      - name: "mode"
        type: "int"
        values: [0, 1, 2]
        description: "模式(0:不支持CA MIMO, 1:支持CA, 2:支持MIMO)"
      - name: "type"
        type: "int"
        values: [0, 1]
        description: "操作对象(0:本节点, 1:全网)。type=1时，节点入网后才能设置，且所有节点一起断网再重新入网"

  # 锁频配置
  get_lock_frequency:
    at_command: "AT^DLF?"
    description: "获取锁频配置"
    response_format: "text"

  set_lock_frequency:
    at_command: "AT^DLF=%d,%d,%d"
    description: "设置锁频配置"
    parameters:
      - name: "lock_type"
        type: "int"
        values: [0, 1]
        description: "0:不锁频, 1:锁定指定频点"
      - name: "pcell_freq"
        type: "int"
        description: "主小区频点(100KHz)"
      - name: "scell_freq"
        type: "int"
        description: "辅小区频点(100KHz)"

  # 子频段范围配置
  get_sub_band_range:
    at_command: "AT^DSONSBR?"
    description: "获取子频段范围配置"
    response_format: "text"

  set_sub_band_range:
    at_command: "AT^DSONSBR=%d,%d,%d"
    description: "设置子频段范围"
    parameters:
      - name: "band"
        type: "int"
        values: [64, 65, 66, 67, 69, 70, 71, 73]
        description: "子频段编号"
      - name: "earfcn_start"
        type: "int"
        description: "起始频点号"
      - name: "earfcn_end"
        type: "int"
        description: "结束频点号"

  # 1.4GHz频段子频段范围配置 (BAND66: 14200-15300)
  get_1_4g_sub_band_range:
    at_command: "AT^DSONSBR?"
    description: "获取1.4GHz子频段范围配置"
    response_format: "text"

  set_1_4g_sub_band_range:
    at_command: "AT^DSONSBR=66,%d,%d"
    description: "设置1.4GHz子频段范围"
    parameters:
      - name: "earfcn_start"
        type: "int"
        description: "起始频点号(14200-15300)"
      - name: "earfcn_end"
        type: "int"
        description: "结束频点号(14200-15300)"

  # 600MHz频段子频段范围配置 (BAND71: 5660-6780)
  get_600m_sub_band_range:
    at_command: "AT^DSONSBR?"
    description: "获取600MHz子频段范围配置"
    response_format: "text"

  set_600m_sub_band_range:
    at_command: "AT^DSONSBR=71,%d,%d"
    description: "设置600MHz子频段范围"
    parameters:
      - name: "earfcn_start"
        type: "int"
        description: "起始频点号(5660-6780)"
      - name: "earfcn_end"
        type: "int"
        description: "结束频点号(5660-6780)"

  # 固定功率配置
  get_fixed_tx_power:
    at_command: "AT^DSONSFTP?"
    description: "获取固定功率配置"
    response_format: "text"

  set_fixed_tx_power:
    at_command: "AT^DSONSFTP=%d,\"%s\",%d"
    description: "设置固定功率"
    parameters:
      - name: "mode"
        type: "int"
        values: [0, 1]
        description: "0:关闭固定功率, 1:开启固定功率"
      - name: "power"
        type: "string"
        description: "固定功率值(dBm), 范围-40到20"
      - name: "cellid"
        type: "int"
        values: [0, 1]
        description: "0:主小区, 1:辅小区（CA模式必须设置，非CA模式不能设置）"

  # 连续无线信号长发配置
  get_continuous_tx:
    at_command: "AT^DSONCTX?"
    description: "获取连续无线信号长发配置"
    response_format: "text"

  set_continuous_tx:
    at_command: "AT^DSONCTX=%d,%d,%d,\"%s\",%d,%d"
    description: "设置连续无线信号长发"
    parameters:
      - name: "mode"
        type: "int"
        values: [0, 1]
        description: "0:关闭长发, 1:开启长发"
      - name: "freq"
        type: "int"
        description: "频点频率(100KHz)"
      - name: "bandwidth"
        type: "int"
        description: "带宽"
      - name: "power"
        type: "string"
        description: "功率(dBm)"
      - name: "tx_mode"
        type: "int"
        values: [0, 1]
        description: "发送方式(0:单天线, 1:双天线)"
      - name: "single_tone"
        type: "int"
        values: [0, 1]
        description: "单音方式(0:调制, 1:单音)"

  # ELog功能配置
  get_elog_function:
    at_command: "AT^ELFUN?"
    description: "获取ELog功能配置"
    response_format: "text"

  set_elog_function:
    at_command: "AT^ELFUN=%d"
    description: "设置ELog功能"
    parameters:
      - name: "mode"
        type: "int"
        values: [0, 1]
        description: "0:关闭ELog, 1:开启ELog"

  # APLog功能配置
  get_aplog_function:
    at_command: "AT^APLFUN?"
    description: "获取APLog功能配置"
    response_format: "text"

  set_aplog_function:
    at_command: "AT^APLFUN=%d"
    description: "设置APLog功能"
    parameters:
      - name: "n"
        type: "int"
        values: [0, 1]
        description: "0:关闭APLog, 1:开启APLog"

  # 终端类型设置
  get_ue_type:
    at_command: "AT^DSONUETS?"
    description: "获取终端类型"
    response_format: "text"

  set_ue_type:
    at_command: "AT^DSONUETS=%d"
    description: "设置终端类型"
    parameters:
      - name: "type"
        type: "int"
        values: [0, 1]
        description: "0:一般终端, 1:手持终端"

  # 系统控制命令
  reboot_device:
    at_command: "AT^POWERCTL=1"
    description: "重启设备"

  restore_factory_settings:
    at_command: "AT^RECOVSET=1"
    description: "恢复出厂设置"

  # 注意：HW2.0 MESH设备不支持AT^DSONSCF命令
  # AT^DSONSCF命令仅用于HW2.0 Star和HW2.0 Star 2W600设备
  # HW2.0 MESH设备通过AT^DSONSCAP命令的mode参数来设置CA/MIMO模式
  # mode=1表示支持CA，mode=2表示支持MIMO




  # 从节点最大发射功率设置
  get_slave_max_tx_power:
    at_command: "AT^DSSMTP?"
    description: "获取从节点最大发射功率"
    response_format: "text"

  set_slave_max_tx_power:
    at_command: "AT^DSSMTP=\"%s\",\"%s\""
    description: "设置从节点最大发射功率"
    parameters:
      - name: "power"
        type: "string"
        description: "从节点pcell最大发射功率(dBm)"
      - name: "scell_power"
        type: "string"
        description: "从节点scell最大发射功率(dBm)"

  # 自动组网配置设备信息
  get_auto_org_net_device_info:
    at_command: "AT^DAOCNDI?"
    description: "获取自动组网配置设备信息"
    response_format: "text"

  set_auto_org_net_device_info:
    at_command: "AT^DAOCNDI=%s,%s"
    description: "设置自动组网配置设备信息"
    parameters:
      - name: "pcell_band_bitmap"
        type: "string"
        description: "主小区频段位图(十六进制)"
      - name: "scell_band_bitmap"
        type: "string"
        description: "辅小区频段位图(十六进制)" 