GATT BLE variable array formatting?

Loosedoglew
Posts: 2
Joined: Sun Mar 31, 2019 12:01 pm

GATT BLE variable array formatting?

Postby Loosedoglew » Sun Mar 31, 2019 6:44 pm

Hello people of the internet, first ever post on here!

I'm building a BLE client that will hopefully advertise a few GATT services on an ESP32, so far I've got a couple of services working successfully like battery and temperature, with each one on it's own service.

I've already got a few working that have fixed length structures, such as: cycling_power, Sensor_location (0x2A5D) an unsigned 8 bit int. But other characteristics like 'Cycling Power Measurement' have a 'variable length structure containing a Flags field' and I'm not sure how to tackle these.

I will include screenshots from nRF connect app during some reverse engineering attempts I've made. You can see in the value field in the 5th and 6th hexadecimal places that the value increased when I cycled from 0 to 100 watts.

https://ibb.co/fvW9kty
https://ibb.co/8my0QsP

Code: Select all

cyclingPower.setValue(powerMeasurmentStructure);
      cyclingPower.notify();
What type should I assign for powerMeasurmentStructure and can setValue be used? Any existing examples would be great!

Thanks in advance!
Louis

chegewara
Posts: 2240
Joined: Wed Jun 14, 2017 9:00 pm

Re: GATT BLE variable array formatting?

Postby chegewara » Fri Apr 05, 2019 4:19 am

https://www.bluetooth.com/specification ... rement.xml

You have to build struct and then just send an array of uint8 values.

Loosedoglew
Posts: 2
Joined: Sun Mar 31, 2019 12:01 pm

Re: GATT BLE variable array formatting?

Postby Loosedoglew » Tue Apr 09, 2019 11:13 pm

Hello, thanks for the reply!

I've just completed a crash course in structs and after consulting the bottom of the page (.xml) table, that details the order of MSB to LSB I'm still unsure how to format the size in

Code: Select all

characteristic.setValue(data, size);
Do you have any advice or links to an example I could try, I'm struggled to find anything on notifying using BLE of variable length structure.

Who is online

Users browsing this forum: No registered users and 161 guests