Open Jayy001 opened 1 year ago
Does it work if you change the permissions for the app on the Android device?
Hi @Jayy001
Try to install the app via: 'adb install -g app.apk', the -g flag should grant all runtime permissions, see if this fixes the error. If the permissions where not asked during startup of the app (without the -g flag), see the android package, it provides a simple function to request permissions from the user.
Should be fixed by #1398
@dlech I don't think this will be fixed by #1398. The permissions mentioned in the log were already present in buildozer.spec. The error is most likely caused by the kivy app not asking for the permissions on startup.
This can be quite easily done, I have a fix for this ready, but it still needs testing. I will create a PR when it's tested.
As mentioned above, the issue can be temporarily fixed by installing the apk using 'adb install -g app.apk'.
Kind regards, robgar2001
Can confirm that fixed my issue @robgar2001 and I no longer need to manually add the java files. The only final hurdle I had was to install typing_extensions
via pip install typing_extensions
and then add that to the buildozer.spec
file - otherwise the application kept crashing with a Module not found: typing_extensions
error.
Sorry this took so long, I had completely forgotten about this issue
@dlech I now get this error when trying to read the characteristic, using this code:
if selected_device.name.startswith("GAN"):
cube = GanCube(selected_device.address)
cube.name = selected_device.name
cube.address = selected_device.address
print(f"Connecting to {cube.name}, {cube.address}")
async with BleakClient(cube.address) as client:
cube_service = None
for service in client.services:
if service.uuid == cube.SERVICE_UUID:
cube_service = service
break
if cube_service is None:
print(f"Unable to find {cube.BRAND} CUBE service or unsppported {cube.BRAND} CUBEs")
return
read_chrct = None
write_chrct = None
for chrct in cube_service.characteristics:
if chrct.uuid == cube.CHRCT_UUID_READ:
read_chrct = chrct
elif chrct.uuid == cube.CHRCT_UUID_WRITE:
write_chrct = chrct
if read_chrct is None or write_chrct is None:
print(f"Unable to find {cube.BRAND} CUBE read or write characteristic")
return
print(f"Connected to {cube.BRAND} CUBE")
await client.start_notify(read_chrct, gan_read_handler)
Now this works fine when I run it on my computer (can read the characteristic just fine), but when I run it from my android device it gives that error. Any ideas as to what could be messing it up? Running it with adb install -g app
Does the characteristic actually support notifications (i.e. run the service_explorer sample or use nRF Connect app to enumerate everything to see what is there)?
Hi @Jayy001
Typing-extensions was indeed still missing as a requirement. It was probably cached somewhere when I was testing it.
I also added the code to request permissions on startup, aldough it seems to be a bit buggy. This might be something to add on the todo list.
Maybe you can test and have a look at it on your device before I submit a pull request? So try to install without the -g flag mentioned earlier.
Link to my bleak fork:
https://github.com/robgar2001/bleak
Kind regards, robgar2001
Does the characteristic actually support notifications (i.e. run the service_explorer sample or use nRF Connect app to enumerate everything to see what is there)?
yes,
Now this works fine when I run it on my computer (can read the characteristics just fine)
It's 100% a problem with the android version, as I have run this exact application before on my computer with no issues. Furthermore, when scanning for characteristics/descriptors it does show 1 descriptor available - it's only when I try to connect to it that the bug occurs.
Hi @Jayy001
Typing-extensions was indeed still missing as a requirement. It was probably cached somewhere when I was testing it.
I also added the code to request permissions on startup, aldough it seems to be a bit buggy. This might be something to add on the todo list.
Maybe you can test and have a look at it on your device before I submit a pull request? So try to install without the -g flag mentioned earlier.
Link to my bleak fork:
https://github.com/robgar2001/bleak
Kind regards, robgar2001
Can do, will let you know
@dlech I now get this error when trying to read the characteristic, using this code:
if selected_device.name.startswith("GAN"): cube = GanCube(selected_device.address) cube.name = selected_device.name cube.address = selected_device.address print(f"Connecting to {cube.name}, {cube.address}") async with BleakClient(cube.address) as client: cube_service = None for service in client.services: if service.uuid == cube.SERVICE_UUID: cube_service = service break if cube_service is None: print(f"Unable to find {cube.BRAND} CUBE service or unsppported {cube.BRAND} CUBEs") return read_chrct = None write_chrct = None for chrct in cube_service.characteristics: if chrct.uuid == cube.CHRCT_UUID_READ: read_chrct = chrct elif chrct.uuid == cube.CHRCT_UUID_WRITE: write_chrct = chrct if read_chrct is None or write_chrct is None: print(f"Unable to find {cube.BRAND} CUBE read or write characteristic") return print(f"Connected to {cube.BRAND} CUBE") await client.start_notify(read_chrct, gan_read_handler)
Now this works fine when I run it on my computer (can read the characteristic just fine), but when I run it from my android device it gives that error. Any ideas as to what could be messing it up? Running it with
adb install -g app
Is the problems solved? I meet the same problem.
Greets check my app if you're having trouble: https://github.com/narodnik/meater_plus_kivy_app
bluetoothctl -v
) in case of Linux:Description
Trying to run the basic example given for android https://github.com/hbldh/bleak/tree/develop/examples/kivy
What I Did
Added Java files from https://github.com/hbldh/bleak/tree/develop/bleak/backends/p4android/java/com/github/hbldh/bleak to local folder
java
and inbuildozer.spec
modifedandroid.add_src = java
Logs