Closed Thembelani closed 1 year ago
Hi @Thembelani,
When you say the guid is not set I am not sure I follow. Do you mean that you are not able to access the guid with e.value.guid
? If you are passing the capture event in deviceRemoval
to _closeDeviceHelper
then it should be accessible.
Do you have a logger? If so, what does it print for logger.log('Device ${isManager ? 'Manager' : ''} Removal =>', name + ' ($guid)');
? If not, try adding one and then share the information in the logger.
Please let us know if the issue persists!
Hi @mcsocket The is my code vs the output.
P.S. Thank you for helping me with this issue.
Hi @mcsocket
This issue arises when we pair a device that we do not open immediately with the following.
dynamic res = await scanner.capture.openDevice(scanner.guid, _capture);
or we close a device with the following.
dynamic res = await scanner.capture.close();
In both cases, when the device shuts off and deviceRemoval event is fired, e.value.guid returns an empty string.
If we have a system where more than one device is paired, we should be open and close them while they are still paired.
I'll have to double check but I think that's expected. When a device is not open in Capture, you will receive a device removal to indicate it's gone, but the guid would be null.
Hi.
I am successfully receiving the deviceRemoval event however the guid is not set.
Future<void> _closeDeviceHelper(e, handle) async { String guid = e.value.guid; String name = e.value.name; logger.log('Device Removal =>', name + ' ($guid)'); try { dynamic res = await _deviceCapture!.close(); if (res == 0) { List<DeviceInfo> arr = _devices; arr.removeWhere((element) => element.guid == guid); setState(() { _devices = arr; _currentScan = null; _deviceCapture = null; }); } _updateVals('Device Closed', 'Successfully removed "$name"'); } on CaptureException catch (exception) { _updateVals('${exception.code}', 'Unable to remove "$name"', exception.method, exception.details); } }