/// <Docs>GATT client</Docs> /// <summary> /// Raises the connection state change event. /// </summary> /// <param name="gatt">Gatt.</param> /// <param name="status">Status.</param> /// <param name="newState">New state.</param> public override void OnConnectionStateChange(BluetoothGatt gatt, GattStatus status, ProfileState newState) { base.OnConnectionStateChange(gatt, status, newState); if (status != GattStatus.Success) return; var device = new Device(gatt.Device, gatt, this, 0, null); switch (newState) { case ProfileState.Disconnected: device.State = DeviceState.Disconnected; try { gatt.Close(); gatt = null; } catch (Exception ex) { Debug.WriteLine("Unable to close connection to gatt. Exception: {0}", ex.Message); } finally { DeviceDisconnected(this, new DeviceConnectionEventArgs(device)); } break; case ProfileState.Connected: device.State = DeviceState.Connected; DeviceConnected(this, new DeviceConnectionEventArgs(device)); break; } }
public override void OnConnectionStateChange (BluetoothGatt gatt, GattStatus status, ProfileState newState) { Console.WriteLine ("OnConnectionStateChange: "); base.OnConnectionStateChange (gatt, status, newState); //TODO: need to pull the cached RSSI in here, or read it (requires the callback) Device device = new Device (gatt.Device, gatt, this, 0); switch (newState) { // disconnected case ProfileState.Disconnected: Console.WriteLine ("disconnected"); this.DeviceDisconnected (this, new DeviceConnectionEventArgs () { Device = device }); break; // connecting case ProfileState.Connecting: Console.WriteLine ("Connecting"); break; // connected case ProfileState.Connected: Console.WriteLine ("Connected"); this.DeviceConnected (this, new DeviceConnectionEventArgs () { Device = device }); break; // disconnecting case ProfileState.Disconnecting: Console.WriteLine ("Disconnecting"); break; } }
/// <summary> /// Creates a new Instance of the CS Profile. Values are editable and can be commited by calling Save(); /// </summary> /// <param name="username"></param> public Profile(ProfileBase pb) { //Profile Base does not have any data unitl a value is first accessed. //So we need to store the profile base instead of SettingsPropertyValueCollection profilebase = pb; state = ProfileState.ReadWrite; }
private void OnConnectionChanged(ProfileState profileState) { DialogView.CloseDialog(this); if (profileState == ProfileState.Disconnected) { FinishActivity(123); } }
/// <summary> /// Erstellt eine neue Beschreibung. /// </summary> /// <param name="profile">Das zu beschreibende Geräteprofil.</param> /// <returns>Die gewünschte Beschreibung.</returns> public static ProfileInfo Create( ProfileState profile ) { // Validate if (profile == null) throw new ArgumentNullException( nameof( profile ) ); // Create return new ProfileInfo { Name = profile.ProfileName }; }
public override void OnConnectionStateChange(BluetoothDevice device, ProfileState status, ProfileState newState) { var message = "Bluetooth Server connection state: {0} Device: " + device.Address; Debug.WriteLineIf(newState == ProfileState.Connected, string.Format(message, "Connected")); Debug.WriteLineIf(newState == ProfileState.Disconnected, string.Format(message, "Disconnected")); var handler = ConnectionStateChanged; if (handler != null) handler(device, status, newState); }
/// <summary> /// Erstellt eine neue Sammlung. /// </summary> /// <param name="state">Das zugehörige Geräteprofil.</param> /// <param name="recording">Die Beschreibung der Aufgabe.</param> /// <returns>Die gewünschte Steuerung.</returns> public static SourceScanProxy Create( ProfileState state, VCRRecordingInfo recording ) { // Validate if (state == null) throw new ArgumentNullException( nameof( state ) ); if (recording == null) throw new ArgumentNullException( nameof( recording ) ); // Forward return new SourceScanProxy( state, recording ); }
/// <summary> /// Erzeugt eine neue Verwaltung. /// </summary> /// <param name="forResource">Das Geräteprofil, auf dem der Lauf erfolgen soll.</param> /// <param name="profile">Das zugehörige Geräteprofil.</param> /// <param name="lastUpdate">Methode zur Ermittelung des letzten Aktualisierungszeitpunktes.</param> /// <exception cref="ArgumentNullException">Der letzte Aktualisierungszeitpunkt ist nicht gesetzt.</exception> private SourceListTask( IScheduleResource forResource, ProfileState profile, Func<DateTime?> lastUpdate ) : base( "Sendersuchlauf", Guid.NewGuid() ) { // Validate if (forResource == null) throw new ArgumentNullException( nameof( forResource ) ); if (lastUpdate == null) throw new ArgumentNullException( nameof( lastUpdate ) ); // Remember m_Resources = new[] { forResource }; m_LastUpdate = lastUpdate; // Set the job directory if (profile != null) CollectorDirectory = profile.Server.JobManager.CollectorDirectory; }
private void CloneProfile(DelcomProfileViewModel profileToClone) { var profile = (MonitoringProfile)NewProfile.GetProfile(); profile.States.Clear(); NewProfile.States.Clear(); foreach (var state in profileToClone.States) { var profileState = new ProfileState { BuildState = state.BuildState, Green = state.Green, Yellow = state.Yellow, Red = state.Red, Flash = state.Flash }; profile.States.Add(profileState); NewProfile.States.Add(new ProfileStateViewModel(profileState)); } }
public override void OnConnectionStateChange (BluetoothGatt gatt, GattStatus status, ProfileState newState) { Console.WriteLine ("OnConnectionStateChange: "); base.OnConnectionStateChange (gatt, status, newState); //TODO: need to pull the cached RSSI in here, or read it (requires the callback) Device device = new Device (gatt.Device, gatt, this, 0); switch (newState) { // disconnected case ProfileState.Disconnected: Console.WriteLine ("disconnected"); if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop) { Console.WriteLine("Changing connection priority to balanced"); gatt.RequestConnectionPriority(BluetoothGatt.ConnectionPriorityBalanced); } this.DeviceDisconnected (this, new DeviceConnectionEventArgs () { Device = device }); break; // connecting case ProfileState.Connecting: Console.WriteLine ("Connecting"); break; // connected case ProfileState.Connected: Console.WriteLine ("Connected"); if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop) { Console.WriteLine("Changing connection priority to high"); gatt.RequestConnectionPriority(BluetoothGatt.ConnectionPriorityHigh); } this.DeviceConnected (this, new DeviceConnectionEventArgs () { Device = device }); break; // disconnecting case ProfileState.Disconnecting: Console.WriteLine ("Disconnecting"); break; } }
public override void OnConnectionStateChange (BluetoothGatt gatt, GattStatus status, ProfileState newState) { Console.WriteLine ("OnConnectionStateChange: "); //TODO: need to pull the cached RSSI in here, or read it (requires the callback) var device = _adapter.DiscoveredDevices.Find(gatt.Device); if (device == null) { Debug.WriteLine(string.Format("Device {0} has not been discovered yet.", gatt.Device.Name)); device = new Device(gatt.Device, gatt, this, 0); _adapter.DiscoveredDevices.Add(device); } switch (newState) { // disconnected case ProfileState.Disconnected: Console.WriteLine("Disconnected."); device.Disconnect(); OnDeviceDisconnected(device); break; // connecting case ProfileState.Connecting: Console.WriteLine("Connecting"); device.SetState(DeviceState.Connecting); break; // connected case ProfileState.Connected: Console.WriteLine("Connected"); device.SetState(DeviceState.Connected); OnDeviceConnected(device); break; // disconnecting case ProfileState.Disconnecting: Console.WriteLine("Disconnecting"); device.SetState(DeviceState.Disconnected); break; } }
/// <summary> /// Erstellt eine neue Aktualisierung. /// </summary> /// <param name="state">Das zugehörige Geräteprofil.</param> /// <param name="recording">Daten der primären Aufzeichnung.</param> private ProgramGuideProxy( ProfileState state, VCRRecordingInfo recording ) : base( state, recording ) { // Reset fields if (VCRConfiguration.Current.EnableFreeSat) m_extensions = EPGExtensions.FreeSatUK; else m_extensions = EPGExtensions.None; // All sources we know about var allSources = new Dictionary<string, SourceSelection>( StringComparer.InvariantCultureIgnoreCase ); // Load all sources of this profile foreach (var source in VCRProfiles.GetSources( ProfileName )) { // Remember by direct name allSources[source.DisplayName] = source; // allSources by unique name allSources[source.QualifiedName] = source; } // Fill in all foreach (var legacyName in VCRConfiguration.Current.ProgramGuideSources) { // Skip if empty if (string.IsNullOrEmpty( legacyName )) continue; // Locate SourceSelection realSource; if (allSources.TryGetValue( legacyName, out realSource )) m_selected.Add( realSource.Source ); else VCRServer.Log( LoggingLevel.Full, Properties.Resources.BadEPGStation, legacyName ); } }
public override void OnConnectionStateChange(BluetoothGatt gatt, GattStatus status, ProfileState newState) { var handler = ConnectionStateChanged; if (handler != null) { handler(gatt, status, newState); } }
public override void OnConnectionStateChange(BluetoothGatt gatt, GattStatus status, ProfileState newState) { base.OnConnectionStateChange(gatt, status, newState); IDevice device = null; if (status != GattStatus.Success) { Mvx.TaggedError("OnConnectionStateChange", "GattCallback error: {0}", status); DeviceConnectionError(this, new DeviceConnectionEventArgs(){ Device = device }); // We don't return. Allowing to fall-through to the SWITCH, which will assume a disconnect, close GATT and clean up. // The above error event handles the case where the error happened during a Connect call, which will close out any waiting asyncs. } else { Mvx.Trace("GattCallback state: {0}", newState.ToString()); } switch (newState) { // disconnected case ProfileState.Disconnected: if (DeviceOperationRegistry.TryGetValue(gatt.Device.Address, out device)) { Mvx.Trace("Disconnected by user"); //Found so we can remove it DeviceOperationRegistry.Remove(gatt.Device.Address); ConnectedDeviceRegistry.Remove(gatt.Device.Address); gatt.Close(); DeviceDisconnected(this, new DeviceConnectionEventArgs { Device = device }); break; } //connection must have been lost, bacause our device was not found in the registry but was still connected if (ConnectedDeviceRegistry.TryGetValue(gatt.Device.Address, out device)) { Mvx.Trace("Disconnected by lost connection"); ConnectedDeviceRegistry.Remove(gatt.Device.Address); gatt.Close(); DeviceConnectionLost(this, new DeviceConnectionEventArgs() { Device = device }); break; } gatt.Close(); // Close GATT regardless, else we can accumulate zombie gatts. Mvx.Trace("Disconnect. Device not found in registry. Not raising disconnect/lost event."); break; // connecting case ProfileState.Connecting: Mvx.Trace("Connecting"); break; // connected case ProfileState.Connected: Mvx.Trace("Connected"); //Try to find the device in the registry so that the same instance is updated if (DeviceOperationRegistry.TryGetValue(gatt.Device.Address, out device)) { ((Device)device).Update(gatt.Device, gatt, this); //Found so we can remove it DeviceOperationRegistry.Remove(gatt.Device.Address); } else { //only for on auto-reconnect (device is not in operation registry) device = new Device(gatt.Device, gatt, this, 0); } ConnectedDeviceRegistry[gatt.Device.Address] = device; DeviceConnected(this, new DeviceConnectionEventArgs() { Device = device }); break; // disconnecting case ProfileState.Disconnecting: Mvx.Trace("Disconnecting"); break; } }
public override void OnConnectionStateChange(BluetoothGatt gatt, [GeneratedEnum] GattStatus status, [GeneratedEnum] ProfileState newState) { base.OnConnectionStateChange(gatt, status, newState); var args = new BLEGATTProfileStateStatusEventArgs(gatt, status, newState); _wes.RaiseEvent(nameof(ConnectionStateChanged), this, args); }
public ConnectionStateEventArgs(BluetoothGatt gatt, GattStatus status, ProfileState newState) : base(gatt, status) { this.NewState = newState; }
public override void OnConnectionStateChange(BluetoothGatt gatt, GattStatus status, ProfileState newState) { base.OnConnectionStateChange(gatt, status, newState); if (!gatt.Device.Address.Equals(_device.BluetoothDevice.Address)) { Trace.Message($"Gatt callback for device {_device.BluetoothDevice.Address} was called for device with address {gatt.Device.Address}. This shoud not happen. Please log an issue."); return; } //ToDo ignore just for me Trace.Message($"References of parent device and gatt callback device equal? {ReferenceEquals(_device.BluetoothDevice, gatt.Device).ToString().ToUpper()}"); Trace.Message($"OnConnectionStateChange: GattStatus: {status}"); switch (newState) { // disconnected case ProfileState.Disconnected: // Close GATT regardless, else we can accumulate zombie gatts. CloseGattInstances(gatt); // If status == 19, then connection was closed by the peripheral device (clean disconnect), consider this as a DeviceDisconnected if (_device.IsOperationRequested || (int)status == 19) { Trace.Message("Disconnected by user"); //Found so we can remove it _device.IsOperationRequested = false; _adapter.ConnectedDeviceRegistry.Remove(gatt.Device.Address); if (status != GattStatus.Success && (int)status != 19) { // The above error event handles the case where the error happened during a Connect call, which will close out any waiting asyncs. // Android > 5.0 uses this switch branch when an error occurs during connect Trace.Message($"Error while connecting '{_device.Name}'. Not raising disconnect event."); _adapter.HandleConnectionFail(_device, $"GattCallback error: {status}"); } else { //we already hadled device error so no need th raise disconnect event(happens when device not in range) _adapter.HandleDisconnectedDevice(true, _device); } break; } //connection must have been lost, because the callback was not triggered by calling disconnect Trace.Message($"Disconnected '{_device.Name}' by lost connection"); _adapter.ConnectedDeviceRegistry.Remove(gatt.Device.Address); _adapter.HandleDisconnectedDevice(false, _device); // inform pending tasks ConnectionInterrupted?.Invoke(this, EventArgs.Empty); break; // connecting case ProfileState.Connecting: Trace.Message("Connecting"); break; // connected case ProfileState.Connected: Trace.Message("Connected"); //Check if the operation was requested by the user if (_device.IsOperationRequested) { _device.Update(gatt.Device, gatt); //Found so we can remove it _device.IsOperationRequested = false; } else { //ToDo explore this //only for on auto-reconnect (device is not in operation registry) _device.Update(gatt.Device, gatt); } if (status != GattStatus.Success) { // The above error event handles the case where the error happened during a Connect call, which will close out any waiting asyncs. // Android <= 4.4 uses this switch branch when an error occurs during connect Trace.Message($"Error while connecting '{_device.Name}'. GattStatus: {status}. "); _adapter.HandleConnectionFail(_device, $"GattCallback error: {status}"); CloseGattInstances(gatt); } else { _adapter.ConnectedDeviceRegistry[gatt.Device.Address] = _device; _adapter.HandleConnectedDevice(_device); } break; // disconnecting case ProfileState.Disconnecting: Trace.Message("Disconnecting"); break; } }
public override void OnConnectionStateChange(BluetoothGatt gatt, GattStatus status, ProfileState newState) { base.OnConnectionStateChange(gatt, status, newState); IDevice device; Trace.Message($"OnConnectionStateChange: GattStatus: {status}"); switch (newState) { // disconnected case ProfileState.Disconnected: if (_adapter.DeviceOperationRegistry.TryGetValue(gatt.Device.Address, out device)) { Trace.Message("Disconnected by user"); //Found so we can remove it _adapter.DeviceOperationRegistry.Remove(gatt.Device.Address); _adapter.ConnectedDeviceRegistry.Remove(gatt.Device.Address); gatt.Close(); if (status != GattStatus.Success) { // The above error event handles the case where the error happened during a Connect call, which will close out any waiting asyncs. // Android > 5.0 uses this switch branch when an error occurs during connect Trace.Message($"Error while connecting '{device.Name}'. Not raising disconnect event."); _adapter.HandleConnectionFail(device, $"GattCallback error: {status}"); } else { //we already hadled device error so no need th raise disconnect event(happens when device not in range) _adapter.HandleDisconnectedDevice(true, device); } break; } //connection must have been lost, bacause our device was not found in the registry but was still connected if (_adapter.ConnectedDeviceRegistry.TryGetValue(gatt.Device.Address, out device)) { Trace.Message($"Disconnected '{device.Name}' by lost connection"); _adapter.ConnectedDeviceRegistry.Remove(gatt.Device.Address); gatt.Close(); _adapter.HandleDisconnectedDevice(false, device); break; } gatt.Close(); // Close GATT regardless, else we can accumulate zombie gatts. Trace.Message("Disconnect. Device not found in registry. Not raising disconnect/lost event."); break; // connecting case ProfileState.Connecting: Trace.Message("Connecting"); break; // connected case ProfileState.Connected: Trace.Message("Connected"); //Try to find the device in the registry so that the same instance is updated if (_adapter.DeviceOperationRegistry.TryGetValue(gatt.Device.Address, out device)) { ((Device)device).Update(gatt.Device, gatt, this); //Found so we can remove it _adapter.DeviceOperationRegistry.Remove(gatt.Device.Address); } else { //only for on auto-reconnect (device is not in operation registry) device = new Device(_adapter, gatt.Device, gatt, this, 0); } if (status != GattStatus.Success) { // The aboe error event handles the case where the error happened during a Connect call, which will close out any waiting asyncs. // Android <= 4.4 uses this switch branch when an error occurs during connect Trace.Message($"Error while connecting '{device.Name}'. GattStatus: {status}. "); _adapter.HandleConnectionFail(device, $"GattCallback error: {status}"); gatt.Close(); } else { _adapter.ConnectedDeviceRegistry[gatt.Device.Address] = device; _adapter.HandleConnectedDevice(device); } break; // disconnecting case ProfileState.Disconnecting: Trace.Message("Disconnecting"); break; } }
public ProfileStateViewModel(ProfileState profileState) { this.profileState = profileState; }
public override void OnConnectionStateChange(BluetoothDevice device, ProfileState status, ProfileState newState) { this.ConnectionStateChanged?.Invoke(this, new ConnectionStateChangeEventArgs(device, status, newState)); }
public override void OnConnectionStateChange(BluetoothGatt gatt, GattStatus status, ProfileState newState) { switch (status) { case GattStatus.ConnectionCongested: break; case GattStatus.Failure: break; case GattStatus.InsufficientAuthentication: break; case GattStatus.InsufficientEncryption: break; case GattStatus.InvalidAttributeLength: break; case GattStatus.InvalidOffset: break; case GattStatus.ReadNotPermitted: break; case GattStatus.RequestNotSupported: break; case GattStatus.Success: switch (newState) { case ProfileState.Connected: break; case ProfileState.Connecting: break; case ProfileState.Disconnected: if (_record != null) { (_context as GlucoseDeviceActivity)?.RunOnUiThread(() => { DisplayMessageToUi("Citirea s-a efectuat cu success"); (_context as GlucoseDeviceActivity)?.UpdateUi( _record?.GlucoseConcentration * 100000); }); } else { (_context as GlucoseDeviceActivity)?.RunOnUiThread(() => { DisplayMessageToUi("Nu s-au gasit date"); (_context as GlucoseDeviceActivity)?.UpdateUi(); }); } break; case ProfileState.Disconnecting: break; default: throw new ArgumentOutOfRangeException(nameof(newState), newState, null); } if (newState == ProfileState.Connected) { gatt.DiscoverServices(); } break; case GattStatus.WriteNotPermitted: break; default: throw new ArgumentOutOfRangeException(nameof(status), status, null); } }
// Overridden from BluetoothGattCallback public sealed override void OnConnectionStateChange(BluetoothGatt gatt, GattStatus status, ProfileState newState) { lock (locker) { switch (newState) { case ProfileState.Connected: { handler.RemoveCallbacksAndMessages(null); connectionState = EConnectionState.Resolving; lastSeen = DateTime.Now; // We at least know that the device is nearby at this point. if (!gatt.DiscoverServices()) { Log.E(this, "Failed to start service discovery for: " + device.Name); Disconnect(); } else { connectionState = EConnectionState.Resolving; handler.SendEmptyMessageDelayed(MSG_CHECK_SERVICES, SERVICES_DELAY); } break; } // ProfileState.Connected case ProfileState.Connecting: { break; } // ProfileState.Connecting case ProfileState.Disconnected: { // Only attempt a reconnect if the device disconnected unexpectedly bool reconnect = connectionState == EConnectionState.Connected && manager.ion.preferences.device.allowDeviceAutoConnect; Disconnect(reconnect); break; } // ProfileState.Disconnected case ProfileState.Disconnecting: { break; } // ProfileState.Disconnecting } } }
public override void OnConnectionStateChange(BluetoothDevice device, [GeneratedEnum] ProfileState status, [GeneratedEnum] ProfileState newState) { if (status == ProfileState.Connected) { OnDeviceAdded?.Invoke(device); } base.OnConnectionStateChange(device, status, newState); }
public override void OnConnectionStateChange(BluetoothDevice device, ProfileState status, ProfileState newState) { base.OnConnectionStateChange(device, status, newState); ConnectionStateChange(this, new BleEventArgs() { Device = device, NewState = newState }); }
/// <summary> /// Startet die eigentlich Aufzeichnung in einer abgesicherten Umgebung. /// </summary> private void Run() { // Be fully safe try { // Create raw environment var coreEnvironment = new Dictionary <string, string> { { "%wakeupprofile%", ProfileState.WakeUpRequired ? "1" : "0" }, { "%dvbnetprofile%", ProfileName }, }; // Be fully safe try { // Log it VCRServer.Log(LoggingLevel.Schedules, Properties.Resources.RecordingStarted, TypeName); // Report Tools.ExtendedLogging("Started Recording Control Thread for {0}", ProfileName); // Fire all extensions Tools.RunSynchronousExtensions("BeforeProfileAccess", coreEnvironment); // Use it using (Server = CreateCardServerProxy()) { // Check mode var mustWakeUp = ProfileState.WakeUpRequired; if (mustWakeUp) { // Log VCRServer.Log(LoggingLevel.Full, Properties.Resources.RestartMessage); // Report Tools.ExtendedLogging("Will restart Hardware for {0} if Restart Device is configured in Profile", ProfileName); } // Start synchronously ServerImplementation.EndRequest( Server.BeginSetProfile ( ProfileName, mustWakeUp, VCRConfiguration.Current.DisablePCRFromH264Generation, VCRConfiguration.Current.DisablePCRFromMPEG2Generation )); // Report Tools.ExtendedLogging("Card Server is up and running"); // Remember time Representative.PhysicalStart = DateTime.UtcNow; // Create fresh environment and fire extensions - with no files so far FireRecordingStartedExtensions(ExtensionEnvironment = Representative.GetReplacementPatterns()); // Time to allow derived class to start up OnStart(); // Process idle loop - done every second if not interrupted earlier for (IAsyncResult <ServerInformation> stateRequest = null; ; m_wakeUp.WaitOne(m_running ? 1000 : 100)) { // First check for state request if (stateRequest != null) { // No yet done if (!stateRequest.IsCompleted) { continue; } // Process the state OnNewStateAvailable(m_state = stateRequest.Result); // No longer waiting for the next state stateRequest = null; } // See if we are busy in the derived class if (HasPendingServerRequest) { continue; } // Process actions - no asynchronous operations allowed in current version ProcessActions(); // Make sure that scheduler knows we accepted the request ConfirmPendingRequest(); // If we are still idle fire a new state request if (!HasPendingServerRequest) { if (m_running) { stateRequest = Server.BeginGetState(); } else { break; } } } // Time to let derived class shut down properly OnStop(); // Run final state update before protocol entry is created if (m_state != null) { OnNewStateAvailable(m_state); } // Update recording data for the very last time var info = CreateFullInformation(true); if (info != null) { Representative = info.Recording; } // Set real send Representative.EndsAt = DateTime.UtcNow; // Set end state ExtensionEnvironment["%Aborted%"] = m_aborted ? "1" : "0"; // Process extensions FireRecordingFinishedExtensions(ExtensionEnvironment); // No need for further wakeups ProfileState.WakeUpRequired = false; } } catch (Exception e) { // Report VCRServer.Log(e); // Try to make sure that job is not restarted try { // Update SetRestartThreshold(null); } catch (Exception ex) { // Report VCRServer.Log(ex); } } finally { // Detach from server - is already disposed and shut down Server = null; // Fire all extensions Tools.RunSynchronousExtensions("AfterProfileAccess", coreEnvironment); // Detach from profile ProfileState.EndRequest(this); // Write recording ProfileState.Server.JobManager.CreateLogEntry(Representative); // May go to sleep after job is finished ProfileState.Server.ReportRecordingDone(Representative.DisableHibernation, IsRealRecording); // Check for next job on all profiles ProfileState.Collection.BeginNewPlan(); // Report Tools.ExtendedLogging("Recording finished for {0}", ProfileName); // Log it VCRServer.Log(LoggingLevel.Schedules, Properties.Resources.RecordingFinished, TypeName); } } catch (Exception e) { // Report VCRServer.Log(e); } finally { // Make sure that even in case of error we do a full notification ConfirmPendingRequest(true); // Always fire event RequestFinished.Set(); } }
public override void OnConnectionStateChange(BluetoothGatt gatt, GattStatus status, ProfileState newState) { base.OnConnectionStateChange(gatt, status, newState); switch (newState) { case ProfileState.Connecting: Connecting?.Invoke(this, EventArgs.Empty); break; case ProfileState.Connected: Connected?.Invoke(this, EventArgs.Empty); break; case ProfileState.Disconnecting: Disconnecting?.Invoke(this, EventArgs.Empty); break; case ProfileState.Disconnected: Disconnected?.Invoke(this, EventArgs.Empty); break; } }
public ConnectionStateChangeEventArgs(BluetoothDevice device, ProfileState oldState, ProfileState newState) : base(device) { this.OldState = oldState; this.NewState = newState; }
public override void OnConnectionStateChange(BluetoothGatt gatt, [GeneratedEnum] GattStatus status, [GeneratedEnum] ProfileState newState) { base.OnConnectionStateChange(gatt, status, newState); OnConnectionStateChangeOccured?.Invoke(this, new ConnectionStateChangeOccuredEventArgs((Abstractions.GattStatus)(int) status, (Abstractions.ProfileState)(int) newState)); }
public override void OnConnectionStateChange(BluetoothGatt gatt, GattStatus status, ProfileState newState) { if (status == GattStatus.Success && newState == ProfileState.Connected) { try { gatt.DiscoverServices(); } catch (Exception ex) { SensusServiceHelper.Get().Logger.Log("Exception while discovering services: " + ex, LoggingLevel.Normal, GetType()); DisconnectPeripheral(gatt); } } // ensure that all disconnected peripherals get closed (released). without closing, we'll use up all the BLE interfaces. else if (newState == ProfileState.Disconnected) { try { gatt.Close(); } catch (Exception ex) { SensusServiceHelper.Get().Logger.Log("Exception while closing disconnected client: " + ex, LoggingLevel.Normal, GetType()); } } }
/// <summary> /// Erstellt eine neue Sammlung. /// </summary> /// <param name="state">Das zugehörige Geräteprofil.</param> /// <param name="recording">Die Beschreibung der Aufgabe.</param> private SourceScanProxy( ProfileState state, VCRRecordingInfo recording ) : base( state, recording ) { // Finish m_mergeSources = VCRConfiguration.Current.MergeSourceListUpdateResult; }
public override void OnConnectionStateChange(BluetoothGatt gatt, [GeneratedEnum] GattStatus status, [GeneratedEnum] ProfileState newState) { base.OnConnectionStateChange(gatt, status, newState); if (newState == ProfileState.Connected) { State = DeviceState.Connected; connectTCS.TrySetResult(true); } else if (newState == ProfileState.Disconnected) { gatt.Close(); State = DeviceState.Disconnected; //The device can disconnect by itself, not only because we asked disconnectTCS?.TrySetResult(true); OnDeviceDisconnected(); } }
private void OnConnectionStateChanged(BluetoothGatt gatt, GattStatus status, ProfileState newState) { switch (newState) { case ProfileState.Connected: Debug.WriteLine("Connected peripheral: " + gatt.Device.Name); _onConnection(ProfileState.Connected); break; case ProfileState.Disconnected: Debug.WriteLine("Disconnected peripheral: " + gatt.Device.Name); OnDisconnection(); break; case ProfileState.Connecting: Debug.WriteLine("Connecting peripheral: " + gatt.Device.Name); break; case ProfileState.Disconnecting: Debug.WriteLine("Disconnecting peripheral: " + gatt.Device.Name); break; } }
public override void OnConnectionStateChange(BluetoothGatt gatt, [GeneratedEnum] GattStatus status, [GeneratedEnum] ProfileState newState) { try { if (status == GattStatus.Success) { if (newState == ProfileState.Connected && _Device == null) { BLEC("connected to " + gatt.Device.Address + ", status=" + status + ", bond=" + gatt.Device.BondState + ", discovering service..."); _ServerDevice = gatt; _Device = gatt.Device.Address; ConnectionCompleted?.Invoke(true); if (!_ServerDevice.DiscoverServices()) { BLEC_ERR("can't start discovery service"); } } else if (newState == ProfileState.Connected) { gatt.Close(); } else if (newState == ProfileState.Disconnected && _Device != null && gatt.Device.Address == _Device) { _Device = null; ConnectionCompleted?.Invoke(false); } } } catch (Exception ex) { BLEC_ERR("generic connection state changed", ex); } }
/// <Docs>GATT client</Docs> /// <summary> /// Raises the connection state change event. /// </summary> /// <param name="gatt">Gatt.</param> /// <param name="status">Status.</param> /// <param name="newState">New state.</param> public override void OnConnectionStateChange(BluetoothGatt gatt, GattStatus status, ProfileState newState) { base.OnConnectionStateChange(gatt, status, newState); if (status != GattStatus.Success) { return; } var device = new Device(gatt.Device, gatt, this, 0, null); switch (newState) { case ProfileState.Disconnected: device.State = DeviceState.Disconnected; try { gatt.Close(); gatt = null; } catch (Exception ex) { Debug.WriteLine("Unable to close connection to gatt. Exception: {0}", ex.Message); } finally { DeviceDisconnected(this, new DeviceConnectionEventArgs(device)); } break; case ProfileState.Connected: device.State = DeviceState.Connected; DeviceConnected(this, new DeviceConnectionEventArgs(device)); break; } }
public override void OnConnectionStateChange(BluetoothGatt gatt, GattStatus status, ProfileState newState) { Console.WriteLine("OnConnectionStateChange: "); base.OnConnectionStateChange(gatt, status, newState); //TODO: need to pull the cached RSSI in here, or read it (requires the callback) Device device = new Device(gatt.Device, gatt, this, 0); switch (newState) { // disconnected case ProfileState.Disconnected: Console.WriteLine("disconnected"); this.DeviceDisconnected(this, new DeviceConnectionEventArgs() { Device = device }); break; // connecting case ProfileState.Connecting: Console.WriteLine("Connecting"); break; // connected case ProfileState.Connected: Console.WriteLine("Connected"); this.DeviceConnected(this, new DeviceConnectionEventArgs() { Device = device }); break; // disconnecting case ProfileState.Disconnecting: Console.WriteLine("Disconnecting"); break; } }
private BluetoothConnectionStatus GetConnectionStatus() { ProfileState state = DeviceInformation.Manager.GetConnectionState(_device, ProfileType.Gatt); return(state == ProfileState.Connected ? BluetoothConnectionStatus.Connected : BluetoothConnectionStatus.Disconnected); }
public override void OnConnectionStateChange(BluetoothGatt gatt, GattStatus status, ProfileState newState) { var handler = ConnectionStateChanged; if (handler != null) handler(gatt, status, newState); }
public override void OnConnectionStateChange(BluetoothGatt gatt, GattStatus status, ProfileState newState) { if (status == GattStatus.Success) { _owner._discoveryHandle.Set(); } global::System.Diagnostics.Debug.WriteLine(status); }
/// <summary> /// Erstellt eine neue Sammlung. /// </summary> /// <param name="state">Das zugehörige Geräteprofil.</param> /// <param name="recording">Die Beschreibung der Aufgabe.</param> private SourceScanProxy(ProfileState state, VCRRecordingInfo recording) : base(state, recording) { // Finish m_mergeSources = VCRConfiguration.Current.MergeSourceListUpdateResult; }
/// <summary> /// Erzeugt eine neue Verwaltung. /// </summary> /// <param name="forResource">Das Geräteprofil, auf dem der Lauf erfolgen soll.</param> /// <param name="profile">Das zugehörige Geräteprofil.</param> public SourceListTask( IScheduleResource forResource, ProfileState profile ) : this( forResource, profile, () => profile.LastSourceUpdateTime ) { }
public override void OnConnectionStateChange(BluetoothGatt gatt, GattStatus status, ProfileState newState) { String intentAction; if (newState == ProfileState.Connected) { intentAction = BluetoothLeService.ACTION_GATT_CONNECTED; BluetoothLeService.mConnectionState = State.Connected; service.BroadcastUpdate(intentAction); Log.Info(BluetoothLeService.TAG, "Connected to GATT server."); // Attempts to discover services after successful connection. Log.Info(BluetoothLeService.TAG, "Attempting to start service discovery:" + BluetoothLeService.mBluetoothGatt.DiscoverServices()); } else if (newState == ProfileState.Disconnected) { intentAction = BluetoothLeService.ACTION_GATT_DISCONNECTED; BluetoothLeService.mConnectionState = State.Disconnected; Log.Info(BluetoothLeService.TAG, "Disconnected from GATT server."); service.BroadcastUpdate(intentAction); } }
public override void OnConnectionStateChange(BluetoothDevice device, ProfileState status, ProfileState newState) { base.OnConnectionStateChange(device, status, newState); Console.WriteLine("State changed to {0}", newState); }
public override void OnConnectionStateChange(BluetoothGatt gatt, GattStatus status, ProfileState newState) { base.OnConnectionStateChange(gatt, status, newState); IDevice device = null; if (status != GattStatus.Success) { Mvx.TaggedError("OnConnectionStateChange", "GattCallback error: {0}", status); device = new Device(gatt.Device, gatt, this, 0); DeviceConnectionError(this, new DeviceConnectionEventArgs() { Device = device }); // We don't return. Allowing to fall-through to the SWITCH, which will assume a disconnect, close GATT and clean up. // The above error event handles the case where the error happened during a Connect call, which will close out any waiting asyncs. } else { Mvx.Trace("GattCallback state: {0}", newState.ToString()); } switch (newState) { // disconnected case ProfileState.Disconnected: if (DeviceOperationRegistry.TryGetValue(gatt.Device.Address, out device)) { Mvx.Trace("Disconnected by user"); //Found so we can remove it DeviceOperationRegistry.Remove(gatt.Device.Address); ConnectedDeviceRegistry.Remove(gatt.Device.Address); gatt.Close(); DeviceDisconnected(this, new DeviceConnectionEventArgs { Device = device }); break; } //connection must have been lost, bacause our device was not found in the registry but was still connected if (ConnectedDeviceRegistry.TryGetValue(gatt.Device.Address, out device)) { Mvx.Trace("Disconnected by lost connection"); ConnectedDeviceRegistry.Remove(gatt.Device.Address); gatt.Close(); DeviceConnectionLost(this, new DeviceConnectionEventArgs() { Device = device }); break; } gatt.Close(); // Close GATT regardless, else we can accumulate zombie gatts. Mvx.Trace("Disconnect. Device not found in registry. Not raising disconnect/lost event."); break; // connecting case ProfileState.Connecting: Mvx.Trace("Connecting"); break; // connected case ProfileState.Connected: Mvx.Trace("Connected"); //Try to find the device in the registry so that the same instance is updated if (DeviceOperationRegistry.TryGetValue(gatt.Device.Address, out device)) { ((Device)device).Update(gatt.Device, gatt, this); //Found so we can remove it DeviceOperationRegistry.Remove(gatt.Device.Address); } else { //only for on auto-reconnect (device is not in operation registry) device = new Device(gatt.Device, gatt, this, 0); } ConnectedDeviceRegistry[gatt.Device.Address] = device; DeviceConnected(this, new DeviceConnectionEventArgs() { Device = device }); break; // disconnecting case ProfileState.Disconnecting: Mvx.Trace("Disconnecting"); break; } }
/// <summary> /// Erzeugt einen neuen Auftrag. /// </summary> /// <param name="state">Der Zustands des zugehörigen Geräteprofils.</param> /// <param name="firstRecording">Die erste Aufzeichnung, auf Grund derer dieser Zugriff angelegt wurde.</param> public RecordingProxy( ProfileState state, VCRRecordingInfo firstRecording ) : base( state, firstRecording ) { }
public override void OnConnectionStateChange(BluetoothDevice device, ProfileState status, ProfileState newState) { base.OnConnectionStateChange(device, status, newState); Console.WriteLine("State changed to {0}", newState); }
public override void OnConnectionStateChange (BluetoothGatt gatt, GattStatus status, ProfileState newState) { String intentAction; if (newState == ProfileState.Connected) { intentAction = BluetoothLeService.ACTION_GATT_CONNECTED; BluetoothLeService.mConnectionState = State.Connected; service.BroadcastUpdate (intentAction); Log.Info (BluetoothLeService.TAG, "Connected to GATT server."); // Attempts to discover services after successful connection. Log.Info (BluetoothLeService.TAG, "Attempting to start service discovery:" + BluetoothLeService.mBluetoothGatt.DiscoverServices ()); } else if (newState == ProfileState.Disconnected) { intentAction = BluetoothLeService.ACTION_GATT_DISCONNECTED; BluetoothLeService.mConnectionState = State.Disconnected; Log.Info (BluetoothLeService.TAG, "Disconnected from GATT server."); service.BroadcastUpdate (intentAction); } }
public override void OnConnectionStateChange(BluetoothGatt gatt, GattStatus status, ProfileState newState) { if (gatt != _btLeGattSpp._bluetoothGatt) { return; } if (newState == ProfileState.Connected) { #if DEBUG Android.Util.Log.Info(Tag, "Connected to GATT server."); #endif _btLeGattSpp._gattConnectionState = State.Connected; _btLeGattSpp._gattServicesDiscovered = false; _btLeGattSpp._btGattConnectEvent.Set(); gatt.DiscoverServices(); } else if (newState == ProfileState.Disconnected) { #if DEBUG Android.Util.Log.Info(Tag, "Disconnected from GATT server."); #endif _btLeGattSpp._gattConnectionState = State.Disconnected; _btLeGattSpp._gattServicesDiscovered = false; } }
/// <summary> /// Creates a readonly instance of the strongly typed CommunityServer Profile /// </summary> /// <param name="pd"></param> public Profile(ProfileData pd) { reader = new ProfileReader(pd); state = ProfileState.Read; }
/// <summary> /// Ermittelt alle Protokolleinträge für einen bestimmten Zeitraum. /// </summary> /// <param name="firstDate">Erster zu berücksichtigender Tag.</param> /// <param name="lastDate">Letzter zu berücksichtigender Tag.</param> /// <param name="profile">Profile, dessen Protokolle ausgelesen werden sollen.</param> /// <returns>Liste aller Protokolleinträge für den gewünschten Zeitraum.</returns> internal List<VCRRecordingInfo> FindLogEntries( DateTime firstDate, DateTime lastDate, ProfileState profile ) { // Create list var logs = new List<VCRRecordingInfo>(); // Create search patterns var last = lastDate.AddDays( 1 ).ToString( LogEntryDateFormat ); var first = firstDate.ToString( LogEntryDateFormat ); // Load all jobs foreach (var file in LogDirectory.GetFiles( "*" + VCRRecordingInfo.FileSuffix )) { // Skip if (file.Name.CompareTo( first ) < 0) continue; if (file.Name.CompareTo( last ) >= 0) continue; // Load item var logEntry = SerializationTools.Load<VCRRecordingInfo>( file ); if (logEntry == null) continue; // Check if (profile != null) if (!profile.IsResponsibleFor( logEntry.Source )) continue; // Attach the name logEntry.LogIdentifier = file.Name.ToLower(); // Remember logs.Add( logEntry ); } // Sort by start time logs.Sort( VCRRecordingInfo.ComparerByStarted ); // Report return logs; }
/// <summary> /// Erzeugt einen neuen Auftrag. /// </summary> /// <param name="state">Der Zustands des zugehörigen Geräteprofils.</param> /// <param name="firstRecording">Die erste Aufzeichnung, auf Grund derer dieser Zugriff angelegt wurde.</param> public RecordingProxy(ProfileState state, VCRRecordingInfo firstRecording) : base(state, firstRecording) { }
public override void OnConnectionStateChange (BluetoothGatt gatt, GattStatus status, ProfileState newState) { Console.WriteLine ("OnConnectionStateChange: "); base.OnConnectionStateChange (gatt, status, newState); switch (newState) { // disconnected case ProfileState.Disconnected: Console.WriteLine ("disconnected"); //TODO/BUG: Need to remove this, but can't remove the key (uncomment and see bug on disconnect) // if (this._parent._connectedDevices.ContainsKey (gatt.Device)) // this._parent._connectedDevices.Remove (gatt.Device); this._parent.DeviceDisconnected (this, new DeviceConnectionEventArgs () { Device = gatt.Device }); break; // connecting case ProfileState.Connecting: Console.WriteLine ("Connecting"); break; // connected case ProfileState.Connected: Console.WriteLine ("Connected"); //TODO/BUGBUG: need to remove this when disconnected this._parent._connectedDevices.Add (gatt.Device, gatt); this._parent.DeviceConnected (this, new DeviceConnectionEventArgs () { Device = gatt.Device }); break; // disconnecting case ProfileState.Disconnecting: Console.WriteLine ("Disconnecting"); break; } }
public BLEGATTProfileStateStatusEventArgs(BluetoothGatt gatt, GattStatus status, ProfileState newState) { GATT = gatt; Status = status; NewState = newState; }
public Profile() { state = ProfileState.Anonymous; defualtProfileSettings = ProfileBase.Properties; }
public override void OnConnectionStateChange(BluetoothGatt gatt, GattStatus status, ProfileState newState) { ConnectionStateChanged?.Invoke(gatt, status, newState); }
public override void OnConnectionStateChange(BluetoothGatt gatt, [GeneratedEnum] GattStatus status, [GeneratedEnum] ProfileState newState) { try { base.OnConnectionStateChange(gatt, status, newState); if (status == GattStatus.Success && newState == ProfileState.Connected) // && FlowManager.CurrentStep1 >= ApplicationStep.MeasureSpace) { //Console.WriteLine("\n\n\n\n\n\n---> " + FlowManager.CurrentStep1 + "\n\n\n\n\n\n\n\n"); SensorTagConfigurationStep = SensorTagConfigurationStep.None; gatt.DiscoverServices(); BluetoothGatt = gatt; } else { Disconnect(); } } catch (System.Exception ex) { string title = this.GetType().Name + " - " + System.Reflection.MethodBase.GetCurrentMethod().Name; BalizaFacil.App.Instance.UnhandledException(title, ex); } }
/// <summary> /// Erzeugt eine neue Verwaltung. /// </summary> /// <param name="forResource">Das Gerät, für das die Sammlung erfolgt.</param> /// <param name="profile">Das zugehörige Geräteprofil.</param> public ProgramGuideTask( IScheduleResource forResource, ProfileState profile ) : this( forResource, profile, () => profile.ProgramGuide.LastUpdateTime ) { }
public override void OnServiceAdded(ProfileState status, BluetoothGattService service) { Debug.WriteLine("Added service " + service.Uuid); var handler = ServiceAdded; if (handler != null) handler(status, service); }
public override void OnConnectionStateChange(BluetoothGatt gatt, GattStatus status, ProfileState newState) => this.ConnectionStateChanged.OnNext(new ConnectionStateEventArgs(gatt, status, newState));