diff --git a/app/src/main/java/uk/org/openseizuredetector/FragmentCommon.java b/app/src/main/java/uk/org/openseizuredetector/FragmentCommon.java index 179f4e4..6c4226b 100644 --- a/app/src/main/java/uk/org/openseizuredetector/FragmentCommon.java +++ b/app/src/main/java/uk/org/openseizuredetector/FragmentCommon.java @@ -193,10 +193,11 @@ public class FragmentCommon extends FragmentOsdBaseClass { tv.setText(getString(R.string.DataSource) + " = " + "Phone (Demo Mode)"); tv.setBackgroundColor(warnColour); tv.setTextColor(warnTextColour); - } else if (mConnection.mSdServer.mSdDataSourceName.equals("BLE")) { + } else if (mConnection.mSdServer.mSdDataSourceName.equals("BLE") + || mConnection.mSdServer.mSdDataSourceName.equals("BLE2")) { tv.setText(getString(R.string.DataSource) + " = " + mConnection.mSdServer.mSdDataSourceName + " ("+ mConnection.mSdServer.mSdData.watchSdName + ", " - + mConnection.mSdServer.mSdData.watchPartNo+")"); + + mConnection.mSdServer.mSdData.watchSerNo+")"); } else { tv.setText(getString(R.string.DataSource) + " = " + mConnection.mSdServer.mSdDataSourceName); } diff --git a/app/src/main/java/uk/org/openseizuredetector/SdData.java b/app/src/main/java/uk/org/openseizuredetector/SdData.java index 12a38bc..79f04a0 100644 --- a/app/src/main/java/uk/org/openseizuredetector/SdData.java +++ b/app/src/main/java/uk/org/openseizuredetector/SdData.java @@ -144,6 +144,7 @@ public class SdData implements Parcelable { rawData = new double[N_RAW_DATA]; rawData3D = new double[N_RAW_DATA * 3]; dataTime = new Time(Time.getCurrentTimezone()); + dataTime.setToNow(); timeDiff = 0f; } @@ -164,8 +165,12 @@ public class SdData implements Parcelable { // FIXME - this doesn't work!!! Time tnow = new Time(); tnow.setToNow(); - timeDiff = (tnow.toMillis(false) - - dataTime.toMillis(false))/1000f; + if (dataTime != null) { + timeDiff = (tnow.toMillis(false) + - dataTime.toMillis(false)) / 1000f; + } else { + timeDiff = 0f; + } dataTime.setToNow(); Log.v(TAG, "fromJSON(): dataTime = " + dataTime.toString()); maxVal = jo.optInt("maxVal"); diff --git a/app/src/main/java/uk/org/openseizuredetector/SdDataSource.java b/app/src/main/java/uk/org/openseizuredetector/SdDataSource.java index b05c029..91c91a9 100644 --- a/app/src/main/java/uk/org/openseizuredetector/SdDataSource.java +++ b/app/src/main/java/uk/org/openseizuredetector/SdDataSource.java @@ -538,8 +538,12 @@ public abstract class SdDataSource { mSdData.roiPower = (long) roiPower / ACCEL_SCALE_FACTOR; Time tnow = new Time(); tnow.setToNow(); - mSdData.timeDiff = (tnow.toMillis(false) - - mSdData.dataTime.toMillis(false))/1000f; + if (mSdData.dataTime != null) { + mSdData.timeDiff = (tnow.toMillis(false) + - mSdData.dataTime.toMillis(false)) / 1000f; + } else { + mSdData.timeDiff = 0f; + } mSdData.dataTime.setToNow(); mSdData.dataTime.setToNow(); diff --git a/app/src/main/java/uk/org/openseizuredetector/SdDataSourceBLE2.java b/app/src/main/java/uk/org/openseizuredetector/SdDataSourceBLE2.java index cc8abc9..addabaa 100644 --- a/app/src/main/java/uk/org/openseizuredetector/SdDataSourceBLE2.java +++ b/app/src/main/java/uk/org/openseizuredetector/SdDataSourceBLE2.java @@ -153,8 +153,8 @@ public class SdDataSourceBLE2 extends SdDataSource { // FIXME: Read the shared preferences in this class so SdDataSource does not need to know // FIXME: about BLE details. Log.i(TAG, "mBLEDevice is " + mBleDeviceName + ", Addr=" + mBleDeviceAddr); - mSdData.watchSdName = mBleDeviceName; - mSdData.watchPartNo = mBleDeviceAddr; + //mSdData.watchSdName = mBleDeviceName; + mSdData.watchSerNo = mBleDeviceAddr; boolean success = CurrentTimeService.startServer(mContext); @@ -464,7 +464,8 @@ public class SdDataSourceBLE2 extends SdDataSource { byte[] rawDataBytes = characteristic.getValue(); String watchSerNo = new String(rawDataBytes, StandardCharsets.UTF_8); Log.i(TAG, "Received Watch Serial No.: " + watchSerNo); - mSdData.watchSerNo = watchSerNo; + //mSdData.watchSerNo = watchSerNo; + // We do not use this serial number because it is zero for PineTime - we set the MAC address at start-up instead. } else if (charUuidStr.equals(CHAR_DEV_HW_VER)) { byte[] rawDataBytes = characteristic.getValue(); String watchHwVer = new String(rawDataBytes, StandardCharsets.UTF_8);