getAlarmParam method

Future<bool> getAlarmParam({
  1. int timeout = 5,
})

Implementation

Future<bool> getAlarmParam({int timeout = 5}) async {
  bool ret = await writeCgi("trans_cmd_string.cgi?cmd=2106&command=8&",
      timeout: timeout);
  if (ret) {
    CommandResult result = await waitCommandResult((int cmd, Uint8List data) {
      if (cmd == 24785) {
        String str = utf8.decode(data);
        return str.contains("cmd=2106;") && str.contains("command=8;");
      }
      return false;
    }, timeout);
    if (result.isSuccess) {
      Map data = result.getMap();
      pirPushEnable = data["pirPushSwitch"] == "1";
      pirPushVideoEnable = data["pirPushSwitchVideo"] == "1";
      if (data.containsKey("CloudVideoDuration")) {
        pirCloudVideoDuration =
            int.tryParse(data["CloudVideoDuration" ?? "15"]) ?? -1;
      } else {
        pirCloudVideoDuration = -1;
      }
      if (data.containsKey("autoRecordMode")) {
        autoRecordVideoMode =
            int.tryParse(data["autoRecordMode" ?? "0"]) ?? 0;
      } else {
        autoRecordVideoMode = 0;
      }
      await getPirDetection();
      return data["result"] == "0";
    }
  }
  return false;
}