📄 headset_statemanager.c
字号:
single point of entry for the incoming call establish state
RETURNS
void
*/
void stateManagerEnterIncomingCallEstablishState ( hsTaskData * pApp )
{
if (stateManagerGetState() == headsetConnectable )
{
if (pApp->features.AutoAnswerOnConnect )
{
/*then attempt to answer the call*/
MessageSend (&pApp->task , EventAnswer , 0 ) ;
}
}
stateManagerSetState ( pApp , headsetIncomingCallEstablish ) ;
if (pApp->PIO.IncomingRingPIOEnabled )
{
LedManagerSetPIO ( pApp->PIO.IncomingRingPIO , TRUE) ;
}
soundManagerSendAndSetCurrentVolume (pApp ) ;
}
/****************************************************************************
NAME
stateManagerEnterOutgoingCallEstablishState
DESCRIPTION
single point of entry for the outgoing call establish state
RETURNS
void
*/
void stateManagerEnterOutgoingCallEstablishState ( hsTaskData * pApp )
{
stateManagerSetState ( pApp , headsetOutgoingCallEstablish ) ;
if (pApp->PIO.OutgoingRingPIOEnabled )
{
LedManagerSetPIO ( pApp->PIO.OutgoingRingPIO , TRUE) ;
}
}
/****************************************************************************
NAME
stateManagerEnterActiveCallState
DESCRIPTION
single point of entry for the active call state
RETURNS
void
*/
void stateManagerEnterActiveCallState ( hsTaskData * pApp )
{
stateManagerSetState ( pApp , headsetActiveCall ) ;
/*disable the ring PIOs if enabled*/
if (pApp->PIO.IncomingRingPIOEnabled )
{
LedManagerSetPIO ( pApp->PIO.IncomingRingPIO , FALSE) ;
}
if (pApp->PIO.OutgoingRingPIOEnabled )
{
LedManagerSetPIO ( pApp->PIO.OutgoingRingPIO , FALSE) ;
}
/*enable the active call PIO if there is one*/
if (pApp->PIO.CallActivePIOEnabled )
{
LedManagerSetPIO ( pApp->PIO.CallActivePIO , TRUE) ;
}
}
/****************************************************************************
NAME
stateManagerEnterPoweringOffState
DESCRIPTION
single point of entry for the powering off state - enables power off
RETURNS
void
*/
void stateManagerEnterPoweringOffState ( hsTaskData *pApp )
{
SM_DEBUG(("SM : EnterPowerOff\n")) ;
/*Power Down*/
if ( stateManagerIsConnected() )
{
/*then we have an SLC active*/
headsetDisconnectSlc( pApp );
}
/*now just waiting for switch off */
stateManagerEnterLimboState ( pApp ) ;
}
/****************************************************************************
NAME
stateManagerPowerOff
DESCRIPTION
actually power down the device
RETURNS
void
*/
void stateManagerPowerOff ( hsTaskData * pApp )
{
SM_DEBUG(("SM : Power Off\n--goodbye--\n")) ;
/*used as a power on indication if required*/
if (pApp->PIO.PowerOnPIOEnabled )
{
LedManagerSetPIO ( pApp->PIO.PowerOnPIO , FALSE) ;
}
/*now we have finished with the LEDS
LEDManagerClean( &pApp->theLEDTask ) ;*/
/*attempt to physically power down device - this will fail if the chg is plugged in*/
LEDManagerSetPowerPin ( pApp , POWER_OFF ) ;
}
/****************************************************************************
NAME
stateManagerPowerOn
DESCRIPTION
Power on the deviece by latching on the power regs
RETURNS
void
*/
void stateManagerPowerOn( hsTaskData * pApp )
{
SM_DEBUG(("--hello--\nSM : PowerOn\n"));
/* Check for DUT mode enable */
if(!checkForDUTModeEntry(pApp))
{
/*cancel the event power on message if there was one*/
MessageCancelAll ( &pApp->task , EventLimboTimeout ) ;
LEDManagerSetPowerPin ( pApp , POWER_ON ) ;
if (pApp->PIO.PowerOnPIOEnabled )
{
LedManagerSetPIO ( pApp->PIO.PowerOnPIO , TRUE) ;
}
stateManagerEnterConnectableState ( pApp, TRUE ) ;
/*if we want to reconnect after a power on then atempt to reconnect*/
if (pApp->features.AutoReconnectPowerOn )
{
SM_DEBUG(("SM: Auto Reconnect\n")) ;
MessageSend ( &pApp->task , EventEstablishSLC , 0 ) ;
}
}
}
/****************************************************************************
NAME
stateManagerIsConnected
DESCRIPTION
Helper method to see if we are connected or not
RETURNS
bool
*/
bool stateManagerIsConnected ( void )
{
bool lIsConnected = FALSE ;
switch (stateManagerGetState() )
{
case headsetPoweringOn:
case headsetConnectable:
case headsetConnDiscoverable:
case headsetTestMode:
lIsConnected = FALSE ;
break ;
case headsetConnected:
case headsetOutgoingCallEstablish:
case headsetIncomingCallEstablish :
case headsetActiveCall:
case headsetThreeWayCallWaiting:
case headsetThreeWayCallOnHold:
case headsetThreeWayMulticall:
lIsConnected = TRUE ;
break ;
default:
break ;
}
return lIsConnected ;
}
/****************************************************************************
NAME
stateManagerEnterPoweringOnState
DESCRIPTION
method to provide a single point of entry to the limbo /poweringOn state
RETURNS
*/
void stateManagerEnterLimboState ( hsTaskData * pApp )
{
SM_DEBUG(("SM: Enter Limbo State[%d]\n" , pApp->AutoPowerOnTimeoutSecs));
/*in limbo, the internal regs must be latched on (smps and LDO)*/
LEDManagerSetPowerPin ( pApp , POWER_ON ) ;
/*make sure we are neither connectable or discoverable*/
headsetDisableDiscoverable ( pApp ) ;
headsetDisableConnectable ( pApp ) ;
/*set a timeout so that we will turn off eventually anyway*/
MessageSendLater ( &pApp->task , EventLimboTimeout , 0 , D_SEC(pApp->AutoPowerOnTimeoutSecs) ) ;
/* Reset SLC settings */
slcReset();
stateManagerSetState ( pApp , headsetPoweringOn ) ;
}
void stateManagerUpdateLimboState ( hsTaskData * pApp )
{
/*then we are entering here as a result of a power off*/
switch (pApp->power->charger.state)
{
case disconnected :
/*power has been removed and we are logically off so switch off*/
SM_DEBUG(("SM: LimboDiscon\n")) ;
stateManagerPowerOff ( pApp ) ;
break ;
/*this means connected*/
case trickle_charge:
case fast_charge:
case charge_error:
SM_DEBUG(("SM: LimboConn\n")) ;
/*stay in this state until a charger event or a power on occurs*/
break ;
default:
break ;
}
}
/****************************************************************************
NAME
stateManagerEnterTestModeState
DESCRIPTION
method to provide a single point of entry to the test mode state
RETURNS
*/
void stateManagerEnterTestModeState ( hsTaskData * pApp )
{
stateManagerSetState (pApp , headsetTestMode ) ;
}
static void stateManagerResetPIOs ( hsTaskData * pApp )
{
/*disable the ring PIOs if enabled*/
if (pApp->PIO.IncomingRingPIOEnabled )
{
LedManagerSetPIO ( pApp->PIO.IncomingRingPIO , FALSE) ;
}
if (pApp->PIO.OutgoingRingPIOEnabled )
{
LedManagerSetPIO ( pApp->PIO.OutgoingRingPIO , FALSE) ;
}
/*diaable the active call PIO if there is one*/
if (pApp->PIO.CallActivePIOEnabled )
{
LedManagerSetPIO ( pApp->PIO.CallActivePIO , FALSE) ;
}
}
/****************************************************************************
NAME
stateManagerEnterCallWaitingState
DESCRIPTION
method to provide a single point of entry to the 3 way call waiting state
RETURNS
*/
void stateManagerEnterThreeWayCallWaitingState ( hsTaskData * pApp )
{
stateManagerSetState ( pApp , headsetThreeWayCallWaiting ) ;
}
void stateManagerEnterThreeWayCallOnHoldState ( hsTaskData * pApp )
{
stateManagerSetState ( pApp , headsetThreeWayCallOnHold ) ;
}
void stateManagerEnterThreeWayMulticallState ( hsTaskData * pApp )
{
stateManagerSetState ( pApp , headsetThreeWayMulticall ) ;
}
void stateManagerEnterIncomingCallOnHoldState ( hsTaskData * pApp)
{
stateManagerSetState ( pApp , headsetIncomingCallOnHold ) ;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -