Skip to content
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

characteristic reading not working in android #1671

Open
abofme opened this issue Oct 19, 2024 · 0 comments
Open

characteristic reading not working in android #1671

abofme opened this issue Oct 19, 2024 · 0 comments

Comments

@abofme
Copy link

abofme commented Oct 19, 2024

  • bleak version: 0.22.3
  • Python version: 3.11
  • Operating System: android 13

Description

I am making a kivymd app that uses bleak I send and read some characteristics everything works fine in pc but when I export the apk to android and test it on my phone I get this error : Exception during signal sending: api call failed, not waiting for ('onCharacteristicRead', 42) (got using logcat)

What I Did

I set the minimum api to 33 and I have android 13 , scanning, connecting and sending all work I can control an LED on my device.

here is the code related to the error :

async def send_signal(self, value):
        if self.client and self.client.is_connected:
            try:
                await self.client.write_gatt_char(CHARACTERISTIC_UUID, bytearray([value]), response=True)
                print(f"Sent value {value}")
            except Exception as e:
                print(f"Exception during signal sending: {e}")
        else:
            print("Client is not connected")

    async def read_batt(self):
        if self.client and self.client.is_connected:
            try:
                data = await self.client.read_gatt_char(CHARACTERISTIC_UUID)
                self.batt_txt.text = f"{data.decode('utf-8')}"
                print(f"Received battery data: {data.decode('utf-8')}")
            except Exception as e:
                print(f"Exception during signal sending: {e}")
        else:
            print("Client is not connected")
    def get_batt(self, instance):
        loop.run_until_complete(self.send_signal(3))
        loop.run_until_complete(self.read_batt())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants