diff --git a/app/src/main/java/uk/org/openseizuredetector/SdDataSourceNetworkPassive.java b/app/src/main/java/uk/org/openseizuredetector/SdDataSourceNetworkPassive.java index e4b9c73..3a12124 100644 --- a/app/src/main/java/uk/org/openseizuredetector/SdDataSourceNetworkPassive.java +++ b/app/src/main/java/uk/org/openseizuredetector/SdDataSourceNetworkPassive.java @@ -54,8 +54,10 @@ import static java.lang.Math.sqrt; /** - * Abstract class for a seizure detector data source. Subclasses include a pebble smart watch data source and a - * network data source. + * A Passive data source that expects a device to send it data periodically by sending a POST request. + * The POST network request is handled in the SDWebServer class, which calls the 'updateFrom JSON()' + * function to send the data to this datasource. + * SdWebServer expects POST requests to /data and /settings URLs to send data or watch settings. */ public class SdDataSourceNetworkPassive extends SdDataSource { private Handler mHandler = new Handler(); @@ -378,6 +380,8 @@ public class SdDataSourceNetworkPassive extends SdDataSource { // ******* POPULATE WITH DUMMY DATA ***** //makeTestData(); // ************************************** + // FIXME - Use specified sampleFreq, not this hard coded one + mSampleFreq = 25; double freqRes = 1.0*mSampleFreq/mNSamp; Log.v(TAG,"doAnalysis(): mSampleFreq="+mSampleFreq+" mNSamp="+mNSamp+": freqRes="+freqRes); // Set the frequency bounds for the analysis in fft output bin numbers. diff --git a/app/src/main/java/uk/org/openseizuredetector/SdWebServer.java b/app/src/main/java/uk/org/openseizuredetector/SdWebServer.java index 0f3ef2e..c8749bd 100644 --- a/app/src/main/java/uk/org/openseizuredetector/SdWebServer.java +++ b/app/src/main/java/uk/org/openseizuredetector/SdWebServer.java @@ -40,7 +40,7 @@ public class SdWebServer extends NanoHTTPD { } public void setSdData(SdData sdData) { - Log.v(TAG, "setSdData()"); + // Log.v(TAG, "setSdData()"); mSdData = sdData; } @@ -90,10 +90,16 @@ public class SdWebServer extends NanoHTTPD { Log.v(TAG, "WebServer.serve() - POST /data - receiving data from device: parameters=" + parameters.toString()); Log.v(TAG, " header=" + header.toString()); Log.v(TAG, " files=" + files.toString()); - //String postData = files.get("postData"); - //Log.v(TAG, " postData=" + postData); + String postData = files.get("postData"); + Log.v(TAG, " postData=" + postData); // Send the data to the SdDataSource so the app can pick it up. - mSdServer.mSdDataSource.updateFromJSON(parameters.toString()); + if (parameters != null) { + Log.v(TAG,"passing parameters to data source"); + mSdServer.mSdDataSource.updateFromJSON(parameters.get("dataObj").toString()); + } else { + Log.v(TAG,"Passing postData to data source"); + mSdServer.mSdDataSource.updateFromJSON(files.get("postData")); + } if (mSdData.haveSettings) { answer = "OK"; } else {