getSnapshot method

Future<File?> getSnapshot(
  1. String name, {
  2. int timeout = 5,
})

获取截图快照

Implementation

Future<File?> getSnapshot(String name, {int timeout = 5}) async {
  int time = DateTime.now().millisecondsSinceEpoch;
  bool ret = await _command.writeCgi("snapshot.cgi?sensor=${name}&",
      timeout: timeout);
  if (ret) {
    CommandResult result =
        await _command.waitCommandResult((int cmd, Uint8List data) {
      return cmd == 24597;
    }, timeout);
    if (result.isSuccess && result.data != null && result.data!.length > 0) {
      return await _saveSnapshotFile(result.data!, '${time}${"_"}{$name}');
    }
  }
  return null;
}