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

Read characteristics of the BLE device based on UUID #45

Open
SandhiyalalEIC opened this issue Mar 29, 2022 · 6 comments
Open

Read characteristics of the BLE device based on UUID #45

SandhiyalalEIC opened this issue Mar 29, 2022 · 6 comments

Comments

@SandhiyalalEIC
Copy link

SandhiyalalEIC commented Mar 29, 2022

The library works great.
Is there a method where I can read the characteristics of the device(from UUID) using ESP.Here I am not able to do
connectedDevice?.peripheral.discoverServices([UUID]) , as peripheral is not accessible

@vikas-chandra-mnnit
Copy link
Contributor

HI @einfochips1, thanks for the feedback.

Yes, peripheral is not accessible outside the library to keep the handling of BLE devices private to the library and avoid any discontinuity. However, we read each characteristic of the BLE device and store it in the format of a dictionary with the path as key and characteristic as value. If you want to send custom data to the device then you can use the API sendData with your custom path. If a characteristic is available for this path then data will be sent successfully.

@SandhiyalalEIC
Copy link
Author

SandhiyalalEIC commented Mar 30, 2022

Hi @vikas-chandra-mnnit
Thanks for the reply.
DO you mean , something like this:

let data: Data = "FEE2".data(using: .utf8)! //FEE2 is characteristic UUID , I want to read

connectedDevice?.sendData(path: "Custompathhere", data: data, completionHandler: {data,error in
print(data) // Here, will I get the characteristics value?
})

If not can you help me with how to read a characteristics.

@vikas-chandra-mnnit
Copy link
Contributor

Hi @vikas-chandra-mnnit Thanks for the reply. DO you mean , something like this: let data: Data = "FEE2".data(using: .utf8)! //FEE2 is characteristic UUID connectedDevice?.sendData(path: "", data: data, completionHandler: {data,error in print(data)

    })

You will not get the characteristic value here, this API is used to send custom data. Check out this thread. We do not have any API to get characteristic values. You can enable logs in SDK to see all BLE characteristics read from the device in console.

@SandhiyalalEIC
Copy link
Author

SandhiyalalEIC commented Mar 30, 2022

Hi @vikas-chandra-mnnit
Thank you for the reply.Just have a question that
if the device is not advertising the data.We need to request for a characteristics with UUID we want to read.

Without requesting the characteristics UUID, we won't get the value for characteristics.
In console , we will get the general advertising data.Not all the characteristics the device has.
Any way how we can request the value of particular characteristics (if I have UUID)

@mevdev
Copy link

mevdev commented Apr 1, 2023

This is super annoying. Why not just expose CBPeripheral so that more normal Core Bluetooth stuff can be done?

@vikas-chandra-mnnit
Copy link
Contributor

Hi @mevdev, I understand your frustration. The reason we have not made peripheral object public is that we have certain callbacks in SDK that we trigger when some set of conditions are met in Core Bluetooth methods.

However, if you have a specific use case that cannot be accomplished with the existing SDK, you could consider submitting a feature request to us. We are always looking to improve our library and will consider adding the functionality you need in a future release.

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

3 participants