Added experimental support for fall detection, with ability to change fall detection settings from android app.
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="uk.org.openseizuredetector"
|
package="uk.org.openseizuredetector"
|
||||||
android:versionCode="15"
|
android:versionCode="16"
|
||||||
android:versionName="1.11b">
|
android:versionName="1.12">
|
||||||
<uses-sdk android:minSdkVersion="11" />
|
<uses-sdk android:minSdkVersion="11" />
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
||||||
|
|||||||
@@ -111,6 +111,11 @@ public class SdServer extends Service
|
|||||||
private int KEY_NMAX = 17;
|
private int KEY_NMAX = 17;
|
||||||
private int KEY_ALARM_RATIO_THRESH = 18;
|
private int KEY_ALARM_RATIO_THRESH = 18;
|
||||||
private int KEY_BATTERY_PC = 19;
|
private int KEY_BATTERY_PC = 19;
|
||||||
|
//private int KEY_SET_SETTINGS =20; // Phone is asking us to update watch app settings.
|
||||||
|
private int KEY_FALL_THRESH_MIN = 21;
|
||||||
|
private int KEY_FALL_THRESH_MAX = 22;
|
||||||
|
private int KEY_FALL_WINDOW = 23;
|
||||||
|
private int KEY_FALL_ACTIVE =24;
|
||||||
|
|
||||||
// Values of the KEY_DATA_TYPE entry in a message
|
// Values of the KEY_DATA_TYPE entry in a message
|
||||||
private int DATA_TYPE_RESULTS = 1; // Analysis Results
|
private int DATA_TYPE_RESULTS = 1; // Analysis Results
|
||||||
@@ -470,7 +475,7 @@ public class SdServer extends Service
|
|||||||
if (sdData.alarmState == 2) {
|
if (sdData.alarmState == 2) {
|
||||||
sdData.alarmPhrase = "ALARM";
|
sdData.alarmPhrase = "ALARM";
|
||||||
if (mLogAlarms) {
|
if (mLogAlarms) {
|
||||||
Log.v(TAG, "***ALARM*** - Loggin to SD Card");
|
Log.v(TAG, "***ALARM*** - Logging to SD Card");
|
||||||
writeAlarmToSD();
|
writeAlarmToSD();
|
||||||
logData();
|
logData();
|
||||||
} else {
|
} else {
|
||||||
@@ -491,6 +496,30 @@ public class SdServer extends Service
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (sdData.alarmState == 3) {
|
||||||
|
sdData.alarmPhrase = "FALL";
|
||||||
|
if (mLogAlarms) {
|
||||||
|
Log.v(TAG, "***FALL*** - Logging to SD Card");
|
||||||
|
writeAlarmToSD();
|
||||||
|
logData();
|
||||||
|
} else {
|
||||||
|
Log.v(TAG, "***FALL***");
|
||||||
|
}
|
||||||
|
// Make alarm beep tone
|
||||||
|
alarmBeep();
|
||||||
|
// Send SMS Alarm.
|
||||||
|
if (mSMSAlarm) {
|
||||||
|
Time tnow = new Time(Time.getCurrentTimezone());
|
||||||
|
tnow.setToNow();
|
||||||
|
// limit SMS alarms to one per minute
|
||||||
|
if ((tnow.toMillis(false)
|
||||||
|
- mSMSTime.toMillis(false))
|
||||||
|
> 60000) {
|
||||||
|
sendSMSAlarm();
|
||||||
|
mSMSTime = tnow;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Read the data that has been sent, and convert it into
|
// Read the data that has been sent, and convert it into
|
||||||
@@ -747,7 +776,31 @@ public class SdServer extends Service
|
|||||||
intVal = (short)Integer.parseInt(prefStr);
|
intVal = (short)Integer.parseInt(prefStr);
|
||||||
Log.v(TAG, "updatePrefs() AlarmRatioThresh = " + intVal);
|
Log.v(TAG, "updatePrefs() AlarmRatioThresh = " + intVal);
|
||||||
setDict.addUint16(KEY_ALARM_RATIO_THRESH, (short) intVal);
|
setDict.addUint16(KEY_ALARM_RATIO_THRESH, (short) intVal);
|
||||||
// Send to Pebble
|
|
||||||
|
boolean fallActiveBool = SP.getBoolean("FallActive",false);
|
||||||
|
Log.v(TAG, "updatePrefs() FallActive = " + fallActiveBool);
|
||||||
|
if (fallActiveBool)
|
||||||
|
setDict.addUint16(KEY_FALL_ACTIVE,(short)1);
|
||||||
|
else
|
||||||
|
setDict.addUint16(KEY_FALL_ACTIVE,(short)0);
|
||||||
|
|
||||||
|
prefStr = SP.getString("FallThreshMin","200");
|
||||||
|
intVal = (short)Integer.parseInt(prefStr);
|
||||||
|
Log.v(TAG,"updatePrefs() FallThreshMin = "+intVal);
|
||||||
|
setDict.addUint16(KEY_FALL_THRESH_MIN,(short)intVal);
|
||||||
|
|
||||||
|
prefStr = SP.getString("FallThreshMax","1200");
|
||||||
|
intVal = (short)Integer.parseInt(prefStr);
|
||||||
|
Log.v(TAG,"updatePrefs() FallThreshMax = "+intVal);
|
||||||
|
setDict.addUint16(KEY_FALL_THRESH_MAX,(short)intVal);
|
||||||
|
|
||||||
|
prefStr = SP.getString("FallWindow","1500");
|
||||||
|
intVal = (short)Integer.parseInt(prefStr);
|
||||||
|
Log.v(TAG,"updatePrefs() FallWindow = "+intVal);
|
||||||
|
setDict.addUint16(KEY_FALL_WINDOW,(short)intVal);
|
||||||
|
|
||||||
|
|
||||||
|
// Send Watch Settings to Pebble
|
||||||
Log.v(TAG,"updatePrefs() - setDict = "+setDict.toJsonString());
|
Log.v(TAG,"updatePrefs() - setDict = "+setDict.toJsonString());
|
||||||
PebbleKit.sendDataToPebble(getApplicationContext(), SD_UUID, setDict);
|
PebbleKit.sendDataToPebble(getApplicationContext(), SD_UUID, setDict);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
|||||||
@@ -84,6 +84,28 @@
|
|||||||
android:summary="Alarm Ratio Threshold (Default = 30)"
|
android:summary="Alarm Ratio Threshold (Default = 30)"
|
||||||
android:defaultValue="30" />
|
android:defaultValue="30" />
|
||||||
|
|
||||||
|
<CheckBoxPreference
|
||||||
|
android:key="FallActive"
|
||||||
|
android:title="Activate Fall Detection Function"
|
||||||
|
android:summary=""
|
||||||
|
android:defaultValue="false" />
|
||||||
|
<EditTextPreference
|
||||||
|
android:key="FallThreshMin"
|
||||||
|
android:title="Fall Detection Lower Threshold (milli-g)"
|
||||||
|
android:summary=""
|
||||||
|
android:defaultValue="200" />
|
||||||
|
<EditTextPreference
|
||||||
|
android:key="FallThreshMax"
|
||||||
|
android:title="Fall Detection Upper Threshold (milli-g)"
|
||||||
|
android:summary=""
|
||||||
|
android:defaultValue="1200" />
|
||||||
|
<EditTextPreference
|
||||||
|
android:key="FallWindow"
|
||||||
|
android:title="Fall Detection Window (milli-seconds)"
|
||||||
|
android:summary=""
|
||||||
|
android:defaultValue="1500" />
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<EditTextPreference
|
<EditTextPreference
|
||||||
android:key="AppRestartTimeout"
|
android:key="AppRestartTimeout"
|
||||||
|
|||||||
Reference in New Issue
Block a user