Added extra debugging information to log file in the event of an exception during analysis.

This commit is contained in:
Graham Jones
2020-11-06 13:39:44 +00:00
parent 7f368b3655
commit 36285f0d09
5 changed files with 147 additions and 118 deletions

Binary file not shown.

Binary file not shown.

View File

@@ -11,8 +11,8 @@
"type": "SINGLE", "type": "SINGLE",
"filters": [], "filters": [],
"properties": [], "properties": [],
"versionCode": 79, "versionCode": 80,
"versionName": "3.6.1f", "versionName": "3.6.1g",
"enabled": true, "enabled": true,
"outputFile": "app-release.apk" "outputFile": "app-release.apk"
} }

View File

@@ -2,8 +2,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
package="uk.org.openseizuredetector" package="uk.org.openseizuredetector"
android:versionCode="79" android:versionCode="80"
android:versionName="3.6.1f"> android:versionName="3.6.1g">
<!-- android:allowBackup="false" --> <!-- android:allowBackup="false" -->
<uses-permission android:name="android.permission.BLUETOOTH" /> <uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />

View File

@@ -45,6 +45,7 @@ import java.util.TimerTask;
interface SdDataReceiver { interface SdDataReceiver {
public void onSdDataReceived(SdData sdData); public void onSdDataReceived(SdData sdData);
public void onSdDataFault(SdData sdData); public void onSdDataFault(SdData sdData);
} }
@@ -97,7 +98,6 @@ public abstract class SdDataSource {
private int ACCEL_SCALE_FACTOR = 1000; // Amount by which to reduce analysis results to scale to be comparable to analysis on Pebble. private int ACCEL_SCALE_FACTOR = 1000; // Amount by which to reduce analysis results to scale to be comparable to analysis on Pebble.
private int mAlarmCount; private int mAlarmCount;
protected String mBleDeviceAddr; protected String mBleDeviceAddr;
protected String mBleDeviceName; protected String mBleDeviceName;
@@ -114,6 +114,7 @@ public abstract class SdDataSource {
/** /**
* Returns the SdData object stored by this class. * Returns the SdData object stored by this class.
*
* @return * @return
*/ */
public SdData getSdData() { public SdData getSdData() {
@@ -211,7 +212,7 @@ public abstract class SdDataSource {
} catch (Exception e) { } catch (Exception e) {
Log.v(TAG, "Error in stop() - " + e.toString()); Log.v(TAG, "Error in stop() - " + e.toString());
mUtil.writeToSysLogFile("SDDataSource.stop() - error - "+e.toString()); mUtil.writeToSysLogFile("SDDataSource.stop() - error - " + e.toString());
} }
} }
@@ -220,7 +221,7 @@ public abstract class SdDataSource {
* Install the watch app on the watch. * Install the watch app on the watch.
*/ */
public void installWatchApp() { public void installWatchApp() {
Log.v(TAG,"installWatchApp"); Log.v(TAG, "installWatchApp");
try { try {
String url = "http://www.openseizuredetector.org.uk/?page_id=1207"; String url = "http://www.openseizuredetector.org.uk/?page_id=1207";
Intent i = new Intent(Intent.ACTION_VIEW); Intent i = new Intent(Intent.ACTION_VIEW);
@@ -233,9 +234,13 @@ public abstract class SdDataSource {
} }
} }
public void startPebbleApp() { Log.v(TAG,"startPebbleApp()"); } public void startPebbleApp() {
Log.v(TAG, "startPebbleApp()");
}
public void acceptAlarm() { Log.v(TAG,"acceptAlarm()"); } public void acceptAlarm() {
Log.v(TAG, "acceptAlarm()");
}
// Force the data stored in this datasource to update in line with the JSON string encoded data provided. // Force the data stored in this datasource to update in line with the JSON string encoded data provided.
// Used by webServer to update the GarminDatasource. // Used by webServer to update the GarminDatasource.
@@ -246,16 +251,17 @@ public abstract class SdDataSource {
String watchFwVersion; String watchFwVersion;
String sdVersion; String sdVersion;
String sdName; String sdName;
Log.v(TAG,"updateFromJSON - "+jsonStr); JSONArray accelVals = null;
Log.v(TAG, "updateFromJSON - " + jsonStr);
try { try {
JSONObject mainObject = new JSONObject(jsonStr); JSONObject mainObject = new JSONObject(jsonStr);
//JSONObject dataObject = mainObject.getJSONObject("dataObj"); //JSONObject dataObject = mainObject.getJSONObject("dataObj");
JSONObject dataObject = mainObject; JSONObject dataObject = mainObject;
String dataTypeStr = dataObject.getString("dataType"); String dataTypeStr = dataObject.getString("dataType");
Log.v(TAG,"updateFromJSON - dataType="+dataTypeStr); Log.v(TAG, "updateFromJSON - dataType=" + dataTypeStr);
if (dataTypeStr.equals("raw")) { if (dataTypeStr.equals("raw")) {
Log.v(TAG,"updateFromJSON - processing raw data"); Log.v(TAG, "updateFromJSON - processing raw data");
try { try {
mSdData.mHR = dataObject.getDouble("HR"); mSdData.mHR = dataObject.getDouble("HR");
} catch (JSONException e) { } catch (JSONException e) {
@@ -268,8 +274,12 @@ public abstract class SdDataSource {
// if we get 'null' HR (For example if the heart rate is not working) // if we get 'null' HR (For example if the heart rate is not working)
mMute = 0; mMute = 0;
} }
JSONArray accelVals = dataObject.getJSONArray("data"); accelVals = dataObject.getJSONArray("data");
Log.v(TAG, "Received " + accelVals.length() + " acceleration values"); Log.v(TAG, "Received " + accelVals.length() + " acceleration values, rawData Length is " + mSdData.rawData.length);
if (accelVals.length() > mSdData.rawData.length) {
mUtil.writeToSysLogFile("ERROR: Received " + accelVals.length() + " acceleration values, but rawData storage length is "
+ mSdData.rawData.length);
}
int i; int i;
for (i = 0; i < accelVals.length(); i++) { for (i = 0; i < accelVals.length(); i++) {
mSdData.rawData[i] = accelVals.getInt(i); mSdData.rawData[i] = accelVals.getInt(i);
@@ -283,26 +293,26 @@ public abstract class SdDataSource {
} else { } else {
retVal = "OK"; retVal = "OK";
} }
} else if (dataTypeStr.equals("settings")){ } else if (dataTypeStr.equals("settings")) {
Log.v(TAG,"updateFromJSON - processing settings"); Log.v(TAG, "updateFromJSON - processing settings");
mSamplePeriod = (short)dataObject.getInt("analysisPeriod"); mSamplePeriod = (short) dataObject.getInt("analysisPeriod");
mSampleFreq = (short)dataObject.getInt("sampleFreq"); mSampleFreq = (short) dataObject.getInt("sampleFreq");
mSdData.batteryPc = (short)dataObject.getInt("battery"); mSdData.batteryPc = (short) dataObject.getInt("battery");
Log.v(TAG,"updateFromJSON - mSamplePeriod="+mSamplePeriod+" mSampleFreq="+mSampleFreq); Log.v(TAG, "updateFromJSON - mSamplePeriod=" + mSamplePeriod + " mSampleFreq=" + mSampleFreq);
mUtil.writeToSysLogFile("SDDataSource.updateFromJSON - Settings Received"); mUtil.writeToSysLogFile("SDDataSource.updateFromJSON - Settings Received");
mUtil.writeToSysLogFile(" * mSamplePeriod="+mSamplePeriod+" mSampleFreq="+mSampleFreq); mUtil.writeToSysLogFile(" * mSamplePeriod=" + mSamplePeriod + " mSampleFreq=" + mSampleFreq);
mUtil.writeToSysLogFile(" * batteryPc = "+mSdData.batteryPc); mUtil.writeToSysLogFile(" * batteryPc = " + mSdData.batteryPc);
try { try {
watchPartNo = dataObject.getString("watchPartNo"); watchPartNo = dataObject.getString("watchPartNo");
watchFwVersion = dataObject.getString("watchFwVersion"); watchFwVersion = dataObject.getString("watchFwVersion");
sdVersion = dataObject.getString("sdVersion"); sdVersion = dataObject.getString("sdVersion");
sdName = dataObject.getString("sdName"); sdName = dataObject.getString("sdName");
mUtil.writeToSysLogFile(" * sdName = "+sdName+" version "+sdVersion); mUtil.writeToSysLogFile(" * sdName = " + sdName + " version " + sdVersion);
mUtil.writeToSysLogFile(" * watchPartNo = "+watchPartNo+" fwVersion "+watchFwVersion); mUtil.writeToSysLogFile(" * watchPartNo = " + watchPartNo + " fwVersion " + watchFwVersion);
} catch (Exception e) { } catch (Exception e) {
Log.e(TAG,"updateFromJSON - Error Parsing V3.2 JSON String - "+e.toString()); Log.e(TAG, "updateFromJSON - Error Parsing V3.2 JSON String - " + e.toString());
mUtil.writeToSysLogFile("updateFromJSON - Error Parsing V3.2 JSON String - "+ jsonStr + " - " +e.toString()); mUtil.writeToSysLogFile("updateFromJSON - Error Parsing V3.2 JSON String - " + jsonStr + " - " + e.toString());
mUtil.writeToSysLogFile(" This is probably because of an out of date watch app - please upgrade!"); mUtil.writeToSysLogFile(" This is probably because of an out of date watch app - please upgrade!");
e.printStackTrace(); e.printStackTrace();
} }
@@ -311,28 +321,34 @@ public abstract class SdDataSource {
mWatchAppRunningCheck = true; mWatchAppRunningCheck = true;
retVal = "OK"; retVal = "OK";
} else { } else {
Log.e(TAG,"updateFromJSON - unrecognised dataType "+dataTypeStr); Log.e(TAG, "updateFromJSON - unrecognised dataType " + dataTypeStr);
retVal = "ERROR"; retVal = "ERROR";
} }
} catch (Exception e) { } catch (Exception e) {
Log.e(TAG,"updateFromJSON - Error Parsing JSON String - "+ jsonStr+" - "+e.toString()); Log.e(TAG, "updateFromJSON - Error Parsing JSON String - " + jsonStr + " - " + e.toString());
mUtil.writeToSysLogFile("updateFromJSON - Error Parsing JSON String - "+ jsonStr + " - "+e.toString()); mUtil.writeToSysLogFile("updateFromJSON - Error Parsing JSON String - " + jsonStr + " - " + e.toString());
mUtil.writeToSysLogFile("updateFromJSON: Exception at Line Number: "+e.getCause().getStackTrace()[0].getLineNumber()+", "+e.getCause().getStackTrace()[0].toString()); mUtil.writeToSysLogFile("updateFromJSON: Exception at Line Number: " + e.getCause().getStackTrace()[0].getLineNumber() + ", " + e.getCause().getStackTrace()[0].toString());
if (accelVals == null) {
mUtil.writeToSysLogFile("updateFromJSON: accelVals is null when exception thrown");
} else {
mUtil.writeToSysLogFile("updateFromJSON: Received " + accelVals.length() + " acceleration values");
}
e.printStackTrace(); e.printStackTrace();
retVal = "ERROR"; retVal = "ERROR";
} }
return(retVal); return (retVal);
} }
/** /**
* Calculate the magnitude of entry i in the fft array fft * Calculate the magnitude of entry i in the fft array fft
*
* @param fft * @param fft
* @param i * @param i
* @return magnitude ( Re*Re + Im*Im ) * @return magnitude ( Re*Re + Im*Im )
*/ */
private double getMagnitude(double[] fft, int i) { private double getMagnitude(double[] fft, int i) {
double mag; double mag;
mag = (fft[2*i]*fft[2*i] + fft[2*i + 1] * fft[2*i +1]); mag = (fft[2 * i] * fft[2 * i] + fft[2 * i + 1] * fft[2 * i + 1]);
return mag; return mag;
} }
@@ -341,21 +357,26 @@ public abstract class SdDataSource {
* and populate the output data structure mSdData * and populate the output data structure mSdData
*/ */
protected void doAnalysis() { protected void doAnalysis() {
int nMin = 0;
int nMax = 0;
int nFreqCutoff = 0;
double[] fft = null;
try {
// FIXME - Use specified sampleFreq, not this hard coded one // FIXME - Use specified sampleFreq, not this hard coded one
mSampleFreq = 25; mSampleFreq = 25;
double freqRes = 1.0*mSampleFreq/mSdData.mNsamp; double freqRes = 1.0 * mSampleFreq / mSdData.mNsamp;
Log.v(TAG,"doAnalysis(): mSampleFreq="+mSampleFreq+" mNSamp="+mSdData.mNsamp+": freqRes="+freqRes); Log.v(TAG, "doAnalysis(): mSampleFreq=" + mSampleFreq + " mNSamp=" + mSdData.mNsamp + ": freqRes=" + freqRes);
// Set the frequency bounds for the analysis in fft output bin numbers. // Set the frequency bounds for the analysis in fft output bin numbers.
int nMin = (int)(mAlarmFreqMin/freqRes); nMin = (int) (mAlarmFreqMin / freqRes);
int nMax = (int)(mAlarmFreqMax /freqRes); nMax = (int) (mAlarmFreqMax / freqRes);
Log.v(TAG,"doAnalysis(): mAlarmFreqMin="+mAlarmFreqMin+", nMin="+nMin Log.v(TAG, "doAnalysis(): mAlarmFreqMin=" + mAlarmFreqMin + ", nMin=" + nMin
+", mAlarmFreqMax="+mAlarmFreqMax+", nMax="+nMax); + ", mAlarmFreqMax=" + mAlarmFreqMax + ", nMax=" + nMax);
// Calculate the bin number of the cutoff frequency // Calculate the bin number of the cutoff frequency
int nFreqCutoff = (int)(mFreqCutoff /freqRes); nFreqCutoff = (int) (mFreqCutoff / freqRes);
Log.v(TAG,"mFreqCutoff = "+mFreqCutoff+", nFreqCutoff="+nFreqCutoff); Log.v(TAG, "mFreqCutoff = " + mFreqCutoff + ", nFreqCutoff=" + nFreqCutoff);
DoubleFFT_1D fftDo = new DoubleFFT_1D(mSdData.mNsamp); DoubleFFT_1D fftDo = new DoubleFFT_1D(mSdData.mNsamp);
double[] fft = new double[mSdData.mNsamp * 2]; fft = new double[mSdData.mNsamp * 2];
///System.arraycopy(mAccData, 0, fft, 0, mNsamp); ///System.arraycopy(mAccData, 0, fft, 0, mNsamp);
System.arraycopy(mSdData.rawData, 0, fft, 0, mSdData.mNsamp); System.arraycopy(mSdData.rawData, 0, fft, 0, mSdData.mNsamp);
fftDo.realForward(fft); fftDo.realForward(fft);
@@ -365,41 +386,41 @@ public abstract class SdDataSource {
double specPower = 0; double specPower = 0;
for (int i = 1; i < mSdData.mNsamp / 2; i++) { for (int i = 1; i < mSdData.mNsamp / 2; i++) {
if (i <= nFreqCutoff) { if (i <= nFreqCutoff) {
specPower = specPower + getMagnitude(fft,i); specPower = specPower + getMagnitude(fft, i);
} else { } else {
fft[2*i] = 0.; fft[2 * i] = 0.;
fft[2*i+1] = 0.; fft[2 * i + 1] = 0.;
} }
} }
//Log.v(TAG,"specPower = "+specPower); //Log.v(TAG,"specPower = "+specPower);
//specPower = specPower/(mSdData.mNsamp/2); //specPower = specPower/(mSdData.mNsamp/2);
specPower = specPower/mSdData.mNsamp/2; specPower = specPower / mSdData.mNsamp / 2;
//Log.v(TAG,"specPower = "+specPower); //Log.v(TAG,"specPower = "+specPower);
// Calculate the Region of Interest power and power ratio. // Calculate the Region of Interest power and power ratio.
double roiPower = 0; double roiPower = 0;
for (int i=nMin;i<nMax;i++) { for (int i = nMin; i < nMax; i++) {
roiPower = roiPower + getMagnitude(fft,i); roiPower = roiPower + getMagnitude(fft, i);
} }
roiPower = roiPower/(nMax - nMin); roiPower = roiPower / (nMax - nMin);
double roiRatio = 10 * roiPower / specPower; double roiRatio = 10 * roiPower / specPower;
// Calculate the simplified spectrum - power in 1Hz bins. // Calculate the simplified spectrum - power in 1Hz bins.
double[] simpleSpec = new double[SIMPLE_SPEC_FMAX+1]; double[] simpleSpec = new double[SIMPLE_SPEC_FMAX + 1];
for (int ifreq=0;ifreq<SIMPLE_SPEC_FMAX;ifreq++) { for (int ifreq = 0; ifreq < SIMPLE_SPEC_FMAX; ifreq++) {
int binMin = (int)(1 + ifreq/freqRes); // add 1 to loose dc component int binMin = (int) (1 + ifreq / freqRes); // add 1 to loose dc component
int binMax = (int)(1 + (ifreq+1)/freqRes); int binMax = (int) (1 + (ifreq + 1) / freqRes);
simpleSpec[ifreq]=0; simpleSpec[ifreq] = 0;
for (int i=binMin;i<binMax;i++) { for (int i = binMin; i < binMax; i++) {
simpleSpec[ifreq] = simpleSpec[ifreq] + getMagnitude(fft,i); simpleSpec[ifreq] = simpleSpec[ifreq] + getMagnitude(fft, i);
} }
simpleSpec[ifreq] = simpleSpec[ifreq] / (binMax-binMin); simpleSpec[ifreq] = simpleSpec[ifreq] / (binMax - binMin);
} }
// Populate the mSdData structure to communicate with the main SdServer service. // Populate the mSdData structure to communicate with the main SdServer service.
mDataStatusTime.setToNow(); mDataStatusTime.setToNow();
mSdData.specPower = (long)specPower / ACCEL_SCALE_FACTOR; mSdData.specPower = (long) specPower / ACCEL_SCALE_FACTOR;
mSdData.roiPower = (long)roiPower / ACCEL_SCALE_FACTOR; mSdData.roiPower = (long) roiPower / ACCEL_SCALE_FACTOR;
mSdData.dataTime.setToNow(); mSdData.dataTime.setToNow();
mSdData.maxVal = 0; // not used mSdData.maxVal = 0; // not used
mSdData.maxFreq = 0; // not used mSdData.maxFreq = 0; // not used
@@ -410,13 +431,24 @@ public abstract class SdDataSource {
mSdData.alarmFreqMax = mAlarmFreqMax; mSdData.alarmFreqMax = mAlarmFreqMax;
// note mSdData.batteryPc is set from settings data in updateFromJSON() // note mSdData.batteryPc is set from settings data in updateFromJSON()
// FIXME - I haven't worked out why dividing by 1000 seems necessary to get the graph on scale - we don't seem to do that with the Pebble. // FIXME - I haven't worked out why dividing by 1000 seems necessary to get the graph on scale - we don't seem to do that with the Pebble.
for(int i=0;i<SIMPLE_SPEC_FMAX;i++) { for (int i = 0; i < SIMPLE_SPEC_FMAX; i++) {
mSdData.simpleSpec[i] = (int)simpleSpec[i]/ACCEL_SCALE_FACTOR; mSdData.simpleSpec[i] = (int) simpleSpec[i] / ACCEL_SCALE_FACTOR;
} }
Log.v(TAG, "simpleSpec = " + Arrays.toString(mSdData.simpleSpec)); Log.v(TAG, "simpleSpec = " + Arrays.toString(mSdData.simpleSpec));
// Because we have received data, set flag to show watch app running. // Because we have received data, set flag to show watch app running.
mWatchAppRunningCheck = true; mWatchAppRunningCheck = true;
} catch (Exception e) {
Log.e(TAG, "doAnalysis - Exception during Analysis");
mUtil.writeToSysLogFile("doAnalysis - Exception during analysis - " + e.toString());
mUtil.writeToSysLogFile("doAnalysis: Exception at Line Number: " + e.getCause().getStackTrace()[0].getLineNumber() + ", " + e.getCause().getStackTrace()[0].toString());
mUtil.writeToSysLogFile("doAnalysis: mSdData.mNsamp="+mSdData.mNsamp);
mUtil.writeToSysLogFile("doAnalysis: alarmFreqMin="+mAlarmFreqMin+" nMin="+nMin);
mUtil.writeToSysLogFile("doAnalysis: alarmFreqMax="+mAlarmFreqMax+" nMax="+nMax);
mUtil.writeToSysLogFile("doAnalysis: nFreqCutoff.="+nFreqCutoff);
mUtil.writeToSysLogFile("doAnalysis: fft.length="+fft.length);
mWatchAppRunningCheck = false;
}
// Check this data to see if it represents an alarm state. // Check this data to see if it represents an alarm state.
alarmCheck(); alarmCheck();
@@ -500,13 +532,11 @@ public abstract class SdDataSource {
mSdData.mHRFaultStanding = true; mSdData.mHRFaultStanding = true;
mSdData.mHRAlarmStanding = false; mSdData.mHRAlarmStanding = false;
} }
} } else if ((mSdData.mHR > mSdData.mHRThreshMax) || (mSdData.mHR < mSdData.mHRThreshMin)) {
else if ((mSdData.mHR > mSdData.mHRThreshMax) || (mSdData.mHR < mSdData.mHRThreshMin)) {
Log.i(TAG, "Heart Rate Abnormal - " + mSdData.mHR + " bpm"); Log.i(TAG, "Heart Rate Abnormal - " + mSdData.mHR + " bpm");
mSdData.mHRFaultStanding = false; mSdData.mHRFaultStanding = false;
mSdData.mHRAlarmStanding = true; mSdData.mHRAlarmStanding = true;
} } else {
else {
mSdData.mHRFaultStanding = false; mSdData.mHRFaultStanding = false;
mSdData.mHRAlarmStanding = false; mSdData.mHRAlarmStanding = false;
} }
@@ -519,11 +549,11 @@ public abstract class SdDataSource {
* Called from clock_tick_handler() * Called from clock_tick_handler()
*/ */
public void fallCheck() { public void fallCheck() {
int i,j; int i, j;
double minAcc, maxAcc; double minAcc, maxAcc;
long fallWindowSamp = (mFallWindow*mSdData.mSampleFreq)/1000; // Convert ms to samples. long fallWindowSamp = (mFallWindow * mSdData.mSampleFreq) / 1000; // Convert ms to samples.
Log.v(TAG, "check_fall() - fallWindowSamp=" +fallWindowSamp); Log.v(TAG, "check_fall() - fallWindowSamp=" + fallWindowSamp);
// Move window through sample buffer, checking for fall. // Move window through sample buffer, checking for fall.
// Note - not resetting fallAlarmStanding means that fall alarms will always latch until the 'Accept Alarm' button // Note - not resetting fallAlarmStanding means that fall alarms will always latch until the 'Accept Alarm' button
// is pressed. // is pressed.
@@ -545,13 +575,13 @@ public abstract class SdDataSource {
return; return;
} }
if (mMute != 0) { if (mMute != 0) {
Log.v(TAG,"Mute Active - setting fall alarm to mute"); Log.v(TAG, "Mute Active - setting fall alarm to mute");
mSdData.fallAlarmStanding = false; mSdData.fallAlarmStanding = false;
} }
} }
} else { } else {
mSdData.mFallActive = false; mSdData.mFallActive = false;
Log.v(TAG,"check_fall - mFallActive is false - doing nothing"); Log.v(TAG, "check_fall - mFallActive is false - doing nothing");
} }
//if (debug) APP_LOG(APP_LOG_LEVEL_DEBUG,"check_fall() - minAcc=%d, maxAcc=%d", //if (debug) APP_LOG(APP_LOG_LEVEL_DEBUG,"check_fall() - minAcc=%d, maxAcc=%d",
// minAcc,maxAcc); // minAcc,maxAcc);
@@ -569,7 +599,7 @@ public abstract class SdDataSource {
// get time since the last data was received from the Pebble watch. // get time since the last data was received from the Pebble watch.
tdiff = (tnow.toMillis(false) - mDataStatusTime.toMillis(false)); tdiff = (tnow.toMillis(false) - mDataStatusTime.toMillis(false));
Log.v(TAG, "getStatus() - mWatchAppRunningCheck=" + mWatchAppRunningCheck + " tdiff=" + tdiff); Log.v(TAG, "getStatus() - mWatchAppRunningCheck=" + mWatchAppRunningCheck + " tdiff=" + tdiff);
Log.v(TAG,"getStatus() - tdiff="+tdiff+", mDataUpatePeriod="+mDataUpdatePeriod+", mAppRestartTimeout="+mAppRestartTimeout); Log.v(TAG, "getStatus() - tdiff=" + tdiff + ", mDataUpatePeriod=" + mDataUpdatePeriod + ", mAppRestartTimeout=" + mAppRestartTimeout);
mSdData.watchConnected = true; // We can't check connection for passive network connection, so set it to true to avoid errors. mSdData.watchConnected = true; // We can't check connection for passive network connection, so set it to true to avoid errors.
// And is the watch app running? // And is the watch app running?
@@ -663,10 +693,10 @@ public abstract class SdDataSource {
String prefStr; String prefStr;
prefStr = SP.getString("BLE_Device_Addr", "SET_FROM_XML"); prefStr = SP.getString("BLE_Device_Addr", "SET_FROM_XML");
mBleDeviceAddr = prefStr; mBleDeviceAddr = prefStr;
Log.v(TAG,"mBLEDeviceAddr="+mBleDeviceAddr); Log.v(TAG, "mBLEDeviceAddr=" + mBleDeviceAddr);
prefStr = SP.getString("BLE_Device_Name", "SET_FROM_XML"); prefStr = SP.getString("BLE_Device_Name", "SET_FROM_XML");
mBleDeviceName = prefStr; mBleDeviceName = prefStr;
Log.v(TAG,"mBLEDeviceName="+mBleDeviceName); Log.v(TAG, "mBLEDeviceName=" + mBleDeviceName);
prefStr = SP.getString("PebbleDebug", "SET_FROM_XML"); prefStr = SP.getString("PebbleDebug", "SET_FROM_XML");
if (prefStr != null) { if (prefStr != null) {
@@ -763,16 +793,16 @@ public abstract class SdDataSource {
} catch (Exception ex) { } catch (Exception ex) {
Log.v(TAG, "updatePrefs() - Problem parsing preferences!"); Log.v(TAG, "updatePrefs() - Problem parsing preferences!");
mUtil.writeToSysLogFile("SDDataSourceBLE.updatePrefs() - ERROR "+ex.toString()); mUtil.writeToSysLogFile("SDDataSourceBLE.updatePrefs() - ERROR " + ex.toString());
Toast toast = Toast.makeText(mContext, "Problem Parsing Preferences - Something won't work - Please go back to Settings and correct it!", Toast.LENGTH_SHORT); Toast toast = Toast.makeText(mContext, "Problem Parsing Preferences - Something won't work - Please go back to Settings and correct it!", Toast.LENGTH_SHORT);
toast.show(); toast.show();
} }
} }
/** /**
* Display a Toast message on screen. * Display a Toast message on screen.
*
* @param msg - message to display. * @param msg - message to display.
*/ */
public void showToast(String msg) { public void showToast(String msg) {
@@ -781,15 +811,14 @@ public abstract class SdDataSource {
} }
public class SdDataBroadcastReceiver extends BroadcastReceiver { public class SdDataBroadcastReceiver extends BroadcastReceiver {
//private String TAG = "SdDataBroadcastReceiver"; //private String TAG = "SdDataBroadcastReceiver";
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
Log.v(TAG,"SdDataBroadcastReceiver.onReceive()"); Log.v(TAG, "SdDataBroadcastReceiver.onReceive()");
String jsonStr = intent.getStringExtra("data"); String jsonStr = intent.getStringExtra("data");
Log.v(TAG,"SdDataBroadcastReceiver.onReceive() - data="+jsonStr); Log.v(TAG, "SdDataBroadcastReceiver.onReceive() - data=" + jsonStr);
updateFromJSON(jsonStr); updateFromJSON(jsonStr);
} }
} }