/// <summary> /// Monitors the current device SessionStatus until a non-Open session status is returned. Once this has occured, /// the device has become disconnected and should render all state as such. /// </summary> private void MonitorDeviceSession() { if (Application.isEditor) { return; } string errorMessage = string.Empty; SessionStatus sessionStatus = (SessionStatus)GetSessionStatus(ref errorMessage); if (sessionStatus != SessionStatus.Open) { if (string.IsNullOrEmpty(errorMessage)) { Debug.Log(WearableConstants.DEVICE_CONNECTION_MONITOR_WARNING); } else { Debug.LogFormat(WearableConstants.DEVICE_CONNECTION_MONITOR_WARNING_WITH_MESSAGE, errorMessage); } if (_connectedDevice != null) { OnConnectionStatusChanged(Wearable.ConnectionStatus.Disconnected, _connectedDevice); } _config.DisableAllSensors(); _config.DisableAllGestures(); StopDeviceMonitor(); _connectedDevice = null; } }
static WearableConstants() { // Ensure that empty frame has a valid rotation quaternion EMPTY_FRAME = new SensorFrame { rotationNineDof = new SensorQuaternion { value = Quaternion.identity }, rotationSixDof = new SensorQuaternion { value = Quaternion.identity } }; CONNECTING_STATES = new List <ConnectionStatus> { ConnectionStatus.FirmwareUpdateRequired, ConnectionStatus.FirmwareUpdateAvailable, ConnectionStatus.Connecting, ConnectionStatus.AutoReconnect, ConnectionStatus.SecurePairingRequired }; EMPTY_DEVICE_LIST = new Device[0]; GESTURE_IDS = (GestureId[])Enum.GetValues(typeof(GestureId)); SENSOR_IDS = (SensorId[])Enum.GetValues(typeof(SensorId)); UPDATE_INTERVALS = (SensorUpdateInterval[])Enum.GetValues(typeof(SensorUpdateInterval)); SIGNAL_STRENGTHS = (SignalStrength[])Enum.GetValues(typeof(SignalStrength)); ACTIVE_NOISE_REDUCTION_MODES = (ActiveNoiseReductionMode[])Enum.GetValues(typeof(ActiveNoiseReductionMode)); EMPTY_ACTIVE_NOISE_REDUCTION_MODES = new ActiveNoiseReductionMode[0]; DEVICE_STATUS_FLAGS = (DeviceStatusFlags[])Enum.GetValues(typeof(DeviceStatusFlags)); OS_PERMISSIONS = (OSPermission[])Enum.GetValues(typeof(OSPermission)); OS_SERVICES = (OSService[])Enum.GetValues(typeof(OSService)); DISABLED_DEVICE_CONFIG = new WearableDeviceConfig(); DISABLED_DEVICE_CONFIG.DisableAllSensors(); DISABLED_DEVICE_CONFIG.DisableAllGestures(); #pragma warning disable 618 DISALLOWED_EDITOR_PROVIDERS = new[] { ProviderId.BluetoothProvider }; DISALLOWED_RUNTIME_PROVIDERS = new[] { ProviderId.USBProvider }; #pragma warning restore 618 DEBUG_PROVIDER_DEFAULT_AVAILABLE_ANR_MODES = new[] { ActiveNoiseReductionMode.Off, ActiveNoiseReductionMode.Low, ActiveNoiseReductionMode.High }; EMPTY_DEVICE_STATUS = new DeviceStatus(); EMPTY_DYNAMIC_DEVICE_INFO = new DynamicDeviceInfo { transmissionPeriod = -1, activeNoiseReductionMode = ActiveNoiseReductionMode.Invalid, availableActiveNoiseReductionModes = WearableTools.GetActiveNoiseReductionModesAsInt(EMPTY_ACTIVE_NOISE_REDUCTION_MODES), controllableNoiseCancellationLevel = 0, controllableNoiseCancellationEnabled = false, totalControllableNoiseCancellationLevels = 0 }; }
/// <summary> /// Monitors the current device SessionStatus until a non-Open session status is returned. Once this has occured, /// the device has become disconnected and should render all state as such. /// </summary> private void MonitorDeviceSession() { #if UNITY_EDITOR if (_sessionStatus != SessionStatus.Open) { if (string.IsNullOrEmpty(_statusMessage.ToString())) { Debug.Log(WearableConstants.DeviceConnectionMonitorWarning); } else { Debug.LogFormat(WearableConstants.DeviceConnectionMonitorWarningWithMessage, _statusMessage); } if (_connectedDevice != null) { OnConnectionStatusChanged(ConnectionStatus.Disconnected, _connectedDevice); } _config.DisableAllSensors(); _config.DisableAllGestures(); StopDeviceMonitor(); _connectedDevice = null; } #endif // UNITY_EDITOR }
/// <summary> /// Monitors the current device SessionStatus until a non-Open session status is returned. Once this has occured, /// the device has become disconnected and should render all state as such. /// </summary> private void MonitorDeviceSession() { #if UNITY_EDITOR if (_sessionStatus != SessionStatus.Open) { if (string.IsNullOrEmpty(_statusMessage.ToString())) { Debug.Log(WearableConstants.DEVICE_CONNECTION_MONITOR_WARNING); } else { Debug.LogFormat(WearableConstants.DEVICE_CONNECTION_MONITOR_WARNING_WITH_MESSAGE, _statusMessage); } if (_connectedDevice != null) { OnConnectionStatusChanged(ConnectionStatus.Disconnected, _connectedDevice); } _config.DisableAllSensors(); _config.DisableAllGestures(); StopDeviceMonitor(); _connectedDevice = null; } #endif // UNITY_EDITOR }
static WearableConstants() { // Ensure that empty frame has a valid rotation quaternion EmptyFrame = new SensorFrame { rotationNineDof = new SensorQuaternion { value = Quaternion.identity }, rotationSixDof = new SensorQuaternion { value = Quaternion.identity } }; ConnectingStates = new List <ConnectionStatus> { ConnectionStatus.FirmwareUpdateRequired, ConnectionStatus.FirmwareUpdateAvailable, ConnectionStatus.Connecting, ConnectionStatus.AutoReconnect, ConnectionStatus.SecurePairingRequired }; EmptyDeviceList = new Device[0]; EmptyLayoutOptions = new GUILayoutOption[0]; GestureIds = (GestureId[])Enum.GetValues(typeof(GestureId)); SensorIds = (SensorId[])Enum.GetValues(typeof(SensorId)); UpdateIntervals = (SensorUpdateInterval[])Enum.GetValues(typeof(SensorUpdateInterval)); SignalStrengths = (SignalStrength[])Enum.GetValues(typeof(SignalStrength)); DisabledDeviceConfig = new WearableDeviceConfig(); DisabledDeviceConfig.DisableAllSensors(); DisabledDeviceConfig.DisableAllGestures(); #pragma warning disable 618 DisallowedEditorProviders = new[] { ProviderId.MobileProvider, ProviderId.WearableDevice }; DisallowedRuntimeProviders = new[] { ProviderId.MobileProvider, ProviderId.USBProvider }; #pragma warning restore 618 EmptyDeviceStatus = new DeviceStatus(); EmptyDynamicDeviceInfo = new DynamicDeviceInfo { transmissionPeriod = -1 }; }