⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 headset_configmanager.c

📁 bluelab的一个很好的例程
💻 C
📖 第 1 页 / 共 2 页
字号:
    ConfigRetrieve(PSKEY_LINK_LOSS_NUM_RETRIES , &theHeadset->LinkLossNumRetries , sizeof(uint16) ) ;
   
    CONF_DEBUG(("CONF: NumLL Retries [%x]\n", theHeadset->LinkLossNumRetries));
}


/****************************************************************************
NAME 
  configManagerPIOBlock

DESCRIPTION
  Read the system PIO block and configure accordingly
 
RETURNS
  void
*/ 
static void configManagerPIOBlock ( hsTaskData * theHeadset ) 
{
    /* Initialise the memory */
    memset(&theHeadset->PIO , 0 , sizeof ( PIO_block));

	/* Read output PIO assignments */
    ConfigRetrieve(PSKEY_PIO_BLOCK, &theHeadset->PIO, sizeof(PIO_block));
  	
    CONF_DEBUG(("Co [%x][%x]\n" , theHeadset->PIO.PowerOnPIOEnabled , theHeadset->PIO.PowerOnPIO )) ;
    CONF_DEBUG(("Co [%x][%x]\n" , theHeadset->PIO.IncomingRingPIOEnabled , theHeadset->PIO.IncomingRingPIO )) ;
    CONF_DEBUG(("Co [%x][%x]\n" , theHeadset->PIO.OutgoingRingPIOEnabled , theHeadset->PIO.OutgoingRingPIO )) ;

	/* Read input PIO assignments */
	ConfigRetrieve(PSKEY_INPUT_PIO_BLOCK, &theHeadset->input_PIO, sizeof(input_pio_config_type));
	
}

/****************************************************************************
NAME 
  configManagerTimeouts

DESCRIPTION
  Read and configure the automatic switch off time if the range allows
    Also now handles the power on timeout
 
RETURNS
  void
*/ 
static void configManagerTimeouts ( hsTaskData* theHeadset)
{
	if(!ConfigRetrieve(PSKEY_AUTOMATIC_SWITCH_OFF, &theHeadset->AutoSwitchOffTimeSecs, sizeof(uint16)))
		theHeadset->AutoSwitchOffTimeSecs = 0;

    CONF_DEBUG(("Co : AOff ![%d]\n" , theHeadset->AutoSwitchOffTimeSecs )) ;

	if(!ConfigRetrieve(PSKEY_POWER_ON_TIMEOUT, &theHeadset->AutoPowerOnTimeoutSecs, sizeof(uint16)))
		theHeadset->AutoPowerOnTimeoutSecs = 0;
        
    CONF_DEBUG(("Co : APOnTimeout ![%d]\n" , theHeadset->AutoPowerOnTimeoutSecs )) ;
    
    if (!ConfigRetrieve(PSKEY_NETWORK_SERVICE_IND_TIME  , &theHeadset->NetworkServiceIndicatorRepeatTimeSecs , sizeof(uint16) ) )
        theHeadset->NetworkServiceIndicatorRepeatTimeSecs = 0 ; 
        
    CONF_DEBUG(("CO : NETWORKIndTimeout [%d]\n", theHeadset->NetworkServiceIndicatorRepeatTimeSecs))     ;
    
    if (!ConfigRetrieve(PSKEY_POWER_OFF_DISABLED_TIME , &theHeadset->DisablePowerOffAfterPowerOnTimeSecs , sizeof(uint16) ) ) 
        theHeadset->DisablePowerOffAfterPowerOnTimeSecs = 0 ;
        
    CONF_DEBUG(("CO: PowerOffDisabledTimeout [%d]\n" , theHeadset->DisablePowerOffAfterPowerOnTimeSecs)) ;
}

/****************************************************************************
NAME 
  	configManagerButtonDurations

DESCRIPTION
  	Read the button configuration from persistent store and configure
  	the button durations
 
RETURNS
  	void
*/ 
static void configManagerButtonDurations(hsTaskData* theHeadset)
{
 	button_config_type  buttons;
  
   	if(ConfigRetrieve(PSKEY_BUTTON_CONFIG, &buttons, sizeof(button_config_type)))
 	{
  		buttonManagerConfigDurations (buttons.long_press_time,
           							  buttons.very_long_press_time,
           							  buttons.double_press_time,
           							  buttons.repeat_time); 
 	}                  
}
    

/****************************************************************************
NAME 
 	configManagerPower

DESCRIPTION
 	Read the Power Manager configuration
 
RETURNS
 	void
*/ 
static void configManagerPower(hsTaskData* theHeadset)
{
 	power_config_type config;
 
 	memset(&config, 0, sizeof(power_config_type));
 
 	/* 1. Determine battery chemistry from features block, assumes LiON by default */
 	if(theHeadset->features.nimh_charger_en)
  		config.chemistry = nimh;
 
 	/* 2. Read in the battery monitoring configuration */
  	ConfigRetrieve(PSKEY_BATTERY_CONFIG, &config.battery, sizeof(battery_config_type));
  
 	/* 3. Read in the NiMH battery charging configuration if enabled */
 	if(config.chemistry == nimh)
 	{
    	ConfigRetrieve(PSKEY_NIMH_CHARGER_CONFIG, &config.charger, sizeof(charger_config_type));
  	} 
 
  	/* 3. Setup the power manager */
  	powerManagerConfig(theHeadset->power, &config);
}


/****************************************************************************
NAME 
  	configManagerRadio

DESCRIPTION
  	Read the Radio configuration parameters
 
RETURNS
  	void
*/ 

static void configManagerRadio(hsTaskData* theHeadset)
{ 
  	if(!ConfigRetrieve(PSKEY_RADIO_CONFIG, &theHeadset->radio, sizeof(radio_config_type)))
  	{
    	/* Assume HCI defaults */
    	theHeadset->radio.page_scan_interval = HCI_PAGESCAN_INTERVAL_DEFAULT;
    	theHeadset->radio.page_scan_window = HCI_PAGESCAN_WINDOW_DEFAULT;
    	theHeadset->radio.inquiry_scan_interval = HCI_INQUIRYSCAN_INTERVAL_DEFAULT;
    	theHeadset->radio.inquiry_scan_interval = HCI_INQUIRYSCAN_WINDOW_DEFAULT;
  	}
}


/****************************************************************************
NAME 
  	configManagerSound

DESCRIPTION
  	Read the Volume Mappings and set them up
 
RETURNS
  	void
*/ 
static void configManagerVolume (hsTaskData * theHeadset )
{
    uint16 lSize = (SOM_NUM_VOL_SETTINGS * sizeof(vol_config_type) );
    
    /* The volume configuaration */
    vol_config_type lVolConfig [ SOM_NUM_VOL_SETTINGS ];

    uint16 lTemp [10] ;
 
    /* Set to known values */
    memset(lVolConfig, 0, lSize);

    if(ConfigRetrieve(PSKEY_SPEAKER_GAIN_MAPPING, lVolConfig, lSize))
  	{
    	uint16 lProfileVol;
     	memcpy ( lTemp , lVolConfig , 10 ) ;
    
        CONF_DEBUG (("CO: TEMP[%x][%x][%x][%x] [%x][%x][%x][%x]\n" , lTemp[0] ,lTemp[1],lTemp[2],lTemp[3],lTemp[4],lTemp[5],lTemp[6],lTemp[7])) ;

     	/* Now we have the event configuration, map required events to system events */
    	for(lProfileVol = 0; lProfileVol < SOM_NUM_VOL_SETTINGS; lProfileVol++)
        {
            CONF_DEBUG(("Co : AddVolCfg[%d] [%d][%d]\n", lProfileVol , lVolConfig[lProfileVol].IncVol , lVolConfig[lProfileVol].DecVol)) ;
                        
            /* For now*/
            soundManagerConfigureVolumeSettings ( theHeadset ,
                                                  lProfileVol , 
                                                  lVolConfig[lProfileVol].IncVol, 
                                                  lVolConfig[lProfileVol].DecVol,
                                                  lVolConfig[lProfileVol].Mic   , 
                                                  (HeadsetTone_t) lVolConfig[lProfileVol].Tone ,
                                                  lVolConfig[lProfileVol].VolGain ,
                                                  lVolConfig[lProfileVol].MicGain) ;
                                                  
            CONF_DEBUG(("CONF: [%d][%d]\n" ,    lVolConfig[lProfileVol].VolGain ,
                                                  lVolConfig[lProfileVol].MicGain)) ;

        }
    }
    else
    {
        CONF_DEBUG(("Co: !Vol\n")) ;
    }

    {
        uint16 lTemp ;
        
	     if(!ConfigRetrieve(PSKEY_MUTE_REMIND_TIME, &lTemp, sizeof(uint16)))
         {
        
		     theHeadset->theSoundTask.gSMMuteRemindTimeSec = DEFAULT_VOLUME_MUTE_REMINDER_TIME_SEC;
         }
         else
         {
            theHeadset->theSoundTask.gSMMuteRemindTimeSec = lTemp ;
         }
    }    
}


/****************************************************************************
NAME 
  	configManagerGetMicBiasPio

DESCRIPTION
  	Retrieves the MicBias PIO
 
RETURNS
  	void
*/ 
uint16 configManagerGetMicBiasPio ( void )
{
    uint16 lResult = 0;
    
    PsFullRetrieve(441, &lResult, sizeof(uint16));

    CONF_DEBUG(("Co :MicPio[%x]\n", lResult)); 
    
    return lResult ;
}


/****************************************************************************
NAME 
  	configManagerReset

DESCRIPTION
    Resets the Paired Device List - Reboots if PSKEY says to do so
 
RETURNS
  	void
*/ 

void configManagerReset ( hsTaskData * pApp ) 
{
    CONF_DEBUG(("CO: Reset\n")) ;
        
    /* Reset the Default AG */   
    (void )PsStore ( PSKEY_DEFAULT_AG , 0 , 0 ) ;
    
    /* Reset the Last AG */
    (void)PsStore ( PSKEY_LAST_USED_AG , 0 , 0 ) ;
    
    /* Delete the Connecction Libs Paired Device List */
        ConnectionSmDeleteAllAuthDevices(SOM_VOLUME_PSKEY_BASE);
/*        ConnectionSmDeleteAllAuthDevices();*/
}
                

/****************************************************************************
NAME 
  	configManagerEventTone

DESCRIPTION
  	Configure an event tone only if one is defined
 
RETURNS
  	void
*/ 
static void configManagerEventTones ( hsTaskData* theHeadset  )
{ 
    uint16 no_tones = 0;
 
  	/* First read the number of events configured */
  	if(ConfigRetrieve(PSKEY_NO_TONES, &no_tones, sizeof(uint16)))
  	{
        /* Allocate enough memory to hold event configuration */
    	tone_config_type * config = (tone_config_type *) mallocPanic(no_tones * sizeof(tone_config_type));
 
     	/* Now read in tones configuration */
    	if(ConfigRetrieve(PSKEY_TONES, config, no_tones * sizeof(tone_config_type)))
    	{
      		uint16 n;
   
       		/* Now we have the event configuration, map required events to system events */
        	for(n = 0; n < no_tones; n++)
        	{
                CONF_DEBUG(("CO: Ev[%x]Tone[%x] \n" , config[n].event, config[n].tone )) ;
                soundManagerConfigureEventTone ( theHeadset , (config[n].event + EVENTS_EVENT_BASE), config[n].tone  ) ;
            }   
        }                    
    }            
}


/****************************************************************************
NAME 
 	configManagerSupportedFeatures

DESCRIPTION
    Gets the Supported features set from PS - exposed as this needs to be done prior to a HFPInit() 
 
RETURNS
 	void
*/ 
uint16 configManagerSupportedFeatures(hsTaskData * theHeadset) 
{
	
    
	if(!ConfigRetrieve(PSKEY_HFP_SUPPORTED_FEATURES, &theHeadset->supp_features_local, sizeof(uint16)))
    {
        
     	theHeadset->supp_features_local = (HFP_NREC_FUNCTION        | 
            		     				   HFP_THREE_WAY_CALLING    | 
				                   		   HFP_CLI_PRESENTATION     | 
			             				   HFP_VOICE_RECOGNITION    | 
				              			   HFP_REMOTE_VOL_CONTROL   |
                                           HFP_ENHANCED_CALL_STATUS |
                                           HFP_ENHANCED_CALL_CONTROL    );
    }

    CONF_DEBUG(("CONF: SupportedFeatures[%x]\n", theHeadset->supp_features_local )) ;
    
	return theHeadset->supp_features_local  ;
}


/****************************************************************************
NAME 
 	configManagerHFP_1_5_SupportedFeatures

DESCRIPTION
    Gets the HFP 1.5 Supported features set from PS
 
RETURNS
 	void
*/
void configManagerHFP_1_5_SupportedFeatures(hsTaskData* theHeadset)
{
       
    ConfigRetrieve( PSKEY_HFP_1_5_SUPPORTED_FEATURES , &theHeadset->HFP_1_5_supp_features , sizeof( HFP_1_5_features_type ) ) ;
    

    if ( ! theHeadset->HFP_1_5_supp_features.HFP_1_5_Is_Enabled )
    {
        /*then set the defaults*/

        theHeadset->HFP_1_5_supp_features.HFP_1_5_Is_Enabled = FALSE ;
        theHeadset->HFP_1_5_supp_features.supportedSyncPacketTypes = (sync_hv1 | sync_hv2 | sync_hv3) ;        
    }
    else
    {
           /*make sure the mask we have read in is within range*/
        uint16 lAllPktTypes = ( sync_hv1  | sync_hv2  |  sync_hv3 | 
                                sync_ev3  | sync_ev4  |  sync_ev5 | 
                                sync_2ev3 | sync_3ev3 | sync_2ev5 | sync_3ev5 ) ;
                                 
        uint16 lPSPktTypes = theHeadset->HFP_1_5_supp_features.supportedSyncPacketTypes ;
        
        CONF_DEBUG(("CONF: Feat[%x]&[%x] = [%x]\n" , lAllPktTypes , lPSPktTypes , (lAllPktTypes & lPSPktTypes) )) ;
        theHeadset->HFP_1_5_supp_features.supportedSyncPacketTypes =  (lAllPktTypes & lPSPktTypes) ;

    }

}




/****************************************************************************
NAME 
 	configManagerWriteVolumeOrientation

DESCRIPTION
    Set the Volume Orientation Inverted PSKEY to Inverted (true ) or not (false)
 
RETURNS
 	void
*/ 
static void configManagerReadVolumeOrientation ( hsTaskData * theHeadset ) 
{
    uint16 lTemp = 0 ;
    
        /*read in the volume orientation*/
    ConfigRetrieve( PSKEY_VOLUME_ORIENTATION , &lTemp , sizeof( uint16 ) ) ;
  
    theHeadset->VolumeOrientationIsInverted = FALSE ;
    
    if( lTemp )
    {
        theHeadset->VolumeOrientationIsInverted = TRUE ;
    }
    CONF_DEBUG(("CONF : Rd Vol Inverted [%c]\n", theHeadset->VolumeOrientationIsInverted ? 'T':'F' )) ;
}

/****************************************************************************
NAME 
 	configManagerWriteVolumeOrientation

DESCRIPTION
    Set the Volume Orientation Inverted PSKEY to Inverted (true ) or not (false)
 
RETURNS
 	void
*/ 
void configManagerWriteVolumeOrientation( hsTaskData * theHeadset , bool pInverted )
{
    uint16 lTemp = (uint16) pInverted ;

    CONF_DEBUG(("CONF : PS Write Vol Inverted[%c]\n" , lTemp ? 'T':'F'));
    
    (void) PsStore(PSKEY_VOLUME_ORIENTATION, &lTemp, sizeof(uint16)); 
}




⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -