|
@@ -25,6 +25,7 @@ namespace Sensors.Polar
|
|
{
|
|
{
|
|
public Vector3 Acc;
|
|
public Vector3 Acc;
|
|
public float EcgValue;
|
|
public float EcgValue;
|
|
|
|
+ public int Hr;
|
|
}
|
|
}
|
|
|
|
|
|
public class PolarReceiver
|
|
public class PolarReceiver
|
|
@@ -34,9 +35,12 @@ namespace Sensors.Polar
|
|
|
|
|
|
private readonly Subject<EcgData> rawEcgDataSubject = new Subject<EcgData>();
|
|
private readonly Subject<EcgData> rawEcgDataSubject = new Subject<EcgData>();
|
|
private readonly Subject<AccData> rawAccDataSubject = new Subject<AccData>();
|
|
private readonly Subject<AccData> rawAccDataSubject = new Subject<AccData>();
|
|
|
|
+ private readonly Subject<HRData> rawHRDataSubject = new Subject<HRData>();
|
|
|
|
|
|
public IObservable<EcgData> RawEcgData => rawEcgDataSubject.AsObservable();
|
|
public IObservable<EcgData> RawEcgData => rawEcgDataSubject.AsObservable();
|
|
public IObservable<AccData> RawAccData => rawAccDataSubject.AsObservable();
|
|
public IObservable<AccData> RawAccData => rawAccDataSubject.AsObservable();
|
|
|
|
+
|
|
|
|
+ public IObservable<HRData> RawHRData => rawHRDataSubject.AsObservable();
|
|
|
|
|
|
public PolarSensorConfig SensorConfig { get; private set; }
|
|
public PolarSensorConfig SensorConfig { get; private set; }
|
|
public PolarSensorData SensorData => sensorData;
|
|
public PolarSensorData SensorData => sensorData;
|
|
@@ -48,7 +52,7 @@ namespace Sensors.Polar
|
|
|
|
|
|
public void StartListening()
|
|
public void StartListening()
|
|
{
|
|
{
|
|
- connection = new UdpConnection(SensorConfig.ipAddress, SensorConfig.port, OnAccData, OnEcgData);
|
|
|
|
|
|
+ connection = new UdpConnection(SensorConfig.ipAddress, SensorConfig.port, OnAccData, OnEcgData, OnHRData);
|
|
connection.Listen();
|
|
connection.Listen();
|
|
Debug.Log("PolarReceiver: Listening!");
|
|
Debug.Log("PolarReceiver: Listening!");
|
|
}
|
|
}
|
|
@@ -57,6 +61,7 @@ namespace Sensors.Polar
|
|
{
|
|
{
|
|
rawAccDataSubject.Dispose();
|
|
rawAccDataSubject.Dispose();
|
|
rawEcgDataSubject.Dispose();
|
|
rawEcgDataSubject.Dispose();
|
|
|
|
+ rawHRDataSubject.Dispose();
|
|
connection?.StopListening();
|
|
connection?.StopListening();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -80,5 +85,11 @@ namespace Sensors.Polar
|
|
rawEcgDataSubject.OnNext(data);
|
|
rawEcgDataSubject.OnNext(data);
|
|
sensorData.EcgValue = data.Values[0]; //TODO
|
|
sensorData.EcgValue = data.Values[0]; //TODO
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ private void OnHRData(HRData data)
|
|
|
|
+ {
|
|
|
|
+ rawHRDataSubject.OnNext(data);
|
|
|
|
+ sensorData.Hr = data.HeartRate;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|