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