Understanding BLE advertisment packets

zazas321
Posts: 165
Joined: Mon Feb 01, 2021 9:41 am

Understanding BLE advertisment packets

Postby zazas321 » Tue Jan 25, 2022 12:42 pm

Hello. I am learning about the BLE and would like to understand about the advertisment packets. My BLE is configured as following:

Code: Select all

// config adv data

static uint8_t test_manufacturer[3]={'E', 'S', 'P'};

static uint8_t sec_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, 0x18, 0x0D, 0x00, 0x00,
};

static esp_ble_adv_data_t test_adv_config = {
    .set_scan_rsp = false,
    .include_txpower = true,
    .min_interval = 0x0006, //slave connection min interval, Time = min_interval * 1.25 msec
    .max_interval = 0x0010, //slave connection max interval, Time = max_interval * 1.25 msec
    .appearance = 0x00,
    .manufacturer_len = 0, 
    .p_manufacturer_data =  NULL, 
    .service_data_len = 0,
    .p_service_data = NULL,
    .service_uuid_len = sizeof(sec_service_uuid),
    .p_service_uuid = sec_service_uuid,
    .flag = (ESP_BLE_ADV_FLAG_GEN_DISC | ESP_BLE_ADV_FLAG_BREDR_NOT_SPT),
};

// config scan response data
static esp_ble_adv_data_t test_scan_response_conf= {
    .set_scan_rsp = true,
    .include_name = true,
    .manufacturer_len = sizeof(test_manufacturer),
    .p_manufacturer_data = test_manufacturer,
};

static esp_ble_adv_params_t test_adv_params= {
    .adv_int_min        = 0x100,
    .adv_int_max        = 0x100,
    .adv_type           = ADV_TYPE_IND,
    .own_addr_type      = BLE_ADDR_TYPE_PUBLIC,
    .channel_map        = ADV_CHNL_ALL,
    .adv_filter_policy = ADV_FILTER_ALLOW_SCAN_ANY_CON_ANY,
};


I have commented out the scan response as I am not fully understanding what it does.

Code: Select all

       esp_err_t ret = esp_ble_gap_config_adv_data(&test_adv_config );
        if (ret){
            ESP_LOGE(GATTS_TABLE_TAG, "config adv data failed, error code = %x", ret);
        }else{
            adv_config_done |= ADV_CONFIG_FLAG;
        }

/*
        ret = esp_ble_gap_config_adv_data(&test_scan_response_conf);
        if (ret){
            ESP_LOGE(GATTS_TABLE_TAG, "config adv data failed, error code = %x", ret);
        }else{
            adv_config_done |= SCAN_RSP_CONFIG_FLAG;
        }
*/
In the lightBlue APP I see :

https://ibb.co/YhHBtjF

I want to understand the following:

1. What is the purpose of sec_service_uuid and where can I see it in the advertisment packet?


2. I assume esp_ble_adv_data_t configures how the data should be advertised. I cant find the connection between this structure and what I see in the LightBlue.

3. In my attribute table, the main service is configured :

Code: Select all

[TEST_SERVICE]={{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_16, (uint8_t *)&primary_service_uuid, ESP_GATT_PERM_READ,sizeof(uint16_t), sizeof(GATTS_SERVICE_UUID_TEST), (uint8_t *)&GATTS_SERVICE_UUID_TEST}},
In the lightblue app, advertised service UUID's is shown as:
00000d18-0000-1000-8000-00905f9b34fb

I am trying to understand why is it this service ID? With what parameter can I change that?

4. Raw advertisement packet is shown as:
0x02 01 06 02 0A 03 03 03 18 0D 05 12 06 00 10 00 00 ......

I am trying to understand how this advertisement packet is configured and it means?


Could someone help me understand the structure of this manufacturer specifc data and where does this data come from?
Last edited by zazas321 on Wed Jan 26, 2022 5:48 am, edited 2 times in total.

Who is online

Users browsing this forum: No registered users and 23 guests