public async Task <USBDevice> RequestDevice(USBDeviceRequestOptions options = null) { var internalOptions = new _USBDeviceRequestOptions(); if (options != null) { internalOptions.filters = options.Filters.Select(f => new _USBDeviceFilter { classCode = f.ClassCode, productId = f.ProductId, protocolCode = f.ProtocolCode, serialNumber = f.SerialNumber, subClassCode = f.SubClassCode, vendorId = f.VendorId }).ToList(); } else { internalOptions.filters = _emptyFilters; } USBDevice device = null; try { device = await JSRuntime.Current.InvokeAsync <USBDevice>(REQUEST_DEVICE_METHOD, internalOptions); } catch (Exception ex) { Console.WriteLine(ex.GetBaseException().Message); } return(device); }
public async Task <USBDevice> RequestDevice(USBDeviceRequestOptions options = null) { try { if (options == null) { options = new USBDeviceRequestOptions { Filters = _emptyFilters } } ; var device = await JSRuntime.Current.InvokeAsync <USBDevice>(REQUEST_DEVICE_METHOD, options); device.AttachUSB(this); return(device); } catch (JSException) { return(null); } }