From b3637780f3fae3d9f75a02b07d1907eb49a52381 Mon Sep 17 00:00:00 2001 From: Job Hartjes Date: Tue, 19 Feb 2019 15:49:03 +0100 Subject: [PATCH 01/18] IndoorPositioning.updateLocation() assumes the beacons are sorted on rssi from highest to lowest. --- .../com/nexenio/bleindoorpositioning/ble/beacon/Beacon.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/ble/beacon/Beacon.java b/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/ble/beacon/Beacon.java index 0f71606..0ddf79a 100644 --- a/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/ble/beacon/Beacon.java +++ b/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/ble/beacon/Beacon.java @@ -222,7 +222,7 @@ public WindowFilter createSuggestedWindowFilter() { public static Comparator RssiComparator = new Comparator() { public int compare(Beacon firstBeacon, Beacon secondBeacon) { - return firstBeacon.rssi - secondBeacon.rssi; + return secondBeacon.rssi - firstBeacon.rssi; } }; From 1180a78ed7febe75baeea96de6e010c6a4458434 Mon Sep 17 00:00:00 2001 From: Job Hartjes Date: Thu, 28 Feb 2019 16:46:09 +0100 Subject: [PATCH 02/18] Deprecated RssiComparator and introduced two Comparators with more intuitive naming. --- .../bleindoorpositioning/IndoorPositioning.java | 2 +- .../bleindoorpositioning/ble/beacon/Beacon.java | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/IndoorPositioning.java b/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/IndoorPositioning.java index 949f4c4..730b024 100644 --- a/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/IndoorPositioning.java +++ b/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/IndoorPositioning.java @@ -89,7 +89,7 @@ private void updateLocation() { if (usableBeacons.size() < MINIMUM_BEACON_COUNT) { return; } else if (usableBeacons.size() > MINIMUM_BEACON_COUNT) { - Collections.sort(usableBeacons, Beacon.RssiComparator); + Collections.sort(usableBeacons, Beacon.RssiHighToLowComparator); int maximumBeaconIndex = Math.min(MAXIMUM_BEACON_COUNT, usableBeacons.size()); int firstRemovableBeaconIndex = maximumBeaconIndex; for (int beaconIndex = MINIMUM_BEACON_COUNT; beaconIndex < maximumBeaconIndex; beaconIndex++) { diff --git a/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/ble/beacon/Beacon.java b/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/ble/beacon/Beacon.java index 0ddf79a..1f66b48 100644 --- a/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/ble/beacon/Beacon.java +++ b/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/ble/beacon/Beacon.java @@ -219,12 +219,27 @@ public WindowFilter createSuggestedWindowFilter() { return new KalmanFilter(getLatestTimestamp()); } + /** + * RssiComparator is deprecated because its name is unintuitive with the sorting it provides. + * RssiLowToHighComparator has the same functionality, sorting beacons from lowest rssi to highest rssi. + */ + @Deprecated public static Comparator RssiComparator = new Comparator() { + public int compare(Beacon firstBeacon, Beacon secondBeacon) { + return firstBeacon.rssi - secondBeacon.rssi; + } + }; + public static Comparator RssiHighToLowComparator = new Comparator() { public int compare(Beacon firstBeacon, Beacon secondBeacon) { return secondBeacon.rssi - firstBeacon.rssi; } + }; + public static Comparator RssiLowToHighComparator = new Comparator() { + public int compare(Beacon firstBeacon, Beacon secondBeacon) { + return firstBeacon.rssi - secondBeacon.rssi; + } }; /* From 17deea57acae9a0fae0caf528d07a8a40c561675 Mon Sep 17 00:00:00 2001 From: jobhh Date: Thu, 28 Feb 2019 22:48:52 +0100 Subject: [PATCH 03/18] Renamed Comparators and moved them to BeaconUtil. --- .../IndoorPositioning.java | 3 ++- .../ble/beacon/Beacon.java | 18 +++--------------- .../ble/beacon/BeaconUtil.java | 19 +++++++++++++++++++ 3 files changed, 24 insertions(+), 16 deletions(-) diff --git a/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/IndoorPositioning.java b/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/IndoorPositioning.java index 730b024..1012ab0 100644 --- a/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/IndoorPositioning.java +++ b/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/IndoorPositioning.java @@ -3,6 +3,7 @@ import com.nexenio.bleindoorpositioning.ble.beacon.Beacon; import com.nexenio.bleindoorpositioning.ble.beacon.BeaconManager; import com.nexenio.bleindoorpositioning.ble.beacon.BeaconUpdateListener; +import com.nexenio.bleindoorpositioning.ble.beacon.BeaconUtil; import com.nexenio.bleindoorpositioning.ble.beacon.filter.BeaconFilter; import com.nexenio.bleindoorpositioning.ble.beacon.filter.GenericBeaconFilter; import com.nexenio.bleindoorpositioning.location.Location; @@ -89,7 +90,7 @@ private void updateLocation() { if (usableBeacons.size() < MINIMUM_BEACON_COUNT) { return; } else if (usableBeacons.size() > MINIMUM_BEACON_COUNT) { - Collections.sort(usableBeacons, Beacon.RssiHighToLowComparator); + Collections.sort(usableBeacons, BeaconUtil.DescendingRssiComparator); int maximumBeaconIndex = Math.min(MAXIMUM_BEACON_COUNT, usableBeacons.size()); int firstRemovableBeaconIndex = maximumBeaconIndex; for (int beaconIndex = MINIMUM_BEACON_COUNT; beaconIndex < maximumBeaconIndex; beaconIndex++) { diff --git a/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/ble/beacon/Beacon.java b/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/ble/beacon/Beacon.java index 1f66b48..c81b574 100644 --- a/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/ble/beacon/Beacon.java +++ b/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/ble/beacon/Beacon.java @@ -220,9 +220,9 @@ public WindowFilter createSuggestedWindowFilter() { } /** - * RssiComparator is deprecated because its name is unintuitive with the sorting it provides. - * RssiLowToHighComparator has the same functionality, sorting beacons from lowest rssi to highest rssi. - */ + * This function and its reverse are implemented with indicative naming in BeaconUtil. + * @deprecated use {@link BeaconUtil.AscendingRssiComparator} instead + */ @Deprecated public static Comparator RssiComparator = new Comparator() { public int compare(Beacon firstBeacon, Beacon secondBeacon) { @@ -230,18 +230,6 @@ public int compare(Beacon firstBeacon, Beacon secondBeacon) { } }; - public static Comparator RssiHighToLowComparator = new Comparator() { - public int compare(Beacon firstBeacon, Beacon secondBeacon) { - return secondBeacon.rssi - firstBeacon.rssi; - } - }; - - public static Comparator RssiLowToHighComparator = new Comparator() { - public int compare(Beacon firstBeacon, Beacon secondBeacon) { - return firstBeacon.rssi - secondBeacon.rssi; - } - }; - /* Getter & Setter */ diff --git a/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/ble/beacon/BeaconUtil.java b/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/ble/beacon/BeaconUtil.java index 3e6e623..014cfef 100644 --- a/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/ble/beacon/BeaconUtil.java +++ b/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/ble/beacon/BeaconUtil.java @@ -4,6 +4,7 @@ import com.nexenio.bleindoorpositioning.ble.beacon.signal.WindowFilter; import com.nexenio.bleindoorpositioning.location.distance.BeaconDistanceCalculator; +import java.util.Comparator; import java.util.List; /** @@ -155,4 +156,22 @@ public static String getReadableBeaconType(Class beaconClass) return beaconClass.getSimpleName(); } + /** + * Used to sort beacons from highest rssi to lowest rssi. + */ + public static Comparator DescendingRssiComparator = new Comparator() { + public int compare(Beacon firstBeacon, Beacon secondBeacon) { + return secondBeacon.rssi - firstBeacon.rssi; + } + }; + + /** + * Used to sort beacons from lowest rssi to highest rssi. + */ + public static Comparator AscendingRssiComparator = new Comparator() { + public int compare(Beacon firstBeacon, Beacon secondBeacon) { + return firstBeacon.rssi - secondBeacon.rssi; + } + }; + } From 7303f8b834e754f89611ca6ce57cd72da07f14e8 Mon Sep 17 00:00:00 2001 From: Job Hartjes Date: Fri, 1 Mar 2019 13:48:32 +0100 Subject: [PATCH 04/18] Fixed Javadoc @link --- .../com/nexenio/bleindoorpositioning/ble/beacon/Beacon.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/ble/beacon/Beacon.java b/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/ble/beacon/Beacon.java index c81b574..f33073e 100644 --- a/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/ble/beacon/Beacon.java +++ b/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/ble/beacon/Beacon.java @@ -221,7 +221,7 @@ public WindowFilter createSuggestedWindowFilter() { /** * This function and its reverse are implemented with indicative naming in BeaconUtil. - * @deprecated use {@link BeaconUtil.AscendingRssiComparator} instead + * @deprecated use {@link BeaconUtil#AscendingRssiComparator} instead */ @Deprecated public static Comparator RssiComparator = new Comparator() { From 3de681a026199361b10c9619c57147e144a76892 Mon Sep 17 00:00:00 2001 From: Stephan Schultz Date: Tue, 12 Mar 2019 16:16:21 +0100 Subject: [PATCH 05/18] Added instance check to indoor positioning beacon filter, bumped version number --- BLE Indoor Positioning/build.gradle | 4 ++-- .../com/nexenio/bleindoorpositioning/IndoorPositioning.java | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/BLE Indoor Positioning/build.gradle b/BLE Indoor Positioning/build.gradle index 554457e..b271175 100644 --- a/BLE Indoor Positioning/build.gradle +++ b/BLE Indoor Positioning/build.gradle @@ -28,8 +28,8 @@ dependencies { sourceCompatibility = "1.7" targetCompatibility = "1.7" -def releaseVersionCode = 14 -def releaseVersionName = "0.3.8" +def releaseVersionCode = 15 +def releaseVersionName = "0.3.9" def projectName = 'BLE Indoor Positioning' def projectDescription = 'Java library for indoor positioing using bluetooth beacons' diff --git a/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/IndoorPositioning.java b/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/IndoorPositioning.java index 1012ab0..12c3df4 100644 --- a/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/IndoorPositioning.java +++ b/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/IndoorPositioning.java @@ -4,6 +4,7 @@ import com.nexenio.bleindoorpositioning.ble.beacon.BeaconManager; import com.nexenio.bleindoorpositioning.ble.beacon.BeaconUpdateListener; import com.nexenio.bleindoorpositioning.ble.beacon.BeaconUtil; +import com.nexenio.bleindoorpositioning.ble.beacon.IBeacon; import com.nexenio.bleindoorpositioning.ble.beacon.filter.BeaconFilter; import com.nexenio.bleindoorpositioning.ble.beacon.filter.GenericBeaconFilter; import com.nexenio.bleindoorpositioning.location.Location; @@ -52,7 +53,6 @@ public class IndoorPositioning implements LocationProvider, BeaconUpdateListener private LocationPredictor locationPredictor = new LocationPredictor(); - private IndoorPositioning() { BeaconManager.registerBeaconUpdateListener(this); } @@ -151,6 +151,9 @@ public static GenericBeaconFilter createUsableIndoorPositionin @Override public boolean matches(Beacon beacon) { + if (!(beacon instanceof IBeacon)) { + return false; + } if (getInstance().indoorPositioningBeaconFilter != null && !getInstance().indoorPositioningBeaconFilter.matches(beacon)) { return false; } @@ -225,4 +228,5 @@ public int getMinimumRssiThreshold() { public void setMinimumRssiThreshold(int minimumRssiThreshold) { this.minimumRssiThreshold = minimumRssiThreshold; } + } From 550900d4a5a8fa5cb8d64f803da5dd43abdff298 Mon Sep 17 00:00:00 2001 From: Stephan Schultz Date: Tue, 12 Mar 2019 16:29:49 +0100 Subject: [PATCH 06/18] Added catch for ClassCastException --- .../nexenio/bleindoorpositioning/ble/beacon/BeaconManager.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/ble/beacon/BeaconManager.java b/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/ble/beacon/BeaconManager.java index b06b327..c733e5c 100644 --- a/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/ble/beacon/BeaconManager.java +++ b/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/ble/beacon/BeaconManager.java @@ -106,6 +106,8 @@ private void notifyBeaconUpdateListeners(Beacon beacon) { for (BeaconUpdateListener beaconUpdateListener : beaconUpdateListeners) { try { beaconUpdateListener.onBeaconUpdated(beacon); + } catch (ClassCastException e) { + // meh } catch (Exception e) { e.printStackTrace(); } From afde739a168e60e689f01c6af815f73d456a54ea Mon Sep 17 00:00:00 2001 From: Stephan Schultz Date: Tue, 12 Mar 2019 17:08:31 +0100 Subject: [PATCH 07/18] Added catch around notifyBeaconUpdateListeners --- .../bleindoorpositioning/ble/beacon/BeaconManager.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/ble/beacon/BeaconManager.java b/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/ble/beacon/BeaconManager.java index c733e5c..776f61f 100644 --- a/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/ble/beacon/BeaconManager.java +++ b/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/ble/beacon/BeaconManager.java @@ -80,7 +80,11 @@ public static AdvertisingPacket processAdvertisingPacket(String macAddress, Adve beacon.addAdvertisingPacket(advertisingPacket); //TODO move outside method processClosestBeacon(beacon); - instance.notifyBeaconUpdateListeners(beacon); + try { + instance.notifyBeaconUpdateListeners(beacon); + } catch (Exception e) { + e.printStackTrace(); + } return advertisingPacket; } @@ -108,8 +112,6 @@ private void notifyBeaconUpdateListeners(Beacon beacon) { beaconUpdateListener.onBeaconUpdated(beacon); } catch (ClassCastException e) { // meh - } catch (Exception e) { - e.printStackTrace(); } } } From 41b56b9a055a6492da5f008bbd1b67c7e9d11d63 Mon Sep 17 00:00:00 2001 From: Marvin Mirtschin Date: Wed, 24 Apr 2019 14:48:59 +0200 Subject: [PATCH 08/18] updates build tools --- BLE Indoor Positioning/build.gradle | 30 +++++++++++++----------- build.gradle | 2 +- gradle/wrapper/gradle-wrapper.properties | 3 ++- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/BLE Indoor Positioning/build.gradle b/BLE Indoor Positioning/build.gradle index 554457e..7162644 100644 --- a/BLE Indoor Positioning/build.gradle +++ b/BLE Indoor Positioning/build.gradle @@ -8,7 +8,7 @@ buildscript { } plugins { - id 'net.researchgate.release' version '2.4.0' + id 'net.researchgate.release' version '2.6.0' id 'com.jfrog.bintray' version '1.7.3' } @@ -97,6 +97,21 @@ def pomConfig = { } } +task sourcesJar(type: Jar) { + classifier = 'sources' + from sourceSets.main.allJava +} + +task javadocJar(type: Jar, dependsOn: javadoc) { + classifier = 'javadoc' + from javadoc.destinationDir +} + +artifacts { + archives sourcesJar + archives javadocJar +} + publishing { publications { mavenJava(MavenPublication) { @@ -123,20 +138,7 @@ publishing { } } -task sourcesJar(type: Jar) { - classifier = 'sources' - from sourceSets.main.allJava -} - -task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' - from javadoc.destinationDir -} -artifacts { - archives sourcesJar - archives javadocJar -} // configure release plugin. See https://github.com/researchgate/gradle-release#configuration release { diff --git a/build.gradle b/build.gradle index e5a39a8..cb23dab 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:3.4.0-alpha01' + classpath 'com.android.tools.build:gradle:3.4.0' } } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index b2f1a62..e5f8c5d 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,7 @@ #Thu Oct 25 13:40:28 CEST 2018 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +android.enableUnitTestBinaryResources=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip From 1554a213d717c85013ba9bf0b183c8513a34907b Mon Sep 17 00:00:00 2001 From: Marvin Mirtschin Date: Wed, 24 Apr 2019 14:54:09 +0200 Subject: [PATCH 09/18] removes unused gradle wrapper property --- gradle/wrapper/gradle-wrapper.properties | 1 - 1 file changed, 1 deletion(-) diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index e5f8c5d..cad6464 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,7 +1,6 @@ #Thu Oct 25 13:40:28 CEST 2018 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -android.enableUnitTestBinaryResources=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip From 3df5909471ee4059d190024082d1f5ab1b6a85a2 Mon Sep 17 00:00:00 2001 From: Steppschuh Date: Wed, 14 Aug 2019 15:03:15 +0200 Subject: [PATCH 10/18] Upgraded build tools and dependencies --- BLE Indoor Positioning/build.gradle | 56 +++++++++---------- app/build.gradle | 22 ++++---- .../HomeActivity.java | 12 ++-- .../bluetooth/BluetoothClient.java | 2 +- .../location/AndroidLocationProvider.java | 4 +- .../ui/LocationAnimator.java | 2 +- .../ui/beaconview/BeaconView.java | 8 +-- .../ui/beaconview/BeaconViewFragment.java | 10 ++-- .../ui/beaconview/ColorUtil.java | 8 +-- .../ui/beaconview/chart/BeaconChart.java | 4 +- .../beaconview/chart/BeaconChartFragment.java | 2 +- .../ui/beaconview/chart/BeaconLineChart.java | 4 +- .../beaconview/chart/RssiFilterLineChart.java | 2 +- .../ui/beaconview/map/BeaconMap.java | 4 +- .../beaconview/map/BeaconMapBackground.java | 2 +- .../ui/beaconview/map/BeaconMapFragment.java | 2 +- .../ui/beaconview/radar/BeaconRadar.java | 2 +- .../beaconview/radar/BeaconRadarFragment.java | 2 +- app/src/main/res/layout/activity_home.xml | 6 +- build.gradle | 3 +- gradle.properties | 2 + gradle/wrapper/gradle-wrapper.properties | 2 +- 22 files changed, 81 insertions(+), 80 deletions(-) diff --git a/BLE Indoor Positioning/build.gradle b/BLE Indoor Positioning/build.gradle index 7162644..bed2c75 100644 --- a/BLE Indoor Positioning/build.gradle +++ b/BLE Indoor Positioning/build.gradle @@ -3,13 +3,13 @@ buildscript { jcenter() } dependencies { - classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.8.1" + classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.9.8" } } plugins { id 'net.researchgate.release' version '2.6.0' - id 'com.jfrog.bintray' version '1.7.3' + id 'com.jfrog.bintray' version '1.8.4' } apply plugin: 'java-library' @@ -28,8 +28,8 @@ dependencies { sourceCompatibility = "1.7" targetCompatibility = "1.7" -def releaseVersionCode = 14 -def releaseVersionName = "0.3.8" +def releaseVersionCode = 15 +def releaseVersionName = "0.3.9" def projectName = 'BLE Indoor Positioning' def projectDescription = 'Java library for indoor positioing using bluetooth beacons' @@ -112,34 +112,34 @@ artifacts { archives javadocJar } -publishing { - publications { - mavenJava(MavenPublication) { - from components.java - groupId projectGroupId - artifact sourcesJar - artifactId projectArtifactId - } - BintrayPublication(MavenPublication) { - from components.java - groupId projectGroupId - artifact sourcesJar - artifact javadocJar - artifactId projectArtifactId - version releaseVersionName - pom.withXml { - def root = asNode() - root.appendNode('name', projectName) - root.appendNode('description', projectDescription) - root.appendNode('url', repositoryUrl) - root.children().last() + pomConfig +project.afterEvaluate { + publishing { + publications { + mavenJava(MavenPublication) { + from components.java + groupId projectGroupId + artifact sourcesJar + artifactId projectArtifactId + } + BintrayPublication(MavenPublication) { + from components.java + groupId projectGroupId + artifact sourcesJar + artifact javadocJar + artifactId projectArtifactId + version releaseVersionName + pom.withXml { + def root = asNode() + root.appendNode('name', projectName) + root.appendNode('description', projectDescription) + root.appendNode('url', repositoryUrl) + root.children().last() + pomConfig + } } } } } - - // configure release plugin. See https://github.com/researchgate/gradle-release#configuration release { failOnUnversionedFiles = false @@ -159,4 +159,4 @@ jacocoTestReport { } } -check.dependsOn jacocoTestReport \ No newline at end of file +check.dependsOn jacocoTestReport diff --git a/app/build.gradle b/app/build.gradle index 42415c1..0e255ac 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -8,7 +8,7 @@ android { targetSdkVersion 28 versionCode 1 versionName "1.0" - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { release { @@ -31,19 +31,19 @@ android { dependencies { implementation project(':BLE Indoor Positioning') - implementation 'com.android.support:appcompat-v7:28.0.0' - implementation 'com.android.support:support-v4:28.0.0' - implementation 'com.android.support:support-media-compat:28.0.0' - implementation 'com.android.support:design:28.0.0' - implementation 'com.android.support.constraint:constraint-layout:1.1.3' + implementation 'androidx.appcompat:appcompat:1.0.0' + implementation 'androidx.legacy:legacy-support-v4:1.0.0' + implementation 'androidx.media:media:1.0.0' + implementation 'com.google.android.material:material:1.0.0' + implementation 'androidx.constraintlayout:constraintlayout:1.1.3' - implementation 'com.google.android.gms:play-services-location:16.0.0' + implementation 'com.google.android.gms:play-services-location:17.0.0' implementation "com.polidea.rxandroidble:rxandroidble:1.4.3" testImplementation 'junit:junit:4.12' - testImplementation "com.android.support.test:runner:1.0.2" - testImplementation "com.android.support.test:rules:1.0.2" - testImplementation 'org.robolectric:robolectric:4.0-beta-1' - androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' + testImplementation 'androidx.test:runner:1.1.0' + testImplementation 'androidx.test:rules:1.1.0' + testImplementation 'org.robolectric:robolectric:4.2' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0' } diff --git a/app/src/main/java/com/nexenio/bleindoorpositioningdemo/HomeActivity.java b/app/src/main/java/com/nexenio/bleindoorpositioningdemo/HomeActivity.java index 4aa8109..d1e85e2 100644 --- a/app/src/main/java/com/nexenio/bleindoorpositioningdemo/HomeActivity.java +++ b/app/src/main/java/com/nexenio/bleindoorpositioningdemo/HomeActivity.java @@ -3,12 +3,12 @@ import android.content.Intent; import android.content.pm.PackageManager; import android.os.Bundle; -import android.support.annotation.NonNull; -import android.support.design.widget.BottomNavigationView; -import android.support.design.widget.CoordinatorLayout; -import android.support.design.widget.Snackbar; -import android.support.v4.app.Fragment; -import android.support.v7.app.AppCompatActivity; +import androidx.annotation.NonNull; +import com.google.android.material.bottomnavigation.BottomNavigationView; +import androidx.coordinatorlayout.widget.CoordinatorLayout; +import com.google.android.material.snackbar.Snackbar; +import androidx.fragment.app.Fragment; +import androidx.appcompat.app.AppCompatActivity; import android.util.Log; import android.view.Menu; import android.view.MenuInflater; diff --git a/app/src/main/java/com/nexenio/bleindoorpositioningdemo/bluetooth/BluetoothClient.java b/app/src/main/java/com/nexenio/bleindoorpositioningdemo/bluetooth/BluetoothClient.java index 50ac5b0..c5b8c43 100644 --- a/app/src/main/java/com/nexenio/bleindoorpositioningdemo/bluetooth/BluetoothClient.java +++ b/app/src/main/java/com/nexenio/bleindoorpositioningdemo/bluetooth/BluetoothClient.java @@ -5,7 +5,7 @@ import android.bluetooth.BluetoothManager; import android.content.Context; import android.content.Intent; -import android.support.annotation.NonNull; +import androidx.annotation.NonNull; import android.util.Log; import com.nexenio.bleindoorpositioning.ble.advertising.AdvertisingPacket; diff --git a/app/src/main/java/com/nexenio/bleindoorpositioningdemo/location/AndroidLocationProvider.java b/app/src/main/java/com/nexenio/bleindoorpositioningdemo/location/AndroidLocationProvider.java index cfaeb4e..dbe92db 100644 --- a/app/src/main/java/com/nexenio/bleindoorpositioningdemo/location/AndroidLocationProvider.java +++ b/app/src/main/java/com/nexenio/bleindoorpositioningdemo/location/AndroidLocationProvider.java @@ -25,8 +25,8 @@ import android.content.pm.PackageManager; import android.os.Build; import android.provider.Settings; -import android.support.annotation.NonNull; -import android.support.v4.app.ActivityCompat; +import androidx.annotation.NonNull; +import androidx.core.app.ActivityCompat; import android.text.TextUtils; import android.util.Log; diff --git a/app/src/main/java/com/nexenio/bleindoorpositioningdemo/ui/LocationAnimator.java b/app/src/main/java/com/nexenio/bleindoorpositioningdemo/ui/LocationAnimator.java index 8c1cfed..85c51c1 100644 --- a/app/src/main/java/com/nexenio/bleindoorpositioningdemo/ui/LocationAnimator.java +++ b/app/src/main/java/com/nexenio/bleindoorpositioningdemo/ui/LocationAnimator.java @@ -2,7 +2,7 @@ import android.animation.Animator; import android.animation.ValueAnimator; -import android.support.annotation.NonNull; +import androidx.annotation.NonNull; import com.nexenio.bleindoorpositioning.location.Location; import com.nexenio.bleindoorpositioning.location.LocationListener; diff --git a/app/src/main/java/com/nexenio/bleindoorpositioningdemo/ui/beaconview/BeaconView.java b/app/src/main/java/com/nexenio/bleindoorpositioningdemo/ui/beaconview/BeaconView.java index 91f56e0..ded8ec6 100644 --- a/app/src/main/java/com/nexenio/bleindoorpositioningdemo/ui/beaconview/BeaconView.java +++ b/app/src/main/java/com/nexenio/bleindoorpositioningdemo/ui/beaconview/BeaconView.java @@ -5,10 +5,10 @@ import android.graphics.Color; import android.graphics.Paint; import android.graphics.PointF; -import android.support.annotation.CallSuper; -import android.support.annotation.ColorInt; -import android.support.annotation.Nullable; -import android.support.v4.content.ContextCompat; +import androidx.annotation.CallSuper; +import androidx.annotation.ColorInt; +import androidx.annotation.Nullable; +import androidx.core.content.ContextCompat; import android.util.AttributeSet; import android.view.View; diff --git a/app/src/main/java/com/nexenio/bleindoorpositioningdemo/ui/beaconview/BeaconViewFragment.java b/app/src/main/java/com/nexenio/bleindoorpositioningdemo/ui/beaconview/BeaconViewFragment.java index 0692f4b..b48fa35 100644 --- a/app/src/main/java/com/nexenio/bleindoorpositioningdemo/ui/beaconview/BeaconViewFragment.java +++ b/app/src/main/java/com/nexenio/bleindoorpositioningdemo/ui/beaconview/BeaconViewFragment.java @@ -2,11 +2,11 @@ import android.content.Context; import android.os.Bundle; -import android.support.annotation.CallSuper; -import android.support.annotation.LayoutRes; -import android.support.annotation.Nullable; -import android.support.design.widget.CoordinatorLayout; -import android.support.v4.app.Fragment; +import androidx.annotation.CallSuper; +import androidx.annotation.LayoutRes; +import androidx.annotation.Nullable; +import androidx.coordinatorlayout.widget.CoordinatorLayout; +import androidx.fragment.app.Fragment; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; diff --git a/app/src/main/java/com/nexenio/bleindoorpositioningdemo/ui/beaconview/ColorUtil.java b/app/src/main/java/com/nexenio/bleindoorpositioningdemo/ui/beaconview/ColorUtil.java index 0364089..b1ea7c0 100644 --- a/app/src/main/java/com/nexenio/bleindoorpositioningdemo/ui/beaconview/ColorUtil.java +++ b/app/src/main/java/com/nexenio/bleindoorpositioningdemo/ui/beaconview/ColorUtil.java @@ -2,10 +2,10 @@ import android.content.Context; import android.content.res.Resources; -import android.support.annotation.ColorInt; -import android.support.annotation.IntDef; -import android.support.annotation.NonNull; -import android.support.v4.content.res.ResourcesCompat; +import androidx.annotation.ColorInt; +import androidx.annotation.IntDef; +import androidx.annotation.NonNull; +import androidx.core.content.res.ResourcesCompat; import com.nexenio.bleindoorpositioningdemo.R; diff --git a/app/src/main/java/com/nexenio/bleindoorpositioningdemo/ui/beaconview/chart/BeaconChart.java b/app/src/main/java/com/nexenio/bleindoorpositioningdemo/ui/beaconview/chart/BeaconChart.java index 20c9d68..d122036 100644 --- a/app/src/main/java/com/nexenio/bleindoorpositioningdemo/ui/beaconview/chart/BeaconChart.java +++ b/app/src/main/java/com/nexenio/bleindoorpositioningdemo/ui/beaconview/chart/BeaconChart.java @@ -1,8 +1,8 @@ package com.nexenio.bleindoorpositioningdemo.ui.beaconview.chart; import android.content.Context; -import android.support.annotation.IntDef; -import android.support.annotation.Nullable; +import androidx.annotation.IntDef; +import androidx.annotation.Nullable; import android.util.AttributeSet; import com.nexenio.bleindoorpositioningdemo.ui.beaconview.BeaconView; diff --git a/app/src/main/java/com/nexenio/bleindoorpositioningdemo/ui/beaconview/chart/BeaconChartFragment.java b/app/src/main/java/com/nexenio/bleindoorpositioningdemo/ui/beaconview/chart/BeaconChartFragment.java index ad366ab..4369134 100644 --- a/app/src/main/java/com/nexenio/bleindoorpositioningdemo/ui/beaconview/chart/BeaconChartFragment.java +++ b/app/src/main/java/com/nexenio/bleindoorpositioningdemo/ui/beaconview/chart/BeaconChartFragment.java @@ -3,7 +3,7 @@ import android.annotation.SuppressLint; import android.os.Bundle; -import android.support.annotation.CallSuper; +import androidx.annotation.CallSuper; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; diff --git a/app/src/main/java/com/nexenio/bleindoorpositioningdemo/ui/beaconview/chart/BeaconLineChart.java b/app/src/main/java/com/nexenio/bleindoorpositioningdemo/ui/beaconview/chart/BeaconLineChart.java index bbb15b3..aa0a68a 100644 --- a/app/src/main/java/com/nexenio/bleindoorpositioningdemo/ui/beaconview/chart/BeaconLineChart.java +++ b/app/src/main/java/com/nexenio/bleindoorpositioningdemo/ui/beaconview/chart/BeaconLineChart.java @@ -8,8 +8,8 @@ import android.graphics.Paint; import android.graphics.PointF; import android.graphics.Shader; -import android.support.annotation.ColorInt; -import android.support.annotation.Nullable; +import androidx.annotation.ColorInt; +import androidx.annotation.Nullable; import android.util.AttributeSet; import com.nexenio.bleindoorpositioning.ble.advertising.AdvertisingPacket; diff --git a/app/src/main/java/com/nexenio/bleindoorpositioningdemo/ui/beaconview/chart/RssiFilterLineChart.java b/app/src/main/java/com/nexenio/bleindoorpositioningdemo/ui/beaconview/chart/RssiFilterLineChart.java index 1088ed7..373743c 100644 --- a/app/src/main/java/com/nexenio/bleindoorpositioningdemo/ui/beaconview/chart/RssiFilterLineChart.java +++ b/app/src/main/java/com/nexenio/bleindoorpositioningdemo/ui/beaconview/chart/RssiFilterLineChart.java @@ -3,7 +3,7 @@ import android.content.Context; import android.graphics.Canvas; import android.graphics.PointF; -import android.support.annotation.Nullable; +import androidx.annotation.Nullable; import android.util.AttributeSet; import com.nexenio.bleindoorpositioning.ble.advertising.AdvertisingPacket; diff --git a/app/src/main/java/com/nexenio/bleindoorpositioningdemo/ui/beaconview/map/BeaconMap.java b/app/src/main/java/com/nexenio/bleindoorpositioningdemo/ui/beaconview/map/BeaconMap.java index d242910..fdeb134 100644 --- a/app/src/main/java/com/nexenio/bleindoorpositioningdemo/ui/beaconview/map/BeaconMap.java +++ b/app/src/main/java/com/nexenio/bleindoorpositioningdemo/ui/beaconview/map/BeaconMap.java @@ -10,8 +10,8 @@ import android.graphics.RadialGradient; import android.graphics.RectF; import android.graphics.Shader; -import android.support.annotation.CallSuper; -import android.support.annotation.Nullable; +import androidx.annotation.CallSuper; +import androidx.annotation.Nullable; import android.util.AttributeSet; import com.nexenio.bleindoorpositioning.ble.advertising.AdvertisingPacket; diff --git a/app/src/main/java/com/nexenio/bleindoorpositioningdemo/ui/beaconview/map/BeaconMapBackground.java b/app/src/main/java/com/nexenio/bleindoorpositioningdemo/ui/beaconview/map/BeaconMapBackground.java index 4035fa8..f0ccd5e 100644 --- a/app/src/main/java/com/nexenio/bleindoorpositioningdemo/ui/beaconview/map/BeaconMapBackground.java +++ b/app/src/main/java/com/nexenio/bleindoorpositioningdemo/ui/beaconview/map/BeaconMapBackground.java @@ -2,7 +2,7 @@ import android.graphics.Bitmap; import android.graphics.Point; -import android.support.annotation.NonNull; +import androidx.annotation.NonNull; import com.nexenio.bleindoorpositioning.location.Location; import com.nexenio.bleindoorpositioning.location.projection.CanvasProjection; diff --git a/app/src/main/java/com/nexenio/bleindoorpositioningdemo/ui/beaconview/map/BeaconMapFragment.java b/app/src/main/java/com/nexenio/bleindoorpositioningdemo/ui/beaconview/map/BeaconMapFragment.java index 20b80db..63ef77a 100644 --- a/app/src/main/java/com/nexenio/bleindoorpositioningdemo/ui/beaconview/map/BeaconMapFragment.java +++ b/app/src/main/java/com/nexenio/bleindoorpositioningdemo/ui/beaconview/map/BeaconMapFragment.java @@ -5,7 +5,7 @@ import android.graphics.BitmapFactory; import android.graphics.Point; import android.os.Bundle; -import android.support.annotation.CallSuper; +import androidx.annotation.CallSuper; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; diff --git a/app/src/main/java/com/nexenio/bleindoorpositioningdemo/ui/beaconview/radar/BeaconRadar.java b/app/src/main/java/com/nexenio/bleindoorpositioningdemo/ui/beaconview/radar/BeaconRadar.java index f554264..f4fb24e 100644 --- a/app/src/main/java/com/nexenio/bleindoorpositioningdemo/ui/beaconview/radar/BeaconRadar.java +++ b/app/src/main/java/com/nexenio/bleindoorpositioningdemo/ui/beaconview/radar/BeaconRadar.java @@ -7,7 +7,7 @@ import android.graphics.Paint; import android.graphics.PointF; import android.graphics.RectF; -import android.support.annotation.Nullable; +import androidx.annotation.Nullable; import android.util.AttributeSet; import com.nexenio.bleindoorpositioning.ble.advertising.AdvertisingPacket; diff --git a/app/src/main/java/com/nexenio/bleindoorpositioningdemo/ui/beaconview/radar/BeaconRadarFragment.java b/app/src/main/java/com/nexenio/bleindoorpositioningdemo/ui/beaconview/radar/BeaconRadarFragment.java index ccfe7e8..c9eefa2 100644 --- a/app/src/main/java/com/nexenio/bleindoorpositioningdemo/ui/beaconview/radar/BeaconRadarFragment.java +++ b/app/src/main/java/com/nexenio/bleindoorpositioningdemo/ui/beaconview/radar/BeaconRadarFragment.java @@ -7,7 +7,7 @@ import android.hardware.SensorEventListener; import android.hardware.SensorManager; import android.os.Bundle; -import android.support.annotation.CallSuper; +import androidx.annotation.CallSuper; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; diff --git a/app/src/main/res/layout/activity_home.xml b/app/src/main/res/layout/activity_home.xml index 85773df..2451f42 100644 --- a/app/src/main/res/layout/activity_home.xml +++ b/app/src/main/res/layout/activity_home.xml @@ -9,7 +9,7 @@ android:layout_height="match_parent" tools:context="com.nexenio.bleindoorpositioningdemo.HomeActivity"> - - + - Date: Wed, 14 Aug 2019 15:17:31 +0200 Subject: [PATCH 11/18] Updated dependencies --- app/build.gradle | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 0e255ac..563a785 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -31,19 +31,19 @@ android { dependencies { implementation project(':BLE Indoor Positioning') - implementation 'androidx.appcompat:appcompat:1.0.0' + implementation 'androidx.appcompat:appcompat:1.0.2' implementation 'androidx.legacy:legacy-support-v4:1.0.0' - implementation 'androidx.media:media:1.0.0' - implementation 'com.google.android.material:material:1.0.0' + implementation 'androidx.media:media:1.0.1' implementation 'androidx.constraintlayout:constraintlayout:1.1.3' + implementation 'com.google.android.material:material:1.0.0' implementation 'com.google.android.gms:play-services-location:17.0.0' implementation "com.polidea.rxandroidble:rxandroidble:1.4.3" testImplementation 'junit:junit:4.12' - testImplementation 'androidx.test:runner:1.1.0' - testImplementation 'androidx.test:rules:1.1.0' + testImplementation 'androidx.test:runner:1.2.0' + testImplementation 'androidx.test:rules:1.2.0' testImplementation 'org.robolectric:robolectric:4.2' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' } From c9489c9630ad8010d432681b979356fb82cc1814 Mon Sep 17 00:00:00 2001 From: Steppschuh Date: Wed, 14 Aug 2019 16:05:42 +0200 Subject: [PATCH 12/18] Removed uuid property from Beacon class, improved comparators --- .../ble/advertising/AdvertisingPacket.java | 6 ++- .../ble/beacon/Beacon.java | 40 +++++++++++++------ .../ble/beacon/BeaconUtil.java | 12 ++++-- .../ble/beacon/IBeacon.java | 14 +++++++ 4 files changed, 55 insertions(+), 17 deletions(-) diff --git a/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/ble/advertising/AdvertisingPacket.java b/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/ble/advertising/AdvertisingPacket.java index 9d4dd38..97d2483 100644 --- a/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/ble/advertising/AdvertisingPacket.java +++ b/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/ble/advertising/AdvertisingPacket.java @@ -40,7 +40,11 @@ public boolean dataEquals(AdvertisingPacket advertisingPacket) { @Override public String toString() { - return AdvertisingPacketUtil.toHexadecimalString(data); + return "AdvertisingPacket{" + + "data=" + AdvertisingPacketUtil.toHexadecimalString(data) + + ", rssi=" + rssi + + ", timestamp=" + timestamp + + '}'; } /* diff --git a/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/ble/beacon/Beacon.java b/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/ble/beacon/Beacon.java index f33073e..ec8b36d 100644 --- a/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/ble/beacon/Beacon.java +++ b/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/ble/beacon/Beacon.java @@ -15,7 +15,6 @@ import java.util.ArrayList; import java.util.Comparator; import java.util.List; -import java.util.UUID; import java.util.concurrent.TimeUnit; /** @@ -26,7 +25,6 @@ public abstract class Beacon

{ public static final long MAXIMUM_PACKET_AGE = TimeUnit.SECONDS.toMillis(60); - protected UUID uuid; protected String macAddress; protected int rssi; // in dBm protected int calibratedRssi; // in dBm @@ -76,7 +74,7 @@ public static List getLocations(List beacons) { public abstract BeaconLocationProvider createLocationProvider(); public boolean hasAnyAdvertisingPacket() { - return advertisingPackets != null && !advertisingPackets.isEmpty(); + return !advertisingPackets.isEmpty(); } public P getOldestAdvertisingPacket() { @@ -123,9 +121,16 @@ public ArrayList

getAdvertisingPacketsBefore(long timestamp) { public void addAdvertisingPacket(P advertisingPacket) { synchronized (advertisingPackets) { rssi = advertisingPacket.getRssi(); - if (!hasAnyAdvertisingPacket() || !advertisingPacket.dataEquals(getLatestAdvertisingPacket())) { + + P latestAdvertisingPacket = getLatestAdvertisingPacket(); + if (latestAdvertisingPacket == null || !advertisingPacket.dataEquals(latestAdvertisingPacket)) { applyPropertiesFromAdvertisingPacket(advertisingPacket); } + + if (latestAdvertisingPacket.getTimestamp() > advertisingPacket.getTimestamp()) { + return; + } + advertisingPackets.add(advertisingPacket); trimAdvertisingPackets(); invalidateDistance(); @@ -221,27 +226,35 @@ public WindowFilter createSuggestedWindowFilter() { /** * This function and its reverse are implemented with indicative naming in BeaconUtil. + * * @deprecated use {@link BeaconUtil#AscendingRssiComparator} instead */ @Deprecated public static Comparator RssiComparator = new Comparator() { public int compare(Beacon firstBeacon, Beacon secondBeacon) { - return firstBeacon.rssi - secondBeacon.rssi; + if (firstBeacon.equals(secondBeacon)) { + return 0; + } + return Integer.compare(firstBeacon.rssi, secondBeacon.rssi); } }; + @Override + public String toString() { + return "Beacon{" + + ", macAddress='" + macAddress + '\'' + + ", rssi=" + rssi + + ", calibratedRssi=" + calibratedRssi + + ", calibratedDistance=" + calibratedDistance + + ", transmissionPower=" + transmissionPower + + ", advertisingPackets=" + advertisingPackets + + '}'; + } + /* Getter & Setter */ - public UUID getUuid() { - return uuid; - } - - public void setUuid(UUID uuid) { - this.uuid = uuid; - } - public String getMacAddress() { return macAddress; } @@ -296,4 +309,5 @@ public LocationProvider getLocationProvider() { public void setLocationProvider(BeaconLocationProvider locationProvider) { this.locationProvider = locationProvider; } + } diff --git a/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/ble/beacon/BeaconUtil.java b/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/ble/beacon/BeaconUtil.java index 014cfef..9f0a2c8 100644 --- a/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/ble/beacon/BeaconUtil.java +++ b/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/ble/beacon/BeaconUtil.java @@ -20,7 +20,7 @@ public abstract class BeaconUtil { * @param transmissionPower the tx power (in dBm) of the beacon * @return estimated range in meters * @see Kontakt.io - * Knowledge Base + * Knowledge Base */ public static float getAdvertisingRange(int transmissionPower) { if (transmissionPower < -30) { @@ -161,7 +161,10 @@ public static String getReadableBeaconType(Class beaconClass) */ public static Comparator DescendingRssiComparator = new Comparator() { public int compare(Beacon firstBeacon, Beacon secondBeacon) { - return secondBeacon.rssi - firstBeacon.rssi; + if (firstBeacon.equals(secondBeacon)) { + return 0; + } + return Integer.compare(secondBeacon.rssi, firstBeacon.rssi); } }; @@ -170,7 +173,10 @@ public int compare(Beacon firstBeacon, Beacon secondBeacon) { */ public static Comparator AscendingRssiComparator = new Comparator() { public int compare(Beacon firstBeacon, Beacon secondBeacon) { - return firstBeacon.rssi - secondBeacon.rssi; + if (firstBeacon.equals(secondBeacon)) { + return 0; + } + return Integer.compare(firstBeacon.rssi, secondBeacon.rssi); } }; diff --git a/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/ble/beacon/IBeacon.java b/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/ble/beacon/IBeacon.java index 5721b92..fe94ae4 100644 --- a/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/ble/beacon/IBeacon.java +++ b/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/ble/beacon/IBeacon.java @@ -46,6 +46,20 @@ public void applyPropertiesFromAdvertisingPacket(P advertisingPacket) { setCalibratedRssi(advertisingPacket.getMeasuredPowerByte()); } + @Override + public String toString() { + return "IBeacon{" + + "proximityUuid=" + proximityUuid + + ", major=" + major + + ", minor=" + minor + + ", macAddress='" + macAddress + '\'' + + ", rssi=" + rssi + + ", calibratedRssi=" + calibratedRssi + + ", transmissionPower=" + transmissionPower + + ", advertisingPackets=" + advertisingPackets + + '}'; + } + /* Getter & Setter */ From 98bcab26959b6ba4b819f85e34736fb0e10e14ef Mon Sep 17 00:00:00 2001 From: Steppschuh Date: Wed, 14 Aug 2019 16:25:33 +0200 Subject: [PATCH 13/18] Adjusted beacon filter to avoid ClassCastException --- .../bleindoorpositioning/IndoorPositioning.java | 13 +++++++++---- .../ble/beacon/filter/BeaconFilter.java | 2 ++ .../ble/beacon/filter/GenericBeaconFilter.java | 6 ++++++ .../ble/beacon/filter/IBeaconFilter.java | 6 ++++++ 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/IndoorPositioning.java b/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/IndoorPositioning.java index 12c3df4..a0efde2 100644 --- a/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/IndoorPositioning.java +++ b/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/IndoorPositioning.java @@ -4,7 +4,6 @@ import com.nexenio.bleindoorpositioning.ble.beacon.BeaconManager; import com.nexenio.bleindoorpositioning.ble.beacon.BeaconUpdateListener; import com.nexenio.bleindoorpositioning.ble.beacon.BeaconUtil; -import com.nexenio.bleindoorpositioning.ble.beacon.IBeacon; import com.nexenio.bleindoorpositioning.ble.beacon.filter.BeaconFilter; import com.nexenio.bleindoorpositioning.ble.beacon.filter.GenericBeaconFilter; import com.nexenio.bleindoorpositioning.location.Location; @@ -17,6 +16,7 @@ import org.apache.commons.math3.exception.TooManyEvaluationsException; +import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.HashSet; @@ -118,7 +118,11 @@ private void updateLocation() { } public static List getUsableBeacons(Collection availableBeacons) { - return getInstance().usableIndoorPositioningBeaconFilter.getMatches(availableBeacons); + BeaconFilter beaconFilter = getInstance().usableIndoorPositioningBeaconFilter; + if (availableBeacons.isEmpty() || !beaconFilter.canMatch(availableBeacons.iterator().next())) { + return new ArrayList<>(); + } + return beaconFilter.getMatches(availableBeacons); } private void onLocationUpdated(Location location) { @@ -151,10 +155,11 @@ public static GenericBeaconFilter createUsableIndoorPositionin @Override public boolean matches(Beacon beacon) { - if (!(beacon instanceof IBeacon)) { + BeaconFilter beaconFilter = getInstance().indoorPositioningBeaconFilter; + if (!beaconFilter.canMatch(beacon)) { return false; } - if (getInstance().indoorPositioningBeaconFilter != null && !getInstance().indoorPositioningBeaconFilter.matches(beacon)) { + if (!beaconFilter.matches(beacon)) { return false; } if (!beacon.hasLocation()) { diff --git a/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/ble/beacon/filter/BeaconFilter.java b/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/ble/beacon/filter/BeaconFilter.java index 9c7978a..5917067 100644 --- a/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/ble/beacon/filter/BeaconFilter.java +++ b/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/ble/beacon/filter/BeaconFilter.java @@ -11,6 +11,8 @@ public interface BeaconFilter { + boolean canMatch(Beacon beacon); + boolean matches(B beacon); List getMatches(Collection beacons); diff --git a/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/ble/beacon/filter/GenericBeaconFilter.java b/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/ble/beacon/filter/GenericBeaconFilter.java index 368be69..a5743d1 100644 --- a/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/ble/beacon/filter/GenericBeaconFilter.java +++ b/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/ble/beacon/filter/GenericBeaconFilter.java @@ -16,6 +16,11 @@ public class GenericBeaconFilter implements BeaconFilter { protected boolean matchMacAddress; + @Override + public boolean canMatch(Beacon beacon) { + return true; + } + @Override public boolean matches(B beacon) { if (matchMacAddress) { @@ -55,4 +60,5 @@ public boolean isMatchMacAddress() { public void setMatchMacAddress(boolean matchMacAddress) { this.matchMacAddress = matchMacAddress; } + } diff --git a/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/ble/beacon/filter/IBeaconFilter.java b/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/ble/beacon/filter/IBeaconFilter.java index 1116588..56a5651 100644 --- a/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/ble/beacon/filter/IBeaconFilter.java +++ b/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/ble/beacon/filter/IBeaconFilter.java @@ -1,5 +1,6 @@ package com.nexenio.bleindoorpositioning.ble.beacon.filter; +import com.nexenio.bleindoorpositioning.ble.beacon.Beacon; import com.nexenio.bleindoorpositioning.ble.beacon.IBeacon; import java.util.ArrayList; @@ -33,6 +34,11 @@ public IBeaconFilter(List proximityUuids) { matchProximityUuid = true; } + @Override + public boolean canMatch(Beacon beacon) { + return super.canMatch(beacon) && beacon instanceof IBeacon; + } + @Override public boolean matches(B beacon) { if (!super.matches(beacon)) { From 0d871970d3475e2e57c949d13adddfd945b69471 Mon Sep 17 00:00:00 2001 From: Steppschuh Date: Wed, 14 Aug 2019 16:28:59 +0200 Subject: [PATCH 14/18] Removed try catch block --- .../bleindoorpositioning/ble/beacon/BeaconManager.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/ble/beacon/BeaconManager.java b/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/ble/beacon/BeaconManager.java index 776f61f..3c71267 100644 --- a/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/ble/beacon/BeaconManager.java +++ b/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/ble/beacon/BeaconManager.java @@ -80,11 +80,7 @@ public static AdvertisingPacket processAdvertisingPacket(String macAddress, Adve beacon.addAdvertisingPacket(advertisingPacket); //TODO move outside method processClosestBeacon(beacon); - try { - instance.notifyBeaconUpdateListeners(beacon); - } catch (Exception e) { - e.printStackTrace(); - } + instance.notifyBeaconUpdateListeners(beacon); return advertisingPacket; } From 79745a402357071669c10b02be046d02008c42e6 Mon Sep 17 00:00:00 2001 From: Steppschuh Date: Thu, 15 Aug 2019 11:44:43 +0200 Subject: [PATCH 15/18] Adjusted beacon keys --- .../ble/advertising/AdvertisingPacket.java | 2 +- .../ble/beacon/BeaconManager.java | 19 ++++--------------- .../bluetooth/BluetoothClient.java | 4 ++-- 3 files changed, 7 insertions(+), 18 deletions(-) diff --git a/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/ble/advertising/AdvertisingPacket.java b/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/ble/advertising/AdvertisingPacket.java index 97d2483..c109338 100644 --- a/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/ble/advertising/AdvertisingPacket.java +++ b/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/ble/advertising/AdvertisingPacket.java @@ -41,7 +41,7 @@ public boolean dataEquals(AdvertisingPacket advertisingPacket) { @Override public String toString() { return "AdvertisingPacket{" + - "data=" + AdvertisingPacketUtil.toHexadecimalString(data) + + "data=" + Arrays.hashCode(data) + ", rssi=" + rssi + ", timestamp=" + timestamp + '}'; diff --git a/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/ble/beacon/BeaconManager.java b/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/ble/beacon/BeaconManager.java index 3c71267..40d4ff3 100644 --- a/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/ble/beacon/BeaconManager.java +++ b/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/ble/beacon/BeaconManager.java @@ -6,6 +6,7 @@ import com.nexenio.bleindoorpositioning.ble.beacon.signal.WindowFilter; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedHashMap; @@ -126,23 +127,11 @@ public static boolean unregisterBeaconUpdateListener(BeaconUpdateListener beacon } public static String getBeaconKey(String macAddress, AdvertisingPacket advertisingPacket) { - return getBeaconKey(macAddress, BeaconUtil.getReadableBeaconType(advertisingPacket)); + return macAddress + "-" + Arrays.hashCode(advertisingPacket.getData()); } - private static String getBeaconKey(String macAddress, String beaconType) { - return macAddress + "-" + beaconType; - } - - public static IBeacon getIBeacon(String macAddress) { - return (IBeacon) getBeacon(macAddress, IBeacon.class); - } - - public static Eddystone getEddystone(String macAddress) { - return (Eddystone) getBeacon(macAddress, Eddystone.class); - } - - public static Beacon getBeacon(String macAddress, Class beaconClass) { - String key = getBeaconKey(macAddress, BeaconUtil.getReadableBeaconType(beaconClass)); + public static Beacon getBeacon(String macAddress, AdvertisingPacket advertisingPacket) { + String key = getBeaconKey(macAddress, advertisingPacket); return getInstance().beaconMap.get(key); } diff --git a/app/src/main/java/com/nexenio/bleindoorpositioningdemo/bluetooth/BluetoothClient.java b/app/src/main/java/com/nexenio/bleindoorpositioningdemo/bluetooth/BluetoothClient.java index c5b8c43..b01d988 100644 --- a/app/src/main/java/com/nexenio/bleindoorpositioningdemo/bluetooth/BluetoothClient.java +++ b/app/src/main/java/com/nexenio/bleindoorpositioningdemo/bluetooth/BluetoothClient.java @@ -5,7 +5,6 @@ import android.bluetooth.BluetoothManager; import android.content.Context; import android.content.Intent; -import androidx.annotation.NonNull; import android.util.Log; import com.nexenio.bleindoorpositioning.ble.advertising.AdvertisingPacket; @@ -18,6 +17,7 @@ import com.polidea.rxandroidble.scan.ScanResult; import com.polidea.rxandroidble.scan.ScanSettings; +import androidx.annotation.NonNull; import rx.Observer; import rx.Subscription; @@ -126,7 +126,7 @@ private void processScanResult(@NonNull ScanResult scanResult) { AdvertisingPacket advertisingPacket = BeaconManager.processAdvertisingData(macAddress, data, scanResult.getRssi()); if (advertisingPacket != null) { - Beacon beacon = BeaconManager.getBeacon(macAddress, advertisingPacket.getBeaconClass()); + Beacon beacon = BeaconManager.getBeacon(macAddress, advertisingPacket); if (beacon instanceof IBeacon && !beacon.hasLocation()) { beacon.setLocationProvider(createDebuggingLocationProvider((IBeacon) beacon)); } From d1f67f5922ac87c50e0ff7792eb518f949ed7a05 Mon Sep 17 00:00:00 2001 From: Steppschuh Date: Thu, 15 Aug 2019 12:31:38 +0200 Subject: [PATCH 16/18] Added null check for indoorPositioningBeaconFilter --- .../bleindoorpositioning/IndoorPositioning.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/IndoorPositioning.java b/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/IndoorPositioning.java index a0efde2..9eddbbc 100644 --- a/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/IndoorPositioning.java +++ b/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/IndoorPositioning.java @@ -156,11 +156,13 @@ public static GenericBeaconFilter createUsableIndoorPositionin @Override public boolean matches(Beacon beacon) { BeaconFilter beaconFilter = getInstance().indoorPositioningBeaconFilter; - if (!beaconFilter.canMatch(beacon)) { - return false; - } - if (!beaconFilter.matches(beacon)) { - return false; + if (beaconFilter != null) { + if (!beaconFilter.canMatch(beacon)) { + return false; + } + if (!beaconFilter.matches(beacon)) { + return false; + } } if (!beacon.hasLocation()) { return false; // beacon has no location assigned, can't use it for multilateration From ba69a00820f985e9c60d80f43de202d03aa71f1c Mon Sep 17 00:00:00 2001 From: Steppschuh Date: Thu, 15 Aug 2019 13:29:50 +0200 Subject: [PATCH 17/18] Added null check for latestAdvertisingPacket --- .../com/nexenio/bleindoorpositioning/ble/beacon/Beacon.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/ble/beacon/Beacon.java b/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/ble/beacon/Beacon.java index ec8b36d..e6bbd02 100644 --- a/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/ble/beacon/Beacon.java +++ b/BLE Indoor Positioning/src/main/java/com/nexenio/bleindoorpositioning/ble/beacon/Beacon.java @@ -127,7 +127,7 @@ public void addAdvertisingPacket(P advertisingPacket) { applyPropertiesFromAdvertisingPacket(advertisingPacket); } - if (latestAdvertisingPacket.getTimestamp() > advertisingPacket.getTimestamp()) { + if (latestAdvertisingPacket != null && latestAdvertisingPacket.getTimestamp() > advertisingPacket.getTimestamp()) { return; } From 5434537c0240c6ed27abb5260e4a8935536656b4 Mon Sep 17 00:00:00 2001 From: Steppschuh Date: Thu, 15 Aug 2019 13:32:18 +0200 Subject: [PATCH 18/18] Bumped version number --- BLE Indoor Positioning/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BLE Indoor Positioning/build.gradle b/BLE Indoor Positioning/build.gradle index bed2c75..be3619e 100644 --- a/BLE Indoor Positioning/build.gradle +++ b/BLE Indoor Positioning/build.gradle @@ -28,8 +28,8 @@ dependencies { sourceCompatibility = "1.7" targetCompatibility = "1.7" -def releaseVersionCode = 15 -def releaseVersionName = "0.3.9" +def releaseVersionCode = 16 +def releaseVersionName = "0.4.0" def projectName = 'BLE Indoor Positioning' def projectDescription = 'Java library for indoor positioing using bluetooth beacons'