Git Product home page Git Product logo

able's People

Contributors

andfmart avatar andreamerello avatar b3b avatar juasiepo avatar robgar2001 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

able's Issues

After upgrading to new recipe, scanning doesn't work.

After upgrading to use the new recipe, scanning has stopped working.

I get this error message:

11-14 07:22:28.012 2773 4619 E BluetoothUtils: Permission denial: Need ACCESS_FINE_LOCATION permission to get scan results

able takes 14 secs to put services/characteristics in dictionary

Hi,

The conversion from Java List to Python dictionary takes 14 seconds or longer.
We only have one service with one characteristic running at the server side.

Our first thought are due to Pyjnius interaction while iterating.
Although this seems very odd.
What could cause this?

The specific method mentioned:

able/able/android/jni.py

Lines 54 to 67 in b45539d

@java_method('(ILjava/util/List;)V')
def on_services(self, status, services):
services_dict = Services()
if status == GATT_SUCCESS:
for service in services.toArray():
service_uuid = service.getUuid().toString()
Logger.debug("Service discovered: {}".format(service_uuid))
services_dict[service_uuid] = {}
for c in service.getCharacteristics().toArray():
characteristic_uuid = c.getUuid().toString()
Logger.debug("Characteristic discovered: {}".format(
characteristic_uuid))
services_dict[service_uuid][characteristic_uuid] = c
self.dispatcher.dispatch('on_services', status, services_dict)

We wrote a 'fix' by doing the iteration in Java, this fixed the issue.
If nobody can present a reason why Python might take so long, I would be willing to create a pull request for the Java implementation.

Kind regards,

Robbe Gaeremynck

JavaException: Class not found 'org/able/PythonBluetooth'

I'm trying to discover near bluetooth LE services, and when I call the start_scan() method I get the following error:

jnius.JavaException: Class not found b'org/jnius/NativeInvocationHandler'

I solved it following this, retrieve the org.jnius.NativeInvocationHandler manually in my main thread using:

autoclass('org.jnius.NativeInvocationHandler')

But now, I get the following error:

python : JavaException: Class not found 'org/able/PythonBluetooth'

It seems like java classes aren't being imported, any ideas?

Full log:

python : Exception in thread Thread-1:
python : Traceback (most recent call last):
python : File "/home/roberto/Programacion/Python/2019/myapp/myapp_03/.buildozer/android/platform/build/build/other_builds/python2/armeabi-v7a__ndk_target_21/python2/Lib/threading.py", line 801, in __bootstrap_inner
python : File "/home/roberto/Programacion/Python/2019/myapp/myapp_03/.buildozer/android/platform/build/build/python-installs/myapp/jnius/init.py", line 54, in jnius_thread_hook
python : File "/home/roberto/Programacion/Python/2019/myapp/myapp_03/.buildozer/android/platform/build/build/other_builds/python2/armeabi-v7a__ndk_target_21/python2/Lib/threading.py", line 754, in run
python : File "/home/roberto/Programacion/Python/2019/myapp/myapp_03/.buildozer/android/app/main.py", line 206, in finddoor
python : File "/home/roberto/Programacion/Python/2019/myapp/myapp_03/.buildozer/android/platform/build/build/python-installs/myapp/able/dispatcher.py", line 30, in init
python : File "/home/roberto/Programacion/Python/2019/myapp/myapp_03/.buildozer/android/platform/build/build/python-installs/myapp/able/android/dispatcher.py", line 19, in _set_ble_interface
python : File "/home/roberto/Programacion/Python/2019/myapp/myapp_03/.buildozer/android/platform/build/build/python-installs/myapp/able/android/jni.py", line 12, in init
python : File "jnius/jnius_proxy.pxi", line 28, in jnius.jnius.PythonJavaClass.init (jnius/jnius.c:33119)
python : File "jnius/jnius_proxy.pxi", line 34, in jnius.jnius.PythonJavaClass._init_j_self_ptr (jnius/jnius.c:33254)
python : File "jnius/jnius_proxy.pxi", line 168, in jnius.jnius.create_proxy_instance (jnius/jnius.c:35785)
python : File "jnius/jnius_export_func.pxi", line 26, in jnius.jnius.find_javaclass (jnius/jnius.c:17877)
python : JavaException: Class not found 'org/able/PythonBluetooth'

help

requirements = hostpython2,kivy,android,able able does not exist ??

Can not start scan

I got this error when start scan BtGatt.ScanManager: Cannot start unfiltered scan in location-off. This scan will be resumed when location is on: 5. I use orange pi 3 lts board, it havent gps

How to receive characteristics more than 20 bytes?

in micropython off docs

Characteristics and descriptors have a default maximum size of 20 bytes. Anything written to them by a client will be truncated to this length. However, any local write will increase the maximum size, so if you want to allow larger writes from a client to a given characteristic, use gatts_write after registration. e.g. gatts_write(char_handle, bytes(100))

how can i send gatts_write(char_handle, bytes(100)) ?

Installing on Linux?

I was trying to install able on linux and import the class BluetoothDispatcher but it was giving error cannot import name BluetoothDispatcher.
ImportError: cannot import name 'BluetoothDispatcher' from 'able' (/user/.local/lib/python3.8/site-packages/able/__init__.py)

When I looked in the folder there was no folder named recipes. So I cloned the project and copy the recipie to that folder but still I get the error. I looked at this issue as well, I have all necessary permissions and things setup.

send data to bt device

how to receive data from device after connect by mac address?
on_characteristic_read()
show nothing after read_characteristic(characteristic) in loop

ImportError: No module named lictionary

file` "...able/__init__.py", line 3, in <module>
04-14 18:32:08.974 23995 24891 I python  :    File ".../able/util.py", line 10, in <module>
04-14 18:32:08.975 23995 24891 I python  :  ImportError: No module named lictionary
04-14 18:32:08.975 23995 24891 I python  : Python for android ended.

It appears you used lictionary without importing it.

Error while building able_recipe wheel in buildozer

Hello,
I would like to ask about the possible causes of the problem with build able_recipe in buildozer. I have done this several times so far without any problems, hence my question and request for help in locating the error, as even after reinstalling the virtual machine the problem persists. I added android and able_recipe to the requirements in buildozer.spec.
Below you will find the log:

IF THIS FAILS, THE MODULES MAY NEED A RECIPE. A reason for this is often modules compiling native code that is unaware of Android cross-compilation and does not work without additional changes / workarounds.
[DEBUG]:   -> running bash -c venv/bin/pip install -v --target '/home/kupa/app/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/myapp/armeabi-v7a' --no-deps -r requirements.txt
[DEBUG]:   	Ignoring "sys._home = value" override
[DEBUG]:   	Using pip 23.1 from /home/kupa/app/.buildozer/android/platform/build-armeabi-v7a/build/venv/lib/python3.9/site-packages/pip (python 3.9)
[DEBUG]:   	Collecting able_recipe (from -r requirements.txt (line 1))
[DEBUG]:   	  Using cached able_recipe-1.0.12.tar.gz (20 kB)
[DEBUG]:   	  Running command pip subprocess to install build dependencies
[DEBUG]:   	  Ignoring "sys._home = value" override
[DEBUG]:   	  Collecting setuptools>=40.8.0
[DEBUG]:   	    Using cached setuptools-67.6.1-py3-none-any.whl (1.1 MB)
[DEBUG]:   	  Collecting wheel
[DEBUG]:   	    Using cached wheel-0.40.0-py3-none-any.whl (64 kB)
[DEBUG]:   	  Installing collected packages: wheel, setuptools
[DEBUG]:   	  Successfully installed setuptools-67.6.1 wheel-0.40.0
[DEBUG]:   	  Installing build dependencies ... done
[DEBUG]:   	  Running command Getting requirements to build wheel
[DEBUG]:   	  Ignoring "sys._home = value" override
[DEBUG]:   	  /tmp/pip-build-env-az1vhz3f/overlay/lib/python3.9/site-packages/setuptools/__init__.py:259: SetuptoolsDeprecationWarning: The function `convert_path` is considered internal and not part of the public API.
[DEBUG]:   	  Its direct usage by 3rd-party packages is considered deprecated and the function
[DEBUG]:   	  may be removed in the future.
[DEBUG]:   	    warnings.warn(cleandoc(msg), SetuptoolsDeprecationWarning)
[DEBUG]:   	  running egg_info
[DEBUG]:   	  writing able_recipe.egg-info/PKG-INFO
[DEBUG]:   	  writing dependency_links to able_recipe.egg-info/dependency_links.txt
[DEBUG]:   	  writing top-level names to able_recipe.egg-info/top_level.txt
[DEBUG]:   	  reading manifest file 'able_recipe.egg-info/SOURCES.txt'
[DEBUG]:   	  reading manifest template 'MANIFEST.in'
[DEBUG]:   	  adding license file 'LICENSE'
[DEBUG]:   	  writing manifest file 'able_recipe.egg-info/SOURCES.txt'
[DEBUG]:   	  Getting requirements to build wheel ... done
[DEBUG]:   	  Running command Preparing metadata (pyproject.toml)
[DEBUG]:   	  Ignoring "sys._home = value" override
[DEBUG]:   	  /tmp/pip-build-env-az1vhz3f/overlay/lib/python3.9/site-packages/setuptools/__init__.py:259: SetuptoolsDeprecationWarning: The function `convert_path` is considered internal and not part of the public API.
[DEBUG]:   	  Its direct usage by 3rd-party packages is considered deprecated and the function
[DEBUG]:   	  may be removed in the future.
[DEBUG]:   	    warnings.warn(cleandoc(msg), SetuptoolsDeprecationWarning)
[DEBUG]:   	  running dist_info
[DEBUG]:   	  creating /tmp/pip-modern-metadata-rueqyx09/able_recipe.egg-info
[DEBUG]:   	  writing /tmp/pip-modern-metadata-rueqyx09/able_recipe.egg-info/PKG-INFO
[DEBUG]:   	  writing dependency_links to /tmp/pip-modern-metadata-rueqyx09/able_recipe.egg-info/dependency_links.txt
[DEBUG]:   	  writing top-level names to /tmp/pip-modern-metadata-rueqyx09/able_recipe.egg-info/top_level.txt
[DEBUG]:   	  writing manifest file '/tmp/pip-modern-metadata-rueqyx09/able_recipe.egg-info/SOURCES.txt'
[DEBUG]:   	  reading manifest file '/tmp/pip-modern-metadata-rueqyx09/able_recipe.egg-info/SOURCES.txt'
[DEBUG]:   	  reading manifest template 'MANIFEST.in'
[DEBUG]:   	  adding license file 'LICENSE'
[DEBUG]:   	  writing manifest file '/tmp/pip-modern-metadata-rueqyx09/able_recipe.egg-info/SOURCES.txt'
[DEBUG]:   	  creating '/tmp/pip-modern-metadata-rueqyx09/able_recipe-1.0.12.dist-info'
[DEBUG]:   	  Preparing metadata (pyproject.toml) ... done
[DEBUG]:   	Collecting certifi (from -r requirements.txt (line 2))
[DEBUG]:   	  Using cached certifi-2022.12.7-py3-none-any.whl (155 kB)
[DEBUG]:   	Building wheels for collected packages: able_recipe
[DEBUG]:   	  Running command Building wheel for able_recipe (pyproject.toml)
[DEBUG]:   	  Ignoring "sys._home = value" override
[DEBUG]:   	  /tmp/pip-build-env-az1vhz3f/overlay/lib/python3.9/site-packages/setuptools/__init__.py:259: SetuptoolsDeprecationWarning: The function `convert_path` is considered internal and not part of the public API.
[DEBUG]:   	  Its direct usage by 3rd-party packages is considered deprecated and the function
[DEBUG]:   	  may be removed in the future.
[DEBUG]:   	    warnings.warn(cleandoc(msg), SetuptoolsDeprecationWarning)
[DEBUG]:   	  running bdist_wheel
[DEBUG]:   	  running build
[DEBUG]:   	  running build_py
[DEBUG]:   	  creating build
[DEBUG]:   	  creating build/lib
[DEBUG]:   	  creating build/lib/able
[DEBUG]:   	  copying able/adapter.py -> build/lib/able
[DEBUG]:   	  copying able/queue.py -> build/lib/able
[DEBUG]:   	  copying able/advertising.py -> build/lib/able
[DEBUG]:   	  copying able/version.py -> build/lib/able
[DEBUG]:   	  copying able/structures.py -> build/lib/able
[DEBUG]:   	  copying able/scan_settings.py -> build/lib/able
[DEBUG]:   	  copying able/__init__.py -> build/lib/able
[DEBUG]:   	  copying able/permissions.py -> build/lib/able
[DEBUG]:   	  copying able/filters.py -> build/lib/able
[DEBUG]:   	  copying able/utils.py -> build/lib/able
[DEBUG]:   	  copying able/dispatcher.py -> build/lib/able
[DEBUG]:   	  creating build/lib/able/android
[DEBUG]:   	  copying able/android/__init__.py -> build/lib/able/android
[DEBUG]:   	  copying able/android/jni.py -> build/lib/able/android
[DEBUG]:   	  copying able/android/dispatcher.py -> build/lib/able/android
[DEBUG]:   	  installing to build/bdist.linux-x86_64/wheel
[DEBUG]:   	  running install
[DEBUG]:   	  Traceback (most recent call last):
[DEBUG]:   	    File "/home/kupa/app/.buildozer/android/platform/build-armeabi-v7a/build/venv/lib/python3.9/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
[DEBUG]:   	      main()
[DEBUG]:   	    File "/home/kupa/app/.buildozer/android/platform/build-armeabi-v7a/build/venv/lib/python3.9/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
[DEBUG]:   	      json_out['return_val'] = hook(**hook_input['kwargs'])
[DEBUG]:   	    File "/home/kupa/app/.buildozer/android/platform/build-armeabi-v7a/build/venv/lib/python3.9/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 251, in build_wheel
[DEBUG]:   	      return _build_backend().build_wheel(wheel_directory, config_settings,
[DEBUG]:   	    File "/tmp/pip-build-env-az1vhz3f/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 413, in build_wheel
[DEBUG]:   	      return self._build_with_temp_dir(['bdist_wheel'], '.whl',
[DEBUG]:   	    File "/tmp/pip-build-env-az1vhz3f/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 398, in _build_with_temp_dir
[DEBUG]:   	      self.run_setup()
[DEBUG]:   	    File "/tmp/pip-build-env-az1vhz3f/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 484, in run_setup
[DEBUG]:   	      super(_BuildMetaLegacyBackend,
[DEBUG]:   	    File "/tmp/pip-build-env-az1vhz3f/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 335, in run_setup
[DEBUG]:   	      exec(code, locals())
[DEBUG]:   	    File "<string>", line 90, in <module>
[DEBUG]:   	    File "/tmp/pip-build-env-az1vhz3f/overlay/lib/python3.9/site-packages/setuptools/__init__.py", line 108, in setup
[DEBUG]:   	      return distutils.core.setup(**attrs)
[DEBUG]:   	    File "/tmp/pip-build-env-az1vhz3f/overlay/lib/python3.9/site-packages/setuptools/_distutils/core.py", line 185, in setup
[DEBUG]:   	      return run_commands(dist)
[DEBUG]:   	    File "/tmp/pip-build-env-az1vhz3f/overlay/lib/python3.9/site-packages/setuptools/_distutils/core.py", line 201, in run_commands
[DEBUG]:   	      dist.run_commands()
[DEBUG]:   	    File "/tmp/pip-build-env-az1vhz3f/overlay/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 969, in run_commands
[DEBUG]:   	      self.run_command(cmd)
[DEBUG]:   	    File "/tmp/pip-build-env-az1vhz3f/overlay/lib/python3.9/site-packages/setuptools/dist.py", line 1221, in run_command
[DEBUG]:   	      super().run_command(command)
[DEBUG]:   	    File "/tmp/pip-build-env-az1vhz3f/overlay/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
[DEBUG]:   	      cmd_obj.run()
[DEBUG]:   	    File "/tmp/pip-build-env-az1vhz3f/overlay/lib/python3.9/site-packages/wheel/bdist_wheel.py", line 378, in run
[DEBUG]:   	      self.run_command("install")
[DEBUG]:   	    File "/tmp/pip-build-env-az1vhz3f/overlay/lib/python3.9/site-packages/setuptools/_distutils/cmd.py", line 318, in run_command
[DEBUG]:   	      self.distribution.run_command(command)
[DEBUG]:   	    File "/tmp/pip-build-env-az1vhz3f/overlay/lib/python3.9/site-packages/setuptools/dist.py", line 1221, in run_command
[DEBUG]:   	      super().run_command(command)
[DEBUG]:   	    File "/tmp/pip-build-env-az1vhz3f/overlay/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
[DEBUG]:   	      cmd_obj.run()
[DEBUG]:   	    File "<string>", line 76, in run
[DEBUG]:   	    File "<string>", line 20, in javaclass_dir
[DEBUG]:   	    File "<string>", line 44, in build_dir
[DEBUG]:   	    File "<string>", line 51, in python_installs_dir
[DEBUG]:   	  Exception: Python installs directory is not found. Please report issue to: https://github.com/b3b/able/issues
[DEBUG]:   	  error: subprocess-exited-with-error
[DEBUG]:   	
[DEBUG]:   	  × Building wheel for able_recipe (pyproject.toml) did not run successfully.
[DEBUG]:   	  │ exit code: 1
[DEBUG]:   	  ╰─> See above for output.
[DEBUG]:   	
[DEBUG]:   	  note: This error originates from a subprocess, and is likely not a problem with pip.
[DEBUG]:   	  full command: /home/kupa/app/.buildozer/android/platform/build-armeabi-v7a/build/venv/bin/python /home/kupa/app/.buildozer/android/platform/build-armeabi-v7a/build/venv/lib/python3.9/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py build_wheel /tmp/tmp3iqynll2
[DEBUG]:   	  cwd: /tmp/pip-install-ujgrc__d/able-recipe_1dac39e59d4d4a2588765a8ed7ece7cc
[DEBUG]:   	  Building wheel for able_recipe (pyproject.toml) ... error
[DEBUG]:   	  ERROR: Failed building wheel for able_recipe
[DEBUG]:   	Failed to build able_recipe
[DEBUG]:   	ERROR: Could not build wheels for able_recipe, which is required to install pyproject.toml-based projects

ImportError: cannot import name BluetoothDispatcher

'''File "bleandroid.py", line 7, in
04-14 19:48:16.062 8847 9321 I python : ImportError: cannot import name BluetoothDispatcher
04-14 19:48:16.062 8847 9321 I python : Python for android ended.'''

Does your library even work?

Error on last release

Hi , i get error on last release, on 1.0.3 all is ok. What can be wrong?

BLE-python: Connected to GATT server, status:0
BLE-python: onServicesDiscovered - success
python : Traceback (most recent call last):
python : File "jnius/jnius_proxy.pxi", line 50, in jnius.jnius.PythonJavaClass.invoke
python : File "jnius/jnius_proxy.pxi", line 76, in jnius.jnius.PythonJavaClass._invoke
python : File "/var/ttgo/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/ttgobt/able/android/jni.py", line 54, in on_services
python : File "kivy/_event.pyx", line 703, in kivy._event.EventDispatcher.dispatch
python : File "kivy/_event.pyx", line 1214, in kivy._event.EventObservers.dispatch
python : File "kivy/_event.pyx", line 1138, in kivy._event.EventObservers._dispatch
python : File "/var/ttgo/.buildozer/android/app/main.py", line 183, in on_services
python : File "/var/ttgo/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/ttgobt/able/android/dispatcher.py", line 74, in enable_notifications
python : File "/var/ttgo/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/ttgobt/able/queue.py", line 18, in wrapper
python : File "/var/ttgo/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/ttgobt/able/queue.py", line 63, in enque
python : File "/var/ttgo/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/ttgobt/able/queue.py", line 36, in wrapped
python : File "/var/ttgo/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/ttgobt/able/queue.py", line 77, in execute_next
python : File "/var/ttgo/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/ttgobt/able/queue.py", line 90, in execute_task
python : File "/var/ttgo/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/ttgobt/able/dispatcher.py", line 140, in write_descriptor
python : File "jnius/jnius_export_class.pxi", line 763, in jnius.jnius.JavaMethod.call
python : File "jnius/jnius_conversion.pxi", line 130, in jnius.jnius.populate_args
python : File "jnius/jnius_conversion.pxi", line 586, in jnius.jnius.convert_pyarray_to_java
python : TypeError: an integer is required

Permission error

I got this error when I start scan

03-10 05:40:17.769 30353 30419 I python  :    File "jnius/jnius_utils.pxi", line 91, in jnius.jnius.check_exception
03-10 05:40:17.815 30353 30419 I python  :  jnius.jnius.JavaException: JVM exception occurred: Didn't find class "org.kivy.android.PythonActivity$PermissionsCallback" on path: DexPathList[[directory "."],nativeLibraryDirectories=[/system/lib64, /system/system_ext/lib64, /system/lib64, /system/system_ext/lib64]] java.lang.ClassNotFoundException```

Write on remote device using ble

I have an working app that publishes a write service with UUID 0d06. This service works ok as I can send some text using the BLE scanner app for android

I am trying to send text using ble's write_characteristic. Here you are my piece of code (based on BLE functions test):

    def write(self, characteristic):
        Logger.debug("Inside write")
        characteristic = self.characteristics['write']
        self.ble.write_characteristic(characteristic, 'TEST')

I have declared:

    uids = {
        'string': '0d01',
        'counter_reset': '0d02',
        'counter_increment': '0d03',
        'counter_read': '0d04',
        'notifications': '0d05',
       write': '0d06'
    }

and

    def on_services(self, ble, status, services):
        if status != GATT_SUCCESS:
            self.state = 'services_error'
            return
        self.state = 'connected'
        self.services = services
        self.read_test_string(ble)
        self.characteristics = {
            'counter_increment': self.services.search(
                self.uids['counter_increment']),
            'counter_reset': self.services.search(
                self.uids['counter_reset']),
            'write': self.services.search(
                self.uids['write']),
        }

The services are detected ok:

12-09 23:07:31.017 10385 10417 I python  : [INFO   ] [Base        ] Start application main loop                                                                                             
12-09 23:07:33.316 10385 10417 I python  : [DEBUG  ] set queue timeout to 1.0                                                                                                               
12-09 23:07:34.737 10385 10385 I python  : [DEBUG  ] on_scan_started
12-09 23:07:39.018 10385 10385 I python  : [DEBUG  ] on_scan_completed
12-09 23:07:40.283 10385 10401 I python  : [DEBUG  ] [on_connection_state_change status=0 state] 2                                                                                          
12-09 23:07:40.400 10385 10401 I python  : [DEBUG  ] [Service discovered] 16fe0d00-c111-11e3-b8c8-0002a5d5c51b                                                                              
12-09 23:07:40.432 10385 10401 I python  : [DEBUG  ] [Characteristic discovered] 16fe0d05-c111-11e3-b8c8-0002a5d5c51b                                                                       
12-09 23:07:40.433 10385 10401 I python  : [DEBUG  ] [Characteristic discovered] 16fe0d06-c111-11e3-b8c8-0002a5d5c51b  

But when I try to send the text I get the following error:

12-09 23:07:42.808 10385 10417 I python  :    File "/data/data/org.kivy.kivy_ble_write/files/app/bluetooth.kv", line 50, in <module>
12-09 23:07:42.809 10385 10417 I python  :      on_press: app.write()
12-09 23:07:42.810 10385 10417 I python  :  TypeError: write() missing 1 required positional argument: 'characteristic'                                                                                          
12-09 23:07:42.810 10385 10417 I python  : Python for android ended.
^CTraceback (most recent call last):
  File "/usr/local/bin/buildozer", line 11, in <module>
    load_entry_point('buildozer==0.40.dev0', 'console_scripts', 'buildozer')()
  File "/usr/local/lib/python3.7/dist-packages/buildozer-0.40.dev0-py3.7.egg/buildozer/scripts/client.py", line 13, in main
    Buildozer().run_command(sys.argv[1:])
  File "/usr/local/lib/python3.7/dist-packages/buildozer-0.40.dev0-py3.7.egg/buildozer/__init__.py", line 1071, in run_command
    self.target.run_commands(args)
  File "/usr/local/lib/python3.7/dist-packages/buildozer-0.40.dev0-py3.7.egg/buildozer/target.py", line 92, in run_commands
    func(args)
  File "/usr/local/lib/python3.7/dist-packages/buildozer-0.40.dev0-py3.7.egg/buildozer/targets/android.py", line 1336, in cmd_logcat
    show_output=True)
  File "/usr/local/lib/python3.7/dist-packages/buildozer-0.40.dev0-py3.7.egg/buildozer/__init__.py", line 311, in cmd                                                                                            
    readx = select.select([fd_stdout, fd_stderr], [], [])[0]
KeyboardInterrupt

Any idea what am I doing wrong?

Thanks for your time

Didn't find class "org.able.BLE"

i came across this problem to day while trying to build to start my new project

Traceback (most recent call last):
07-15 03:04:18.792 5657 5696 I python : File "/home/sooko/prj/git/able/examples/alert/.buildozer/android/app/main.py", line 6, in
07-15 03:04:18.792 5657 5696 I python : File "/home/sooko/prj/git/able/examples/alert/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/python-installs/ble/arm64-v8a/able/init.py", line 30, in
07-15 03:04:18.792 5657 5696 I python : File "/home/sooko/prj/git/able/examples/alert/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/python-installs/ble/arm64-v8a/able/android/dispatcher.py", line 14, in
07-15 03:04:18.792 5657 5696 I python : File "/home/sooko/prj/git/able/examples/alert/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/python-installs/ble/arm64-v8a/jnius/reflect.py", line 209, in autoclass
07-15 03:04:18.792 5657 5696 I python : File "jnius/jnius_export_func.pxi", line 22, in jnius.jnius.find_javaclass
07-15 03:04:18.792 5657 5696 I python : File "jnius/jnius_utils.pxi", line 79, in jnius.jnius.check_exception
07-15 03:04:18.792 5657 5696 I python : jnius.jnius.JavaException: JVM exception occurred: Didn't find class "org.able.BLE" on path: DexPathList[[zip file "/data/app/~~jl-LfZi21GTWADs9WNsRiw==/io.sooko.ble-Yc3olsilIiK7s8JWfe1Q-A==/base.apk"],nativeLibraryDirectories=[/data/app/~~jl-LfZi21GTWADs9WNsRiw==/io.sooko.ble-Yc3olsilIiK7s8JWfe1Q-A==/lib/arm64, /data/app/~~jl-LfZi21GTWADs9WNsRiw==/io.sooko.ble-Yc3olsilIiK7s8JWfe1Q-A==/base.apk!/lib/arm64-v8a, /system/lib64, /system_ext/lib64]] java.lang.ClassNotFoundException
07-15 03:04:18.792 5657 5696 I python : Python for android ended.

Unable to send string data

In java you can send string data via the write characteristic, in able you are unable to via the write characteristic.

Had to write my own function to do it.

ImportError: cannot import name 'BluetoothDispatcher' from 'able'

Hello,

Using Buildozer to build my Kivy app with the ABLE library, but after following every instruction given in here, I get this at the end of the Bulldozer log.

python : ImportError: cannot import name 'BluetoothDispatcher' from 'able' (/data/user/0/org.test.bleable/files/app/_python_bundle/site-packages/able/init.pyc)

I have already included the following in my buildozer.spec file:
requirements = python3,kivy,android,able,lictionary,tatsu
p4a.local_recipes = ../recipes

what am I missing?

'BLE' object has no attribute '_ble'

Hi,
I'm trying to run your example but I face this problem:

AttributeError: 'BLE' object has no attribute '_ble'

Please help, since this is the only Python BLE library that support Android.

JavaException("Class not found b'org/able/BLE'")

I suspect it's an issue with python-for-android but, I just thought I'd give you a heads up about this before anyone complains. What branch of python-for-android and pyjnius worked last for bletest from your experience? I made the mistake of releasing a broken APK on the Play Store because I hadn't changed anything that should have broken anything (just added new UUIDs for additional BLE devices supported by my app) and now I'm hurting because of it so, if you have any ideas, please share them with me. Also, I'm still planning on helping add better documentation for ABLE if you're cool with that. I wrote this back in 2012 (and practically didn't know what I was talking about yet; just slapped the article together overnight while doing the research on the fly) so, I think I'm up to the task of technical writing: https://www.androidauthority.com/android-hacking-apps-pentesting-57063/

Android Phone as a Peripheral

I haven't used Kivy yet, but before I do I wanted to know if it has the capability to make my android act as a peripheral that sends messages?

Can this library be used to do so ?

Thanks

Using able with a python-for-android service

We have created a Kivy application which spawns a service and we wish to run able within this. We tried running some existing working code but get

05-28 13:23:56.487  8004  8024 I python  :  jnius.jnius.JavaException: JVM exception occurred: Attempt to invoke virtual method 'android.content.pm.PackageManager android.content.Context.getPackageManager()' on a null object reference
05-28 13:23:56.487  8004  8024 I python  : Python for android ended.

Is this at all possible?
Many thanks

Change ScanSettings?

It seems that this uses a deprecated startLeScan function, and a newer API allows for filtering, and things like low power background scans. Is this functionality on the road map for the future?

It would be very useful for key tracker beacons and the like.

Receiving data through notifications

Hi, I really love the simplicity of this library for managing a GATT client. I just wanted to check my understanding about receiving data through notifications. Am i right in thinking that i enable it with "enable_notifications" (in dispatcher.py) and then "on_characteristic_changed" (in dispatcher.py) will be called when a notification for that characteristic is received. So i just have to somehow override the stub callback function "on_characteristic_changed" to handle the data being received?

Thanks!

Buildozer Failed Building Alert Example

I tried building the project with the same buildozer.spec and main.py file but I got the error when it came with the setup.py in able_recipe

Installing collected packages: plyer, certifi, able_recipe
Running command Running setup.py install for able_recipe
Ignoring "sys._home = value" override
running install
Traceback (most recent call last):
File "", line 2, in
File "", line 34, in
File "/tmp/pip-install-9vo91z2q/able-recipe_352b77a036ee40c08e174b90b1836cdf/setup.py", line 57, in
setup(
File "/mnt/c/Users/***/Downloads/service_advertise/.buildozer/android/platform/build-armeabi-v7a/build/venv/lib/python3.8/site-packages/setuptools/init.py", line 165, in setup
return distutils.core.setup(**attrs)
File "/mnt/c/Users/sirak_p9ehh80/Downloads/service_advertise/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/hostpython3/desktop/hostpython3/Lib/distutils/core.py", line 148, in setup
dist.run_commands()
File "/mnt/c/Users/sirak_p9ehh80/Downloads/service_advertise/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/hostpython3/desktop/hostpython3/Lib/distutils/dist.py", line 966, in run_commands
self.run_command(cmd)
File "/mnt/c/Users/sirak_p9ehh80/Downloads/service_advertise/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/hostpython3/desktop/hostpython3/Lib/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/tmp/pip-install-9vo91z2q/able-recipe_352b77a036ee40c08e174b90b1836cdf/setup.py", line 35, in run
raise Exception(
Exception: javaclasses directory is not found. Please report issue to: https://github.com/b3b/able/issues
error: subprocess-exited-with-error

× Running setup.py install for able_recipe did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.
full command: /mnt/c/Users/***/Downloads/service_advertise/.buildozer/android/platform/build-armeabi-v7a/build/venv/bin/python -u -c '
exec(compile('"'"''"'"''"'"'

This is -- a caller that pip uses to run setup.py

- It imports setuptools before invoking setup.py, to enable projects that directly

import from distutils.core to work with newer packaging standards.

- It provides a clear error message when setuptools is not installed.

- It sets sys.argv[0] to the underlying setup.py, when invoking setup.py so

setuptools doesn'"'"'t think the script is -c. This avoids the following warning:

manifest_maker: standard file '"'"'-c'"'"' not found".

- It generates a shim setup.py, for handling setup.cfg-only projects.

import os, sys, tokenize

try:
import setuptools
except ImportError as error:
print(
"ERROR: Can not execute setup.py since setuptools is not available in "
"the build environment.",
file=sys.stderr,
)
sys.exit(1)

file = %r
sys.argv[0] = file

if os.path.exists(file):
filename = file
with tokenize.open(file) as f:
setup_py_code = f.read()
else:
filename = ""
setup_py_code = "from setuptools import setup; setup()"

exec(compile(setup_py_code, filename, "exec"))
'"'"''"'"''"'"' % ('"'"'/tmp/pip-install-9vo91z2q/able-recipe_352b77a036ee40c08e174b90b1836cdf/setup.py'"'"',), "", "exec"))' install --record /tmp/pip-record-q2092ddf/install-record.txt --single-version-externally-managed --home /tmp/pip-target-zbhwrrpi --compile --install-headers /tmp/pip-target-zbhwrrpi/include/site/python3.8/able_recipe
cwd: /tmp/pip-install-9vo91z2q/able-recipe_352b77a036ee40c08e174b90b1836cdf/
Running setup.py install for able_recipe ... error
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> able_recipe

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.

STDERR:

ERROR:[2] Could not read registry key
cannot connect to daemon at tcp:5037: cannot connect to 127.0.0.1:5037: No connection could be made because the target machine actively refused it. (10061)
cannot connect to daemon at tcp:5037: Connection refused

Preparing a development environment

I have the testapp running in my mobile phone and it can connect to the server.go successfully

Now I am preparing a development environment. While trying to launch the testapp on my linux box I get the main window successfully but when I click on connect button I get the following error:
"
File "/home/juan/git/able/.venv/lib/python3.7/site-packages/able/dispatcher.py", line 14, in getattr
raise Exception(self.msg)
Exception: BLE is not implemented for platform
"
It makes sense as the BLE is expected to work with the Android Bluetooth Low Energy API.

The other option I am implementing to create a development environment is to install the kivy-remote-shell on my android phone so I will get a python with all the libraries that will allow me to run quick tests. But for the moment I am having some issues installing it.

Any Idea about how to create a development environment?

Thanks for your time

Clarify re-connection routine

This issue is to address possible steps to document re-connection routine: see PR #33 by @robgar2001

Possible steps:

  • BLE.connectGatt() Java method should close current GATT client before connection to new
  • Add an example on using re-connection
  • Perhaps, add able.BluetoothDispatcher.reconnect_gatt() method as a shorthand for "re-connect to a remote device after the connection has been dropped"

How to install?

Hi, I know this is probably a stupid question, but how do I install able? I need it for an android kivy app, so I'm using buildozer, but I can't install it. I tried with pip, and by installing pythonhere, but nothing works or, at least, it doesn't show up in my module list.

bletest app crashing on my mobile

Hi,

I am testing the bletest app on my Android phone. I can open it but when I press the connect button, the app just disappears. I have checked if it has bluetooth permissions and all seem fine. Also I have checked if the crash leaves any log file on my mobile without luck

I am testing it with the server.go application delivered. The server.go application works as expected and I can connect to it using any BLE browser app for android.

The alert app starts ok but as I don't have a MI band I cannot test it properly. Anyway if I press the "Press to Alert Mi" button, it flashes but at least the app doesn't crash

Any idea what am I missing?

Add connect by mac address or through java class bluetoothdevice

This is not an issue but a request

Please add a function to connect to a device by the mac address or though the java class bluetoothdevice that can be obtained from the paired devices list: autoclass('android.bluetooth.BluetoothAdapter').getDefaultAdapter().getBondedDevices().toArray()

Use case: not always is desired to scan devices, but quickly connect through the mac address or java class bluetoothdevice from paired devices list

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.