// Initialize LBS. init.led_write_handler = led_write_handler; err_code = ble_lbs_init(&m_lbs, &init); APP_ERROR_CHECK(err_code); } 暂时不看nrf_ble_qwr_init函数~ 主要来看ble_lbs_init,此函数目的是增加led及button的相关Service Characteristic等 uint32_t ble_lbs_init(ble_lbs_t * p_...
staticvoidservices_init(void){ret_code_terr_code;ble_lbs_init_tinit={0};nrf_ble_qwr_init_tqwr_init={0};// Initialize Queued Write Module.qwr_init.error_handler=nrf_qwr_error_handler;err_code=nrf_ble_qwr_init(&m_qwr,&qwr_init);APP_ERROR_CHECK(err_code);// Initialize LBS.init.led...
static void services_init(void) { uint32_t err_code; ble_lbs_init_t init; init.led_write_handler = led_write_handler; err_code = ble_lbs_init(&m_lbs, &init); APP_ERROR_CHECK(err_code); } /**@brief Function for initializing security parameters. */ static void sec_params_init(vo...
leds_init(); //非必要 timers_init(); //非必要 buttons_init(); //非必要 ble_stack_init(); //必要 gap_params_init(); //必要 services_init(); //必要 advertising_init(); //必要 conn_params_init(); //视情况而定,如果连接之后不需要协商连接参数,这个函数可以不要 // Start execution....
for(nrf_section_iter_init(&iter, &sdh_stack_observers);nrf_section_iter_get(&iter) !=NULL;nrf_section_iter_next(&iter)){nrf_sdh_stack_observer_t* p_observer;nrf_sdh_stack_evt_handler_thandler; p_observer = (nrf_sdh_stack_observer_t*) nrf_section_iter_get(&iter);handler = p_obse...
p_section = (my_type_t*)nrf_section_iter_get(&iter); } 三、BLE事件回调 以SDK15.1/ble_app_blinky工程为例, 追踪它的BLE回调事件的调用逻辑。 在main.c –> ble_stack_init()中,调用了: NRF_SDH_BLE_OBSERVER(m_ble_observer, APP_BLE_OBSERVER_PRIO, ble_evt_handler, NULL); ...
nrf_section_iter_t iter;for (nrf_section_iter_init(&iter, &sdh_ble_observers);nrf_section_iter_get(&iter) != NULL;nrf_section_iter_next(&iter)){nrf_sdh_ble_evt_observer_t * p_observer;nrf_sdh_ble_evt_handler_t handler; p_observer = (nrf_sdh_ble_evt_observer_t *)nrf_section_...
static void timers_init(void) { ret_code_t err_code = app_timer_init(); APP_ERROR_CHECK(err_code); // Create a data generation timer for testing throughput. err_code = app_timer_create(&m_timer_throughput_id, APP_TIMER_MODE_REPEATED, data_throughput_timeout_handler); APP_ERROR_...
ble_uuid_t adv_uuids[] = {{LBS_UUID_SERVICE, m_lbs.uuid_type}}; // Build and set advertising data. 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_MOD...
*/staticvoidconn_params_init(void){ret_code_terr_code;ble_conn_params_init_tconstconnection_params_init = { .p_conn_params =NULL, .first_conn_params_update_delay = FIRST_CONN_PARAMS_UPDATE_DELAY, .next_conn_params_update_delay = NEXT_CONN_PARAMS_UPDATE_DELAY, ...