openDevice method

Future openDevice(
  1. String guid,
  2. Capture? capture
)

Initiate connection to open physical device. Set new root capture in order to work within device ecosystem. If successful, set clientOrDeviceHandle to response value and return code for 'no error' (0).

Implementation

Future openDevice(String guid, Capture? capture) async {
  if (capture == null) {
    throw CaptureException(SktErrors.ESKT_INVALIDPARAMETER,
        'The provided parameter is invalid', 'NO CAPTURE INSTANCE');
  } else {
    this.rootCapture = capture;
    this.transport = capture.transport;
    this.transportHandle = capture.transportHandle;
    try {
      dynamic value = await this
          .transport
          ?.openDevice(this.rootCapture!.clientOrDeviceHandle, guid);
      this.clientOrDeviceHandle = value;
      return SktErrors.ESKT_NOERROR;
    } on CaptureException {
      rethrow;
    } catch (e) {
      throw CaptureException(SktErrors.ESKT_COMMUNICATIONERROR, 'There was an error during communication.', e.toString());
    }
  }
}