下面是一个简单的示例,展示如何利用 Scan Response 数据扩展广播内容:
c// 广播数据
uint8_t adv_data[] = {
0x02, 0x01, 0x06, // 标头
0x11, 0x07, 0xAB, 0xCD, 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0, 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC // UUID
};
// 扫描响应数据
uint8_t scan_rsp_data[] = {
0x0F, 0x09, 'E', 'x', 'a', 'm', 'p', 'l', 'e', ' ', 'D', 'e', 'v', 'i', 'c', 'e'
};
ble_gap_adv_params_t adv_params = {
.interval = 100,
.type = BLE_GAP_ADV_TYPE_ADV_IND,
};
sd_ble_gap_adv_data_set(adv_data, sizeof(adv_data), scan_rsp_data, sizeof(scan_rsp_data));
sd_ble_gap_adv_start(&adv_params);
|