I would like to add NUS, BAS, and SMP services to advertisement. But the following error messages shown on RTT Viewer.
00> *** Booting Zephyr OS build v3.2.99-ncs2 ***
00> [00:00:00.001,617] <inf> main: button long press test
00>
00> Starting button Test example
00> btInit() e
00> bt_passkey_set(123456)
00> btInit() x
00> _btReady(0) e
00> Bluetooth initialized
00> [00:00:00.032,745] <err> bt_adv: Too big advertising data
00> Advertising failed to start (err 0xffffffea)
00> _btReady(0) x
The following are source code.
static const struct bt_data ad[] = {
BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR)),
BT_DATA(BT_DATA_NAME_COMPLETE, DEVICE_NAME, DEVICE_NAME_LEN),
};
static const struct bt_data sd[] = {
BT_DATA_BYTES(BT_DATA_UUID128_ALL, 0x84, 0xaa, 0x60, 0x74, 0x52, 0x8a, 0x8b, 0x86,
0xd3, 0x4c, 0xb7, 0x1d, 0x1d, 0xdc, 0x53, 0x8d),
BT_DATA_BYTES(BT_DATA_UUID128_ALL, BT_UUID_NUS_VAL),
BT_DATA_BYTES(BT_DATA_UUID16_ALL, BT_UUID_16_ENCODE(BT_UUID_BAS_VAL)),
};
int btAdvStart(void) {
int ret = bt_le_adv_start(BT_LE_ADV_CONN, ad, ARRAY_SIZE(ad), sd, ARRAY_SIZE(sd));
if (ret != 0) {
printk("Advertising failed to start (err 0x%x)\n", ret);
return ERROR_ADVERTISING_START_FAIL;
}
return 0;
}