Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • ccc-ffm/scanble
  • dachdecker2/scanble
  • mrm2m/scanble
3 results
Show changes
Commits on Source (7)
......@@ -3,8 +3,9 @@
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="distributionType" value="LOCAL" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleHome" value="$APPLICATION_HOME_DIR$/gradle/gradle-2.2" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
......
......@@ -4,7 +4,6 @@
<modules>
<module fileurl="file://$PROJECT_DIR$/ScanBle.iml" filepath="$PROJECT_DIR$/ScanBle.iml" />
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
<module fileurl="file://$PROJECT_DIR$/scanble.iml" filepath="$PROJECT_DIR$/scanble.iml" />
</modules>
</component>
</project>
......
......@@ -12,7 +12,6 @@
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
......
......@@ -10,7 +10,7 @@
<configuration>
<option name="SELECTED_BUILD_VARIANT" value="debug" />
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugJava" />
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
<option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugTest" />
<option name="SOURCE_GEN_TASK_NAME" value="generateDebugSources" />
<option name="TEST_SOURCE_GEN_TASK_NAME" value="generateDebugTestSources" />
......@@ -31,11 +31,13 @@
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/generated/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/test/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/test/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/test/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/test/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/test/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/generated/test/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />
......@@ -77,12 +79,13 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
</content>
<orderEntry type="jdk" jdkName="Android API 20 Platform" jdkType="Android SDK" />
<orderEntry type="jdk" jdkName="Android API 21 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="sgfilter_v1_2" level="project" />
<orderEntry type="library" exported="" name="commons-math-2.0" level="project" />
<orderEntry type="library" exported="" name="commons-math3-3.3" level="project" />
<orderEntry type="library" exported="" name="sgfilter_v1_2" level="project" />
</component>
</module>
apply plugin: 'com.android.application'
android {
compileSdkVersion 20
compileSdkVersion 18
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "org.mekelburger.moritz.scanble"
minSdkVersion 19
minSdkVersion 18
targetSdkVersion 20
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
// runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
......@@ -30,6 +28,8 @@ android {
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
productFlavors {
}
}
dependencies {
......
......@@ -8,7 +8,6 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.Objects;
import java.util.Set;
import java.util.List;
import java.util.TreeMap;
......@@ -51,7 +50,7 @@ public class AdvertisementHistory extends TreeMap<Long, Integer> {
*
* @return padded data set
*/
private double[] getPaddedData() {
private double[] getPaddedData(String beaconID) {
List<Integer> tmpResult = new ArrayList<Integer>();
Object[] timestamps;
long lastTimestamp = 0;
......@@ -66,7 +65,7 @@ public class AdvertisementHistory extends TreeMap<Long, Integer> {
timestamps = this.keySet().toArray();
if (System.currentTimeMillis() - ((Long) timestamps[timestamps.length - 1]).longValue() >
AdvertisementHistory.TIMEOUT) {
AdvertisementHistory.OLD) {
Log.d(TAG, String.format("Last time stamp too old: %d - %d = %d > %d",
System.currentTimeMillis(),
((Long) timestamps[timestamps.length - 1]).longValue(),
......@@ -99,18 +98,19 @@ public class AdvertisementHistory extends TreeMap<Long, Integer> {
tmpResult.add(this.get(currentTs));
}
double[] result = new double[tmpResult.size()];
for (int i=0; i < tmpResult.size(); i++) {
result[i] = (double) tmpResult.get(i);
for (int i=tmpResult.size() - 1; i >= 0; i--) {
if (tmpResult.get(i).intValue() == 0) {
result[i] = result[i+1];
} else {
result[i] = (double) tmpResult.get(i);
}
}
ContinuousPadder continuousPadder = new ContinuousPadder(true, false);
continuousPadder.apply(result);
Log.d(TAG, String.format("Padded %d values", tmpResult.size() - this.keySet().size()));
Log.v(TAG, String.format("Padded data: %s", Arrays.toString(result)));
Log.v(TAG, String.format("Padded data: %s - %s", beaconID, Arrays.toString(result)));
return result;
}
public float getCurrentValue() {
double[] dataSet = this.getPaddedData();
public float getCurrentValue(String beaconID) {
double[] dataSet = this.getPaddedData(beaconID);
if (dataSet.length <= 3) {
return Float.NaN;
}
......
......@@ -24,7 +24,7 @@ public class Beacon extends SimpleBeacon{
public SimpleBeacon flatCopy() {
SimpleBeacon result = new SimpleBeacon(this.getPosition().clone(), this.getDistance(),
this.getDistanceError(), this.advertisements.getCurrentValue());
this.getDistanceError(), this.advertisements.getCurrentValue(this.getMac()));
return result;
}
......@@ -34,7 +34,7 @@ public class Beacon extends SimpleBeacon{
}
public float getDistance() {
float ratio_power = this.tx - this.advertisements.getCurrentValue();
float ratio_power = this.tx - this.advertisements.getCurrentValue(this.getMac());
float distance = (float) Math.pow(Math.pow(10., ratio_power / 10.), 0.5);
Log.d(TAG, String.format("Distance %s: %.2f (from %d measurements)", this.getMac(),
distance, this.advertisements.size()));
......
......@@ -90,12 +90,15 @@ public class BeaconHandler implements Runnable {
this.bluetoothAdapter.startLeScan(leScanCallback);
scanning = true;
this.stopLeScanFuture = this.stopLeScanWorker.schedule(stopLe, BeaconHandler.INACTIVITY_TIMEOUT, TimeUnit.MILLISECONDS);
KNOWN_BEACONS.put("00:07:80:68:28:29", new float[]{0.f,-3f,1.f});
KNOWN_BEACONS.put("00:07:80:68:28:29", new float[]{6.f,-3f,1.f});
KNOWN_BEACONS.put("00:07:80:C0:FF:EE", new float[]{0.f,-3f,1.f});
KNOWN_BEACONS.put("00:07:80:68:28:64", new float[]{0.f,3f,2.25f});
// KNOWN_BEACONS.put("00:07:80:11:11:11", new float[]{0f,0f,0f});
KNOWN_BEACONS.put("00:07:80:79:00:BA", new float[]{-3.f,0.f,0.8f});
KNOWN_BEACONS.put("00:07:80:72:CD:E3", new float[]{3.f,0.f,1.f});
KNOWN_BEACONS.put("00:07:80:79:00:BA", new float[]{9.f,1.f,0.8f}); // DKBLE BLE113
KNOWN_BEACONS.put("00:07:80:72:CD:E3", new float[]{6.f,0.f,1.f}); // BLE113 eval-board
KNOWN_BEACONS.put("00:07:80:7F:41:30", new float[]{-2.f,0.f,2.f});
KNOWN_BEACONS.put("0E:F3:EE:5A:04:CD", new float[]{0.f,0.f,1.2f});
KNOWN_BEACONS.put("60:03:08:AE:CB:F2", new float[]{0.f,0.f,0.2f});
}
/**
......
......@@ -8,12 +8,17 @@ import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.RelativeLayout;
import android.widget.Switch;
import android.widget.TextView;
import java.util.concurrent.Executors;
......@@ -32,6 +37,9 @@ public class MainActivity extends Activity {
private static final ScheduledExecutorService requestPosition =
Executors.newSingleThreadScheduledExecutor();
private ScheduledFuture<?> requestPositionFuture;
private Handler runhandler = new Handler();
private Boolean doAutoUpdate = false;
ServiceConnection serviceConnection = new ServiceConnection() {
@Override
......@@ -69,37 +77,55 @@ public class MainActivity extends Activity {
@Override
public void onClick(View v) {
Log.d(TAG, "Button pressed - START");
String beaconString = "";
for (SimpleBeacon b: beaconService.getBeaconHandler().getTmpBeacons()) {
beaconString += b.toString();
beaconString += "\n";
}
((TextView) findViewById(R.id.textView)).setText(
String.format("Position: %.2f, %.2f\n%s",
beaconService.getBeaconHandler().getPos()[0],
beaconService.getBeaconHandler().getPos()[1],
beaconString));
// ((TextView) findViewById(R.id.textView)).setText("Foo!");
/* if (bounded) {
beaconService.getBeaconHandler().getPos();
} // */
updateText("Button");
Log.d(TAG, "Button pressed - END");
}
});
bindService(intent, this.serviceConnection, BIND_ABOVE_CLIENT);
/* this.requestPositionFuture = this.requestPosition.scheduleAtFixedRate(new Runnable() {
Switch do_switch = (Switch) findViewById(R.id.myswitch);
do_switch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void run() {
Log.d(TAG, "Timer - START");
// ((TextView) findViewById(R.id.textView)).setText(beaconService.getBeaconHandler().getPos().toString());
runOnUiThread();
((TextView) findViewById(R.id.textView)).setText("Foo!");
Log.d(TAG, "Timer - END");
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if(isChecked)
{
doAutoUpdate = true;
runhandler.postDelayed(new Runnable() {
@Override
public void run() {
Log.d(TAG, "Timer2 - START");
updateText("Scheduler");
Log.d(TAG, "Timer2 - END");
if (doAutoUpdate)
runhandler.postDelayed(this, 1000);
}
}
, 1000);
}
else
doAutoUpdate = false;
}
}, 1, 2, TimeUnit.SECONDS); // */
});
bindService(intent, this.serviceConnection, BIND_ABOVE_CLIENT);
getWindow().getDecorView().findViewById(android.R.id.content).invalidate();
((TextView) findViewById(R.id.textView)).invalidate();
}
private void updateText (String defaultString) {
String beaconString = "";
for (SimpleBeacon b: beaconService.getBeaconHandler().getTmpBeacons()) {
beaconString += b.toString();
beaconString += "\n";
}
((TextView) findViewById(R.id.textView)).setText(
String.format("caller: %s\nPosition: %.2f, %.2f\n%s",
defaultString,
beaconService.getBeaconHandler().getPos()[0],
beaconService.getBeaconHandler().getPos()[1],
beaconString));
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
......
......@@ -14,15 +14,24 @@
android:text="Tu was!"
android:id="@+id/button"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
android:layout_alignParentStart="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Text"
android:text="New Text\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
android:id="@+id/textView"
android:layout_alignParentEnd="true"
android:layout_below="@+id/button"
android:layout_alignParentStart="true" />
android:layout_alignParentStart="true"
android:inputType="textMultiLine" />
<Switch
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="autouptdate"
android:id="@+id/myswitch"
android:layout_alignParentTop="true"
android:layout_alignEnd="@+id/textView" />
</RelativeLayout>
......@@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.2'
classpath 'com.android.tools.build:gradle:0.14.4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
......
#Wed Apr 10 15:27:10 PDT 2013
#Sun Nov 23 15:26:37 CET 2014
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-1.12-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2-all.zip
......@@ -7,12 +7,13 @@
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="true">
<component name="NewModuleRootManager" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/build/classes/main" />
<output-test url="file://$MODULE_DIR$/build/classes/test" />
<exclude-output />
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
......