I took examples from the "examples/bluetooth" folder in esp_idf and no one is working correctly when activating CONFIG_SET_RAW_ADV_DATA
I made few tests and I report here the simplest:
working on "examples/bluetooth/ble_compatibility_test"
I simply changed (activating( the define for CONFIG_SET_RAW_ADV_DATA in ble_compatibility_test.c
Code: Select all
#define CONFIG_SET_RAW_ADV_DATA 1
The same, but modifying the correct strutcts, I made in "esp_ble_adv_data_t adv_data" and "esp_ble_adv_data_t scan_rsp_data"
First test, I compiled and loaded the example in ESP32 using the code WITHOUT activating CONFIG_SET_RAW_ADV_DATA
nRF Connect on my iPhone showed me manufacturer data and twice the Service UUID are advertized.
(why do we have to define the 128bit Service UUID two times???? once in adv_data and once in scan_rsp_data).
Code: Select all
//#define CONFIG_SET_RAW_ADV_DATA 1
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,
};
static uint8_t test_manufacturer[] = {0x55, 0xaa, 0x55, 0xaa };
/* 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 = 0x20,
.max_interval = 0x40,
.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 = 0x20,
.max_interval = 0x40,
.appearance = 0x00,
// .manufacturer_len = 0, //TEST_MANUFACTURER_DATA_LEN,
// .p_manufacturer_data = NULL, //&test_manufacturer[0],
.manufacturer_len = sizeof(test_manufacturer),
.p_manufacturer_data = test_manufacturer,
.service_data_len = 0,
.p_service_data = NULL,
.service_uuid_len = 16,
.p_service_uuid = service_uuid,
.flag = (ESP_BLE_ADV_FLAG_GEN_DISC | ESP_BLE_ADV_FLAG_BREDR_NOT_SPT),
};
https://www.dropbox.com/s/iljcv26iecg0r ... 1.PNG?dl=0
After that I tried to activate CONFIG_SET_RAW_ADV_DATA inserting the manufacturer data in raw_adv_data.
nRF Connect showed me the manufacturer data correctly but only one time the Service UUID (ignoring the one in raw_scan_rsp_data ??)
Code: Select all
#define CONFIG_SET_RAW_ADV_DATA 1
#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 */
0x0E, 0x09, 'B', 'L', 'E', '_', 'C', 'O','M', 'P', '_', 'R','A', 'W', '1'
/* DMT Manufacturer Data */
,0x05, 0xff, 0x55, 0xaa, 0x55, 0xaa
};
static uint8_t raw_scan_rsp_data[] = {
/* flags */
0x02, 0x01, 0x06,
/* tx power */
0x02, 0x0a, 0xeb,
/* service uuid */
0x03, 0x03, 0xFF,0x00
/* DMT Manufacturer Data */
//,0x05, 0xff, 0x55, 0xaa, 0x55, 0xaa
};
https://www.dropbox.com/s/kqesx9oym9lqs ... 3.PNG?dl=0
Last test has been activation of CONFIG_SET_RAW_ADV_DATA and setting manufacturer data in raw_scan_rsp_data.
nRF Connect didn't showed me any manufacturer data and only one time the Service UUID (ignoring all the data in raw_scan_rsp_data).
Code: Select all
#define CONFIG_SET_RAW_ADV_DATA 1
#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 */
0x0E, 0x09, 'B', 'L', 'E', '_', 'C', 'O','M', 'P', '_', 'R','A', 'W', '0'
/* DMT Manufacturer Data */
//,0x05, 0xff, 0x55, 0xaa, 0x55, 0xaa
};
static uint8_t raw_scan_rsp_data[] = {
/* flags */
0x02, 0x01, 0x06,
/* tx power */
0x02, 0x0a, 0xeb,
/* service uuid */
0x03, 0x03, 0xFF,0x00
/* DMT Manufacturer Data */
,0x05, 0xff, 0x55, 0xaa, 0x55, 0xaa
};
https://www.dropbox.com/s/jbqn8xim5o8hp ... 2.PNG?dl=0
I tried also to modify the parameters in
Code: Select all
static esp_ble_adv_params_t adv_params = {
.adv_int_min = 0x40,
.adv_int_max = 0x40,
.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,
};
Code: Select all
static esp_ble_adv_params_t adv_params = {
.adv_int_min = 0x40,
.adv_int_max = 0x40,
.adv_type = ADV_TYPE_SCAN_IND,
.own_addr_type = BLE_ADDR_TYPE_PUBLIC,
.channel_map = ADV_CHNL_ALL,
.adv_filter_policy = ADV_FILTER_ALLOW_SCAN_ANY_CON_ANY,
};
A part these little changed I didn't make any change to the code provided by Espressif.
Am I making something wrong ??
Ciao
Daniele