Skip to content

Commit 3f2e48e

Browse files
committed
Added battery advisor in PieEmpaticaFirstAvail, added error advisor for physiolitix
1 parent 62539a5 commit 3f2e48e

File tree

1 file changed

+12
-5
lines changed
  • SensorFlow/plugins/src/main/java/eu/fbk/mpba/sensorsflows/plugins/inputs/empatica

1 file changed

+12
-5
lines changed

SensorFlow/plugins/src/main/java/eu/fbk/mpba/sensorsflows/plugins/inputs/empatica/EmpaticaNode.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package eu.fbk.mpba.sensorsflows.plugins.inputs.empatica;
22

33
import android.content.Context;
4+
import android.os.Handler;
45
import android.util.Log;
56
import android.widget.Toast;
67

@@ -18,6 +19,7 @@ public class EmpaticaNode implements NodePlugin<Long, double[]> {
1819
final String LOG_TAG = "ALE EMP DEV";
1920

2021
private boolean lastCheckTODO = true;
22+
private float batteryLevel = -1;
2123

2224
final EmpaticaBeam beam;
2325
final EmpaticaSensor.Accelerometer mAcc;
@@ -58,11 +60,6 @@ public EmpaticaNode(String key, final Context context, String address, Runnable
5860
@Override
5961
public void didReceiveAcceleration(int x, int y, int z, double timestamp) {
6062
mAcc.sensorValue(proTime(timestamp), new double[]{x, y, z});
61-
if (lastCheckTODO) {
62-
lastCheckTODO = false;
63-
if (connectedStreaming != null)
64-
new Thread(connectedStreaming).start();
65-
}
6663
}
6764

6865
@Override
@@ -72,6 +69,12 @@ public void didReceiveBVP(float bvp, double timestamp) {
7269

7370
@Override
7471
public void didReceiveBatteryLevel(float battery, double timestamp) {
72+
batteryLevel = battery;
73+
if (lastCheckTODO) {
74+
lastCheckTODO = false;
75+
if (connectedStreaming != null)
76+
new Handler(context.getMainLooper()).post(connectedStreaming);
77+
}
7578
mBat.sensorValue(proTime(timestamp), new double[]{battery});
7679
Log.v(LOG_TAG, EmpaticaNode.this.getName() + " didReceiveBatteryLevel: " + battery);
7780
}
@@ -183,4 +186,8 @@ protected void finalize() throws Throwable {
183186
public void close() {
184187
beam.destroy();
185188
}
189+
190+
public float getBatteryLevel() {
191+
return batteryLevel;
192+
}
186193
}

0 commit comments

Comments
 (0)