/// <summary> /// An event handler that keeps the onChange eventListener of the different sensors alive. /// </summary> /// <param name="sender"> a timer object</param> /// <param name="e"> </param> private async void refreshNotifications(object sender, ElapsedEventArgs e) { if (notificationsEnabled) { await BLE_Utilities.executeOnNotification(Sensor.Keys, notifyButton); await BLE_Utilities.executeOnNotification(Sensor.Accelerometer, NotifyAccelerometer); await BLE_Utilities.executeOnNotification(Sensor.Humidity, NotifyHumidity); await BLE_Utilities.executeOnNotification(Sensor.Gyroscope, NotifyGyroscope); await BLE_Utilities.executeOnNotification(Sensor.Magnetometer, NotifyMagnetometer); await BLE_Utilities.executeOnNotification(Sensor.Temperature, NotifyTemperature); } }
//#EVENT LISTENERS FOR GUI COMPONENTS private async void buttonEnableNotifications_Click(object sender, RoutedEventArgs e) { notificationsEnabled = !notificationsEnabled; if (notificationsEnabled) { buttonEnableNotifications.Content = "Disable Notifications"; Title = "Demo - Notifications [On]"; await BLE_Utilities.executeOnNotification(Sensor.Keys, notifyButton); await BLE_Utilities.executeOnNotification(Sensor.Accelerometer, NotifyAccelerometer); await BLE_Utilities.executeOnNotification(Sensor.Humidity, NotifyHumidity); await BLE_Utilities.executeOnNotification(Sensor.Gyroscope, NotifyGyroscope); await BLE_Utilities.executeOnNotification(Sensor.Magnetometer, NotifyMagnetometer); await BLE_Utilities.executeOnNotification(Sensor.Pressure, NotifyPressure); await BLE_Utilities.executeOnNotification(Sensor.Temperature, NotifyTemperature); } else { Title = "Demo - Notifications [Off]"; buttonEnableNotifications.Content = "Enable Notifications"; await BLE_Utilities.dispose(Sensor.Keys); await BLE_Utilities.dispose(Sensor.Accelerometer); await BLE_Utilities.dispose(Sensor.Humidity); await BLE_Utilities.dispose(Sensor.Gyroscope); await BLE_Utilities.dispose(Sensor.Magnetometer); await BLE_Utilities.dispose(Sensor.Pressure); await BLE_Utilities.dispose(Sensor.Temperature); } }