Connecting to a GATT Server that has a custom 128 bit serrvice UUID

ranger3
Posts: 1
Joined: Thu Apr 15, 2021 1:34 pm

Connecting to a GATT Server that has a custom 128 bit serrvice UUID

Postby ranger3 » Wed Apr 28, 2021 11:22 am

Hi,

I'm following the gatt_client tutorial, and I need to modify the code to connect to a gatt server that is advertising a 128 bit custom service UUID.
I have added the required custom UUID in a define: -
  1. #define REMOTE_SERVICE_UUID         {0x12, 0x34, 0x56, 0x0E, 0x53, 0xF4, 0xF5, 0xA4, 0xAE, 0x42, 0xF9, 0x24, 0x12, 0x34, 0x56, 0xE8}
  2. #define REMOTE_NOTIFY_CHAR_UUID     {0x89, 0x78, 0x12, 0x34, 0x53, 0xF4, 0xF5, 0xA4, 0xAE, 0x42, 0xF9, 0x24, 0x12, 0x34, 0x56, 0xE8}
I've then modified the 'remote_filter_service_uuid' from the original: -
  1. static esp_bt_uuid_t remote_filter_service_uuid = {
  2.     .len = ESP_UUID_LEN_16,
  3.     .uuid = {.uuid16 = REMOTE_SERVICE_UUID,},
  4. };
  5.  
  6. static esp_bt_uuid_t remote_filter_char_uuid = {
  7.     .len = ESP_UUID_LEN_16,
  8.     .uuid = {.uuid16 = REMOTE_NOTIFY_CHAR_UUID,},
  9. };
To this, using 128 bit instead of 16: -
  1. static esp_bt_uuid_t remote_filter_service_uuid = {
  2.     .len = ESP_UUID_LEN_128,
  3.     .uuid = {
  4.         .uuid128 = REMOTE_SERVICE_UUID,
  5.     },
  6. };
  7.  
  8. static esp_bt_uuid_t remote_filter_char_uuid = {
  9.     .len = ESP_UUID_LEN_128,
  10.     .uuid = {
  11.         .uuid128 = REMOTE_NOTIFY_CHAR_UUID,
  12.     },
  13. };
The problem is it won't compile - it fails on the following line in the 'gattc_profile_event_handler' function: -
  1. if( p_data->search_res.srvc_id.uuid.uuid.uuid128 == REMOTE_SERVICE_UUID)
With this error: -
  1. In function 'gattc_profile_event_handler':
  2. ../components/ble_comms/ble_comms.c:37:37: error: expected expression before '{' token
  3.  #define REMOTE_SERVICE_UUID         {0x12, 0x34, 0x56, 0x0E, 0x53, 0xF4, 0xF5, 0xA4, 0xAE, 0x42, 0xF9, 0x24, 0x12, 0x34, 0x56, 0xE8}
  4.                                      ^
  5. ../components/ble_comms/ble_comms.c:195:69: note: in expansion of macro 'REMOTE_SERVICE_UUID'
  6.                  if( p_data->search_res.srvc_id.uuid.uuid.uuid128 == REMOTE_SERVICE_UUID)
What am I missing? Any help would be greatly appreciated!

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

Re: Connecting to a GATT Server that has a custom 128 bit serrvice UUID

Postby chegewara » Wed Apr 28, 2021 6:15 pm

You are trying to compare 2 arrays, it wont work this way. Easiest will be to use:

Code: Select all

memcmp()

Who is online

Users browsing this forum: No registered users and 100 guests