Re-enabled logging to local db
This commit is contained in:
@@ -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="91"
|
android:versionCode="92"
|
||||||
android:versionName="3.7.0b">
|
android:versionName="3.9.0a">
|
||||||
<!-- 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" />
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ public class LogManager {
|
|||||||
|
|
||||||
|
|
||||||
public LogManager(Context context) {
|
public LogManager(Context context) {
|
||||||
|
Log.d(TAG,"LogManger Constructor");
|
||||||
mLogRemote = false;
|
mLogRemote = false;
|
||||||
mLogRemoteMobile = false;
|
mLogRemoteMobile = false;
|
||||||
mOSDUrl = null;
|
mOSDUrl = null;
|
||||||
@@ -74,17 +75,21 @@ public class LogManager {
|
|||||||
|
|
||||||
Handler handler = new Handler();
|
Handler handler = new Handler();
|
||||||
mUtil = new OsdUtil(mContext, handler);
|
mUtil = new OsdUtil(mContext, handler);
|
||||||
|
openDb();
|
||||||
startRemoteLogTimer();
|
startRemoteLogTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean openDb() {
|
private boolean openDb() {
|
||||||
|
Log.d(TAG, "openDb");
|
||||||
try {
|
try {
|
||||||
mOSDDb = new OsdDbHelper(mDbTableName, mContext);
|
mOSDDb = new OsdDbHelper(mDbTableName, mContext);
|
||||||
if (!checkTableExists(mOSDDb, mDbTableName)) {
|
if (!checkTableExists(mOSDDb, mDbTableName)) {
|
||||||
Log.e(TAG,"ERROR - Table does not exist");
|
Log.e(TAG,"ERROR - Table does not exist");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
Log.d(TAG,"table "+mDbTableName+" exists ok");
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
Log.e(TAG, "Failed to open Database: " + e.toString());
|
Log.e(TAG, "Failed to open Database: " + e.toString());
|
||||||
@@ -96,6 +101,7 @@ public class LogManager {
|
|||||||
private boolean checkTableExists(OsdDbHelper osdDb, String osdTableName) {
|
private boolean checkTableExists(OsdDbHelper osdDb, String osdTableName) {
|
||||||
Cursor c = null;
|
Cursor c = null;
|
||||||
boolean tableExists = false;
|
boolean tableExists = false;
|
||||||
|
Log.d(TAG,"checkTableExists()");
|
||||||
try {
|
try {
|
||||||
c = osdDb.getWritableDatabase().query(osdTableName, null,
|
c = osdDb.getWritableDatabase().query(osdTableName, null,
|
||||||
null, null, null, null, null);
|
null, null, null, null, null);
|
||||||
@@ -120,6 +126,9 @@ public class LogManager {
|
|||||||
String SQLStr = "SQLStr";
|
String SQLStr = "SQLStr";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
double roiRatio = -1;
|
||||||
|
if (sdData.specPower != 0)
|
||||||
|
roiRatio = 10. * sdData.roiPower / sdData.specPower;
|
||||||
SQLStr = "INSERT INTO "+ mDbTableName
|
SQLStr = "INSERT INTO "+ mDbTableName
|
||||||
+ "(dataTime, wearer_id, BattPC, specPow, roiRatio, avAcc, sdAcc, hr, status, dataJSON, uploaded)"
|
+ "(dataTime, wearer_id, BattPC, specPow, roiRatio, avAcc, sdAcc, hr, status, dataJSON, uploaded)"
|
||||||
+ " VALUES("
|
+ " VALUES("
|
||||||
@@ -127,7 +136,7 @@ public class LogManager {
|
|||||||
+ -1 + ","
|
+ -1 + ","
|
||||||
+ sdData.batteryPc + ","
|
+ sdData.batteryPc + ","
|
||||||
+ sdData.specPower + ","
|
+ sdData.specPower + ","
|
||||||
+ 10. * sdData.roiPower / sdData.specPower + ","
|
+ roiRatio + ","
|
||||||
+ sdData.getAvAcc() + ","
|
+ sdData.getAvAcc() + ","
|
||||||
+ sdData.getSdAcc() + ","
|
+ sdData.getSdAcc() + ","
|
||||||
+ sdData.mHR + ","
|
+ sdData.mHR + ","
|
||||||
@@ -136,6 +145,7 @@ public class LogManager {
|
|||||||
+ 0
|
+ 0
|
||||||
+")";
|
+")";
|
||||||
mOSDDb.getWritableDatabase().execSQL(SQLStr);
|
mOSDDb.getWritableDatabase().execSQL(SQLStr);
|
||||||
|
Log.d(TAG,"data written to database");
|
||||||
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
Log.e(TAG,"writeToLocalDb(): Error Writing Data: " + e.toString());
|
Log.e(TAG,"writeToLocalDb(): Error Writing Data: " + e.toString());
|
||||||
@@ -302,10 +312,11 @@ public class LogManager {
|
|||||||
public static final int DATABASE_VERSION = 1;
|
public static final int DATABASE_VERSION = 1;
|
||||||
public static final String DATABASE_NAME = "OsdData.db";
|
public static final String DATABASE_NAME = "OsdData.db";
|
||||||
private String mOsdTableName;
|
private String mOsdTableName;
|
||||||
private String TAG = "OsdDbHelper";
|
private String TAG = "LogManager.OsdDbHelper";
|
||||||
|
|
||||||
public OsdDbHelper(String osdTableName, Context context) {
|
public OsdDbHelper(String osdTableName, Context context) {
|
||||||
super(context, DATABASE_NAME, null, DATABASE_VERSION);
|
super(context, DATABASE_NAME, null, DATABASE_VERSION);
|
||||||
|
Log.d(TAG,"OsdDbHelper constructor");
|
||||||
mOsdTableName = osdTableName;
|
mOsdTableName = osdTableName;
|
||||||
}
|
}
|
||||||
public void onCreate(SQLiteDatabase db) {
|
public void onCreate(SQLiteDatabase db) {
|
||||||
|
|||||||
@@ -219,9 +219,7 @@ public class SdServer extends Service implements SdDataReceiver {
|
|||||||
updatePrefs();
|
updatePrefs();
|
||||||
|
|
||||||
// Create our log manager.
|
// Create our log manager.
|
||||||
//mLm = new LogManager(mLogDataRemote, mLogDataRemoteMobile,
|
mLm = new LogManager(this);
|
||||||
// mOSDUname, mOSDPasswd, mOSDWearerId, mOSDUrl, this);
|
|
||||||
//mLm = new LogManager(this);
|
|
||||||
|
|
||||||
Log.v(TAG, "onStartCommand: Datasource =" + mSdDataSourceName);
|
Log.v(TAG, "onStartCommand: Datasource =" + mSdDataSourceName);
|
||||||
switch (mSdDataSourceName) {
|
switch (mSdDataSourceName) {
|
||||||
@@ -1109,7 +1107,7 @@ public class SdServer extends Service implements SdDataReceiver {
|
|||||||
if (mLogData) {
|
if (mLogData) {
|
||||||
Log.v(TAG, "logData() - writing data to SD Card");
|
Log.v(TAG, "logData() - writing data to SD Card");
|
||||||
writeToSD();
|
writeToSD();
|
||||||
//mLm.writeToLocalDb(mSdData);
|
mLm.writeToLocalDb(mSdData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,8 @@
|
|||||||
<resources>
|
<resources>
|
||||||
<string name="app_name">OpenSeizureDetector</string>
|
<string name="app_name">OpenSeizureDetector</string>
|
||||||
<string name="changelog">
|
<string name="changelog">
|
||||||
"V3.7.0 - Added support for Garmin Blood Oxygen Saturation measurements
|
"V3.9.x - Added logging of data to remote server
|
||||||
|
\nV3.7.0 - Added support for Garmin Blood Oxygen Saturation measurements
|
||||||
\nV3.6.2 - Fix of issue with log file permissions on some Android 10 devices and added more translatable strings with polish translation.
|
\nV3.6.2 - Fix of issue with log file permissions on some Android 10 devices and added more translatable strings with polish translation.
|
||||||
\nV3.6.1 - Possible fix for issue with shutting down system and expanded Polish translation to all settings screens.
|
\nV3.6.1 - Possible fix for issue with shutting down system and expanded Polish translation to all settings screens.
|
||||||
\nV3.6 - Added phone sensor data source for testing without a watches
|
\nV3.6 - Added phone sensor data source for testing without a watches
|
||||||
|
|||||||
Reference in New Issue
Block a user