ESP GATT Attribute value always unit8_t* ?

Abhiram
Posts: 22
Joined: Mon Apr 24, 2017 5:09 pm

ESP GATT Attribute value always unit8_t* ?

Postby Abhiram » Wed Jul 19, 2017 7:54 am

Hi all,

I am facing one trivial issue while coding for BLE GATT characteristic , esp_attr_value_t ( esp_gatts_defs.h) is used in my code for pointing to values to be exchanged.

I need to update a signed value , say for example : time zone of -5 hours, the attribute_value parameter in the esp_attr_value_t
structure is unit8_t* , so its not allowing me to use signed numbers.

should'nt this be a void* instead of unit8_t* ?

f.h-f.s.
Posts: 215
Joined: Thu Dec 08, 2016 2:53 pm

Re: ESP GATT Attribute value always unit8_t* ?

Postby f.h-f.s. » Wed Jul 19, 2017 9:29 am

When I try to add a gatt characteristic in nRF connect for example, I cant pass a negative value. You can pass a string "-5", or cast the value into a signed datatype.

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: ESP GATT Attribute value always unit8_t* ?

Postby kolban » Wed Jul 19, 2017 1:26 pm

@Abhiram

If I have an allocated chunk of storage:

uint8_t* buffer = (uint8_t*)malloc(1000);

Then I can write different types of data there such as:

int a;
*(int*)(buffer) = a;

or:

short b;
*(short*)(buffer) = b;

see also:
https://stackoverflow.com/questions/226 ... -t-or-char
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

Who is online

Users browsing this forum: Google [Bot] and 128 guests