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

How to request data from connected Server? #53

Open
Gruftgrabbler opened this issue Nov 1, 2023 · 0 comments
Open

How to request data from connected Server? #53

Gruftgrabbler opened this issue Nov 1, 2023 · 0 comments

Comments

@Gruftgrabbler
Copy link

Gruftgrabbler commented Nov 1, 2023

Issue Summary

I am facing a problem with my BLE Client's data request to a BLE Server. The issue is related to the pybgapi library, and I need assistance in resolving it.

[I created another Issue at the pybgapi repository. I am not 100% sure if it goes there or here, if you think I am in the wrong spot let me know or delete the issue]

Here is the relevant code snippet:

if self.conn_state == "enable_indication":
    # ...
    self.lib.bt.gatt.read_characteristic_value(
        evt.connection, SENSOR_DATA_CHARACTERISTIC)

The SENSOR_DATA_CHARACTERISTIC variable is defined as:

#UUID = 34850bc9-95e5-4701-956c-656ce1afdc66
SENSOR_DATA_CHARACTERISTIC = b"\x66\xdc\xaf\xe1\x6c\x65\x6c\x95\x01\x47\xe5\x95\xc9\x0b\x85\x34"

I am encountering the following error:

File "/Users/username/Documents/GitHub/pybgapi-examples/lib/python3.11/site-packages/bgapi/apiparser.py", line 30, in toInt
    return int(s)
ValueError: invalid literal for int() with base 10: b'f\xdc\xaf\xe1lel\x95\x01G\xe5\x95\xc9\x0b\x854'

I also tried another variant where I casted the byte to an integer value, but I guess this was not a good idea neither.

    self.lib.bt.gatt.read_characteristic_value(
        evt.connection, int.from_bytes(SENSOR_DATA_CHARACTERISTIC, byteorder='little'))

Thank you for any advice in solving this issue and let me know if you need more information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant