实际使用中,我们会用到广播回应包,现在自定义数据示例如下: 1)APP.C文件中修改如下 static void appm_advertising_init(void) { struct app_adv_modes_config_tag adv_config; adv_config.whitelist_enabled = false; adv_config.directed_enabled = false; adv_config.directed_timeout = APP_ADV_DIRECTED_TIMEOUT; adv_config.fast_enabled = true; adv_config.fast_interval = APP_ADV_FAST_INTERVAL; adv_config.fast_timeout = APP_ADV_FAST_TIMEOUT; adv_config.slow_enabled = false; adv_config.slow_interval = APP_ADV_SLOW_INTERVAL; adv_config.slow_timeout = APP_ADV_SLOW_TIMEOUT; appm_adv_init(NULL, &adv_config); uint8_t default_adv_data[ADV_DATA_LEN - 3]; uint16_t adv_len = 0; appm_build_adv_data(ADV_DATA_LEN - 3, &adv_len, (uint8_t*)default_adv_data); appm_adv_set_adv_data((uint8_t*)default_adv_data, adv_len); uint8_t manufa[12] = {0}; // Manufacturer Specific Data manufa[0] = sizeof(manufa) - 1; manufa[1] = APP_ADV_DATATYPE_MANUFACTURER_SPECIFIC_DATA; manufa[2] = 0x01; manufa[3] = 100; manufa[4] = 0x01; manufa[5] = 0x02; manufa[6] = 0x03; manufa[7] = 0x04; manufa[8] = 0x05; manufa[9] = 0x06; manufa[10] = 0x07; manufa[11] = 0x08; uint8_t res_data[APP_ADV_MAX_LEN]; uint8_t res_data_len = sizeof(manufa); memcpy(res_data, manufa, sizeof(manufa)); appm_adv_set_res_data(res_data, res_data_len); } 2)抓包工具查看回应包 |