Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bluetooth Beacon Detection functionality added #3

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
4ecc5a9
commented most important files for better overview of functionality
wurmc Mar 11, 2019
ce84569
removed bluetooth master slave functionality by commenting out all re…
wurmc Mar 18, 2019
cfcb20c
rearranged order of sensors in frontend list: set cellular info, wifi…
wurmc Mar 25, 2019
158f529
added bluetooth beacon measuring functionality found in BluetoothData…
wurmc Mar 30, 2019
6f897c9
some changes in bluetooth beacon measuring functionality. translated …
wurmc Apr 7, 2019
e449d09
created DummyDataCollector to find errors and test txt file writing f…
wurmc Apr 8, 2019
b1e28c6
DummyDataCollector is now working fine. Initialisation of bluetooth i…
wurmc Apr 14, 2019
c135d4a
BluetoothDataCollector is now successfully writing Hex values into tx…
wurmc Apr 14, 2019
3c14825
BluetoothDataCollector is now working. It writes the device address, …
wurmc Apr 14, 2019
b3ea495
File upload is now working. Files are uploaded to /var/www/uploads/. …
wurmc Apr 25, 2019
d51126b
Bluetooth synchronisation including master slave functionality integr…
wurmc May 4, 2019
f19f8e1
Bluetooth synchronisation including master slave functionality is now…
wurmc May 9, 2019
6b57ba0
Bluetooth synchronisation including master slave functionality is now…
wurmc May 9, 2019
22e438c
Bluetooth synchronisation including master slave functionality is now…
wurmc May 9, 2019
0ffe2b1
Merge pull request #1 from wurmc/BT_Sync
wurmc May 9, 2019
24b2c1b
Update README.md
wurmc May 10, 2019
7c3fec7
some git sync commits
wurmc May 21, 2019
d520b69
some git sync commits
wurmc May 21, 2019
7887e0b
Merge remote-tracking branch 'remotes/origin/master'
wurmc May 21, 2019
bdd09db
adapted copyright
wurmc Jun 7, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 13 additions & 3 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 16 additions & 34 deletions PHP_upload_script.txt
Original file line number Diff line number Diff line change
@@ -1,40 +1,22 @@
<?php
foreach ($_FILES["fileToUpload"]["error"] as $key => $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;
}

<?php
$target_dir = "../uploads/";
foreach ($_FILES["fileToUpload"]["error"] as $key => $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";
}
}
?>



24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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:

Expand Down
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.WAKE_LOCK" />


<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
Expand Down Expand Up @@ -105,5 +104,4 @@
android:value="@integer/google_play_services_version" />

</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -30,6 +30,8 @@
* Created by ThiasTux.
*/

// class for the 'About" Activity screen

public class AboutActivity extends AppCompatActivity {

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -113,22 +113,25 @@ 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";
public static final String SENSOR_NAME_GYR = "Gyroscope";
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";
public static final String SENSOR_NAME_TEMP = "Temperature";
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";
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -48,6 +48,9 @@
* href="http://developer.android.com/guide/topics/ui/settings.html">Settings
* API Guide</a> 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();
Expand Down Expand Up @@ -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)));
}

Expand Down
Loading