|
|
@ -6,8 +6,6 @@ |
|
|
|
#include <string.h> |
|
|
|
|
|
|
|
#include "sys.h" |
|
|
|
BLE_NUS_DEF(m_nus, NRF_SDH_BLE_TOTAL_LINK_COUNT); /**< BLE NUS service instance. */ |
|
|
|
NRF_BLE_QWR_DEF(m_qwr); /**< Context for the Queued Write module.*/ |
|
|
|
/******************************************************************************* |
|
|
|
* 广播包配置 * |
|
|
|
*******************************************************************************/ |
|
|
@ -203,25 +201,7 @@ void zble_module_init(zble_module_cfg_t* cfg) { |
|
|
|
* 蓝牙服务初始化 * |
|
|
|
*******************************************************************************/ |
|
|
|
{ |
|
|
|
// if (cfg->on_service_init) cfg->on_service_init(); |
|
|
|
|
|
|
|
uint32_t err_code; |
|
|
|
ble_nus_init_t nus_init; |
|
|
|
nrf_ble_qwr_init_t qwr_init = {0}; |
|
|
|
|
|
|
|
// Initialize Queued Write Module. |
|
|
|
qwr_init.error_handler = NULL; |
|
|
|
|
|
|
|
err_code = nrf_ble_qwr_init(&m_qwr, &qwr_init); |
|
|
|
APP_ERROR_CHECK(err_code); |
|
|
|
|
|
|
|
// Initialize NUS. |
|
|
|
memset(&nus_init, 0, sizeof(nus_init)); |
|
|
|
|
|
|
|
nus_init.data_handler = NULL; |
|
|
|
|
|
|
|
err_code = ble_nus_init(&m_nus, &nus_init); |
|
|
|
APP_ERROR_CHECK(err_code); |
|
|
|
if (cfg->on_service_init) cfg->on_service_init(); |
|
|
|
} |
|
|
|
|
|
|
|
/******************************************************************************* |
|
|
@ -235,14 +215,15 @@ void zble_module_init(zble_module_cfg_t* cfg) { |
|
|
|
|
|
|
|
init.advdata.name_type = BLE_ADVDATA_FULL_NAME; |
|
|
|
init.advdata.include_appearance = false; |
|
|
|
init.advdata.flags = BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE; |
|
|
|
// init.advdata.flags = BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE; |
|
|
|
init.advdata.flags = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE; |
|
|
|
|
|
|
|
init.srdata.uuids_complete.uuid_cnt = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]); |
|
|
|
init.srdata.uuids_complete.p_uuids = m_adv_uuids; |
|
|
|
|
|
|
|
init.config.ble_adv_fast_enabled = true; |
|
|
|
init.config.ble_adv_fast_interval = APP_ADV_INTERVAL; |
|
|
|
init.config.ble_adv_fast_timeout = APP_ADV_DURATION; |
|
|
|
init.config.ble_adv_fast_timeout = 0; |
|
|
|
init.evt_handler = on_adv_evt; |
|
|
|
|
|
|
|
err_code = ble_advertising_init(&m_advertising, &init); |
|
|
|