hi,
I am using Bluetooth gatt_C demo and I want to change it to uuid128, this is what I am doing could you please advice?
I get this error: missing braces around initializer [-Werror=missing-braces] ----------> .uuid = {.uuid128 = REMOTE_SERVICE_UUID,},
const uint8_t REMOTE_SERVICE_UUID[] = {0x00, 0x03, 0x5b, 0x03, 0x58, 0xe6, 0x07, 0xdd, 0x02, 0x1a, 0x08, 0x12, 0x3a, 0x00, 0x03, 0x00};
const uint8_t REMOTE_NOTIFY_CHAR_UUID[] = {0x00, 0x00, 0x29, 0x02, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5f, 0x9b, 0x34, 0xfb};
static esp_bt_uuid_t remote_filter_service_uuid = {
.len = ESP_UUID_LEN_128,
.uuid = {.uuid128 = REMOTE_SERVICE_UUID,}, // missing braces around initializer [-Werror=missing-braces]
};
static esp_bt_uuid_t remote_filter_char_uuid = {
.len = ESP_UUID_LEN_128,
.uuid = {.uuid128 = REMOTE_NOTIFY_CHAR_UUID,},
};
thank you!
BLE UUID128
Re: BLE UUID128
Did you try:
or
Code: Select all
static esp_bt_uuid_t remote_filter_char_uuid = {
.len = ESP_UUID_LEN_128,
.uuid = REMOTE_NOTIFY_CHAR_UUID,
};
Code: Select all
static esp_bt_uuid_t remote_filter_char_uuid = {
.len = ESP_UUID_LEN_128,
.uuid.uuid128 = REMOTE_NOTIFY_CHAR_UUID,
};
Re: BLE UUID128
I get this error "error: initializer element is not computable at load time"
I can't copy an array value into another array with just = sign, uuid128 is an array with 16 member see below.
/// UUID type
typedef struct {
#define ESP_UUID_LEN_16 2
#define ESP_UUID_LEN_32 4
#define ESP_UUID_LEN_128 16
uint16_t len; /*!< UUID length, 16bit, 32bit or 128bit */
union {
uint16_t uuid16;
uint32_t uuid32;
uint8_t uuid128[ESP_UUID_LEN_128];
} uuid; /*!< UUID */
} __attribute__((packed)) esp_bt_uuid_t;
i tried this "memcpy((void*)&remote_filter_service_uuid.uuid.uuid128[0],(void*)&REMOTE_SERVICE_UUID[0], sizeof(REMOTE_SERVICE_UUID)); "but then i need to use it inside a function, then i started having other issues
I can't copy an array value into another array with just = sign, uuid128 is an array with 16 member see below.
/// UUID type
typedef struct {
#define ESP_UUID_LEN_16 2
#define ESP_UUID_LEN_32 4
#define ESP_UUID_LEN_128 16
uint16_t len; /*!< UUID length, 16bit, 32bit or 128bit */
union {
uint16_t uuid16;
uint32_t uuid32;
uint8_t uuid128[ESP_UUID_LEN_128];
} uuid; /*!< UUID */
} __attribute__((packed)) esp_bt_uuid_t;
i tried this "memcpy((void*)&remote_filter_service_uuid.uuid.uuid128[0],(void*)&REMOTE_SERVICE_UUID[0], sizeof(REMOTE_SERVICE_UUID)); "but then i need to use it inside a function, then i started having other issues
Re: BLE UUID128
Based on what I'm understanding of the story and code fragments, the following should work:
if it doesn't, post exactly what you coded and the full error message text.
Code: Select all
memcpy(remote_filter_service.uuid.uuid128, REMOTE_SERVICE_UUID, 16);
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32
Re: BLE UUID128
here is the error message "error: 'remote_filter_char_uuid' has an incomplete type &count);"
which is here under
case ESP_GATTC_SEARCH_CMPL_EVT:
status = esp_ble_gattc_get_char_by_uuid( gattc_if,
p_data->search_cmpl.conn_id,
gl_profile_tab[PROFILE_A_APP_ID].service_start_handle,
gl_profile_tab[PROFILE_A_APP_ID].service_end_handle,
remote_filter_char_uuid,
char_elem_result,
&count);
/////////////////this lives in Bluetooth.h that I created///////////////
const uint8_t REMOTE_SERVICE_UUID[] = {0x00, 0x03, 0x5b, 0x03, 0x58, 0xe6, 0x07, 0xdd, 0x02, 0x1a, 0x08, 0x12, 0x3a, 0x00, 0x03, 0x00};
const uint8_t REMOTE_NOTIFY_CHAR_UUID[] = {0x00, 0x00, 0x29, 0x02, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5f, 0x9b, 0x34, 0xfb};
///////////////////////////////////////////////////////////////
/////////////////this lives in Bluetooth.h that I created///////////////
struct esp_bt_uuid_t remote_filter_service_uuid;
struct esp_bt_uuid_t remote_filter_char_uuid;
struct esp_bt_uuid_t notify_descr_uuid;
////////////////////////////////////////////////////////////
/////////////////this lives in Bluetooth.c that I created///////////////
void init_UUID ()
{
remote_filter_service_uuid.len = ESP_UUID_LEN_128;
memcpy((void*)&remote_filter_service_uuid.uuid.uuid128[0],(void*)&REMOTE_SERVICE_UUID[0], sizeof(REMOTE_SERVICE_UUID));
remote_filter_char_uuid.len = ESP_UUID_LEN_128;
memcpy((void*)&remote_filter_char_uuid.uuid.uuid128[0], (void*)&REMOTE_NOTIFY_CHAR_UUID[0], sizeof(REMOTE_NOTIFY_CHAR_UUID));
notify_descr_uuid.len = ESP_UUID_LEN_16;
notify_descr_uuid.uuid.uuid16 = ESP_GATT_UUID_CHAR_CLIENT_CONFIG;
}
////////////////////////////////////////////////////////////////////
which is here under
case ESP_GATTC_SEARCH_CMPL_EVT:
status = esp_ble_gattc_get_char_by_uuid( gattc_if,
p_data->search_cmpl.conn_id,
gl_profile_tab[PROFILE_A_APP_ID].service_start_handle,
gl_profile_tab[PROFILE_A_APP_ID].service_end_handle,
remote_filter_char_uuid,
char_elem_result,
&count);
/////////////////this lives in Bluetooth.h that I created///////////////
const uint8_t REMOTE_SERVICE_UUID[] = {0x00, 0x03, 0x5b, 0x03, 0x58, 0xe6, 0x07, 0xdd, 0x02, 0x1a, 0x08, 0x12, 0x3a, 0x00, 0x03, 0x00};
const uint8_t REMOTE_NOTIFY_CHAR_UUID[] = {0x00, 0x00, 0x29, 0x02, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5f, 0x9b, 0x34, 0xfb};
///////////////////////////////////////////////////////////////
/////////////////this lives in Bluetooth.h that I created///////////////
struct esp_bt_uuid_t remote_filter_service_uuid;
struct esp_bt_uuid_t remote_filter_char_uuid;
struct esp_bt_uuid_t notify_descr_uuid;
////////////////////////////////////////////////////////////
/////////////////this lives in Bluetooth.c that I created///////////////
void init_UUID ()
{
remote_filter_service_uuid.len = ESP_UUID_LEN_128;
memcpy((void*)&remote_filter_service_uuid.uuid.uuid128[0],(void*)&REMOTE_SERVICE_UUID[0], sizeof(REMOTE_SERVICE_UUID));
remote_filter_char_uuid.len = ESP_UUID_LEN_128;
memcpy((void*)&remote_filter_char_uuid.uuid.uuid128[0], (void*)&REMOTE_NOTIFY_CHAR_UUID[0], sizeof(REMOTE_NOTIFY_CHAR_UUID));
notify_descr_uuid.len = ESP_UUID_LEN_16;
notify_descr_uuid.uuid.uuid16 = ESP_GATT_UUID_CHAR_CLIENT_CONFIG;
}
////////////////////////////////////////////////////////////////////
Re: BLE UUID128
this is where the problem was
wrong ----------------> struct esp_bt_uuid_t remote_filter_service_uuid;
correct----------------> esp_bt_uuid_t remote_filter_service_uuid;
because: esp_bt_uuid_t is typedef
typedef struct
{
#define ESP_UUID_LEN_16 2
#define ESP_UUID_LEN_32 4
#define ESP_UUID_LEN_128 16
uint16_t len; /*!< UUID length, 16bit, 32bit or 128bit */
union {
uint16_t uuid16;
uint32_t uuid32;
uint8_t uuid128[ESP_UUID_LEN_128];
} uuid; /*!< UUID */
} __attribute__((packed)) esp_bt_uuid_t;
wrong ----------------> struct esp_bt_uuid_t remote_filter_service_uuid;
correct----------------> esp_bt_uuid_t remote_filter_service_uuid;
because: esp_bt_uuid_t is typedef
typedef struct
{
#define ESP_UUID_LEN_16 2
#define ESP_UUID_LEN_32 4
#define ESP_UUID_LEN_128 16
uint16_t len; /*!< UUID length, 16bit, 32bit or 128bit */
union {
uint16_t uuid16;
uint32_t uuid32;
uint8_t uuid128[ESP_UUID_LEN_128];
} uuid; /*!< UUID */
} __attribute__((packed)) esp_bt_uuid_t;
-
- Posts: 4
- Joined: Fri Aug 03, 2018 8:52 am
Re: BLE UUID128
why not:
Joan
Code: Select all
static esp_bt_uuid_t remote_filter_char_uuid = {
.len = ESP_UUID_LEN_128,
.uuid = {
.uuid128 = {
REMOTE_NOTIFY_CHAR_UUID[0],
REMOTE_NOTIFY_CHAR_UUID[1],
REMOTE_NOTIFY_CHAR_UUID[2],
REMOTE_NOTIFY_CHAR_UUID[3],
REMOTE_NOTIFY_CHAR_UUID[4],
REMOTE_NOTIFY_CHAR_UUID[5],
REMOTE_NOTIFY_CHAR_UUID[6],
REMOTE_NOTIFY_CHAR_UUID[7],
REMOTE_NOTIFY_CHAR_UUID[8],
REMOTE_NOTIFY_CHAR_UUID[9],
REMOTE_NOTIFY_CHAR_UUID[10],
REMOTE_NOTIFY_CHAR_UUID[11],
REMOTE_NOTIFY_CHAR_UUID[12],
REMOTE_NOTIFY_CHAR_UUID[13],
REMOTE_NOTIFY_CHAR_UUID[14],
REMOTE_NOTIFY_CHAR_UUID[15],
},
}
};
Who is online
Users browsing this forum: Google [Bot] and 197 guests