uploadImage method

Future<void> uploadImage(
  1. int image,
  2. List<int> data,
  3. List<int> hash,
  4. Duration chunkTimeout, {
  5. int chunkSize = 128,
  6. void onProgress(
    1. int
    )?,
  7. int windowSize = 3,
})

Uploads an image to the device.

image is the type of the image (usually 0). The data will be sent to the device in chunks. Use McuImage.decode to obtain the hash.

If specified, onProgress will be called after each uploaded chunk. Its parameter is the number bytes uploaded so far.

windowSize is the maximum number of in-flight chunks. Defaults to 3. Use 1 for no concurrency (send packet, wait for response, send next).

Implementation

Future<void> uploadImage(
  int image,
  List<int> data,
  List<int> hash,
  Duration chunkTimeout, {
  int chunkSize = 128,
  void Function(int)? onProgress,
  int windowSize = 3,
}) async {
  final upload = _ImageUpload(
    client: this,
    image: image,
    data: data,
    hash: hash,
    chunkTimeout: chunkTimeout,
    maxChunkSize: chunkSize,
    onProgress: onProgress,
    windowSize: windowSize,
  );
  upload.start();
  return upload.completer.future;
}