in src/Covi/Features/BluetoothTracing/DeviceManager/Internal/DefaultDeviceManager.cs [324:365]
public void HandleDeviceCommunicationDiscoveredCharacteristicRead(DeviceDescriptor descriptor, byte[] payload, Action<DeviceDescriptor> onNext = null)
{
try
{
if (_discoveredDevices.TryGetValue(descriptor.Identifier, out var deviceDescriptor))
{
try
{
if (PayloadFormatter.TryGetValue(payload, out var packageData))
{
_logger.LogDebug(
$"DeviceManager - Characteristic read - processing. id: {descriptor.Identifier}.");
deviceDescriptor.Context = descriptor.Context;
var contact = new ContactDescriptor(packageData.DeviceId, DateTime.UtcNow);
DeviceProcessorProvider.GetInstance().Process(contact);
Monitor.Enter(deviceDescriptor.ProcessingLock);
try
{
deviceDescriptor.Processed = true;
}
finally
{
Monitor.Exit(deviceDescriptor.ProcessingLock);
}
}
}
catch (Exception ex)
{
_logger.LogError(ex, $"DeviceManager - Characteristic read - Processing failed. id: {deviceDescriptor.Identifier}.");
}
// Disconnect peripheral
onNext?.Invoke(deviceDescriptor);
}
}
catch (Exception ex)
{
_logger.LogError(ex,
$"DeviceManager - Characteristic read - Processing failed. id: {descriptor.Identifier}. Reason: {ex.Message}.");
}
}