getPirDetection method

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

人体侦测等级 关-----0 低-----1 中-----2 高-----3

Implementation

Future<bool> getPirDetection({int timeout = 5}) async {
  bool ret = await writeCgi(
      "trans_cmd_string.cgi?cmd=2106&command=3&mark=12345678&",
      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=3;");
      }
      return false;
    }, timeout);
    if (result.isSuccess) {
      Map data = result.getMap();
      pirDetection = int.tryParse(data["humanDetection"] ?? "") ?? 0;
      pirLevel = int.tryParse(data["humanDetection"] ?? "") ?? 0;
      distanceAdjust = int.tryParse(data["DistanceAdjust"] ?? "") ?? 0;
      humanoidDetection = int.tryParse(data["HumanoidDetection"] ?? "") ?? 0;
      return data["result"] == "0";
    }
  }
  return false;
}