void app_connection_func(ke_task_id_t task_id, struct gapc_connection_req_ind const *param) { /*-------------------------------------------------------------- * ENABLE REQUIRED PROFILES *-------------------------------------------------------------*/ #if (BLE_SPOTA_RECEIVER) app_spotar_enable(); #endif //BLE_SPOTA_RECEIVER #if BLE_BATT_SERVER batt_level = 0; old_batt_level = 0; app_batt_enable(batt_level, old_batt_level); app_batt_poll_start(); #endif // BLE_BATT_SERVER #if BLE_FINDME_TARGET app_findt_enable(); #endif // BLE_FINDME_TARGET #if BLE_FINDME_LOCATOR app_findl_enable(); #endif //BLE_FINDME_LOCATOR #if (BLE_APP_PRESENT) app_dis_enable_prf(app_env.conhdl); #endif }
void app_connection_func(struct gapc_connection_req_ind const *param) { if (app_env.conidx != GAP_INVALID_CONIDX) { #if (BLE_DIS_SERVER) app_dis_enable_prf(app_env.conhdl); #endif #if (BLE_SAMPLE128) app_sample128_enable(); #endif //这个timer 是10ms的时基100*10ms=1S //ke_timer_set(APP_SAMPLE128_TIMER,TASK_APP,Sample_LED_Blink); /************************************************** Handle connection request event. Enable required profiles i.e. *****************************************************/ //ke_timer_set(TASK_APP,TASK_APP,50); ke_state_set(TASK_APP, APP_CONNECTED); // Retrieve the connection info from the parameters app_env.conhdl = param->conhdl; app_env.peer_addr_type = param->peer_addr_type; memcpy(app_env.peer_addr.addr, param->peer_addr.addr, BD_ADDR_LEN); # if (BLE_APP_SEC) // send connection confirmation app_connect_confirm(app_sec_env.auth); # else // (BLE_APP_SEC) // send connection confirmation app_connect_confirm(GAP_AUTH_REQ_NO_MITM_NO_BOND); # endif // (BLE_APP_SEC) } else { // No connection has been establish, restart advertising //app_adv_start(); } return; }