Adding manufacturer data into both advertising and scan response packets

We have some custom hardware that acts as a peripheral, and currently has the advertising data packet set up as follows:

// Bluetooth Advertising data
static const struct bt_data ad[] = {
	BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR)),   // Sets up advertising parameters
	BT_DATA_BYTES(BT_DATA_UUID128_ALL, BT_UUID_SPD_SERVICE),  				// Defines any Service UUIDs to include in advertising packet
};

BT_UUID_SPD_SERVICE is our custom 128-bit UUID that enables our custom App to filter out all the other peripherals when scanning.

When we start the BLE advertising, this is how we have it set up:

#define DEVICE_NAME CONFIG_BT_DEVICE_NAME  // Device Name - set in proj.conf
#define DEVICE_NAME_LEN (sizeof(DEVICE_NAME)-1)  // Device name is 7 characters in length

#define BT_LE_ADV_CONN_LSR_AD BT_LE_ADV_PARAM(BT_LE_ADV_OPT_CONNECTABLE |\
											BT_LE_ADV_OPT_USE_NAME |\
											BT_LE_ADV_OPT_FORCE_NAME_IN_AD,\
											BT_GAP_ADV_FAST_INT_MIN_1,\
											BT_GAP_ADV_FAST_INT_MAX_2,\
											NULL)

err = bt_le_adv_start(BT_LE_ADV_CONN_LSR_AD, ad, ARRAY_SIZE(ad), sd, ARRAY_SIZE(sd));

We are also populating the scan response packet with a bunch of custom data.  The set up of that looks like this:

Byte # 0 1 2 3 4 - 30
Manufacturer Data Packet Length Data Type Definition (0xFF) Manufacturer Data Tag Manufacturer Data Tag Data

What we are currently trying to add a byte of data into the advertising data packet, so that we can distiguish between different versions of our device that are using the same custom UUID (we need to use the same UUID for both versions).

We modified the advertising data array as follows:

static uint8_t adv_mfg_data = {0x01};

// Bluetooth Advertising data
static const struct bt_data ad[] = {
	BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR)),   // Sets up advertising parameters
	BT_DATA_BYTES(BT_DATA_UUID128_ALL, BT_UUID_SPD_SERVICE),  				// Defines any Service UUIDs to include in advertising packet
    BT_DATA(BT_DATA_MANUFACTURER_DATA, &adv_mfg_data, sizeof(adv_mfg_data)),
};

But even though it looks like we have space in the advertising packet, it seems to be pushing the byte into the Scan Response Packet, as when we read that in, its all scrambled.

When I check the length of the ad[] array prior to attempting to add the extra byte, I get a result of 16 bytes.  When I add the extra byte, it goes up to 24 bytes.  As I understand it, there is a total of 31 bytes available in the advertising packet, so I can't quite understand why we can't add one more in to our current packet and still have things function.

Can anyone assist me with solving this issue?

Regards,

Mike

Parents
  • When I add the extra byte, it goes up to 24 bytes. 

    You have 29 bytes of data excluding length and type. It is strange that the advertising data suddenly jumps to 24 bytes when you add the extra byte.  Could it be that this has to do something with the data alignment?

    When you look at the advertising data, can you see if your manufacturer data is aligned to a byte border?

Reply
  • When I add the extra byte, it goes up to 24 bytes. 

    You have 29 bytes of data excluding length and type. It is strange that the advertising data suddenly jumps to 24 bytes when you add the extra byte.  Could it be that this has to do something with the data alignment?

    When you look at the advertising data, can you see if your manufacturer data is aligned to a byte border?

Children
No Data
Related