Reading ESP32 GATT Characteristic - need help deciphering what the data means

karunt
Posts: 76
Joined: Sat Apr 03, 2021 7:58 am

Reading ESP32 GATT Characteristic - need help deciphering what the data means

Postby karunt » Fri Jan 07, 2022 7:26 pm

Working with the wifi provisioning example provided by ESP. Am able to successfully send wifi credentials to ESP32 chip over BLE. After successfully writing the credentials to the prov-config (0xFF52) characteristic, I attempt to read what the prov-config (0xFF52) characteristic has recorded. Android app code is as follows:

Code: Select all

BleClient.read(deviceID, '021a9004-0382-4aea-bff4-6b3f1c5adfb4', '021aff52-0382-4aea-bff4-6b3f1c5adfb4')
where '021a9004-0382-4aea-bff4-6b3f1c5adfb4' is the custom service uuid and 021aff52-0382-4aea-bff4-6b3f1c5adfb4 is the prov-config specific characteristic uuid.

A log of the response to the read operation shows the following: 8, 3, 106, 0

What do these numbers mean? Are they in some sort of a DataView format? How can I convert them to something that makes sense? Does the 0 at the end mean that the write operation was successful? What about the credentials that I wrote to the characteristic? Do those get erased from the characteristic after being copied to nvs_flash? If not, how do I know what credentials were written to the characteristic?

Thanks.

karunt
Posts: 76
Joined: Sat Apr 03, 2021 7:58 am

Re: Reading ESP32 GATT Characteristic - need help deciphering what the data means

Postby karunt » Fri Mar 11, 2022 3:47 am

For anybody else struggling with something similar, the data shown below is a Uint8Array (buffer array) format and needs to be processed by the code created by the protobuf compiler. The following link will help you understand how to decipher the data returned by BleClient.read (ie, 8, 3, 106, 0 - it's really in an array format: ["1": 8, "2": 3, "3": 106, "4": 0]. If you still have questions about this, send me a message.

https://medium.com/nerd-for-tech/protob ... b324a64564

Who is online

Users browsing this forum: No registered users and 57 guests