S130同时支持中央设备和外围设备在利用调试的时候出现广播名超时停止发布修改如下内容:
static void advertising_init(void)
{
uint32_t err_code;
ble_advdata_t advdata;
// Build advertising data struct to pass into @ref ble_advertising_init.
memset(&advdata, 0, sizeof(advdata));
advdata.name_type = BLE_ADVDATA_FULL_NAME;
advdata.include_appearance = true;
advdata.flags = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE; //控制连接模式
advdata.uuids_complete.uuid_cnt = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
advdata.uuids_complete.p_uuids = m_adv_uuids;
ble_adv_modes_config_t options = {0};
options.ble_adv_fast_enabled = BLE_ADV_FAST_ENABLED;
options.ble_adv_fast_interval = APP_ADV_INTERVAL;
options.ble_adv_fast_timeout = APP_ADV_TIMEOUT_IN_SECONDS;
err_code = ble_advertising_init(&advdata, NULL, &options, on_adv_evt, NULL);
APP_ERROR_CHECK(err_code);
}
advdata.flags 中的广播类型修改为可以一直广播模式如上红色标记处
options.ble_adv_fast_enabled = BLE_ADV_FAST_ENABLED; //广播类型为fast类型广播
options.ble_adv_fast_interval = APP_ADV_INTERVAL;
options.ble_adv_fast_timeout = APP_ADV_TIMEOUT_IN_SECONDS; //这个是超时时间
宏定义APP_ADV_TIMEOUT_IN_SECONDS为0可以取消超时不发送广播
注意个人在完成中由于原有例程中含有很多打印信息,打印初始化程序被屏蔽造成在连接中意外断开通过宏定义修改屏蔽打印信息NRF_LOG-USES_UART=0