controlPrivacyPosStatus method

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

Implementation

Future<bool> controlPrivacyPosStatus(bool value, {int timeout = 5}) async {
  var switchValue = value ? '1' : '3';
  bool ret = await _command.writeCgi(
      "trans_cmd_string.cgi?cmd=2013&command=1&posturn=$switchValue&",
      timeout: timeout);

  if (ret) {
    CommandResult result =
        await _command.waitCommandResult((int cmd, Uint8List data) {
      if (cmd == 24785) {
        String str = utf8.decode(data);
        return str.contains("cmd=2013;") && str.contains("command=1;");
      }
      return false;
    }, timeout);
    if (result.isSuccess == true) {
      Map data = result.getMap();
      return data["result"] == "0";
    }
  }
  return false;
}