Sorted issue with startupActivity showing data recieved when it had not been, and disabled (non-functioning) ip camera settings.
This commit is contained in:
@@ -28,9 +28,11 @@ import android.os.Parcelable;
|
|||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.text.format.Time;
|
import android.text.format.Time;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
|
|
||||||
@@ -40,6 +42,7 @@ public class SdData implements Parcelable {
|
|||||||
private final static String TAG = "SdData";
|
private final static String TAG = "SdData";
|
||||||
/* Analysis settings */
|
/* Analysis settings */
|
||||||
public boolean haveSettings = false; // flag to say if we have received settings or not.
|
public boolean haveSettings = false; // flag to say if we have received settings or not.
|
||||||
|
public boolean haveData = false; // flag to say we have received data.
|
||||||
public long alarmFreqMin;
|
public long alarmFreqMin;
|
||||||
public long alarmFreqMax;
|
public long alarmFreqMax;
|
||||||
public long nMin;
|
public long nMin;
|
||||||
@@ -51,7 +54,7 @@ public class SdData implements Parcelable {
|
|||||||
public long batteryPc;
|
public long batteryPc;
|
||||||
|
|
||||||
/* Analysis results */
|
/* Analysis results */
|
||||||
public Time dataTime;
|
public Time dataTime = null;
|
||||||
public long alarmState;
|
public long alarmState;
|
||||||
public boolean alarmStanding = false;
|
public boolean alarmStanding = false;
|
||||||
public boolean fallAlarmStanding = false;
|
public boolean fallAlarmStanding = false;
|
||||||
@@ -74,11 +77,11 @@ public class SdData implements Parcelable {
|
|||||||
* Intialise this SdData object from a JSON String
|
* Intialise this SdData object from a JSON String
|
||||||
*/
|
*/
|
||||||
public boolean fromJSON(String jsonStr) {
|
public boolean fromJSON(String jsonStr) {
|
||||||
Log.v(TAG,"fromJSON() - parsing jsonString - "+jsonStr);
|
Log.v(TAG, "fromJSON() - parsing jsonString - " + jsonStr);
|
||||||
try {
|
try {
|
||||||
JSONObject jo = new JSONObject(jsonStr);
|
JSONObject jo = new JSONObject(jsonStr);
|
||||||
Log.v(TAG,"fromJSON(): jo = "+jo.toString());
|
Log.v(TAG, "fromJSON(): jo = " + jo.toString());
|
||||||
Log.v(TAG,"fromJSON(): dataTimeStr="+jo.optString("dataTimeStr"));
|
Log.v(TAG, "fromJSON(): dataTimeStr=" + jo.optString("dataTimeStr"));
|
||||||
//Calendar cal = Calendar.getInstance();
|
//Calendar cal = Calendar.getInstance();
|
||||||
//SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddTHHmmss", Locale.UK);
|
//SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddTHHmmss", Locale.UK);
|
||||||
//cal.setTime(sdf.parse(jo.optString("dataTimeStr")));
|
//cal.setTime(sdf.parse(jo.optString("dataTimeStr")));
|
||||||
@@ -98,16 +101,16 @@ public class SdData implements Parcelable {
|
|||||||
alarmThresh = jo.optInt("alarmThresh");
|
alarmThresh = jo.optInt("alarmThresh");
|
||||||
alarmRatioThresh = jo.optInt("alarmRatioThresh");
|
alarmRatioThresh = jo.optInt("alarmRatioThresh");
|
||||||
JSONArray specArr = jo.optJSONArray("simpleSpec");
|
JSONArray specArr = jo.optJSONArray("simpleSpec");
|
||||||
for (int i=0;i<specArr.length();i++) {
|
for (int i = 0; i < specArr.length(); i++) {
|
||||||
simpleSpec[i] = specArr.optInt(i);
|
simpleSpec[i] = specArr.optInt(i);
|
||||||
}
|
}
|
||||||
|
haveData = true;
|
||||||
return true;
|
return true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.v(TAG,"fromJSON() - error parsing result");
|
Log.v(TAG, "fromJSON() - error parsing result");
|
||||||
|
haveData = false;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -121,39 +124,39 @@ public class SdData implements Parcelable {
|
|||||||
try {
|
try {
|
||||||
JSONObject jsonObj = new JSONObject();
|
JSONObject jsonObj = new JSONObject();
|
||||||
if (dataTime != null) {
|
if (dataTime != null) {
|
||||||
jsonObj.put("dataTime",dataTime.format("%d-%m-%Y %H:%M:%S"));
|
jsonObj.put("dataTime", dataTime.format("%d-%m-%Y %H:%M:%S"));
|
||||||
jsonObj.put("dataTimeStr",dataTime.format("%Y%m%dT%H%M%S"));
|
jsonObj.put("dataTimeStr", dataTime.format("%Y%m%dT%H%M%S"));
|
||||||
} else {
|
}else{
|
||||||
jsonObj.put("dataTimeStr","00000000T000000");
|
jsonObj.put("dataTimeStr", "00000000T000000");
|
||||||
jsonObj.put("dataTime","00-00-00 00:00:00");
|
jsonObj.put("dataTime", "00-00-00 00:00:00");
|
||||||
}
|
}
|
||||||
Log.v(TAG,"mSdData.dataTime = " + dataTime);
|
Log.v(TAG, "mSdData.dataTime = " + dataTime);
|
||||||
jsonObj.put("maxVal", maxVal);
|
jsonObj.put("maxVal", maxVal);
|
||||||
jsonObj.put("maxFreq",maxFreq);
|
jsonObj.put("maxFreq", maxFreq);
|
||||||
jsonObj.put("specPower",specPower);
|
jsonObj.put("specPower", specPower);
|
||||||
jsonObj.put("roiPower",roiPower);
|
jsonObj.put("roiPower", roiPower);
|
||||||
jsonObj.put("batteryPc",batteryPc);
|
jsonObj.put("batteryPc", batteryPc);
|
||||||
jsonObj.put("pebbleConnected",pebbleConnected);
|
jsonObj.put("pebbleConnected", pebbleConnected);
|
||||||
jsonObj.put("pebbleAppRunning",pebbleAppRunning);
|
jsonObj.put("pebbleAppRunning", pebbleAppRunning);
|
||||||
jsonObj.put("haveSettings",haveSettings);
|
jsonObj.put("haveSettings", haveSettings);
|
||||||
jsonObj.put("alarmState",alarmState);
|
jsonObj.put("alarmState", alarmState);
|
||||||
jsonObj.put("alarmPhrase",alarmPhrase);
|
jsonObj.put("alarmPhrase", alarmPhrase);
|
||||||
jsonObj.put("alarmThresh",alarmThresh);
|
jsonObj.put("alarmThresh", alarmThresh);
|
||||||
jsonObj.put("alarmRatioThresh",alarmRatioThresh);
|
jsonObj.put("alarmRatioThresh", alarmRatioThresh);
|
||||||
JSONArray arr = new JSONArray();
|
JSONArray arr = new JSONArray();
|
||||||
for (int i=0;i<simpleSpec.length;i++) {
|
for (int i = 0; i < simpleSpec.length; i++) {
|
||||||
arr.put(simpleSpec[i]);
|
arr.put(simpleSpec[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
jsonObj.put("simpleSpec",arr);
|
jsonObj.put("simpleSpec", arr);
|
||||||
|
|
||||||
retval = jsonObj.toString();
|
retval = jsonObj.toString();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
Log.v(TAG,"Error Creating Data Object - "+ex.toString());
|
Log.v(TAG, "Error Creating Data Object - " + ex.toString());
|
||||||
retval = "Error Creating Data Object - "+ex.toString();
|
retval = "Error Creating Data Object - " + ex.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
return(retval);
|
return (retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int describeContents() {
|
public int describeContents() {
|
||||||
@@ -174,6 +177,7 @@ public class SdData implements Parcelable {
|
|||||||
public SdData createFromParcel(Parcel in) {
|
public SdData createFromParcel(Parcel in) {
|
||||||
return new SdData(in);
|
return new SdData(in);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SdData[] newArray(int size) {
|
public SdData[] newArray(int size) {
|
||||||
return new SdData[size];
|
return new SdData[size];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -338,6 +338,7 @@ public class SdDataSourcePebble extends SdDataSource {
|
|||||||
mSdData.specPower = data.getUnsignedIntegerAsLong(KEY_SPECPOWER);
|
mSdData.specPower = data.getUnsignedIntegerAsLong(KEY_SPECPOWER);
|
||||||
mSdData.roiPower = data.getUnsignedIntegerAsLong(KEY_ROIPOWER);
|
mSdData.roiPower = data.getUnsignedIntegerAsLong(KEY_ROIPOWER);
|
||||||
mSdData.alarmPhrase = "Unknown";
|
mSdData.alarmPhrase = "Unknown";
|
||||||
|
mSdData.haveData = true;
|
||||||
mSdDataReceiver.onSdDataReceived(mSdData);
|
mSdDataReceiver.onSdDataReceived(mSdData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -465,6 +466,7 @@ public class SdDataSourcePebble extends SdDataSource {
|
|||||||
mSdData.pebbleAppRunning = false;
|
mSdData.pebbleAppRunning = false;
|
||||||
Log.v(TAG, "getPebbleStatus() - Pebble App Not Running - Attempting to Re-Start");
|
Log.v(TAG, "getPebbleStatus() - Pebble App Not Running - Attempting to Re-Start");
|
||||||
startWatchApp();
|
startWatchApp();
|
||||||
|
mPebbleStatusTime = tnow; // set status time to now so we do not re-start app repeatedly.
|
||||||
getPebbleSdSettings();
|
getPebbleSdSettings();
|
||||||
// Only make audible warning beep if we have not received data for more than mFaultTimerPeriod seconds.
|
// Only make audible warning beep if we have not received data for more than mFaultTimerPeriod seconds.
|
||||||
if (tdiff > (mDataPeriod+mFaultTimerPeriod) * 1000) {
|
if (tdiff > (mDataPeriod+mFaultTimerPeriod) * 1000) {
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ public class SdServer extends Service implements SdDataReceiver {
|
|||||||
private HandlerThread thread;
|
private HandlerThread thread;
|
||||||
private WakeLock mWakeLock = null;
|
private WakeLock mWakeLock = null;
|
||||||
public SdDataSource mSdDataSource;
|
public SdDataSource mSdDataSource;
|
||||||
public SdData mSdData;
|
public SdData mSdData = null;
|
||||||
public String mSdDataSourceName = "undefined"; // The name of the data soruce specified in the preferences.
|
public String mSdDataSourceName = "undefined"; // The name of the data soruce specified in the preferences.
|
||||||
private boolean mLatchAlarms = false;
|
private boolean mLatchAlarms = false;
|
||||||
private boolean mCancelAudible = false;
|
private boolean mCancelAudible = false;
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ public class SdServiceConnection implements ServiceConnection {
|
|||||||
public boolean hasSdData() {
|
public boolean hasSdData() {
|
||||||
if (mSdServer!=null) {
|
if (mSdServer!=null) {
|
||||||
if (mSdServer.mSdData!=null) {
|
if (mSdServer.mSdData!=null) {
|
||||||
return true;
|
return mSdServer.mSdData.haveData;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -31,7 +31,9 @@
|
|||||||
android:defaultValue="true"
|
android:defaultValue="true"
|
||||||
android:key="UseIpCamera"
|
android:key="UseIpCamera"
|
||||||
android:summary="Use IP Camera to View Images"
|
android:summary="Use IP Camera to View Images"
|
||||||
android:title="Enable IP Camera" />
|
android:title="Enable IP Camera"
|
||||||
|
android:enabled="False"
|
||||||
|
/>
|
||||||
|
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
|||||||
@@ -25,7 +25,9 @@
|
|||||||
<header android:fragment="uk.org.openseizuredetector.PrefActivity$CameraPrefsFragment"
|
<header android:fragment="uk.org.openseizuredetector.PrefActivity$CameraPrefsFragment"
|
||||||
android:icon="@drawable/icon_24x24"
|
android:icon="@drawable/icon_24x24"
|
||||||
android:title="Camera Settings"
|
android:title="Camera Settings"
|
||||||
android:summary="IP Camera Preferences" />
|
android:summary="IP Camera Preferences"
|
||||||
|
android:enabled="false"
|
||||||
|
/>
|
||||||
|
|
||||||
|
|
||||||
</preference-headers>
|
</preference-headers>
|
||||||
Reference in New Issue
Block a user