void bleController_OnNotification(TI_BLE_HCI_ClientLib.HCIEvents.HCIEvent_ATT_Handle_Value_Notification notification) { SensorType sensorType = SensorType.Unknown; switch (notification.CharacteristicHandle) { case HEART_RATE_DATA_CHARACTERISTIC_HANDLE: sensorType = SensorType.HearRate; if (!bag.Contains(sensorType)) bag.Add(sensorType, notification.Value[1]); else bag[sensorType] = notification.Value[1]; break; default: break; } if (bag.Count > 0) this.OnSensorValueChanged(bag); }
private void bleController_OnNotification(TI_BLE_HCI_ClientLib.HCIEvents.HCIEvent_ATT_Handle_Value_Notification notification) { SensorType sensorType = SensorType.Unknown; switch (notification.CharacteristicHandle) { case IR_TEMP_DATA_CHARACTERISTIC_HANDLE: sensorType = SensorType.Temperature; double temperature = this.CalculateAmbientTemperature(notification.Value); if (!bag.Contains(sensorType)) bag.Add(sensorType, temperature); else bag[sensorType] = temperature; break; case HUMIDITY_DATA_CHARACTERISTIC_HANDLE: sensorType = SensorType.Humidity; double humidity = this.CalculateHumidityInPercent(notification.Value); if (!bag.Contains(sensorType)) bag.Add(sensorType, humidity); else bag[sensorType] = humidity; break; case ACCELEROMETER_DATA_CHARACTERISTIC_HANDLE: sensorType = SensorType.Accelerometer; sbyte[] signed = { (sbyte)notification.Value[0], (sbyte)notification.Value[1], (sbyte)notification.Value[2] }; double[] acceleration = this.CalculateGForce(signed); if (!bag.Contains(sensorType)) bag.Add(sensorType, acceleration); else bag[sensorType] = acceleration; break; } if (bag.Count > 0) this.OnSensorValueChanged(bag); }