setAlarmMotion method

Future<bool> setAlarmMotion(
  1. int motion_push_plan_enable, {
  2. int timeout = 5,
})

设置报警计划 command == 2 报警计划

Implementation

Future<bool> setAlarmMotion(int motion_push_plan_enable,
    {int timeout = 5}) async {
  bool ret = await writeCgi(
      "trans_cmd_string.cgi?cmd=2017&command=2&mark=10672216&motion_push_plan1=0&motion_push_plan2=0&motion_push_plan3=0&motion_push_plan4=0&motion_push_plan5=0&motion_push_plan6=0&motion_push_plan7=0&motion_push_plan8=0&motion_push_plan9=0&motion_push_plan10=0&motion_push_plan11=0&motion_push_plan12=0&motion_push_plan13=0&motion_push_plan14=0&motion_push_plan15=0&motion_push_plan16=0&motion_push_plan17=0&motion_push_plan18=0&motion_push_plan19=0&motion_push_plan20=0&motion_push_plan21=0&motion_push_plan_enable=$motion_push_plan_enable&",
      timeout: timeout);
  if (ret) {
    CommandResult result = await waitCommandResult((int cmd, Uint8List data) {
      if (cmd == 24785) {
        String str = utf8.decode(data);
        return str.contains("cmd=2017;") && str.contains("command=2;");
      }
      return false;
    }, timeout);
    if (result.isSuccess) {
      Map data = result.getMap();
      if (data["motion_push_enable"] == "0") {
        pirPushEnable = false;
      } else if (data["motion_push_enable"] == "1") {
        pirPushEnable = true;
      }

      return true;
    }
  }
  return false;
}