BLE UUID128

Alen59
Posts: 25
Joined: Mon Mar 19, 2018 12:00 pm

BLE UUID128

Postby Alen59 » Mon Apr 16, 2018 9:27 pm

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!

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

Re: BLE UUID128

Postby chegewara » Tue Apr 17, 2018 6:01 pm

Did you try:

Code: Select all

static esp_bt_uuid_t remote_filter_char_uuid = {
.len = ESP_UUID_LEN_128,
.uuid =  REMOTE_NOTIFY_CHAR_UUID,
};
or

Code: Select all

static esp_bt_uuid_t remote_filter_char_uuid = {
.len = ESP_UUID_LEN_128,
.uuid.uuid128 = REMOTE_NOTIFY_CHAR_UUID,
};

Alen59
Posts: 25
Joined: Mon Mar 19, 2018 12:00 pm

Re: BLE UUID128

Postby Alen59 » Thu Apr 19, 2018 8:01 pm

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

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

Re: BLE UUID128

Postby kolban » Fri Apr 20, 2018 2:03 am

Based on what I'm understanding of the story and code fragments, the following should work:

Code: Select all

memcpy(remote_filter_service.uuid.uuid128, REMOTE_SERVICE_UUID, 16);
if it doesn't, post exactly what you coded and the full error message text.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

Alen59
Posts: 25
Joined: Mon Mar 19, 2018 12:00 pm

Re: BLE UUID128

Postby Alen59 » Fri Apr 20, 2018 4:39 pm

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;

}
////////////////////////////////////////////////////////////////////

Alen59
Posts: 25
Joined: Mon Mar 19, 2018 12:00 pm

Re: BLE UUID128

Postby Alen59 » Tue Apr 24, 2018 2:40 pm

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;

Joan Daddle
Posts: 4
Joined: Fri Aug 03, 2018 8:52 am

Re: BLE UUID128

Postby Joan Daddle » Fri Aug 03, 2018 9:05 am

why not:

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],
    },
  }
};
Joan

Who is online

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