Page 1 of 1

ESP GATT Attribute value always unit8_t* ?

Posted: Wed Jul 19, 2017 7:54 am
by Abhiram
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* ?

Re: ESP GATT Attribute value always unit8_t* ?

Posted: Wed Jul 19, 2017 9:29 am
by f.h-f.s.
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.

Re: ESP GATT Attribute value always unit8_t* ?

Posted: Wed Jul 19, 2017 1:26 pm
by kolban
@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