/************************************************************************* NAME InitUserFeatures DESCRIPTION This function initialises all of the user features - this will result in a poweron message if a user event is configured correctly and the device will complete the power on RETURNS */ void InitUserFeatures ( void ) { /* Set to a known value*/ theSink.VoiceRecognitionIsActive = hfp_invalid_link ; theSink.buttons_locked = FALSE; theSink.last_outgoing_ag = hfp_primary_link; theSink.csr_speech_recognition_is_active = FALSE ; if (theSink.VolumeOrientationIsInverted) { MessageSend ( &theSink.task , EventUsrVolumeOrientationInvert , 0 ) ; } /* set the LED enable disable state which now persists over a reset */ #ifndef NO_LED if (theSink.theLEDTask->gLEDSEnabled) { LedManagerEnableLEDS () ; } else { LedManagerDisableLEDS () ; } #endif /* Set inquiry tx power and RSSI inquiry mode */ ConnectionWriteInquiryTx(theSink.conf2->rssi.tx_power); ConnectionWriteInquiryMode(&theSink.task, inquiry_mode_eir); /* RSSI with EIR data */ /* Check if we're here as result of a watchdog timeout */ powerManagerCheckPanic(); /*automatically power on the heasdet as soon as init is complete*/ if(theSink.panic_reconnect) { INIT_DEBUG(("INIT: Recover to state 0x%X\n", theSink.rundata->old_state)); if(theSink.rundata->old_state != deviceLimbo) MessageSend( &theSink.task , EventSysPowerOnPanic , NULL ) ; else theSink.panic_reconnect = FALSE; } else if((theSink.features.AutoPowerOnAfterInitialisation && !powerManagerIsChargerConnected())) { INIT_DEBUG(("INIT: Power On\n")); MessageSend( &theSink.task , EventUsrPowerOn , NULL ) ; } /* initialise the default volume levels */ theSink.volume_levels->a2dp_volume[0].masterVolume = ((theSink.conf1->volume_config.volume_control_config.no_of_steps * theSink.features.DefaultA2dpVolLevel)/ VOLUME_NUM_VOICE_STEPS); theSink.volume_levels->a2dp_volume[1].masterVolume = ((theSink.conf1->volume_config.volume_control_config.no_of_steps * theSink.features.DefaultA2dpVolLevel)/ VOLUME_NUM_VOICE_STEPS); /* set task to receive system messages */ MessageSystemTask(&theSink.task); INIT_DEBUG(("INIT: complete\n")); }
/**************************************************************************** NAME handleClInitCfm DESCRIPTION Handles the CL library initialisation result. */ static void handleClInitCfm(const CL_INIT_CFM_T *cfm) { mvdAppState app_state = the_app->app_state; switch (app_state) { case AppStateInitialising: { if (cfm->status == success) { /* Configure Mode4 Security Settings */ ConnectionSmSecModeConfig(&the_app->task, cl_sm_wae_acl_owner_none, FALSE, TRUE); /* Turn off all SDP security */ ConnectionSmSetSecurityLevel(protocol_l2cap, 1, ssp_secl4_l0, TRUE, FALSE, FALSE); if (cfm->version == bluetooth2_1) { /* EIR inquiry mode */ ConnectionWriteInquiryMode(&the_app->task, inquiry_mode_eir); } /* Set default role switch policy */ ConnectionSetRoleSwitchParams(NULL); initProfile(); } else { DEBUG_CL((" App failed to init CL\n")); Panic(); } break; } default: { unexpectedClMessage(app_state, CL_INIT_CFM); break; } } }