acconeer / acconeer-android-example-apps

Other
0 stars 4 forks source link

App not connecting #1

Closed FritzWalter123 closed 3 years ago

FritzWalter123 commented 3 years ago

Hello, I tried to connect app with module...app is searching without finding a device. In system bluetooth environment I can see but not connect device. Module is powered by USB... Any idea?

vackraetraed commented 3 years ago

Hello @FritzWalter123 ,

As the app has been made available as is this has not been kept up to date. It does seem to have troubles detecting the XM122 with Bluetooth and an older unknown version of the app is able to detect it.

I will look into if we want to work on fixing this android app. In the meantime, the Java source code is available if you feel confident in Java programming and debugging the application.

Best regards, Anton

vackraetraed commented 3 years ago

You could try this apk file: https://ws.onehub.com/files/tvrroy9q

It might be an older version that I had on my phone that seem to still "work".

FritzWalter123 commented 3 years ago

Hello, Now i can see the device but can't connect. Ask for pairing and when i push ok it disconnect.

vackraetraed commented 3 years ago

@FritzWalter123

That is unfortunate! Unfortunately this Android app was made by a 3rd party and Acconeer does not have the necessary experience with Android development to support this app.

I tried to reverse engineer both apk files to compare the differences within Bluetooth connectivity but my inexperience with Android apps and Java makes this a somewhat hard issue.

chunicaa commented 3 years ago

Hi @FritzWalter123 there is a problem with permissions. For Android 10 you should ask for ACCESS_FINE_LOCATION permission in manifest. https://github.com/NordicSemiconductor/Android-Scanner-Compat-Library/issues/75

dovoto commented 3 years ago

You could try this apk file: https://ws.onehub.com/files/tvrroy9q

It might be an older version that I had on my phone that seem to still "work".

This one at least shows the device then briefly connects...then asks to pair...then disconnects :(

About to just start from scratch.

[edit] after some reattempting I am able to get this older version to work. It takes a few attempts but it sufficient to demo the product. I will see if I can fix the issue on the current code base and do a PR. I feel like it is tied to location permissions as chunicaa suggests though simply changing to FINE does not fix the issue.

vackraetraed commented 3 years ago

Hello, sorry for late reply but yesterday we had our day at the office where we get to work on something of our choosing. I decided to look at this app and Android programming for the first time in my life. And as @chunicaa mentioned, it had to do with ACCESS_FINE_LOCATION. I will add my changes once I have privileges for the repository but decided to add the changes here meanwhile if anyone has the need for them.

Here is the git diff for the distance detector which made the app work on at least Android 9 and Android 11:

diff --git a/src/distance_bluetooth/app/src/main/AndroidManifest.xml b/src/distance_bluetooth/app/src/main/AndroidManifest.xml index 8501cb7..194c09a 100755 --- a/src/distance_bluetooth/app/src/main/AndroidManifest.xml +++ b/src/distance_bluetooth/app/src/main/AndroidManifest.xml @@ -2,7 +2,7 @@ <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.acconeer.bluetooth.distance">

@@ -32,4 +32,4 @@

- \ No newline at end of file + diff --git a/src/distance_bluetooth/app/src/main/java/com/acconeer/bluetooth/distance/fragments/ScanningDialogFragment.java b/src/distance_bluetooth/app/src/main/java/com/acconeer/bluetooth/distance/fragments/ScanningDialogFragment.java index 9a3f752..1ed17fc 100644 --- a/src/distance_bluetooth/app/src/main/java/com/acconeer/bluetooth/distance/fragments/ScanningDialogFragment.java +++ b/src/distance_bluetooth/app/src/main/java/com/acconeer/bluetooth/distance/fragments/ScanningDialogFragment.java @@ -191,7 +191,7 @@ public class ScanningDialogFragment extends PreferenceDialogFragmentCompat imple startActivity(new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE)); }); grantLocationButton.setOnClickListener(v -> {

diff --git a/src/distance_bluetooth/app/src/main/java/com/acconeer/bluetooth/distance/utils/Utils.java b/src/distance_bluetooth/app/src/main/java/com/acconeer/bluetooth/distance/utils/Utils.java index 0799bcd..1cdbfab 100644 --- a/src/distance_bluetooth/app/src/main/java/com/acconeer/bluetooth/distance/utils/Utils.java +++ b/src/distance_bluetooth/app/src/main/java/com/acconeer/bluetooth/distance/utils/Utils.java @@ -29,7 +29,7 @@ public class Utils { }

 public static boolean hasLocationPermission(Context context) {
vackraetraed commented 3 years ago

Well, that insert of the diff did not look very pretty. Anyway, I will try to add the update this week.

Best regards, Anton

vackraetraed commented 3 years ago

All right, app is now updated. Will close this issue since it should be resolved.

Best regards, Anton