BLE GATT advertising raw data vs normal data

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

BLE GATT advertising raw data vs normal data

Postby zazas321 » Wed Aug 18, 2021 6:30 am

Hello. I am learning about the BLE and have the example code running:
https://github.com/espressif/esp-idf/bl ... through.md

I am analysing the code line by line trying to understand it better so I can use it efficiently. Could someone help me understand what is up with the raw data advertising and scan response. When do I want to use raw data versus the normal structure?

Code: Select all

//DISABLE RAW DATA ADV
//#define CONFIG_SET_RAW_ADV_DATA



#ifdef CONFIG_SET_RAW_ADV_DATA
static uint8_t raw_adv_data[] = {
        // flags 
        0x02, 0x01, 0x06,
        // tx power
        0x02, 0x0a, 0xeb,
        // service uuid 
        0x03, 0x03, 0xFF, 0x00,
        // device name 
        0x0f, 0x09, 'E', 'S', 'P', '_', 'G', 'A', 'T', 'T', 'S', '_', 'D','E', 'M', 'O'
};
static uint8_t raw_scan_rsp_data[] = {
        // flags 
        0x02, 0x01, 0x06,
        // tx power 
        0x02, 0x0a, 0xeb,
        // service uuid 
        0x03, 0x03, 0xFF,0x00
};



#else
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,
};

/* The length of adv data must be less than 31 bytes */
static esp_ble_adv_data_t adv_data = {
    .set_scan_rsp        = false,
    .include_name        = true,
    .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,    //TEST_MANUFACTURER_DATA_LEN,
    .p_manufacturer_data = NULL, //test_manufacturer,
    .service_data_len    = 0,
    .p_service_data      = NULL,
    .service_uuid_len    = sizeof(service_uuid),
    .p_service_uuid      = service_uuid,
    .flag = (ESP_BLE_ADV_FLAG_GEN_DISC | ESP_BLE_ADV_FLAG_BREDR_NOT_SPT),
};

// scan response data
static esp_ble_adv_data_t scan_rsp_data = {
    .set_scan_rsp        = true,
    .include_name        = true,
    .include_txpower     = true,
    .min_interval        = 0x0006,
    .max_interval        = 0x0010,
    .appearance          = 0x00,
    .manufacturer_len    = 0, //TEST_MANUFACTURER_DATA_LEN,
    .p_manufacturer_data = NULL, //&test_manufacturer[0],
    .service_data_len    = 0,
    .p_service_data      = NULL,
    .service_uuid_len    = sizeof(service_uuid),
    .p_service_uuid      = service_uuid,
    .flag = (ESP_BLE_ADV_FLAG_GEN_DISC | ESP_BLE_ADV_FLAG_BREDR_NOT_SPT),
};


When selecting RAW data adv mode, I only advertise the following data is that right?

Code: Select all

static uint8_t raw_adv_data[] = {
        // flags 
        0x02, 0x01, 0x06,
        // tx power
        0x02, 0x0a, 0xeb,
        // service uuid 
        0x03, 0x03, 0xFF, 0x00,
        // device name 
        0x0f, 0x09, 'E', 'S', 'P', '_', 'G', 'A', 'T', 'T', 'S', '_', 'D','E', 'M', 'O'
};
But when raw data is disabled, I can control many parameters such as min/max interval and others..


Can someone explain me when raw data should be used and how it should be used efficiently? How can I determine whether I need raw data adv for my project or not

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

Re: BLE GATT advertising raw data vs normal data

Postby chegewara » Fri Aug 20, 2021 10:09 am

1) esp_ble_adv_data_t - is data stucture that has predefined fields for simplified usage
2) raw data is more flexible, but requires knowledge how to create data buffer; here you can find full list of types you can use in raw data:
https://btprodspecificationrefs.blob.co ... rofile.pdf

Who is online

Users browsing this forum: No registered users and 94 guests