This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Advertising BLE FOTA service and custom service with Zephyr

I am having problems advertising both FOTA and a custom service.  I started with the peripheral sample (zephyr\samples\bluetooth\peripheral) and the smp_svr sample (\zephyr\samples\subsys\mgmt\mcumgr\smp_svr)

In the peripheral sample, the advertising data is this:

static const struct bt_data ad[] = {
  BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR)),
  BT_DATA_BYTES(BT_DATA_UUID16_ALL,
    BT_UUID_16_ENCODE(BT_UUID_HRS_VAL),
    BT_UUID_16_ENCODE(BT_UUID_BAS_VAL),
    BT_UUID_16_ENCODE(BT_UUID_CTS_VAL)),
  BT_DATA_BYTES(BT_DATA_UUID128_ALL,
    0xf0, 0xde, 0xbc, 0x9a, 0x78, 0x56, 0x34, 0x12,
    0x78, 0x56, 0x34, 0x12, 0x78, 0x56, 0x34, 0x12),
};

In the smp_svr sample, the advertising data for the FOTA service is this:

static const struct bt_data ad[] = {
  BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR)),
  BT_DATA_BYTES(BT_DATA_UUID128_ALL,
    0x84, 0xaa, 0x60, 0x74, 0x52, 0x8a, 0x8b, 0x86,
    0xd3, 0x4c, 0xb7, 0x1d, 0x1d, 0xdc, 0x53, 0x8d),
};

In both samples, this array is passed into the bt_le_adv_start function, although the smp_svr calls the advertising function through the work queue (struct k_work).

My question is, how do I advertise both services?  I was not able to find any documentation on the format of the ad[] array