/// <summary> /// Checks the device for dynamic data changes during a session. /// </summary> private void MonitorDynamicDeviceInfo() { if (!_connectedDevice.HasValue) { return; } Device device = _connectedDevice.Value; Device lastDevice = device; DynamicDeviceInfo dynamicDeviceInfo = GetDynamicDeviceInfo(); // Copy dynamic info to the device struct, then update the provider's device. // Do this at the beginning so any callbacks invoked will have up-to-date info available. device.SetDynamicInfo(dynamicDeviceInfo); _connectedDevice = device; // Calculate incoming outgoing events DeviceStatus deviceStatus = device.deviceStatus; DeviceStatus risingEvents = deviceStatus.GetRisingEdges(lastDevice.deviceStatus); DeviceStatus fallingEvents = deviceStatus.GetFallingEdges(lastDevice.deviceStatus); // Service suspended/resumes if (risingEvents.GetFlagValue(DeviceStatusFlags.SensorServiceSuspended)) { SensorServiceSuspendedReason reason = deviceStatus.GetServiceSuspendedReason(); if (SensorServiceSuspended != null) { SensorServiceSuspended.Invoke(reason); } } if (fallingEvents.GetFlagValue(DeviceStatusFlags.SensorServiceSuspended)) { if (SensorServiceResumed != null) { SensorServiceResumed.Invoke(); } } // ANR state changed if (lastDevice.activeNoiseReductionMode != device.activeNoiseReductionMode) { if (ActiveNoiseReductionModeChanged != null) { ActiveNoiseReductionModeChanged.Invoke(device.activeNoiseReductionMode); } } // CNC state changed if ((lastDevice.controllableNoiseCancellationLevel != device.controllableNoiseCancellationLevel) || (lastDevice.controllableNoiseCancellationEnabled != device.controllableNoiseCancellationEnabled)) { if (ControllableNoiseCancellationInfoChanged != null) { ControllableNoiseCancellationInfoChanged.Invoke( device.controllableNoiseCancellationLevel, device.controllableNoiseCancellationEnabled); } } }