esp-idf-provisioning-ios
esp-idf-provisioning-ios copied to clipboard
Read characteristics of the BLE device based on UUID
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
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.
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.
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.
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)
This is super annoying. Why not just expose CBPeripheral so that more normal Core Bluetooth stuff can be done?
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.