From 5bf8ff55d35e08f624b5eb10ba4f53d19a47bf21 Mon Sep 17 00:00:00 2001 From: liminyang Date: Tue, 16 Jun 2020 20:36:33 +0800 Subject: [PATCH 1/2] docs:add 128-bit UUID description Gatt_client demo lacks description.When service and characteristic UUID is 128-bit, should change the order of UUID defined by macro in little-endian storage mode. --- .../Gatt_Client_Example_Walkthrough.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/examples/bluetooth/bluedroid/ble/gatt_client/tutorial/Gatt_Client_Example_Walkthrough.md b/examples/bluetooth/bluedroid/ble/gatt_client/tutorial/Gatt_Client_Example_Walkthrough.md index 8c82d34b1..e102279f4 100644 --- a/examples/bluetooth/bluedroid/ble/gatt_client/tutorial/Gatt_Client_Example_Walkthrough.md +++ b/examples/bluetooth/bluedroid/ble/gatt_client/tutorial/Gatt_Client_Example_Walkthrough.md @@ -484,6 +484,24 @@ Where, ```c #define REMOTE_SERVICE_UUID 0x00FF ``` +There will be a detail to note if the UUID of the service application that the client is interested in is a 128-bit UUID, which is related to the little-endian storage mode of the processor architecture . The struct of UUID is defined as: + +```c +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; /*!< 16bit UUID */ + uint32_t uuid32; /*!< 32bit UUID */ + uint8_t uuid128[ESP_UUID_LEN_128]; /*!< 128bit UUID */ + } uuid; /*!< UUID */ +} __attribute__((packed)) esp_bt_uuid_t; +``` + +In little-endian storage mode, you can define service UUID directly in the normal order if it's a 16-bit or a 32-bit UUID. However, if service UUID is a 128-bit UUID, there is a little difference. For example, if the UUID of the service application that the client is interested in is 12345678-a1b2-c3d4-e5f6-9fafd205e457, `REMOTE_SERVICE_UUID` should be defined as {0x57,0xE4,0x05,0xD2,0xAF,0x9F,0xF6,0xE5,0xD4,0xC3,0xB2,0xA1,0x78,0x56,0x34,0x12}. + The services are then discovered as follows: ```c From 8364bca3f48ad8d1c87754f3844c3e2e7d29302c Mon Sep 17 00:00:00 2001 From: liminyang Date: Wed, 17 Jun 2020 11:58:41 +0800 Subject: [PATCH 2/2] docs:perfect 128-bit UUID description The previous description is not easy for the reader to understand, some changees have been made to perfect it. Closes https://github.com/espressif/esp-idf/issues/5057 --- .../gatt_client/tutorial/Gatt_Client_Example_Walkthrough.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/bluetooth/bluedroid/ble/gatt_client/tutorial/Gatt_Client_Example_Walkthrough.md b/examples/bluetooth/bluedroid/ble/gatt_client/tutorial/Gatt_Client_Example_Walkthrough.md index e102279f4..26a639b8a 100644 --- a/examples/bluetooth/bluedroid/ble/gatt_client/tutorial/Gatt_Client_Example_Walkthrough.md +++ b/examples/bluetooth/bluedroid/ble/gatt_client/tutorial/Gatt_Client_Example_Walkthrough.md @@ -484,7 +484,8 @@ Where, ```c #define REMOTE_SERVICE_UUID 0x00FF ``` -There will be a detail to note if the UUID of the service application that the client is interested in is a 128-bit UUID, which is related to the little-endian storage mode of the processor architecture . The struct of UUID is defined as: +If UUID of the service application the user is interested in is 128-bit, then there is one note below for the user which is relevant with the little-endian storage mode of the processor architecture. +The struct of UUID is defined as: ```c typedef struct { @@ -500,7 +501,7 @@ typedef struct { } __attribute__((packed)) esp_bt_uuid_t; ``` -In little-endian storage mode, you can define service UUID directly in the normal order if it's a 16-bit or a 32-bit UUID. However, if service UUID is a 128-bit UUID, there is a little difference. For example, if the UUID of the service application that the client is interested in is 12345678-a1b2-c3d4-e5f6-9fafd205e457, `REMOTE_SERVICE_UUID` should be defined as {0x57,0xE4,0x05,0xD2,0xAF,0x9F,0xF6,0xE5,0xD4,0xC3,0xB2,0xA1,0x78,0x56,0x34,0x12}. +Note: In little-endian storage mode, you can define service UUID directly in the normal order if it's a 16-bit or a 32-bit UUID, but if service UUID is 128-bit, there is minor difference. For example, if the UUID of the service application that the user is interested in is 12345678-a1b2-c3d4-e5f6-9fafd205e457, `REMOTE_SERVICE_UUID` should be defined as {0x57,0xE4,0x05,0xD2,0xAF,0x9F,0xF6,0xE5,0xD4,0xC3,0xB2,0xA1,0x78,0x56,0x34,0x12}. The services are then discovered as follows: