Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BLE : How to expose 128bits UUID of a characteristic (IDFGH-4855) #3050

Closed
Marc-Aurele opened this issue Feb 13, 2019 · 10 comments
Closed

BLE : How to expose 128bits UUID of a characteristic (IDFGH-4855) #3050

Marc-Aurele opened this issue Feb 13, 2019 · 10 comments
Assignees
Labels
Resolution: Done Issue is done internally Status: Done Issue is done internally

Comments

@Marc-Aurele
Copy link

Marc-Aurele commented Feb 13, 2019

Hello,

My characteristics expose only 16 bits instead of full UUID (128bits). Is there a way to expose the full UUID ?

static const uint16_t custom_svc        = 0xFF00;
static const uint16_t custom_str_uuid   = 0xFF01;
static const uint8_t custom_ccc[2]      = {0x00, 0x00};
static uint8_t  custom_str_value[10+1]  = "NULL";

#define GATTS_DEMO_CHAR_VAL_LEN_MAX 500

static const esp_gatts_attr_db_t custom_att_db[CUSTOM_IDX_NB] =
{
    /* Custom service Declaration */
    [CUSTOM_IDX_SVC]            = {{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_16, (uint8_t *)&primary_service_uuid, ESP_GATT_PERM_READ,
                                    sizeof(uint16_t), sizeof(custom_svc), (uint8_t *)&custom_svc}},

    /* Characteristic Declaration */
    [CUSTOM_IDX_CHAR]           = {{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_16, (uint8_t *)&character_declaration_uuid, ESP_GATT_PERM_READ,
                                    CHAR_DECLARATION_SIZE,CHAR_DECLARATION_SIZE, (uint8_t *)&char_prop_read_write_notify}},

    /* Characteristic Value */
    [CUSTOM_IDX_CHAR_VAL]       = {{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_16, (uint8_t *)&custom_str_uuid, ESP_GATT_PERM_WRITE|ESP_GATT_PERM_READ,
                                    GATTS_DEMO_CHAR_VAL_LEN_MAX, sizeof(custom_str_value), (uint8_t *)custom_str_value}},

    /* Client Characteristic Configuration Descriptor */
    [CUSTOM_IDX_CHAR_CFG]       = {{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_16, (uint8_t *)&character_client_config_uuid, ESP_GATT_PERM_READ | ESP_GATT_PERM_WRITE,
                                    sizeof(uint16_t), sizeof(custom_ccc), (uint8_t *)custom_ccc}},
};

Regards,

Aurélien

@chegewara
Copy link
Contributor

Dou you want to have service with 128 bit UUID or advertise service with 128 bit UUID?

@Marc-Aurele
Copy link
Author

Hi @chegewara
Once my device is paired, I want all my characteristics expose a 128 bits UUID if possible. For now, it seems my characteristics only expose a 16 bits UUID.
Regards,

@Weijian-Espressif
Copy link
Collaborator

@chegewara,
thanks for your help.
@Marc-Aurele ,
Has your problem been solved?

@Marc-Aurele
Copy link
Author

Marc-Aurele commented Feb 27, 2019

Hi all,

Thank you very much @chegewara for the proposition but i'm afraid to not understand exactly what you mean. Indeed, what i want is the following. Here are two devices :

capture d ecran de 2019-02-27 12-13-40

These two devices expose custum characteristics (red border)
Mine is on the left, but as you can see, it exposes only 16 bits uuid whereas the one on the right exposes the full 128 bits uuid.
Maybe i'm missing something in the link you attached to your previous post.

Regards,

@chegewara
Copy link
Contributor

https://github.com/espressif/esp-idf/blob/master/examples/bluetooth/gatt_server_service_table/main/gatts_table_creat_demo.c#L103-L104

https://github.com/espressif/esp-idf/blob/master/examples/bluetooth/gatt_server_service_table/main/gatts_table_creat_demo.c#L120-L121

If you setup it with different UUIDs then you can advertise 2 different 128bit UUIDs at the same time.
Remember this option is to use with normal advertising, if you are using raw advertising then you need to build advertising packet byte by byte.

@Marc-Aurele
Copy link
Author

Thank you very much @chegewara ;)

@hcanak
Copy link

hcanak commented Mar 2, 2021

Hello,
I have a question about the same project (gatts_table_creat_demo.c).
I want to "advertise" service with 128 bit UUID. In the example file line 85-89 defines 128bit UUID. See below;

static uint8_t service_uuid[16] = {
/* LSB <--------------------------------------------------------------------------------> MSB */
//first uuid, 16bit, [12],[13] is the value
0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80, 0x00, 0x10, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00,
};

When i compile and run the project it does NOT advertise above 128bit UUID instead it advertise 2 "0x00FF" services!!!. Please see attachment of LightBlue caps.
Inked2021-03-02 20 21_LI

Now, my questions;

  1. Although we supplied one 128bit UUID in line 85-89, we get responce of two 16bit UUIDs (0x00FF).
    How can i get 128bit advertisement UUID?
  2. When i change service_uuid[12] and service_uuid[13], it advertise that value as it said in the comment line 87. Why do we get two 16bit service UUIDs while we set only one 16bit UUID?

Thanks in advance.

@github-actions github-actions bot changed the title BLE : How to expose 128bits UUID of a characteristic BLE : How to expose 128bits UUID of a characteristic (IDFGH-4855) Mar 2, 2021
@xulongzhuang
Copy link

xulongzhuang commented Apr 6, 2021

Hello, @hcanak
First, the two UUIDs are displayed because the broadcast data and scan response data are configured at the same time. You can remove esp_ble_gap_config_adv_data(&scan_rsp_data) or esp_ble_gap_config_scan_rsp_data_raw(raw_scan_rsp_data, sizeof(raw_scan_rsp_data)) to display only one service uuid.
Second, the reason why 128 bit UUID is set but only 16 bit UUID is displayed in the broadcast is the return value of the following uuidType function, The base of service_uuid is the same as BASE_UUID, so there is no need to put all 128 bit UUIDs in the broadcast, unless we change service_uuid and BASE_UUID are very different

int uuidType(unsigned char *p_uuid)
{
    int i = 0;
    int match = 0;
    int all_zero = 1;

    for (i = 0; i != 16; ++i) {
       if (i == 12 || i == 13) {
            continue;
        }  

        if (p_uuid[i] == BASE_UUID[i]) {
            ++match;
        }

        if (p_uuid[i] != 0) {
            all_zero = 0;
        }
    }
    if (all_zero) {
        return 0;
    }
    if (match == 12) {
        return LEN_UUID_32;
    }
    if (match == 14) {
        return LEN_UUID_16;
    }
    return LEN_UUID_128;
}

@HieuDAY1
Copy link

@chegewara Can you reshare the link?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: Done Issue is done internally Status: Done Issue is done internally
Projects
None yet
Development

No branches or pull requests

9 participants