diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..15a15b2 --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml index 7ac24c7..f43d428 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -3,6 +3,9 @@ - + diff --git a/.idea/modules.xml b/.idea/modules.xml index 4d4cc30..dd40647 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -2,8 +2,8 @@ - + \ No newline at end of file diff --git a/PHP_upload_script.txt b/PHP_upload_script.txt index 04ae5fc..5d30b5b 100755 --- a/PHP_upload_script.txt +++ b/PHP_upload_script.txt @@ -1,40 +1,22 @@ $error) { - if ($error == UPLOAD_ERR_OK) { - $tmp_name = $_FILES["fileToUpload"]["tmp_name"][$key]; - $name = $_FILES["fileToUpload"]["name"][$key]; - $file_path = "./uploads/"; - $file_path = $file_path . $name; - if(move_uploaded_file($tmp_name, $file_path)) - { - echo "OK:".$name."\r\n"; +$target_dir = "../uploads/"; +foreach ($_FILES as $file) { + if ($file['type'] !== 'text/plain' && $file['type'] !== 'video/3gp') { + continue; // ignore non text or 3gp files + } - } else{ - echo "ERR:".$name."\r\n"; - } - } + $name = $file['name']; + $error = $file['error']; -} -?> + if ($error !== UPLOAD_ERR_OK) { + echo "ERR:${error}:${name}\r\n"; + continue; + } - $error) { - $name = $_FILES["fileToUpload"]["name"][$key]; - if ($error == UPLOAD_ERR_OK) { - $tmp_name = $_FILES["fileToUpload"]["tmp_name"][$key]; - $target_file = $target_dir . $name; - if(move_uploaded_file($tmp_name, $target_file)) - { - echo "OK:".$error.":".$name."\r\n"; - } else{ - echo "ERR:UPLOAD_ERR_MOVE:".$name."\r\n"; - } - } else { - echo "ERR:".$error.":".$name."\r\n"; - } + if (move_uploaded_file($file['tmp_name'], $target_dir . $name)) { + echo "OK:${error}:${name}\r\n"; + } else { + echo "ERR:UPLOAD_ERR_MOVE:${name}\r\n"; + } } ?> - - - diff --git a/README.md b/README.md index 8b032db..454ca25 100644 --- a/README.md +++ b/README.md @@ -10,13 +10,14 @@ Application features: - Environmental sensors data as temperature, light, pressure and humidity; - Positioning sensors data such as location and satellites; - Networks connectivity data, as network cells and WiFi networks; + - Available Bluetooth beacons - Battery level - Microphone audio - Google activity recognition labels - Every sensors can be configured in the settings to enable/disable it, set the sampling frequency, the remote upload of its data. - Remote upload of data (`PHP_upload_script.txt` contains the PHP code for the server) - Multidevice (master-slaves) configuration -- Bluetooth connection for synchronization among device of time and status (logging/no logging, labels, sublabels) +- Bluetooth connection for synchronization among devices of time and status (logging/no logging, labels, sublabels) - Autostart at boot/reboot - Background logging using persistent notification - Logging of data on files (a new file is created at regular interval to reduce data loss) @@ -51,6 +52,27 @@ The remote upload functionality requires to set up the remote address for the up Due to the changes to the permissions systems in the latest versions of Android, please check and authorize the access to Microphone, Storage, Telephone and Location in the system settings before to use the application. +## User guide +### Getting started +- Install the app on a smartphone via apk +- Make sure ALL permissions are enabled in the system settings for this app +- Enable Bluetooth, Wifi, Mobile Data and Location sensors of the phone + +### Configuration +- Start the app +- Open the settings by entering the setting's password +- Set the user name, device location (master or slave), maximum log file size and logging time intervals in "General" +- Set the server address for the file upload in "Synchronisation" +- Make sure all sensors are enabled +- Set the sampling rates for the sensors if needed + +### Collecting data +- Connect all slaves to the master if needed +- Start the data collection by pressing the "OFF" button +- Data gets now collected until stopping it by pressing "ON" +- Logs can be labeled for more meta information +- To upload all log files to the server make sure the phone is connected to a Wifi network and press "Upload" + ## LICENSE This application has been developed for research purpose and release under MIT License. The usage of this application in research and publications must be acknowledged by citing the following publication: diff --git a/app/build.gradle b/app/build.gradle index b7a484a..a2b7d17 100755 --- a/app/build.gradle +++ b/app/build.gradle @@ -2,7 +2,7 @@ apply plugin: 'com.android.application' android { compileSdkVersion 26 - buildToolsVersion '27.0.3' + buildToolsVersion '28.0.3' defaultConfig { applicationId "uk.ac.sussex.wear.android.datalogger" diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 5dbb85f..5bf9215 100755 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -21,7 +21,6 @@ - - diff --git a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/AboutActivity.java b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/AboutActivity.java index 4276bcd..8549606 100644 --- a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/AboutActivity.java +++ b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/AboutActivity.java @@ -1,6 +1,6 @@ /* * Copyright (c) 2017. Mathias Ciliberto, Francisco Javier Ordoñez Morales, - * Hristijan Gjoreski, Daniel Roggen + * Hristijan Gjoreski, Daniel Roggen, Clara Wurm * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -30,6 +30,8 @@ * Created by ThiasTux. */ +// class for the 'About" Activity screen + public class AboutActivity extends AppCompatActivity { @Override diff --git a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/Constants.java b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/Constants.java index 9f08d80..e487891 100755 --- a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/Constants.java +++ b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/Constants.java @@ -1,6 +1,6 @@ /* * Copyright (c) 2017. Mathias Ciliberto, Francisco Javier Ordoñez Morales, - * Hristijan Gjoreski, Daniel Roggen + * Hristijan Gjoreski, Daniel Roggen, Clara Wurm * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -113,6 +113,9 @@ private Constants() { // Names for each sensor/collector with log files associated + public static final String SENSOR_NAME_CELL = "Cells"; + public static final String SENSOR_NAME_WIFI = "WiFi"; + public static final String SENSOR_NAME_BLUETOOTH = "Bluetooth"; public static final String SENSOR_NAME_API_HAR = "API_HAR"; public static final String SENSOR_NAME_LABELS = "Labels"; public static final String SENSOR_NAME_ACC = "Accelerometer"; @@ -120,7 +123,7 @@ private Constants() { public static final String SENSOR_NAME_MAG = "Magnetometer"; public static final String SENSOR_NAME_MIC = "Audio"; public static final String SENSOR_NAME_BAT = "Battery"; - public static final String SENSOR_NAME_CELL = "Cells"; + public static final String SENSOR_NAME_DEPR_CELL = "DeprCells"; public static final String SENSOR_NAME_LOC = "Location"; public static final String SENSOR_NAME_SAT = "GPS"; @@ -128,7 +131,7 @@ private Constants() { public static final String SENSOR_NAME_LT = "Ambient"; public static final String SENSOR_NAME_PRES = "Pressure"; public static final String SENSOR_NAME_HUM = "Humidity"; - public static final String SENSOR_NAME_WIFI = "WiFi"; + public static final String SENSOR_NAME_ORIEN = "Orientation"; public static final String SENSOR_NAME_LIN_ACC = "LinearAcceleration"; public static final String SENSOR_NAME_GRA = "Gravity"; diff --git a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/DisplayActivity.java b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/DisplayActivity.java index b4d2fef..a031ae8 100755 --- a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/DisplayActivity.java +++ b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/DisplayActivity.java @@ -1,6 +1,6 @@ /* * Copyright (c) 2017. Mathias Ciliberto, Francisco Javier Ordoñez Morales, - * Hristijan Gjoreski, Daniel Roggen + * Hristijan Gjoreski, Daniel Roggen, Clara Wurm * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -504,6 +504,7 @@ public void refreshContentLayout() { menu.findItem(R.id.action_pair).setVisible(false); } + // IMPORTANT ! this creates the menu button @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. diff --git a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/SettingsActivity.java b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/SettingsActivity.java index 311b2a1..15afebd 100755 --- a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/SettingsActivity.java +++ b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/SettingsActivity.java @@ -1,6 +1,6 @@ /* * Copyright (c) 2017. Mathias Ciliberto, Francisco Javier Ordoñez Morales, - * Hristijan Gjoreski, Daniel Roggen + * Hristijan Gjoreski, Daniel Roggen, Clara Wurm * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -48,6 +48,9 @@ * href="http://developer.android.com/guide/topics/ui/settings.html">Settings * API Guide for more information on developing a Settings UI. */ + +// child class for 'Settings' Activity screen + public class SettingsActivity extends AppCompatPreferenceActivity { private static final String TAG = SettingsActivity.class.getSimpleName(); @@ -209,16 +212,19 @@ public void onCreate(Bundle savedInstanceState) { // to their values. When their values change, their summaries are // updated to reflect the new value, per the Android Design // guidelines + bindPreferenceSummaryToValue(findPreference(getResources().getString(R.string.pref_sensors_key_samplingPeriod_cells))); + bindPreferenceSummaryToValue(findPreference(getResources().getString(R.string.pref_sensors_key_samplingPeriod_WiFi))); + bindPreferenceSummaryToValue(findPreference(getResources().getString(R.string.pref_sensors_key_samplingPeriod_Bluetooth))); bindPreferenceSummaryToValue(findPreference(getResources().getString(R.string.pref_sensors_key_samplingPeriod_accelerometer))); bindPreferenceSummaryToValue(findPreference(getResources().getString(R.string.pref_sensors_key_samplingPeriod_gyroscope))); bindPreferenceSummaryToValue(findPreference(getResources().getString(R.string.pref_sensors_key_samplingPeriod_magnetometer))); bindPreferenceSummaryToValue(findPreference(getResources().getString(R.string.pref_sensors_key_samplingPeriod_microphone))); - bindPreferenceSummaryToValue(findPreference(getResources().getString(R.string.pref_sensors_key_samplingPeriod_cells))); + bindPreferenceSummaryToValue(findPreference(getResources().getString(R.string.pref_sensors_key_samplingPeriod_temperature))); bindPreferenceSummaryToValue(findPreference(getResources().getString(R.string.pref_sensors_key_samplingPeriod_light))); bindPreferenceSummaryToValue(findPreference(getResources().getString(R.string.pref_sensors_key_samplingPeriod_pressure))); bindPreferenceSummaryToValue(findPreference(getResources().getString(R.string.pref_sensors_key_samplingPeriod_humidity))); - bindPreferenceSummaryToValue(findPreference(getResources().getString(R.string.pref_sensors_key_samplingPeriod_WiFi))); + bindPreferenceSummaryToValue(findPreference(getResources().getString(R.string.pref_sensors_key_samplingPeriod_orientation))); } diff --git a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/SharedPreferencesHelper.java b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/SharedPreferencesHelper.java index cd2907d..26f75b8 100755 --- a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/SharedPreferencesHelper.java +++ b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/SharedPreferencesHelper.java @@ -1,6 +1,6 @@ /* * Copyright (c) 2017. Mathias Ciliberto, Francisco Javier Ordoñez Morales, - * Hristijan Gjoreski, Daniel Roggen + * Hristijan Gjoreski, Daniel Roggen, Clara Wurm * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -61,7 +61,7 @@ public static String[] getUiErrorsMessagesList(Context context){ public static int getLogFilesMaxsize(Context context){ String value = getSharedPrefsInstance(context). - getString(context.getResources().getString(R.string.pref_general_key_log_files_maxSize), "0"); + getString(context.getResources().getString(R.string.pref_general_key_log_files_maxSize), "1000"); if (!value.equals("")){ return Integer.parseInt(value); } else { @@ -95,6 +95,69 @@ public static int getDetectionIntervalHARAPI(Context context){ } } + //SharedPreferences Sensors - Cells network + public static boolean isEnabledCellsInfo(Context context){ + return getSharedPrefsInstance(context) + .getBoolean(context.getResources().getString(R.string.pref_sensors_key_enabled_cells), true); + } + + public static int getSamplingPeriodCellsInfo(Context context){ + String value = getSharedPrefsInstance(context) + .getString(context.getResources().getString(R.string.pref_sensors_key_samplingPeriod_cells), "1"); + if (!value.equals("")){ + return Integer.parseInt(value); + } else { + return 0; + } + } + + public static boolean toSyncCellsInfo(Context context){ + return getSharedPrefsInstance(context) + .getBoolean(context.getResources().getString(R.string.pref_sensors_key_sync_cells), true); + } + + //SharedPreferences Sensors - WiFi + public static boolean isEnabledWiFi(Context context){ + return getSharedPrefsInstance(context) + .getBoolean(context.getResources().getString(R.string.pref_sensors_key_enabled_WiFi), true); + } + + public static int getSamplingPeriodWiFiInfo(Context context){ + String value = getSharedPrefsInstance(context) + .getString(context.getResources().getString(R.string.pref_sensors_key_samplingPeriod_WiFi), "1"); + if (!value.equals("")){ + return Integer.parseInt(value); + } else { + return 0; + } + } + + public static boolean toSyncWiFi(Context context){ + return getSharedPrefsInstance(context) + .getBoolean(context.getResources().getString(R.string.pref_sensors_key_sync_WiFi), true); + } + + //SharedPreferences Sensors - Bluetooth + public static boolean isEnabledBluetooth(Context context){ + return getSharedPrefsInstance(context) + .getBoolean(context.getResources().getString(R.string.pref_sensors_key_enabled_Bluetooth), true); + } + + public static int getSamplingPeriodBluetoothInfo(Context context){ + String value = getSharedPrefsInstance(context) + .getString(context.getResources().getString(R.string.pref_sensors_key_samplingPeriod_Bluetooth), "1"); + if (!value.equals("")){ + return Integer.parseInt(value); + } else { + return 0; + } + } + + public static boolean toSyncBluetooth(Context context){ + return getSharedPrefsInstance(context) + .getBoolean(context.getResources().getString(R.string.pref_sensors_key_sync_Bluetooth), true); + } + //SharedPreferences Sensors - Accelerometer public static boolean isEnabledAccelerometer(Context context){ return getSharedPrefsInstance(context) @@ -175,26 +238,7 @@ public static boolean toSyncBattery(Context context){ .getBoolean(context.getResources().getString(R.string.pref_sensors_key_sync_battery), true); } - //SharedPreferences Sensors - Cells network - public static boolean isEnabledCellsInfo(Context context){ - return getSharedPrefsInstance(context) - .getBoolean(context.getResources().getString(R.string.pref_sensors_key_enabled_cells), true); - } - public static int getSamplingPeriodCellsInfo(Context context){ - String value = getSharedPrefsInstance(context) - .getString(context.getResources().getString(R.string.pref_sensors_key_samplingPeriod_cells), "1"); - if (!value.equals("")){ - return Integer.parseInt(value); - } else { - return 0; - } - } - - public static boolean toSyncCellsInfo(Context context){ - return getSharedPrefsInstance(context) - .getBoolean(context.getResources().getString(R.string.pref_sensors_key_sync_cells), true); - } //SharedPreferences Sensors - Cells network (deprecated) public static boolean isEnabledDeprCellsInfo(Context context){ @@ -293,26 +337,7 @@ public static boolean toSyncHumidity(Context context){ .getBoolean(context.getResources().getString(R.string.pref_sensors_key_sync_humidity), true); } - //SharedPreferences Sensors - WiFi - public static boolean isEnabledWiFi(Context context){ - return getSharedPrefsInstance(context) - .getBoolean(context.getResources().getString(R.string.pref_sensors_key_enabled_WiFi), true); - } - public static int getSamplingPeriodWiFiInfo(Context context){ - String value = getSharedPrefsInstance(context) - .getString(context.getResources().getString(R.string.pref_sensors_key_samplingPeriod_WiFi), "1"); - if (!value.equals("")){ - return Integer.parseInt(value); - } else { - return 0; - } - } - - public static boolean toSyncWiFi(Context context){ - return getSharedPrefsInstance(context) - .getBoolean(context.getResources().getString(R.string.pref_sensors_key_sync_WiFi), true); - } //SharedPreferences Sensors - Orientation public static boolean isEnabledOrientation(Context context){ @@ -708,5 +733,4 @@ public static void setSlavesConnected(Context context, int value){ .putInt(Constants.BLUETOOTH_SLAVES_CONNECTED_KEY, value) .commit(); } - } diff --git a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/bt/BluetoothConnectionHelper.java b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/bt/BluetoothConnectionHelper.java index d0417aa..5da909c 100755 --- a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/bt/BluetoothConnectionHelper.java +++ b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/bt/BluetoothConnectionHelper.java @@ -1,6 +1,6 @@ /* * Copyright (c) 2017. Mathias Ciliberto, Francisco Javier Ordoñez Morales, - * Hristijan Gjoreski, Daniel Roggen + * Hristijan Gjoreski, Daniel Roggen, Clara Wurm * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -20,6 +20,7 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ + package uk.ac.sussex.wear.android.datalogger.bt; import android.bluetooth.BluetoothAdapter; @@ -91,10 +92,11 @@ public BluetoothConnectionHelper(Context context, Handler handler, boolean isSer } } - /** +/** * Start the chat service. Specifically start AcceptThread to begin a * session in listening (server) mode. Called by the Activity onResume() */ + public synchronized void start(int index) { Log.d(TAG, "::start Starting bluetooth at index " + index); @@ -144,9 +146,10 @@ public synchronized void start(int index) { } - /** +/** * Stop all threads */ + public synchronized void stop(int index) { Log.d(TAG, "::stop Stopping bluetooth slot "+index); @@ -180,11 +183,12 @@ public synchronized void stop(int index) { setState(STATE_NONE, index); } - /** +/** * Set the current state of the chat connection * * @param state An integer defining the current connection state */ + private synchronized void setState(int state, int index) { Log.d(TAG, "setState("+index+") " + mStates[index] + " -> " + state); mStates[index] = state; @@ -193,9 +197,10 @@ private synchronized void setState(int state, int index) { mHandler.obtainMessage(Constants.BLUETOOTH_MESSAGE_STATE_CHANGE, state, index).sendToTarget(); } - /** +/** * Return the current connection state. */ + public synchronized int getState(int index) { return mStates[index]; } @@ -207,13 +212,13 @@ public synchronized boolean isConnected(int index) { return mConnectedThreads[index].isConnected(); } - - /** +/** * Start the ConnectedThread to begin managing a Bluetooth connection * * @param socket The BluetoothSocket on which the connection was made * @param device The BluetoothDevice that has been connected */ + public synchronized void connected(BluetoothSocket socket, BluetoothDevice device, int index) { Log.d(TAG, "::connected Starting ConnectedThread for bluetooth at index "+index); @@ -268,9 +273,10 @@ public synchronized void connected(BluetoothSocket socket, BluetoothDevice devic setState(STATE_CONNECTED, index); } - /** +/** * Indicate that the connection attempt failed and notify the UI Activity. */ + private synchronized void connectionFailed(int index) { // Send a failure message back to the Activity Message msg = mHandler.obtainMessage(Constants.BLUETOOTH_MESSAGE_CONNECTION_FAILED, index); @@ -280,9 +286,10 @@ private synchronized void connectionFailed(int index) { mHandler.sendMessage(msg); } - /** +/** * Indicate that the connection was lost and notify the UI Activity. */ + private synchronized void connectionLost(int index) { // Send the name of the connected device back to the UI Activity Message msg = mHandler.obtainMessage(Constants.BLUETOOTH_MESSAGE_CONNECTION_LOST); @@ -292,11 +299,12 @@ private synchronized void connectionLost(int index) { mHandler.sendMessage(msg); } - /** +/** * Start the ConnectThread to initiate a connection to a remote device. * * @param address The address to connect */ + public synchronized void connect(String address, int index) { Log.i(TAG, "::connect Trying to connect to address " + address + ". "); @@ -368,13 +376,13 @@ public synchronized void sendMessage(String message, int index){ } } - - /** +/** * Write to the ConnectedThread in an unsynchronized manner * * @param out The bytes to write * @see ConnectedThread#write(byte[]) */ + private void write(byte[] out, int index) { Log.d(TAG,"Writing message to "+index); // Create temporary object @@ -389,12 +397,12 @@ private void write(byte[] out, int index) { r.write(out); } - - /** +/** * This thread runs while listening for incoming connections. It behaves * like a server-side client. It runs until a connection is accepted * (or until cancelled). */ + private class AcceptThread extends Thread { // The local server socket private final BluetoothServerSocket mmServerSocket; @@ -468,12 +476,12 @@ public void cancel() { } } - - /** +/** * This thread runs while attempting to make an outgoing connection * with a device. It runs straight through; the connection either * succeeds or fails. */ + private class ConnectThread extends Thread { private final BluetoothSocket mmSocket; private final BluetoothDevice mmDevice; @@ -593,10 +601,12 @@ public void cancel() { } } - /** + +/** * This thread runs during a connection with a remote device. * It handles all incoming and outgoing transmissions. */ + private class ConnectedThread extends Thread { private final BluetoothSocket mmSocket; private final InputStream mmInStream; @@ -669,11 +679,12 @@ public boolean isConnected() { return mmSocket.isConnected(); } - /** +/** * Write to the connected OutStream. * * @param buffer The bytes to write */ + public void write(byte[] buffer) { try { @@ -714,4 +725,4 @@ public void run() { } } -} \ No newline at end of file +} diff --git a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/bt/BluetoothConnectionHelper2.java b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/bt/BluetoothConnectionHelper2.java index 4980b03..7e009b2 100644 --- a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/bt/BluetoothConnectionHelper2.java +++ b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/bt/BluetoothConnectionHelper2.java @@ -1,6 +1,6 @@ /* * Copyright (c) 2017. Mathias Ciliberto, Francisco Javier Ordoñez Morales, - * Hristijan Gjoreski, Daniel Roggen + * Hristijan Gjoreski, Daniel Roggen, Clara Wurm * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -20,6 +20,7 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ + package uk.ac.sussex.wear.android.datalogger.bt; import android.bluetooth.BluetoothAdapter; @@ -88,3 +89,4 @@ public int getState(int location) { return 0; } } + diff --git a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/bt/BluetoothConnector.java b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/bt/BluetoothConnector.java index 9f102c8..5df9a5e 100755 --- a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/bt/BluetoothConnector.java +++ b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/bt/BluetoothConnector.java @@ -1,6 +1,6 @@ /* * Copyright (c) 2017. Mathias Ciliberto, Francisco Javier Ordoñez Morales, - * Hristijan Gjoreski, Daniel Roggen + * Hristijan Gjoreski, Daniel Roggen, Clara Wurm * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -20,6 +20,7 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ + package uk.ac.sussex.wear.android.datalogger.bt; import android.bluetooth.BluetoothAdapter; @@ -35,10 +36,12 @@ import java.util.List; import java.util.UUID; + /** * Created by fjordonez on 27/01/17. */ + public class BluetoothConnector { private BluetoothSocketWrapper bluetoothSocket; @@ -49,12 +52,13 @@ public class BluetoothConnector { private int candidate; - /** +/** * @param device the device * @param secure if connection should be done via a secure socket * @param adapter the Android BT adapter * @param uuid a list of UUIDs. if null or empty, the Serial PP id is used */ + public BluetoothConnector(BluetoothDevice device, boolean secure, BluetoothAdapter adapter, UUID uuid) { this.device = device; @@ -239,9 +243,10 @@ public void close() throws IOException { public static class FallbackException extends Exception { - /** +/** * */ + private static final long serialVersionUID = 1L; public FallbackException(Exception e) { @@ -249,4 +254,4 @@ public FallbackException(Exception e) { } } -} \ No newline at end of file +} diff --git a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/bt/BluetoothDeviceListActivity.java b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/bt/BluetoothDeviceListActivity.java index ca4def3..0e35268 100755 --- a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/bt/BluetoothDeviceListActivity.java +++ b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/bt/BluetoothDeviceListActivity.java @@ -1,6 +1,6 @@ /* * Copyright (c) 2017. Mathias Ciliberto, Francisco Javier Ordoñez Morales, - * Hristijan Gjoreski, Daniel Roggen + * Hristijan Gjoreski, Daniel Roggen, Clara Wurm * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -20,6 +20,7 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ + package uk.ac.sussex.wear.android.datalogger.bt; import android.app.Activity; @@ -56,12 +57,12 @@ public class BluetoothDeviceListActivity extends Activity { private static final String TAG = BluetoothDeviceListActivity.class.getSimpleName(); - /** +/** * Member fields */ private BluetoothAdapter mBtAdapter; - /** +/** * Newly discovered devices */ private ArrayAdapter mNewDevicesArrayAdapter; @@ -143,9 +144,10 @@ protected void onDestroy() { this.unregisterReceiver(mReceiver); } - /** +/** * Start device discover with the BluetoothAdapter */ + private void doDiscovery() { Log.d(TAG, "doDiscovery()"); @@ -165,7 +167,7 @@ private void doDiscovery() { mBtAdapter.startDiscovery(); } - /** +/** * The on-click listener for all devices in the ListViews */ private AdapterView.OnItemClickListener mDeviceClickListener @@ -188,7 +190,7 @@ public void onItemClick(AdapterView av, View v, int arg2, long arg3) { } }; - /** +/** * The BroadcastReceiver that listens for discovered devices and changes the title when * discovery is finished */ @@ -218,3 +220,4 @@ public void onReceive(Context context, Intent intent) { }; } + diff --git a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/bt/MultiBluetoothManager.java b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/bt/MultiBluetoothManager.java index c10e48c..a723bbe 100755 --- a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/bt/MultiBluetoothManager.java +++ b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/bt/MultiBluetoothManager.java @@ -1,6 +1,6 @@ /* * Copyright (c) 2017. Mathias Ciliberto, Francisco Javier Ordoñez Morales, - * Hristijan Gjoreski, Daniel Roggen + * Hristijan Gjoreski, Daniel Roggen, Clara Wurm * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -20,6 +20,7 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ + package uk.ac.sussex.wear.android.datalogger.bt; import android.bluetooth.BluetoothAdapter; @@ -45,6 +46,7 @@ * Created by fjordonez on 27/01/17. */ + public class MultiBluetoothManager { private static final String TAG = MultiBluetoothManager.class.getSimpleName(); @@ -58,6 +60,7 @@ public class MultiBluetoothManager { private int[] mStates; private boolean mIsServer; + private BluetoothClient mBluetoothClient; private ArrayList mServerConnectedList; @@ -92,8 +95,7 @@ public synchronized void start(int index) { } - - /** +/** * Start the ConnectThread to initiate a connection to a remote device. * * @param address The address to connect @@ -121,11 +123,10 @@ private void connectionSuccess(String address, int index) { } - - - /** +/** * Indicate that the connection attempt failed and notify the UI Activity. */ + private void connectionFailed(int index) { // Send a failure message back to the Activity Message msg = mHandler.obtainMessage(Constants.BLUETOOTH_MESSAGE_CONNECTION_FAILED, index); @@ -350,3 +351,4 @@ public void closeConnection(){ } } + diff --git a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/bt/multibluetooth/bluetooth/client/BluetoothClient.java b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/bt/multibluetooth/bluetooth/client/BluetoothClient.java index 3233756..604782d 100755 --- a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/bt/multibluetooth/bluetooth/client/BluetoothClient.java +++ b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/bt/multibluetooth/bluetooth/client/BluetoothClient.java @@ -1,6 +1,6 @@ /* * Copyright (c) 2017. Mathias Ciliberto, Francisco Javier Ordoñez Morales, - * Hristijan Gjoreski, Daniel Roggen + * Hristijan Gjoreski, Daniel Roggen, Clara Wurm * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -20,6 +20,7 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ + package uk.ac.sussex.wear.android.datalogger.bt.multibluetooth.bluetooth.client; import android.bluetooth.BluetoothAdapter; @@ -32,11 +33,10 @@ import java.io.OutputStreamWriter; import java.util.UUID; - - /** * Created by Rami MARTIN on 13/04/2014. */ + public class BluetoothClient implements Runnable { private boolean CONTINUE_READ_WRITE = true; diff --git a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/bt/multibluetooth/bluetooth/client/BluetoothConnector.java b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/bt/multibluetooth/bluetooth/client/BluetoothConnector.java index 6db3512..950de0a 100755 --- a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/bt/multibluetooth/bluetooth/client/BluetoothConnector.java +++ b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/bt/multibluetooth/bluetooth/client/BluetoothConnector.java @@ -1,6 +1,6 @@ /* * Copyright (c) 2017. Mathias Ciliberto, Francisco Javier Ordoñez Morales, - * Hristijan Gjoreski, Daniel Roggen + * Hristijan Gjoreski, Daniel Roggen, Clara Wurm * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -20,6 +20,7 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ + package uk.ac.sussex.wear.android.datalogger.bt.multibluetooth.bluetooth.client; import android.bluetooth.BluetoothAdapter; @@ -44,13 +45,13 @@ public class BluetoothConnector { private List uuidCandidates; private int candidate; - - /** +/** * @param device the device * @param secure if connection should be done via a secure socket * @param adapter the Android BT adapter * @param uuid a list of UUIDs. if null or empty, the Serial PP id is used */ + public BluetoothConnector(BluetoothDevice device, boolean secure, BluetoothAdapter adapter, UUID uuid) { this.device = device; @@ -236,7 +237,7 @@ public void close() throws IOException { public static class FallbackException extends Exception { /** - * + * */ private static final long serialVersionUID = 1L; @@ -245,4 +246,4 @@ public FallbackException(Exception e) { } } -} \ No newline at end of file +} diff --git a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/bt/multibluetooth/bluetooth/server/BluetoothServer.java b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/bt/multibluetooth/bluetooth/server/BluetoothServer.java index 229cf2b..5e2c6ba 100755 --- a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/bt/multibluetooth/bluetooth/server/BluetoothServer.java +++ b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/bt/multibluetooth/bluetooth/server/BluetoothServer.java @@ -1,6 +1,6 @@ /* * Copyright (c) 2017. Mathias Ciliberto, Francisco Javier Ordoñez Morales, - * Hristijan Gjoreski, Daniel Roggen + * Hristijan Gjoreski, Daniel Roggen, Clara Wurm * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -20,6 +20,7 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ + package uk.ac.sussex.wear.android.datalogger.bt.multibluetooth.bluetooth.server; import android.bluetooth.BluetoothAdapter; @@ -36,6 +37,7 @@ /** * Created by Rami MARTIN on 13/04/2014. */ + public class BluetoothServer implements Runnable { private boolean CONTINUE_READ_WRITE = true; diff --git a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/bt/multibluetooth/bus/BluetoothCommunicator.java b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/bt/multibluetooth/bus/BluetoothCommunicator.java index 4a256ef..861cd3b 100755 --- a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/bt/multibluetooth/bus/BluetoothCommunicator.java +++ b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/bt/multibluetooth/bus/BluetoothCommunicator.java @@ -1,6 +1,6 @@ /* * Copyright (c) 2017. Mathias Ciliberto, Francisco Javier Ordoñez Morales, - * Hristijan Gjoreski, Daniel Roggen + * Hristijan Gjoreski, Daniel Roggen, Clara Wurm * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -20,11 +20,14 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ + package uk.ac.sussex.wear.android.datalogger.bt.multibluetooth.bus; + /** * Created by Rami MARTIN on 13/04/2014. */ + public class BluetoothCommunicator { public String mMessageReceive; @@ -33,3 +36,4 @@ public BluetoothCommunicator(String messageReceive){ mMessageReceive = messageReceive; } } + diff --git a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/bt/multibluetooth/bus/BondedDevice.java b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/bt/multibluetooth/bus/BondedDevice.java index 9c420e1..69d9ac3 100755 --- a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/bt/multibluetooth/bus/BondedDevice.java +++ b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/bt/multibluetooth/bus/BondedDevice.java @@ -1,6 +1,6 @@ /* * Copyright (c) 2017. Mathias Ciliberto, Francisco Javier Ordoñez Morales, - * Hristijan Gjoreski, Daniel Roggen + * Hristijan Gjoreski, Daniel Roggen, Clara Wurm * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -20,10 +20,13 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ + package uk.ac.sussex.wear.android.datalogger.bt.multibluetooth.bus; + /** * Created by Rami MARTIN on 21/04/2014. */ public class BondedDevice { } + diff --git a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/bt/multibluetooth/bus/ClientConnectionFail.java b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/bt/multibluetooth/bus/ClientConnectionFail.java index 10f43d1..a62af07 100755 --- a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/bt/multibluetooth/bus/ClientConnectionFail.java +++ b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/bt/multibluetooth/bus/ClientConnectionFail.java @@ -1,6 +1,6 @@ /* * Copyright (c) 2017. Mathias Ciliberto, Francisco Javier Ordoñez Morales, - * Hristijan Gjoreski, Daniel Roggen + * Hristijan Gjoreski, Daniel Roggen, Clara Wurm * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -20,10 +20,14 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ + package uk.ac.sussex.wear.android.datalogger.bt.multibluetooth.bus; + /** * Created by Rami MARTIN on 13/04/2014. */ + public class ClientConnectionFail { } + diff --git a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/bt/multibluetooth/bus/ClientConnectionSuccess.java b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/bt/multibluetooth/bus/ClientConnectionSuccess.java index 747f608..abc2501 100755 --- a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/bt/multibluetooth/bus/ClientConnectionSuccess.java +++ b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/bt/multibluetooth/bus/ClientConnectionSuccess.java @@ -1,6 +1,6 @@ /* * Copyright (c) 2017. Mathias Ciliberto, Francisco Javier Ordoñez Morales, - * Hristijan Gjoreski, Daniel Roggen + * Hristijan Gjoreski, Daniel Roggen, Clara Wurm * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -20,6 +20,7 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ + package uk.ac.sussex.wear.android.datalogger.bt.multibluetooth.bus; /** @@ -27,3 +28,4 @@ */ public class ClientConnectionSuccess { } + diff --git a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/bt/multibluetooth/bus/ServeurConnectionFail.java b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/bt/multibluetooth/bus/ServeurConnectionFail.java index 41b6c60..da9a34b 100755 --- a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/bt/multibluetooth/bus/ServeurConnectionFail.java +++ b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/bt/multibluetooth/bus/ServeurConnectionFail.java @@ -1,6 +1,6 @@ /* * Copyright (c) 2017. Mathias Ciliberto, Francisco Javier Ordoñez Morales, - * Hristijan Gjoreski, Daniel Roggen + * Hristijan Gjoreski, Daniel Roggen, Clara Wurm * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -20,8 +20,10 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ + package uk.ac.sussex.wear.android.datalogger.bt.multibluetooth.bus; + /** * Created by Rami MARTIN on 13/04/2014. */ @@ -33,3 +35,4 @@ public ServeurConnectionFail(String clientAdressConnectionFail){ mClientAdressConnectionFail = clientAdressConnectionFail; } } + diff --git a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/bt/multibluetooth/bus/ServeurConnectionSuccess.java b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/bt/multibluetooth/bus/ServeurConnectionSuccess.java index 2b70fd1..31cc85c 100755 --- a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/bt/multibluetooth/bus/ServeurConnectionSuccess.java +++ b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/bt/multibluetooth/bus/ServeurConnectionSuccess.java @@ -1,6 +1,6 @@ /* * Copyright (c) 2017. Mathias Ciliberto, Francisco Javier Ordoñez Morales, - * Hristijan Gjoreski, Daniel Roggen + * Hristijan Gjoreski, Daniel Roggen, Clara Wurm * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -20,6 +20,7 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ + package uk.ac.sussex.wear.android.datalogger.bt.multibluetooth.bus; /** @@ -33,3 +34,4 @@ public ServeurConnectionSuccess(String clientAdressConnected){ mClientAdressConnected = clientAdressConnected; } } + diff --git a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/collector/AbstractDataCollector.java b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/collector/AbstractDataCollector.java index 98866ff..15a3fea 100755 --- a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/collector/AbstractDataCollector.java +++ b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/collector/AbstractDataCollector.java @@ -1,6 +1,6 @@ /* * Copyright (c) 2017. Mathias Ciliberto, Francisco Javier Ordoñez Morales, - * Hristijan Gjoreski, Daniel Roggen + * Hristijan Gjoreski, Daniel Roggen, Clara Wurm * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -22,8 +22,11 @@ package uk.ac.sussex.wear.android.datalogger.collector; +// abstract parent class for various data collectors -public abstract class AbstractDataCollector { +import android.app.Activity; + +public abstract class AbstractDataCollector extends Activity { protected long mNanosOffset = 0; protected String mSensorName; diff --git a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/collector/AudioDataCollector.java b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/collector/AudioDataCollector.java index a07d14c..ce0c636 100755 --- a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/collector/AudioDataCollector.java +++ b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/collector/AudioDataCollector.java @@ -32,6 +32,7 @@ import uk.ac.sussex.wear.android.datalogger.db.DataLoggerDataSource; import uk.ac.sussex.wear.android.datalogger.log.LoggerHelper; +// child class for collecting audio data of phone's microphone public class AudioDataCollector extends AbstractDataCollector { diff --git a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/collector/BTHelper/DeviceAdapter.java b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/collector/BTHelper/DeviceAdapter.java new file mode 100644 index 0000000..f239732 --- /dev/null +++ b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/collector/BTHelper/DeviceAdapter.java @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2019. Mathias Ciliberto, Francisco Javier Ordoñez Morales, + * Hristijan Gjoreski, Daniel Roggen, Clara Wurm + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +// (c) 2016 youten, http://greety.sakura.ne.jp/redo/ + +package uk.ac.sussex.wear.android.datalogger.collector.BTHelper; + +/* +* created by wurmc +* */ + +import android.bluetooth.BluetoothDevice; +import java.util.List; + +public class DeviceAdapter { + + private List mList; + + public DeviceAdapter(List objects) { + mList = objects; + } + + public String updateDevice(BluetoothDevice newDevice, int rssi, byte[] scanRecord) { + if ((newDevice == null) || (newDevice.getAddress() == null)) { + return ""; + } + long now = System.currentTimeMillis(); + + boolean contains = false; + for (ScannedDevice device : mList) { + if (newDevice.getAddress().equals(device.getDevice().getAddress())) { + contains = true; + // update + device.setAddress(device.getDevice().getAddress()); + device.setRssi(rssi); + /*device.setLastUpdatedMs(now);*/ + device.setScanRecord(scanRecord); + break; + } + } + if (!contains) { + // add new BluetoothDevice + mList.add(new ScannedDevice(newDevice, rssi, scanRecord, now)); + } + + // create summary + int totalCount = 0; + if (mList != null) { + totalCount = mList.size(); + } + String summary = /*"iBeacon:" + Integer.toString(iBeaconCount) +*/ " (Total:" + + Integer.toString(totalCount) + ")"; + + return summary; + } + + public List getScanList() { + return mList; + } +} diff --git a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/collector/BTHelper/ScannedDevice.java b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/collector/BTHelper/ScannedDevice.java new file mode 100644 index 0000000..a09876d --- /dev/null +++ b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/collector/BTHelper/ScannedDevice.java @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2019. Mathias Ciliberto, Francisco Javier Ordoñez Morales, + * Hristijan Gjoreski, Daniel Roggen, Clara Wurm + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +// (c) 2016 youten, http://greety.sakura.ne.jp/redo/ + +package uk.ac.sussex.wear.android.datalogger.collector.BTHelper; + +/* +* created by wurmc +* */ + +import android.bluetooth.BluetoothDevice; + +public class ScannedDevice { + + /* BluetoothDevice */ + private BluetoothDevice mDevice; + /* Advertise Scan Record */ + private byte[] mScanRecord; + /* RSSI */ + private int mRssi; + private String mDevAddress; + + public ScannedDevice(BluetoothDevice device, int rssi, byte[] scanRecord, long now) { + if (device == null) { + throw new IllegalArgumentException("BluetoothDevice is null"); + } + /*mLastUpdatedMs = now;*/ + mDevice = device; + /*mDisplayName = device.getName(); + if ((mDisplayName == null) || (mDisplayName.length() == 0)) { + mDisplayName = UNKNOWN; + }*/ + mRssi = rssi; + mScanRecord = scanRecord; + } + + public BluetoothDevice getDevice() { + return mDevice; + } + + public int getRssi() { + return mRssi; + } + + public void setRssi(int rssi) { + mRssi = rssi; + } + + public void setAddress(String address){ + mDevAddress = address; + } + + public String getScanRecordHexString() { + return ScannedDevice.asHex(mScanRecord); + } + + private static String asHex(byte bytes[]) { + if ((bytes == null) || (bytes.length == 0)) { + return ""; + } + + // バイト配列の2倍の長さの文字列バッファを生成。 + // Generate a string buffer twice as long as a byte array. + StringBuffer sb = new StringBuffer(bytes.length * 2); + + // バイト配列の要素数分、処理を繰り返す。 + // Repeat the process for the number of elements in the byte array. + for (int index = 0; index < bytes.length; index++) { + // バイト値を自然数に変換。 + // Convert byte values ​​to natural numbers. + int bt = bytes[index] & 0xff; + + // バイト値が0x10以下か判定。 + // Determine whether the byte value is 0x10 or less. + if (bt < 0x10) { + // 0x10以下の場合、文字列バッファに0を追加。 + // Add 0 to string buffer if it is less than 0x10. + sb.append("0"); + } + + // バイト値を16進数の文字列に変換して、文字列バッファに追加。 + // Convert byte value to hexadecimal string and add to string buffer. + sb.append(Integer.toHexString(bt).toUpperCase()); + } + + // 16進数の文字列を返す。 + // Return a hexadecimal string. + return sb.toString(); + } + + public void setScanRecord(byte[] scanRecord) { + mScanRecord = scanRecord; + } +} diff --git a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/collector/BatteryDataCollector.java b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/collector/BatteryDataCollector.java index c19d172..7879af9 100755 --- a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/collector/BatteryDataCollector.java +++ b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/collector/BatteryDataCollector.java @@ -35,6 +35,8 @@ import uk.ac.sussex.wear.android.datalogger.log.CustomLogger; +// child class for collecting battery data of the phone + public class BatteryDataCollector extends AbstractDataCollector { private static final String TAG = BatteryDataCollector.class.getSimpleName(); diff --git a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/collector/BluetoothDataCollector.java b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/collector/BluetoothDataCollector.java new file mode 100644 index 0000000..e32ae7d --- /dev/null +++ b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/collector/BluetoothDataCollector.java @@ -0,0 +1,207 @@ +/* + * Copyright (c) 2019. Mathias Ciliberto, Francisco Javier Ordoñez Morales, + * Hristijan Gjoreski, Daniel Roggen, Clara Wurm + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +// (c) 2016 youten, http://greety.sakura.ne.jp/redo/ + +package uk.ac.sussex.wear.android.datalogger.collector; + +import android.annotation.SuppressLint; +import android.bluetooth.BluetoothAdapter; +import android.bluetooth.BluetoothDevice; +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.os.Handler; +import android.os.SystemClock; +import android.util.Log; + +import uk.ac.sussex.wear.android.datalogger.R; +import uk.ac.sussex.wear.android.datalogger.collector.BTHelper.DeviceAdapter; +import uk.ac.sussex.wear.android.datalogger.collector.BTHelper.ScannedDevice; +import uk.ac.sussex.wear.android.datalogger.log.CustomLogger; +import android.widget.Toast; + +import java.io.File; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +// child class for collecting Bluetooth data +// functionality from iBeaconDetector https://github.com/youten/iBeaconDetector + +/* +* Created by wurmc +* */ + +public class BluetoothDataCollector extends AbstractDataCollector implements BluetoothAdapter.LeScanCallback{ + + private static final String TAG = BluetoothDataCollector.class.getSimpleName(); + + private CustomLogger logger = null; + + private int mSamplingPeriodUs; + + private Context mContext; + + // Timer to manage specific sampling rates + private Handler mTimerHandler = null; + private Runnable mTimerRunnable = null; + + // Receiver class for monitoring changes in BT states + private BluetoothInfoReceiver mBTInfoReceiver; + + //needed Bluetooth variables + private BluetoothAdapter mBTAdapter = null; + private boolean mIsScanning; + private DeviceAdapter mDeviceAdapter; + + @SuppressLint("ServiceCast") + public BluetoothDataCollector(Context context, String sessionName, String sensorName, int samplingPeriodUs, long nanosOffset, int logFileMaxSize) { + + mSensorName = sensorName; + String path = sessionName + File.separator + mSensorName + "_" + sessionName; + + logger = new CustomLogger(context, path, sessionName, mSensorName, "txt", false, mNanosOffset, logFileMaxSize); + + mSamplingPeriodUs = samplingPeriodUs; + mContext = context; + // Offset to match timestamps both in master and slaves devices + mNanosOffset = nanosOffset; + // call init + init(); + if (mSamplingPeriodUs > 0) { + mTimerHandler = new Handler(); + mTimerRunnable = new Runnable() { + // still problems here !!! run() seems to not work properly. Log doesn't get called + // no BT txt files are written + @Override + public void run() { + logBluetoothInfo(mDeviceAdapter.getScanList()); + int millis = 1000 / mSamplingPeriodUs; + mTimerHandler.postDelayed(this, millis); + } + }; + } else { + mBTInfoReceiver = new BluetoothInfoReceiver(); + } + + } + + private void init(){ + // initialise mBTAdapter + mBTAdapter = BluetoothAdapter.getDefaultAdapter(); + if (mBTAdapter == null) { + Toast.makeText(this, R.string.bt_not_supported, Toast.LENGTH_SHORT).show(); + finish(); + return; + } + + mDeviceAdapter = new DeviceAdapter(new ArrayList()); + } + + private void logBluetoothInfo(List scanList){ + // System local time in millis + long currentMillis = (new Date()).getTime(); + + // System nanoseconds since boot, including time spent in sleep. + long nanoTime = SystemClock.elapsedRealtimeNanos() + mNanosOffset; + + String message = String.format("%s", currentMillis) + ";" + + String.format("%s", nanoTime) + ";" + + String.format("%s", mNanosOffset) + ";" + + scanList.size(); + + for (ScannedDevice scan : scanList){ + // Get BLE Beacon Device Address + String address = scan.getDevice().getAddress(); + // Get BLE Beacon RSSI + int rssi = scan.getRssi(); + // Get BLE Beacon Hex Info out of scanRecord + String scanRecord = scan.getScanRecordHexString(); + + message += ";" + + address + ";" + + rssi + ";" + + scanRecord; + } + //message += "Hello"; + logger.log(message); + logger.log(System.lineSeparator()); + } + + private class BluetoothInfoReceiver extends BroadcastReceiver { + @Override + public void onReceive(Context context, Intent intent) { + logBluetoothInfo(mDeviceAdapter.getScanList()); + } + } + + @Override + public void start() { + Log.i(TAG, "start:: Starting listener for sensor: " + getSensorName()); + + // if query from iBeaconDetector + if ((mBTAdapter != null) && (!mIsScanning)) { + mBTAdapter.startLeScan(this); + mIsScanning = true; + } + + mTimerHandler.postDelayed(mTimerRunnable, 0); + + logger.start(); + } + + @Override + public void stop() { + Log.i(TAG,"stop:: Stopping listener for sensor " + getSensorName()); + + if (mBTAdapter != null) { + mBTAdapter.stopLeScan(this); + } + mIsScanning = false; + + mTimerHandler.removeCallbacks(mTimerRunnable); + + logger.stop(); + } + + @Override + public void haltAndRestartLogging() { + logger.stop(); + logger.resetByteCounter(); + logger.start(); + } + + @Override + public void updateNanosOffset(long nanosOffset) { + mNanosOffset = nanosOffset; + } + + @Override + public void onLeScan(final BluetoothDevice newDevice, final int newRssi, final byte[] newScanRecord) { + runOnUiThread(new Runnable() { + @Override + public void run() { + String summary = mDeviceAdapter.updateDevice(newDevice, newRssi, newScanRecord); + } + }); + } +} diff --git a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/collector/CellsInfoDataCollector.java b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/collector/CellsInfoDataCollector.java index 5a24475..3a385bc 100755 --- a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/collector/CellsInfoDataCollector.java +++ b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/collector/CellsInfoDataCollector.java @@ -1,6 +1,6 @@ /* * Copyright (c) 2017. Mathias Ciliberto, Francisco Javier Ordoñez Morales, - * Hristijan Gjoreski, Daniel Roggen + * Hristijan Gjoreski, Daniel Roggen, Clara Wurm * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -22,9 +22,12 @@ package uk.ac.sussex.wear.android.datalogger.collector; +import android.Manifest; import android.content.Context; +import android.content.pm.PackageManager; import android.os.Handler; import android.os.SystemClock; +import android.support.v4.app.ActivityCompat; import android.telephony.CellIdentityCdma; import android.telephony.CellIdentityGsm; import android.telephony.CellIdentityLte; @@ -50,7 +53,7 @@ import uk.ac.sussex.wear.android.datalogger.log.CustomLogger; - +// child class for collecting data about mobile cells (GSM, CDMA, LTE, WCDMA) in phone's range public class CellsInfoDataCollector extends AbstractDataCollector { @@ -70,8 +73,12 @@ public class CellsInfoDataCollector extends AbstractDataCollector { private Handler mTimerHandler = null; private Runnable mTimerRunnable = null; + private Context mcontext = null; + + + public CellsInfoDataCollector(final Context context, String sessionName, String sensorName, int samplingPeriodUs, long nanosOffset, int logFileMaxSize) { - public CellsInfoDataCollector(Context context, String sessionName, String sensorName, int samplingPeriodUs, long nanosOffset, int logFileMaxSize){ + mcontext = context; mSensorName = sensorName; String path = sessionName + File.separator + mSensorName + "_" + sessionName; @@ -99,6 +106,16 @@ public CellsInfoDataCollector(Context context, String sessionName, String sensor @Override public void run() { // Returns all observed cell information from all radios on the device including the primary and neighboring cells. + if (ActivityCompat.checkSelfPermission(context, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { + // TODO: Consider calling + // ActivityCompat#requestPermissions + // here to request the missing permissions, and then overriding + // public void onRequestPermissionsResult(int requestCode, String[] permissions, + // int[] grantResults) + // to handle the case where the user grants the permission. See the documentation + // for ActivityCompat#requestPermissions for more details. + return; + } logCellInfo(mTelephonyManager.getAllCellInfo()); int millis = 1000 / mSamplingPeriodUs; mTimerHandler.postDelayed(this, millis); @@ -110,7 +127,7 @@ public void run() { } - private void logCellInfo(List cellInfo){ + private void logCellInfo(List cellInfo) { if (logger != null) { String message = getCellInfoString(cellInfo); logger.log(message); @@ -126,7 +143,7 @@ public void start() { Log.i(TAG, "start:: Starting listener for sensor: " + getSensorName()); logger.start(); - if (mCellInfoListener != null){ + if (mCellInfoListener != null) { mTelephonyManager.listen(mCellInfoListener, PhoneStateListener.LISTEN_CELL_INFO | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS | PhoneStateListener.LISTEN_CELL_LOCATION); @@ -137,7 +154,7 @@ public void start() { @Override public void stop() { - Log.i(TAG,"stop:: Stopping listener for sensor " + getSensorName()); + Log.i(TAG, "stop:: Stopping listener for sensor " + getSensorName()); if (mCellInfoListener != null) { mTelephonyManager.listen(mCellInfoListener, PhoneStateListener.LISTEN_NONE); @@ -175,11 +192,21 @@ public void onCellInfoChanged(List cellInfo) { } @Override - public void onCellLocationChanged(CellLocation location){ + public void onCellLocationChanged(CellLocation location) { super.onCellLocationChanged(location); // getAllCellInfo() returns all observed cell information from all radios on the device including the primary and neighboring cells // This is preferred over using getCellLocation although for older devices this may return null in which case getCellLocation should be called. + if (ActivityCompat.checkSelfPermission(mcontext, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { + // TODO: Consider calling + // ActivityCompat#requestPermissions + // here to request the missing permissions, and then overriding + // public void onRequestPermissionsResult(int requestCode, String[] permissions, + // int[] grantResults) + // to handle the case where the user grants the permission. See the documentation + // for ActivityCompat#requestPermissions for more details. + return; + } logCellInfo(mTelephonyManager.getAllCellInfo()); } @@ -189,6 +216,16 @@ public void onSignalStrengthsChanged(SignalStrength signalStrength) { // getAllCellInfo() returns all observed cell information from all radios on the device including the primary and neighboring cells // This is preferred over using getCellLocation although for older devices this may return null in which case getCellLocation should be called. + if (ActivityCompat.checkSelfPermission(mcontext, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { + // TODO: Consider calling + // ActivityCompat#requestPermissions + // here to request the missing permissions, and then overriding + // public void onRequestPermissionsResult(int requestCode, String[] permissions, + // int[] grantResults) + // to handle the case where the user grants the permission. See the documentation + // for ActivityCompat#requestPermissions for more details. + return; + } logCellInfo(mTelephonyManager.getAllCellInfo()); } } diff --git a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/collector/DataCollectors.java b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/collector/DataCollectors.java index 97cb3a8..c0568df 100755 --- a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/collector/DataCollectors.java +++ b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/collector/DataCollectors.java @@ -1,6 +1,6 @@ /* * Copyright (c) 2017. Mathias Ciliberto, Francisco Javier Ordoñez Morales, - * Hristijan Gjoreski, Daniel Roggen + * Hristijan Gjoreski, Daniel Roggen, Clara Wurm * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -31,6 +31,7 @@ import uk.ac.sussex.wear.android.datalogger.Constants; import uk.ac.sussex.wear.android.datalogger.SharedPreferencesHelper; +// class for collecting sensor data, includes all sensors to be measured public class DataCollectors { @@ -59,7 +60,54 @@ public void startDataCollectors(Context context, String sessionName, long nanosO // Initialization of collectors objects array mCollectors = new ArrayList<>(); - + + // Measures the status of the WiFi networks + if (SharedPreferencesHelper.isEnabledWiFi(context)){ + mCollectors.add(new WiFiDataCollector(context, sessionName, + Constants.SENSOR_NAME_WIFI, + SharedPreferencesHelper.getSamplingPeriodWiFiInfo(context), + nanosOffset, + SharedPreferencesHelper.getLogFilesMaxsize(context))); + } + + // Measures the status of the cellular network in number of cells and signal strength + if (SharedPreferencesHelper.isEnabledCellsInfo(context)){ + try{ + mCollectors.add(new CellsInfoDataCollector(context, sessionName, + Constants.SENSOR_NAME_CELL, + SharedPreferencesHelper.getSamplingPeriodCellsInfo(context), + nanosOffset, + SharedPreferencesHelper.getLogFilesMaxsize(context))); + } catch (Exception e){ + Log.e(TAG, "Error creating " + Constants.SENSOR_NAME_CELL + " data collector: " + e.getMessage()); + } + } + + // Measures the status of the Bluetooth networks + if (SharedPreferencesHelper.isEnabledBluetooth(context)){ + try{ + //PROBLEM + mCollectors.add(new BluetoothDataCollector(context, sessionName, + Constants.SENSOR_NAME_BLUETOOTH, + SharedPreferencesHelper.getSamplingPeriodBluetoothInfo(context), + nanosOffset, + SharedPreferencesHelper.getLogFilesMaxsize(context))); + } catch (Exception e){ + Log.e(TAG, "Error creating " + Constants.SENSOR_NAME_BLUETOOTH + " data collector: " + e.getMessage()); + } + } + + // Calls DummyDataCollector + try{ + Log.e(TAG, "Error creating " + "DummyDataCollector" + " test_datacoll"); + mCollectors.add(new DummyDataCollector(context, sessionName, + "Dummy", 1, + nanosOffset, + SharedPreferencesHelper.getLogFilesMaxsize(context))); + } catch (Exception e){ + Log.e(TAG, "Error creating " + "Dummy" + " data collector: " + e.getMessage()); + } + // Measures the acceleration force in m/s2 that is applied to a device on all three physical axes (x, y, and z), including the force of gravity. // SensorEvent.values[0] Acceleration force along the x axis (including gravity). // SensorEvent.values[1] Acceleration force along the y axis (including gravity). @@ -131,19 +179,6 @@ public void startDataCollectors(Context context, String sessionName, long nanosO SharedPreferencesHelper.getLogFilesMaxsize(context))); } - // Measures the status of the cellular network in number of cells and signal strength - if (SharedPreferencesHelper.isEnabledCellsInfo(context)){ - try{ - mCollectors.add(new CellsInfoDataCollector(context, sessionName, - Constants.SENSOR_NAME_CELL, - SharedPreferencesHelper.getSamplingPeriodCellsInfo(context), - nanosOffset, - SharedPreferencesHelper.getLogFilesMaxsize(context))); - } catch (Exception e){ - Log.e(TAG, "Error creating " + Constants.SENSOR_NAME_CELL + " data collector: " + e.getMessage()); - } - } - // Measures the status of the cellular network in number of cells and signal strength (deprecated version) if (SharedPreferencesHelper.isEnabledDeprCellsInfo(context)){ try{ @@ -228,15 +263,6 @@ public void startDataCollectors(Context context, String sessionName, long nanosO } } - // Measures the status of the WiFi networks - if (SharedPreferencesHelper.isEnabledWiFi(context)){ - mCollectors.add(new WiFiDataCollector(context, sessionName, - Constants.SENSOR_NAME_WIFI, - SharedPreferencesHelper.getSamplingPeriodWiFiInfo(context), - nanosOffset, - SharedPreferencesHelper.getLogFilesMaxsize(context))); - } - // Measures position of the device relative to the earth's frame of reference (specifically, // the magnetic north pole). // Sensor type TYPE_ORIENTATION was deprecated in Android 2.2 (API level 8), and this sensor @@ -256,7 +282,6 @@ public void startDataCollectors(Context context, String sessionName, long nanosO } } - // Linear acceleration TYPE_LINEAR_ACCELERATION // Measures the acceleration force in m/s2 that is applied to a device on all three physical axes (x, y, and z), excluding the force of gravity. // SensorEvent.values[0] Acceleration force along the x axis (excluding gravity). m/s2 @@ -275,7 +300,6 @@ public void startDataCollectors(Context context, String sessionName, long nanosO } } - // Gravity TYPE_GRAVITY // Measures the force of gravity in m/s2 that is applied to a device on all three physical axes (x, y, z). // SensorEvent.values[0] Force of gravity along the x axis. m/s2 @@ -294,14 +318,15 @@ public void startDataCollectors(Context context, String sessionName, long nanosO } } - - // All data collectors are started - for (AbstractDataCollector collector : mCollectors) { - Log.i(TAG, "Calling collector " + collector.getSensorName()); - collector.start(); + try{ + for (AbstractDataCollector collector : mCollectors) { + Log.i(TAG, "Calling collector " + collector.getSensorName()); + collector.start(); + } + } catch (Exception e){ + Log.e(TAG, "Error starting data collector: " + e.getMessage()); } - } public void stopDataCollectors() { diff --git a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/collector/Depr_CellsInfoDataCollector.java b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/collector/Depr_CellsInfoDataCollector.java index 73b51c5..d6dd1a2 100755 --- a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/collector/Depr_CellsInfoDataCollector.java +++ b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/collector/Depr_CellsInfoDataCollector.java @@ -37,6 +37,8 @@ import uk.ac.sussex.wear.android.datalogger.log.CustomLogger; +// old child class for collecting data about mobile cells + public class Depr_CellsInfoDataCollector extends AbstractDataCollector { private static final String TAG = Depr_CellsInfoDataCollector.class.getSimpleName(); diff --git a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/collector/DummyDataCollector.java b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/collector/DummyDataCollector.java new file mode 100644 index 0000000..fc945ff --- /dev/null +++ b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/collector/DummyDataCollector.java @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2019. Mathias Ciliberto, Francisco Javier Ordoñez Morales, + * Hristijan Gjoreski, Daniel Roggen, Clara Wurm + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package uk.ac.sussex.wear.android.datalogger.collector; + +import android.content.Context; +import android.os.Handler; +import java.io.File; + +import uk.ac.sussex.wear.android.datalogger.log.CustomLogger; + +// child class for testing the txt file write function +// class should only write "Hello" into txt file + +public class DummyDataCollector extends AbstractDataCollector { + + private static final String TAG = "DummyDataCollector"; + + private CustomLogger logger = null; + + // Timer to manage specific sampling rates + private Handler mTimerHandler = null; + private Runnable mTimerRunnable = null; + + public DummyDataCollector(Context context, String sessionName, String sensorName, int samplingPeriodUs, long nanosOffset, int logFileMaxSize){ + //Log.e(TAG, "Error creating " + "DummyDataCollector" + " test_constructor"); + mSensorName = sensorName; + String path = sessionName + File.separator + mSensorName + "_" + sessionName; + logger = new CustomLogger(context, path, sessionName, mSensorName, "txt", false, nanosOffset, logFileMaxSize); + //Log.e(TAG, "Error creating " + "DummyDataCollector" + " test_aftertxt"); + mTimerHandler = new Handler(); + mTimerRunnable = new Runnable() { + @Override + public void run() { + //Log.e(TAG, "Error creating " + Constants.SENSOR_NAME_WIFI + " test"); + logDummyInfo(); + int millis = 1000; + mTimerHandler.postDelayed(this, millis); + } + }; + } + + private void logDummyInfo(){ + //Log.e(TAG, "Error creating " + "DummyDataCollector" + " test_beforelog"); + String message = "Hello"; + logger.log(message); + logger.log(System.lineSeparator()); + //Log.e(TAG, "Error creating " + "DummyDataCollector" + " test_afterlog"); + } + + @Override + public void start() { + //Log.e(TAG, "Error creating " + "DummyDataCollector" + " test_start"); + // logDummyInfo(); + mTimerHandler.postDelayed(mTimerRunnable, 0); + logger.start(); + } + + @Override + public void stop() { + //Log.e(TAG, "Error creating " + "DummyDataCollector" + " test_stop"); + mTimerHandler.removeCallbacks(mTimerRunnable); + logger.stop(); + } + + @Override + public void haltAndRestartLogging() { + //Log.e(TAG, "Error creating " + "DummyDataCollector" + " test_halt"); + logger.stop(); + logger.resetByteCounter(); + logger.start(); + } + + @Override + public void updateNanosOffset(long nanosOffset) { + mNanosOffset = nanosOffset; + } +} diff --git a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/collector/LocationDataCollector.java b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/collector/LocationDataCollector.java index 3157955..b5d38f0 100755 --- a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/collector/LocationDataCollector.java +++ b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/collector/LocationDataCollector.java @@ -34,6 +34,7 @@ import uk.ac.sussex.wear.android.datalogger.log.CustomLogger; +// child class for collecting location data (GPS) public class LocationDataCollector extends AbstractDataCollector implements LocationListener { diff --git a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/collector/OrientationDataCollector.java b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/collector/OrientationDataCollector.java index de1f343..3cb263d 100755 --- a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/collector/OrientationDataCollector.java +++ b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/collector/OrientationDataCollector.java @@ -34,7 +34,7 @@ import uk.ac.sussex.wear.android.datalogger.log.CustomLogger; - +// child class for collecting orientation data (rotation sensor) public class OrientationDataCollector extends AbstractDataCollector implements SensorEventListener { diff --git a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/collector/SatelliteDataCollector.java b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/collector/SatelliteDataCollector.java index 3f6a7b0..7f6636a 100755 --- a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/collector/SatelliteDataCollector.java +++ b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/collector/SatelliteDataCollector.java @@ -34,6 +34,7 @@ import uk.ac.sussex.wear.android.datalogger.log.CustomLogger; +// child class for collecting satellite data (GPS) public class SatelliteDataCollector extends AbstractDataCollector { diff --git a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/collector/SensorDataCollector.java b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/collector/SensorDataCollector.java index c862f43..8fff615 100755 --- a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/collector/SensorDataCollector.java +++ b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/collector/SensorDataCollector.java @@ -34,6 +34,8 @@ import uk.ac.sussex.wear.android.datalogger.log.CustomLogger; +// child class for collecting sensor data + public class SensorDataCollector extends AbstractDataCollector implements SensorEventListener { private static final String TAG = SensorDataCollector.class.getSimpleName(); diff --git a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/collector/WiFiDataCollector.java b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/collector/WiFiDataCollector.java index 4d98882..0d888f4 100755 --- a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/collector/WiFiDataCollector.java +++ b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/collector/WiFiDataCollector.java @@ -1,6 +1,6 @@ /* * Copyright (c) 2017. Mathias Ciliberto, Francisco Javier Ordoñez Morales, - * Hristijan Gjoreski, Daniel Roggen + * Hristijan Gjoreski, Daniel Roggen, Clara Wurm * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -38,6 +38,7 @@ import uk.ac.sussex.wear.android.datalogger.log.CustomLogger; +// child class for collecting wifi data public class WiFiDataCollector extends AbstractDataCollector { @@ -74,7 +75,6 @@ public WiFiDataCollector(Context context, String sessionName, String sensorName, // Offset to match timestamps both in master and slaves devices mNanosOffset = nanosOffset; - if (mSamplingPeriodUs > 0) { mTimerHandler = new Handler(); mTimerRunnable = new Runnable() { @@ -137,7 +137,6 @@ private void logWifiInfo(List scanList){ logger.log(message); logger.log(System.lineSeparator()); } - private class WiFiInfoReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { @@ -145,6 +144,7 @@ public void onReceive(Context context, Intent intent) { } } + @Override public void start(){ Log.i(TAG, "start:: Starting listener for sensor: " + getSensorName()); diff --git a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/data/CommandBTC.java b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/data/CommandBTC.java index 52f07b9..25c2a69 100755 --- a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/data/CommandBTC.java +++ b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/data/CommandBTC.java @@ -22,6 +22,8 @@ package uk.ac.sussex.wear.android.datalogger.data; +// child class for bluetooth connection commands + public class CommandBTC extends CommandBase { String mAddress; diff --git a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/data/CommandBTS.java b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/data/CommandBTS.java index a27b356..d5fe471 100755 --- a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/data/CommandBTS.java +++ b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/data/CommandBTS.java @@ -22,6 +22,8 @@ package uk.ac.sussex.wear.android.datalogger.data; +// child class for bluetooth start commands + public class CommandBTS extends CommandBase { @Override diff --git a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/data/CommandBase.java b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/data/CommandBase.java index 741559a..bd9a79f 100755 --- a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/data/CommandBase.java +++ b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/data/CommandBase.java @@ -26,6 +26,8 @@ import java.util.ArrayList; +// parent class for commands + public abstract class CommandBase { private static final String TAG = CommandBase.class.getSimpleName(); diff --git a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/data/CommandDCE.java b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/data/CommandDCE.java index 26f8072..b51f7be 100755 --- a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/data/CommandDCE.java +++ b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/data/CommandDCE.java @@ -24,6 +24,8 @@ import java.util.Iterator; +// child class for data collection event commands + public class CommandDCE extends CommandBase { private boolean mState; diff --git a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/data/CommandFLE.java b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/data/CommandFLE.java index aaff012..7dcd1d0 100644 --- a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/data/CommandFLE.java +++ b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/data/CommandFLE.java @@ -25,6 +25,9 @@ /** * Created by mathias on 01/02/17. */ + +// child class for flag event commands + public class CommandFLE extends CommandBase { String flag; diff --git a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/data/CommandFUC.java b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/data/CommandFUC.java index 92c7bd6..0758f59 100755 --- a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/data/CommandFUC.java +++ b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/data/CommandFUC.java @@ -22,6 +22,8 @@ package uk.ac.sussex.wear.android.datalogger.data; +// child class for file upload cancel command + public class CommandFUC extends CommandBase { @Override diff --git a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/data/CommandFUS.java b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/data/CommandFUS.java index 77ada40..187f09b 100755 --- a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/data/CommandFUS.java +++ b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/data/CommandFUS.java @@ -22,6 +22,8 @@ package uk.ac.sussex.wear.android.datalogger.data; +// child class for file upload start command + public class CommandFUS extends CommandBase { @Override diff --git a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/data/CommandKA.java b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/data/CommandKA.java index 6ee7172..7214baa 100755 --- a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/data/CommandKA.java +++ b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/data/CommandKA.java @@ -26,6 +26,8 @@ import uk.ac.sussex.wear.android.datalogger.R; +// child class for keep alive commands + public class CommandKA extends CommandBase { private boolean mDataCollectionState; diff --git a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/data/CommandLAE.java b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/data/CommandLAE.java index 6461cb6..82f840a 100755 --- a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/data/CommandLAE.java +++ b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/data/CommandLAE.java @@ -28,6 +28,8 @@ import uk.ac.sussex.wear.android.datalogger.R; +// child class for label annotation event commands + public class CommandLAE extends CommandBase { private static final String TAG = CommandLAE.class.getSimpleName(); diff --git a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/data/DataCollectionSession.java b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/data/DataCollectionSession.java index 935d3d7..30b165e 100755 --- a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/data/DataCollectionSession.java +++ b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/data/DataCollectionSession.java @@ -28,6 +28,9 @@ /** * Created by fjordonez on 01/10/16. */ + +// class for data collection session + public class DataCollectionSession { private Date mStartDate; private Date mEndDate; diff --git a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/db/DataCollectionSessionTable.java b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/db/DataCollectionSessionTable.java index 79719cb..2fab140 100755 --- a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/db/DataCollectionSessionTable.java +++ b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/db/DataCollectionSessionTable.java @@ -25,6 +25,7 @@ import android.database.sqlite.SQLiteDatabase; import android.util.Log; +// class for creating data collection session table public class DataCollectionSessionTable { diff --git a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/db/DataLoggerDataSource.java b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/db/DataLoggerDataSource.java index d47bdef..d597a3f 100755 --- a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/db/DataLoggerDataSource.java +++ b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/db/DataLoggerDataSource.java @@ -32,6 +32,8 @@ import uk.ac.sussex.wear.android.datalogger.data.DataCollectionSession; +// class for data source of datalogger + public class DataLoggerDataSource { private static final String TAG = DataLoggerDataSource.class.getSimpleName(); diff --git a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/db/DataLoggerOpenHelper.java b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/db/DataLoggerOpenHelper.java index 5542888..cb183a9 100755 --- a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/db/DataLoggerOpenHelper.java +++ b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/db/DataLoggerOpenHelper.java @@ -26,6 +26,8 @@ import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; +// class for creating/updating database + public class DataLoggerOpenHelper extends SQLiteOpenHelper { private static final String DATABASE_NAME = "datalogger.db"; diff --git a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/db/LogFileTable.java b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/db/LogFileTable.java index d5ae8f6..464915f 100755 --- a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/db/LogFileTable.java +++ b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/db/LogFileTable.java @@ -25,6 +25,8 @@ import android.database.sqlite.SQLiteDatabase; import android.util.Log; +// class for creation of database with sql statement + public class LogFileTable { private static final String TAG = LogFileTable.class.getSimpleName(); diff --git a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/har/HARecognizerApiHandler.java b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/har/HARecognizerApiHandler.java index ba5cfc3..1a3e671 100755 --- a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/har/HARecognizerApiHandler.java +++ b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/har/HARecognizerApiHandler.java @@ -44,6 +44,8 @@ import uk.ac.sussex.wear.android.datalogger.Constants; import uk.ac.sussex.wear.android.datalogger.log.HARecognizerApiLogger; +// class for using google api client + public class HARecognizerApiHandler implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener, ResultCallback { diff --git a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/har/HARecognizerApiIntentService.java b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/har/HARecognizerApiIntentService.java index 1e0c4c1..ca0004e 100755 --- a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/har/HARecognizerApiIntentService.java +++ b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/har/HARecognizerApiIntentService.java @@ -33,6 +33,8 @@ import uk.ac.sussex.wear.android.datalogger.Constants; +// class for intent service of google api service ?! + public class HARecognizerApiIntentService extends IntentService { private static final String TAG = HARecognizerApiIntentService.class.getSimpleName(); diff --git a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/log/CustomLogger.java b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/log/CustomLogger.java index 2a6ad3f..31fa6ae 100755 --- a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/log/CustomLogger.java +++ b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/log/CustomLogger.java @@ -33,6 +33,8 @@ import uk.ac.sussex.wear.android.datalogger.db.DataLoggerDataSource; +// parent class creating log files + public class CustomLogger { private static final String TAG = CustomLogger.class.getSimpleName(); @@ -88,6 +90,7 @@ public void log(String s) { try { mOutputStream.write(s.getBytes()); }catch(IOException e){ + Log.e(TAG, "::log Error writing in log file "+getBaseFilename()); } if (mMaxSizeKByte>0){ diff --git a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/log/HARecognizerApiLogger.java b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/log/HARecognizerApiLogger.java index 92d82df..f8a00e7 100755 --- a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/log/HARecognizerApiLogger.java +++ b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/log/HARecognizerApiLogger.java @@ -33,6 +33,8 @@ import uk.ac.sussex.wear.android.datalogger.Constants; +// child class for logging HARecognizerApi + public class HARecognizerApiLogger extends CustomLogger { private static final String TAG = HARecognizerApiLogger.class.getSimpleName(); diff --git a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/log/LabelsLogger.java b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/log/LabelsLogger.java index cd2b42e..fab977b 100755 --- a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/log/LabelsLogger.java +++ b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/log/LabelsLogger.java @@ -33,6 +33,9 @@ /** * Created by fjordonez on 01/10/16. */ + +// child class for logging labels + public class LabelsLogger extends CustomLogger { private static final String TAG = LabelsLogger.class.getSimpleName(); diff --git a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/log/LoggerHelper.java b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/log/LoggerHelper.java index de5e868..0b054a9 100755 --- a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/log/LoggerHelper.java +++ b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/log/LoggerHelper.java @@ -31,6 +31,8 @@ * Created by fjordonez on 13/10/16. */ +// class for storing logs in log files, creating directories + public final class LoggerHelper { private static final String TAG = LoggerHelper.class.getSimpleName(); diff --git a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/upload/FileUploader.java b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/upload/FileUploader.java index e5e4e54..a18c2a4 100755 --- a/app/src/main/java/uk/ac/sussex/wear/android/datalogger/upload/FileUploader.java +++ b/app/src/main/java/uk/ac/sussex/wear/android/datalogger/upload/FileUploader.java @@ -1,6 +1,6 @@ /* * Copyright (c) 2017. Mathias Ciliberto, Francisco Javier Ordoñez Morales, - * Hristijan Gjoreski, Daniel Roggen + * Hristijan Gjoreski, Daniel Roggen, Clara Wurm * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -240,6 +240,18 @@ private void createFilesList() { // The files containing activities recognized from the API must be uploaded addFilesToUpload(DataLoggerDataSource.selectUnsyncLogFiles(mContext, Constants.SENSOR_NAME_API_HAR)); + if (SharedPreferencesHelper.toSyncCellsInfo(mContext)){ + addFilesToUpload(DataLoggerDataSource.selectUnsyncLogFiles(mContext, Constants.SENSOR_NAME_CELL)); + } + + if (SharedPreferencesHelper.toSyncWiFi(mContext)){ + addFilesToUpload(DataLoggerDataSource.selectUnsyncLogFiles(mContext, Constants.SENSOR_NAME_WIFI)); + } + + if (SharedPreferencesHelper.toSyncBluetooth(mContext)){ + addFilesToUpload(DataLoggerDataSource.selectUnsyncLogFiles(mContext, Constants.SENSOR_NAME_BLUETOOTH)); + } + if (SharedPreferencesHelper.toSyncAccelerometer(mContext)) { addFilesToUpload(DataLoggerDataSource.selectUnsyncLogFiles(mContext, Constants.SENSOR_NAME_ACC)); } @@ -260,9 +272,6 @@ private void createFilesList() { addFilesToUpload(DataLoggerDataSource.selectUnsyncLogFiles(mContext, Constants.SENSOR_NAME_BAT)); } - if (SharedPreferencesHelper.toSyncCellsInfo(mContext)){ - addFilesToUpload(DataLoggerDataSource.selectUnsyncLogFiles(mContext, Constants.SENSOR_NAME_CELL)); - } if (SharedPreferencesHelper.toSyncLocation(mContext)){ addFilesToUpload(DataLoggerDataSource.selectUnsyncLogFiles(mContext, Constants.SENSOR_NAME_LOC)); @@ -288,9 +297,7 @@ private void createFilesList() { addFilesToUpload(DataLoggerDataSource.selectUnsyncLogFiles(mContext, Constants.SENSOR_NAME_HUM)); } - if (SharedPreferencesHelper.toSyncWiFi(mContext)){ - addFilesToUpload(DataLoggerDataSource.selectUnsyncLogFiles(mContext, Constants.SENSOR_NAME_WIFI)); - } + if (SharedPreferencesHelper.toSyncOrientation(mContext)){ addFilesToUpload(DataLoggerDataSource.selectUnsyncLogFiles(mContext, Constants.SENSOR_NAME_ORIEN)); diff --git a/app/src/main/res/layout/activity_bluetooth_device_list.xml b/app/src/main/res/layout/activity_bluetooth_device_list.xml index d2d57bd..3c1e004 100755 --- a/app/src/main/res/layout/activity_bluetooth_device_list.xml +++ b/app/src/main/res/layout/activity_bluetooth_device_list.xml @@ -19,6 +19,7 @@ ~ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN ~ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --> + - \ No newline at end of file + + diff --git a/app/src/main/res/layout/content_main.xml b/app/src/main/res/layout/content_main.xml index e64874e..d270bf2 100755 --- a/app/src/main/res/layout/content_main.xml +++ b/app/src/main/res/layout/content_main.xml @@ -1,6 +1,6 @@ + BLE not supported on this device. + Bluetooth not supported on this device. + Bluetooth is not enabled, turn it on. not supported @@ -85,6 +89,27 @@ Sensors Enable remote server sync + Cellular network recorder + PREF_SENSORS_ENABLED_CELL_KEY + Enable cells recorder + Sampling rate in Hz (1 for default) + PREF_SENSORS_SAMPLING_CELL_KEY + PREF_SENSORS_SYNC_CELL_KEY + + WiFi recorder + PREF_SENSORS_ENABLED_WIFI_KEY + Enable WiFi recorder + Sampling rate in Hz (1 for default) + PREF_SENSORS_SAMPLING_WIFI_KEY + PREF_SENSORS_SYNC_WIFI_KEY + + Bluetooth recorder + PREF_SENSORS_ENABLED_Bluetooth_KEY + Enable Bluetooth recorder + Sampling rate in Hz (1 for default) + PREF_SENSORS_SAMPLING_Bluetooth_KEY + PREF_SENSORS_SYNC_Bluetooth_KEY + Accelerometer PREF_SENSORS_ENABLED_ACC_KEY Enable accelerometer @@ -118,13 +143,6 @@ Enable battery recorder PREF_SENSORS_SYNC_BAT_KEY - Cellular network recorder - PREF_SENSORS_ENABLED_CELL_KEY - Enable cells recorder - Sampling rate in Hz (0 for default) - PREF_SENSORS_SAMPLING_CELL_KEY - PREF_SENSORS_SYNC_CELL_KEY - Cellular network recorder (deprecated) PREF_SENSORS_ENABLED_DEPR_CELL_KEY Enable cells recorder @@ -168,13 +186,6 @@ PREF_SENSORS_SAMPLING_HUM_KEY PREF_SENSORS_SYNC_HUM_KEY - WiFi recorder - PREF_SENSORS_ENABLED_WIFI_KEY - Enable WiFi recorder - Sampling rate in Hz (1 for default) - PREF_SENSORS_SAMPLING_WIFI_KEY - PREF_SENSORS_SYNC_WIFI_KEY - Orientation PREF_SENSORS_ENABLED_ORIEN_KEY Enable orientation diff --git a/app/src/main/res/xml/pref_data_sync.xml b/app/src/main/res/xml/pref_data_sync.xml index 122e84c..6d69dee 100755 --- a/app/src/main/res/xml/pref_data_sync.xml +++ b/app/src/main/res/xml/pref_data_sync.xml @@ -1,6 +1,6 @@