How to advertise non-standard data in BLE

DerrickLau
Posts: 7
Joined: Mon Apr 13, 2020 9:09 pm

How to advertise non-standard data in BLE

Postby DerrickLau » Tue Jan 24, 2023 5:17 am

I am writing a BLE application that will advertise the number 0x0A040102A601 on all channels with manufacturer ID 0x183. For the structure esp_ble_adv_data_t, how do I put 0x0A040102A601 in p_service_data and 0x183 in p_manufacturer_data? My current method below doesn't work:

I split the hexadecimal into several bytes and populated an array with the values:

Code: Select all

uint8_t ManufacturerData[3]; 
ManufacturerData[0] = 0x01;
ManufacturerData[1] = 0x08;
ManufacturerData[2] = 0x03;

advertisingData[0] = 0x00;
advertisingData[1] = 0x0A;
advertisingData[2] = 0x00;
advertisingData[3] = 0x04;
advertisingData[4] = 0x00;
advertisingData[5] = 0x01;
advertisingData[6] = 0x00;
advertisingData[7] = 0x02;
advertisingData[8] = 0x0A;
advertisingData[9] = 0x06;
advertisingData[10] = 0x00;
advertisingData[11] = 0x01;
I then assigned the arrays, along with their sizes, to esp_ble_adv_data_t:

Code: Select all

.set_scan_rsp = false;
.include_name = true;
.include_txpower = true;
.min_interval = 0x0006;
.max_interval = 0x0010;
.appearance = 0x00;
.manufacturer_len = sizeof(uint8_t) * 4;
.p_manufacturer_data = disneyManufacturerData;
.service_data_len = 12 * sizeof(uint8_t);
.p_service_data = advertisingData;
.service_uuid_len = 0;
.p_service_uuid = NULL;
.flag = (ESP_BLE_ADV_FLAG_GEN_DISC | ESP_BLE_ADV_FLAG_BREDR_NOT_SPT);
What am I doing wrong please?

DerrickLau
Posts: 7
Joined: Mon Apr 13, 2020 9:09 pm

Re: How to advertise non-standard data in BLE

Postby DerrickLau » Wed Jan 25, 2023 4:22 am

Thanks everyone! Solved the issue by checking another example.

Who is online

Users browsing this forum: Google [Bot] and 223 guests