/**
 * LED双色屏JSON通信格式定义
 * WEB/串口 => 设备，为请求格式
 * 设备 => WEB/串口，为响应格式
 */

// ======================== 平台上升 ========================
const platformUpRequest = {
  "board_id": 1,
  "JSON_id": 1,
  "gateway": {
    "platform": {
      "action": "up"
    }
  }
};

const platformUpResponse = {
  "JSON_id": 1,
  "gateway": {
    "platform": {
      "return": 0
    }
  },
  "error_code": 0
};

// ======================== 平台下降 ========================
const platformDownRequest = {
  "board_id": 1,
  "JSON_id": 1,
  "gateway": {
    "platform": {
      "action": "down"
    }
  }
};

const platformDownResponse = {
  "JSON_id": 1,
  "gateway": {
    "platform": {
      "return": 0
    }
  },
  "error_code": 0
};

// ======================== 屏幕开关 ========================
const screenOnRequest = {
  "board_id": 1,
  "JSON_id": 1,
  "gateway": {
    "screen": {
      "power": "on"
    }
  }
};

const screenOnResponse = {
  "JSON_id": 1,
  "gateway": {
    "screen": {
      "return": 0
    }
  },
  "error_code": 0
};

const screenOffRequest = {
  "board_id": 1,
  "JSON_id": 1,
  "gateway": {
    "screen": {
      "power": "off"
    }
  }
};

const screenOffResponse = {
  "JSON_id": 1,
  "gateway": {
    "screen": {
      "return": 0
    }
  },
  "error_code": 0
};

// ======================== 灯光模式 ========================
const lightModeRequest = {
  "board_id": 1,
  "JSON_id": 1,
  "gateway": {
    "light": {
      "mode": 1 // 模式编号，1-n
    }
  }
};

const lightModeResponse = {
  "JSON_id": 1,
  "gateway": {
    "light": {
      "return": 0
    }
  },
  "error_code": 0
};

// ======================== 单个灯控制 ========================
// 这里以灯1开启为例，其他灯位可以修改id值(1-6)
const light1OnRequest = {
  "board_id": 1,
  "JSON_id": 1,
  "gateway": {
    "light": {
      "id": 1,
      "status": "on"
    }
  }
};

const light1OnResponse = {
  "JSON_id": 1,
  "gateway": {
    "light": {
      "return": 0
    }
  },
  "error_code": 0
};

const light1OffRequest = {
  "board_id": 1,
  "JSON_id": 1,
  "gateway": {
    "light": {
      "id": 1,
      "status": "off"
    }
  }
};

const light1OffResponse = {
  "JSON_id": 1,
  "gateway": {
    "light": {
      "return": 0
    }
  },
  "error_code": 0
};

// ======================== 亮度调节 ========================
const setBrightnessRequest = {
  "board_id": 1,
  "JSON_id": 1,
  "gateway": {
    "screen": {
      "brightness": 80 // 亮度值，0-100
    }
  }
};

const setBrightnessResponse = {
  "JSON_id": 1,
  "gateway": {
    "screen": {
      "return": 0
    }
  },
  "error_code": 0
};

// ======================== 节目切换 ========================
const switchProgramRequest = {
  "board_id": 1,
  "JSON_id": 1,
  "gateway": {
    "program": {
      "id": 2 // 节目编号
    }
  }
};

const switchProgramResponse = {
  "JSON_id": 1,
  "gateway": {
    "program": {
      "return": 0
    }
  },
  "error_code": 0
};

// ======================== 设备登录 ========================
const loginRequest = {
  "board_id": 1,
  "JSON_id": 1,
  "gateway": {
    "log_in": {
      "type": 2,
      "pass": "#输入密码#"
    }
  }
};

const loginResponse = {
  "JSON_id": 1,
  "gateway": {
    "log_in": {
      "return": 0
    }
  },
  "error_code": 0
};

// ======================== 修改设备密码 ========================
const changePasswordRequest = {
  "board_id": 1,
  "JSON_id": 1,
  "gateway": {
    "log_in": {
      "type": 2,
      "pass": "#输入密码#",
      "new_pass": "#新密码#"
    }
  }
};

const changePasswordResponse = {
  "JSON_id": 1,
  "gateway": {
    "log_in": {
      "return": 0
    }
  },
  "error_code": 0
};

// ======================== 获取设备状态 ========================
const getStatusRequest = {
  "board_id": 1,
  "JSON_id": 1,
  "gateway": {
    "status": {
      "query": "all"
    }
  }
};

const getStatusResponse = {
  "JSON_id": 1,
  "gateway": {
    "status": {
      "platform": "up", // up/down
      "screen": {
        "power": "on", // on/off
        "brightness": 80
      },
      "light": {
        "mode": 1,
        "lights": [
          {"id": 1, "status": "on"},
          {"id": 2, "status": "off"},
          {"id": 3, "status": "on"},
          {"id": 4, "status": "off"},
          {"id": 5, "status": "on"},
          {"id": 6, "status": "off"}
        ]
      },
      "program": {
        "current": 2,
        "total": 5
      }
    }
  },
  "error_code": 0
};

