Sizeof(struct) call returns invalid struct size
Posted: Thu Sep 07, 2017 11:56 am
I am writing down the structure representing the user descriptor value 0x2904:
Reference is here:https://www.bluetooth.com/specification ... format.xml
I initialise it as below as an example:
I pass it to a gatt attribute table as below:
When I debug and check the size returned by the sizeof operator I obtain 8 bytes instead of 7. The same also reflects on nrf-connect app(Incorrect data length,7 bytes expected). Any reason for this? My local idf repo is at v3.0-dev
Reference is here:https://www.bluetooth.com/specification ... format.xml
Code: Select all
typedef struct
{
uint8_t _format;
int8_t _exponent;
uint16_t _unit;
uint8_t _namespace;
uint16_t _description;
} presentation_t;
Code: Select all
static presentation_t utf8_presentation =
{
._format=25,
._exponent=0,
._unit=0,
._namespace=0,
._description=0,
};
Code: Select all
[USAGE_IDX_DISPLAY_STRING_CFG_1] =
{{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_16, (uint8_t *)&usage_character_char_presentation_uuid, ESP_GATT_PERM_READ,
sizeof(utf8_presentation),sizeof(utf8_presentation), (uint8_t *)&utf8_presentation}}