-
Notifications
You must be signed in to change notification settings - Fork 300
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
Android: Permission Missing #1542
Comments
After some tests, the permission request function implemented inside the scanner for android is not compatibile with the api version = 33, most probably because the p4a is changed. the api version 33 doesn't like the request ACCESS_BACKGROUND_LOCATION. after removing it for API version >= 30, the scanner is working, but the client give out the followind error:
after connecting, when calling : await client.start_notify(UART_TX_CHAR_UUID, self.handle_rx) |
Please find the logs: 04-22 18:07:23.649 26795 26958 I python : Start Scanning |
and the implemented python code:
|
the BLE define: UART_SERVICE_UUID = "6E400001-B5A3-F393-E0A9-E50E24DCCA9E" the print result inside the start_notify: print(characteristic) --> 6e400003-b5a3-f393-e0a9-e50e24dcca9e (Handle: 14): Nordic UART TX |
before calling start_noify: print(client.services.characteristics) --> 04-22 18:44:38.587 32277 32401 I python : {3: <bleak.backends.p4android.characteristic.BleakGATTCharacteristicP4Android object at 0x7434bf7010>, 5: <bleak.backends.p4android.characteristic.BleakGATTCharacteristicP4Android object at 0x7434bf7050>, 8: <bleak.backends.p4android.characteristic.BleakGATTCharacteristicP4Android object at 0x7434bbbb10>, 12: <bleak.backends.p4android.characteristic.BleakGATTCharacteristicP4Android object at 0x7434bbbad0>, 14: <bleak.backends.p4android.characteristic.BleakGATTCharacteristicP4Android object at 0x7434bb9250>} |
Can you suggest any workaround ? |
Descriptor issue: After some test i discovered that the issue is in the add_descriptor function ( \bleak\backends\p4android\characteristic.py) i added some debug print and modification as follows:
it works. the problem is that the fileds "descriptor.uuid" and "defs.CLIENT_CHARACTERISTIC_CONFIGURATION_UUID" are different, so the operation "self.__notification_descriptor = descriptor" never happens Permission issue: i modified the "start" function of the scanner as follow:
it seems it works. the issue is in the api version : if you ask for all the postion permissions simultaneously the OS always replys immediatly with a negative answare. If yoy ask for the ACCESS_BACKGROUND_LOCATION later it works |
Trying to run the basic example given for android
https://github.com/hbldh/bleak/tree/develop/examples/kivy
Added Java files from https://github.com/hbldh/bleak/tree/develop/bleak/backends/p4android/java/com/github/hbldh/bleak to local folder java and in buildozer.spec modifed android.add_src = java
log:
04-22 10:53:06.613 12555 12647 I python : [INFO ] [example ]scanning
04-22 10:53:06.614 12555 12647 I python : [DEBUG ] Starting BTLE scan
04-22 10:53:06.710 12555 12647 I python : [INFO ] [example ]ERROR User denied access to ['android.permission.ACCESS_FINE_LOCATION', 'android.permission.ACCESS_COARSE_LOCATION', 'android.permission.ACCESS_BACKGROUND_LOCATION']
04-22 10:53:06.710 12555 12647 I python : [ERROR ] [Exception in callback None()
04-22 10:53:06.710 12555 12647 I python : handle]
04-22 10:53:06.710 12555 12647 I python : Traceback (most recent call last):
04-22 10:53:06.710 12555 12647 I python : File "/home/ronni/progetti/app_bleak/.buildozer/android/platform/build-arm64-v8a/build/other_builds/python3/arm64-v8a__ndk_target_21/python3/Lib/asyncio/events.py", line 80, in _run
04-22 10:53:06.710 12555 12647 I python : TypeError: 'NoneType' object is not callable
The text was updated successfully, but these errors were encountered: