void CsrVoicePresencesPluginPlayPhrase (uint16 id , uint16 language, Task codec_task , uint16 prompt_volume , AudioPluginFeatures features, Task app_task)
{
    if(koovox_phrase_data != NULL)
        Panic();
    
    PRINT(("PRESENT: Play Phrase:\n"));
    
    /* Allocate the memory */
    koovox_phrase_data = (koovox_phrase_data_T *) PanicUnlessMalloc(sizeof(koovox_phrase_data_T));
    memset(koovox_phrase_data,0,sizeof(koovox_phrase_data_T));
    
    /* Set up params */
    koovox_phrase_data->language      = language;
    koovox_phrase_data->codec_task    = codec_task;
    koovox_phrase_data->prompt_volume = prompt_volume;
    koovox_phrase_data->features      = features;
    koovox_phrase_data->prompt_id     = id;
    koovox_phrase_data->mixing        = FALSE; /* currently unknown so set to false */
    koovox_phrase_data->tone          = NULL;  /* not a tone */
	koovox_phrase_data->app_task	  = app_task;
    
    MessageCancelAll((TaskData*) &csr_voice_presences_plugin, MESSAGE_STREAM_DISCONNECT );
    MessageCancelAll((TaskData*) &csr_voice_presences_plugin, MESSAGE_FROM_KALIMBA);
    
    CsrVoicePresencesPluginPlayDigit(); 
    
    SetVpPlaying(TRUE);
}
void a2dpStreamStartMediaStreamHoldoff (void)
{
    DEBUG_A2DP(("a2dpStreamStartMediaStreamHoldoff\n"));
    the_app->a2dp_media_stream_holdoff = TRUE;
    MessageCancelAll(&the_app->task, APP_A2DP_MEDIA_STREAM_HOLDOFF);
    MessageSendLater(&the_app->task, APP_A2DP_MEDIA_STREAM_HOLDOFF, 0, A2DP_MEDIA_STREAM_HOLDOFF_DELAY);
}
void a2dpStreamStopMediaStreamHoldoff (void)
{
    DEBUG_A2DP(("a2dpStreamStopMediaStreamHoldoff\n"));
    the_app->a2dp_media_stream_requested = FALSE;    /* Only ever used by media stream hold off timer */
    the_app->a2dp_media_stream_holdoff = FALSE;
    MessageCancelAll(&the_app->task, APP_A2DP_MEDIA_STREAM_HOLDOFF);
}
/****************************************************************************
NAME
    scanCancelSdpSearch

DESCRIPTION
    Cancel any pending SDP searches.
    
*/
void scanCancelSdpSearch (void)
{
    ConnectionSdpTerminatePrimitiveRequest(&the_app->task);
    ConnectionSdpCloseSearchRequest(&the_app->task);  /* Generates a CL_SDP_CLOSE_SEARCH_CFM */
    s_profileSearchIdx = (uint16)-1;
    MessageCancelAll(&the_app->task, CL_SDP_SERVICE_SEARCH_CFM);
}
void hfpHandlerRingInd ( void )
{
	/* Disconnect A2DP audio if it is streaming from a standalone A2DP source */
	if (!IsA2dpSourceAnAg())
		streamControlCeaseA2dpStreaming(TRUE);
	
    if ( !theHeadset.InBandRingEnabled )
    {
    	HFP_DEBUG(("HFP_DEBUG: OutBandRing\n")) ;
		
        /* Play ring tone from configuration */
    }    
	
	if ( (theHeadset.profile_connected == hfp_headset_profile) && !theHeadset.HSPCallAnswered )
    {
		/* If using HSP then use ring indication as incoming call */
		theHeadset.HSPIncomingCallInd = TRUE;
       
        stateManagerEnterIncomingCallEstablishState() ;
       
        MessageCancelAll ( &theHeadset.task , APP_CANCEL_HSP_INCOMING_CALL ) ;
        MessageSendLater ( &theHeadset.task , APP_CANCEL_HSP_INCOMING_CALL , 0 , D_SEC(6) ) ;
    }
    
}
Пример #6
0
/****************************************************************************
NAME    
    sinkEnableMultipointConnectable
    
DESCRIPTION
    when in multi point mode check to see if device can be made connectable,
    this will be when only one AG is currently connected. this function will
    be called upon certain button presses which will reset the 60 second timer
    and allow a second AG to connect should the device have become non discoverable
    
RETURNS
    none
*/
void sinkEnableMultipointConnectable( void )
{    
    /* only applicable to multipoint devices and don't go connectable when taking or making
       an active call, allow connectable in streaming music state */
    if((theSink.MultipointEnable)&&(stateManagerGetState() != deviceLimbo))
    {
       /* if only one hfp instance is connected then set connectable to active */
       if(deviceManagerNumConnectedDevs() < 2)
       {
            MAIN_DEBUG(("MP Go Conn \n" ));
            
            /* make device connectable */
            sinkEnableConnectable();
         
            /* cancel any currently running timers that would disable connectable mode */
            MessageCancelAll( &theSink.task, EventSysConnectableTimeout );
            
            /* remain connectable for a further 'x' seconds to allow a second 
               AG to be connected if non-zero, otherwise stay connecatable forever */
            if(theSink.conf1->timeouts.ConnectableTimeout_s)
            {
                MessageSendLater(&theSink.task, EventSysConnectableTimeout, 0, D_SEC(theSink.conf1->timeouts.ConnectableTimeout_s));
            }
       }
       /* otherwise do nothing */
    }
}
/****************************************************************************
NAME
    a2dpStreamSetAudioStreamingState

DESCRIPTION
    Sets a new audio streaming state.
    
*/
void a2dpStreamSetAudioStreamingState (mvdStreamingState streaming_state)
{
    DEBUG_EVENT(("a2dpStreamSetAudioStreamingState(%u)\n", (uint16)streaming_state));
    
    /* Set new streaming state and always cancel any outstanding timer messages */
    the_app->audio_streaming_state = streaming_state;
    MessageCancelAll(&the_app->task, APP_AUDIO_STREAMING_TIMER);
}
Пример #8
0
/** stop the probe **/
void battery_probe_stop(void) {
	
	/** cancell all MESSAGE_ADC_RESULT and BATTERY_PROBE_TICK message **/
	MessageFlushTask(getBatteryProbeTask());
	
	/** cancell all BATTERY_PROBE_READING message sent to client **/
	MessageCancelAll(battery_probe.client, BATTERY_PROBING_MESSAGE);
}
/****************************************************************************
DESCRIPTION
    Stop prompt where DSP has not been loaded by the plugin, e.g. (adpcm or pcm) 
    Prompt is either mixing in an existing DSP app or not using the DSP.
*/
static void CsrVoicePresencesPluginStopPhraseMixable ( void ) 
{
    Sink lSink=NULL;
    Task taskdata = NULL;
    
    /* Check for DSP mixing */
    if(GetCurrentDspStatus())
    {
        lSink = StreamKalimbaSink(PRESENT_DSP_PORT);
        /* reset the volume levels of the dsp plugin */
        if(GetAudioPlugin())           	    
            MessageSend( GetAudioPlugin(), AUDIO_PLUGIN_RESET_VOLUME_MSG, 0 ) ;
    }
    else    /* Must be ADPCM not mixing */
    {
        switch(koovox_phrase_data->features.audio_output_type)
        {
            /* is the I2S required? */
            case OUTPUT_INTERFACE_TYPE_I2S:
            {               
                CsrI2SAudioOutputDisconnect( koovox_phrase_data->features.stereo);  
            }
            break;
            
            /* spdif output? */
            case OUTPUT_INTERFACE_TYPE_SPDIF:
            {
                Sink rSink = NULL;
                                
                /* obtain source to SPDIF hardware and disconnect it */
                lSink = StreamAudioSink(AUDIO_HARDWARE_SPDIF, AUDIO_INSTANCE_0, SPDIF_CHANNEL_A );
                rSink = StreamAudioSink(AUDIO_HARDWARE_SPDIF, AUDIO_INSTANCE_0, SPDIF_CHANNEL_B );
                StreamDisconnect(0, lSink);
                StreamDisconnect(0, rSink);
                SinkClose(lSink);
                SinkClose(rSink);
            }
            break;
            
            /* use built in codec */
            default:
            {
                lSink = StreamAudioSink(AUDIO_HARDWARE_CODEC,AUDIO_INSTANCE_0, (koovox_phrase_data->features.stereo ? AUDIO_CHANNEL_A_AND_B : AUDIO_CHANNEL_A));
                /* Disconnect PCM source/sink */
                StreamDisconnect(StreamSourceFromSink(lSink), lSink); 
            }
        }
    }    
    /* close sink and cancel any messages if valid */
    if(lSink)
    {
        /* Cancel all the messages relating to VP that have been sent */
        taskdata = MessageSinkTask(lSink, NULL);
        SinkClose(lSink);
    }
    PRINT(("PRESENT: SinkTask now NULL was %x\n",(uint16)taskdata));
    MessageCancelAll((TaskData*) &csr_voice_presences_plugin, MESSAGE_STREAM_DISCONNECT);
}
/****************************************************************************
 *NAME    
 *    abortContinuation    
 *
 *DESCRIPTION
 *   Abort the stored Continuation response packet. 
 *
 *PARAMETERS
 * avrcp        -       AVRCP Entity
 *****************************************************************************/
void abortContinuation(AVRCP *avrcp)
{
    /* Abort sending continuing packets back to CT. */
    if (avrcp->continuation_data)
        SourceEmpty(avrcp->continuation_data);

    MessageCancelAll(&avrcp->task, AVRCP_INTERNAL_NEXT_CONTINUATION_PACKET);
    avrcp->continuation_pdu = 0;
}
Пример #11
0
static void hal_activating_state_exit(void) {
	
	DEBUG(("hal activating state exit...\n"));
	
	if (hal.beep_finished == FALSE) {
		
		MessageCancelAll(getHalTask(), HAL_ACTIVATING_TIMEOUT);
	}	
}
static void pioChanged(Task task, PioState *pioState, uint16 pio_bits)
{
    InternalState next;
    uint16 raw_bits = 0;
    uint16 mState = pio_bits;
    bool pio_changed = TRUE;

    mState &= ~ 0;
    raw_bits = (pio_bits & 0);
    if (raw_bits != pioState->pio_states.pio_raw_bits)
    {
        PIO_RAW_T *message = malloc(sizeof(PIO_RAW_T));
        message->pio = raw_bits;
        MessageSend(pioState->client, PIO_RAW, message);
        pioState->pio_states.pio_raw_bits = raw_bits;
    }

    next = pio_encode(mState);

    if (mState == pioState->pio_states.store_bits)
        pio_changed = FALSE;

    if (pio_changed)
    {
        if ((pioState->pio_states.store_held != Unknown) && (next != pioState->pio_states.store_held))
        {
            uint16 changed = mState ^ pioState->pio_states.store_bits;
            uint16 released = changed & pioState->pio_states.store_bits;
            if (released == pioState->pio_states.store_bits)
            {
                uint16 count, i;
                const EnterMessage *p = enter_messages[pioState->pio_states.store_held].send;
                count = enter_messages[pioState->pio_states.store_held].count;
                for (i = count; i > 0; i--)
                {
                    if (p[i-1].release)
                        MessageSend(pioState->client, p[i-1].id, 0);
                }
            }
            pioState->pio_states.store_held = Unknown;
        }

        if (pioState->pio_states.timed_id)
        {
            MessageSend(pioState->client, pioState->pio_states.timed_id, 0);
            pioState->pio_states.timed_id = 0;
        }

        (void) MessageCancelAll(task, internal_pio_timer_message);
        if(next != Unknown)
        {
            send_pio_enter_messages(pioState, next);
            send_pio_timed_messages(pioState, next);
        }
        pioState->pio_states.store_bits = mState;
    }
}
Пример #13
0
/***************************************************************************
NAME
    UpgradeSMBlockingOpIsDone

DESCRIPTION
    Let know application that blocking operation is finished.
*/
static void UpgradeSMBlockingOpIsDone()
{
    if(UpgradeCtxGet()->perms == upgrade_perm_always_ask)
    {
        /* Cancelling messages shouldn't be needed but do it anyway */
        MessageCancelAll(UpgradeCtxGet()->mainTask, UPGRADE_BLOCKING_IND);
        MessageSend(UpgradeCtxGet()->mainTask, UPGRADE_BLOCKING_IS_DONE_IND, NULL);
    }
}
/****************************************************************************
NAME
    scanStartAppInquiryTimer

DESCRIPTION
    Starts the timer for inquiry. Inquiry mode will end once the timer fires.
    
*/
void scanStartAppInquiryTimer (void)
{
    if (!the_app->inquiring)    /* Don't restart a timer that is already running */
    {
        MessageCancelAll(&the_app->task, APP_INQUIRY_TIMER);
        MessageSendLater(&the_app->task, APP_INQUIRY_TIMER, 0, 120000);
        the_app->inquiring = TRUE;
        the_app->app_inquiry_timer_expired = FALSE;
    }
}
Пример #15
0
/****************************************************************************
NAME    
    inquiry_complete - Inquiry procedure has completed
*/
void inquiry_complete(void)
{
    INQUIRY_DEBUG(("INQUIRY: complete\n"));
    if (theSource->inquiry_data)
    {
        memory_free(theSource->inquiry_data);
        theSource->inquiry_data = NULL;
        MessageCancelAll(&theSource->app_data.appTask, APP_INQUIRY_STATE_TIMEOUT);
    }
}
void hfpHandlerAudioConnectCfm( const HFP_AUDIO_CONNECT_CFM_T *cfm )
{
    if ( cfm->status == hfp_success)
    {
	    AUDIO_SINK_T sink_type;
		
		if (theHeadset.hfp_hsp == NULL)
		{
			/* The audio has obviously been established before being notified of SLC.
			   Update the HFP pointer accordingly. */
			if (cfm->hfp == theHeadset.hfp)
    		{
        		theHeadset.profile_connected = hfp_handsfree_profile;
				theHeadset.hfp_hsp = theHeadset.hfp;
    		}
    		else if (cfm->hfp == theHeadset.hsp)
    		{
        		theHeadset.profile_connected = hfp_headset_profile;
				theHeadset.hfp_hsp = theHeadset.hsp;
    		}    
		}
		
		/* Stop any audio transfer requests */
		MessageCancelAll(&theHeadset.task, APP_CHECK_FOR_AUDIO_TRANSFER);
	    
        switch (cfm->link_type)
        {
			case sync_link_unknown:  /* Assume SCO if we don't know */
			case sync_link_sco:
				sink_type = AUDIO_SINK_SCO;
				break;
			case sync_link_esco:
				sink_type = AUDIO_SINK_ESCO;
				break;
			default:
				sink_type = AUDIO_SINK_INVALID;
				break;
        }
		
        audioConnectSco(sink_type, cfm->tx_bandwidth) ;
        
       /* Send an event to indicate that a SCO has been opened. This indicates
          that an audio connection has been successfully created to the AG. */
    	MessageSend ( &theHeadset.task , EventSCOLinkOpen , 0 ) ;
    
	    /* If this is a headset instance, enter the active call state */
        if (theHeadset.profile_connected == hfp_headset_profile)
        {
            stateManagerEnterActiveCallState() ;
        }			
		
		/* Update Link Policy as SCO has connected. */
		linkPolicySCOconnect();
    }
}
void handleAVRCPConnectReq(APP_AVRCP_CONNECT_REQ_T *msg)
{
    if ((stateManagerGetAvrcpState() == avrcpReady) && (stateManagerGetHfpState() != headsetPoweringOn))
    {
        MessageCancelAll(&theHeadset.task, APP_AVRCP_CONNECT_REQ);
        /* Change to connecting state */
	    stateManagerSetAvrcpState(avrcpConnecting);
        /* Establish AVRCP connection */
	    AvrcpConnect(theHeadset.avrcp, &msg->addr);
    }
}
Пример #18
0
void CsrSubwooferPluginConnect(Sink audio_sink, Task codec_task, Task app_task, subwooferPluginConnectParams * params)
{
    FILE_INDEX index;
    
    /* Update the current DSP status */
    SetCurrentDspStatus(DSP_LOADING);
    
    /* Give Kalimba the plugin task so it knows where to send messages */
    (void) MessageCancelAll( (TaskData*)&csr_subwoofer_plugin, MESSAGE_FROM_KALIMBA);
    MessageKalimbaTask( (TaskData*)&csr_subwoofer_plugin );
    
    /* Load the Subwofoer DSP application - Panic if it could not be loaded */
    index = PanicFalse( FileFind(FILE_ROOT, kal, sizeof(kal) - 1) );
    PanicFalse( KalimbaLoad(index) );
    
    /* update current DSP status */
    SetCurrentDspStatus(DSP_LOADED_IDLE);
    
    /* Allocate memory to store the plugin data */
    plugin_data = (subwooferPluginData*)PanicUnlessMalloc(sizeof(subwooferPluginData));
    
    /* Initialise the plugin data based on parameters supplied by the application */
    plugin_data->audio_source           = StreamSourceFromSink(audio_sink);
    plugin_data->swat_system_volume_db  = params->swat_system_volume_db;
    plugin_data->swat_trim_gain_db      = params->swat_trim_gain_db;
    plugin_data->adc_volume_index       = params->adc_volume;
    plugin_data->input                  = params->input;
    plugin_data->output                 = params->output;
    plugin_data->sample_rate            = params->sample_rate;
    plugin_data->adc_sample_rate        = params->adc_sample_rate;
    plugin_data->codec_task             = codec_task;
    plugin_data->app_task               = app_task;
    plugin_data->dsp_set_sample_rate    = 0; /* set later in response to AUDIO_PLUGIN_SET_MODE_MSG */
    
    /* Zero the codecs output gain */
    CodecSetOutputGainNow(plugin_data->codec_task, 0, left_and_right_ch);
    CodecSetInputGainNow(plugin_data->codec_task, 0, left_and_right_ch);
    
    
    /* If using the ADC, set the ADC source */
    if (plugin_data->input == SUBWOOFER_INPUT_ADC)
    {
        /* Get the ADC source */
        plugin_data->audio_source = StreamAudioSource(AUDIO_HARDWARE_CODEC, AUDIO_INSTANCE_0, AUDIO_CHANNEL_A);
    }
    
    
    /* Disconnect the source in case it's currently being disposed */
    StreamDisconnect(StreamSourceFromSink(audio_sink), 0);
    
    PRINT(("[SW_PLUGIN] : CsrSubwooferPluginConnect - complete\n"));
}
Пример #19
0
/****************************************************************************
NAME	
	PioSetDimState  
	
DESCRIPTION
    Update funtion for a led that is currently dimming
    
RETURNS
	void
*/
void PioSetDimState ( uint16 pPIO )
{
    uint16 lDim = 0x0000 ;
    LEDActivity_t *gActiveLED = &theSink.theLEDTask->gActiveLEDS[pPIO];

    if (gActiveLED->DimDir && gActiveLED->DimState >= DIM_NUM_STEPS )
    {      
        lDim = 0xFFF;
        DIM_DEBUG(("DIM:+[F] [ON]\n" ));
    }
    else if ( !gActiveLED->DimDir && gActiveLED->DimState == 0x0 )
    {
        lDim = 0 ;
        DIM_DEBUG(("DIM:-[0] [OFF]\n" ));
    }
    else
    {
        if(gActiveLED->DimDir)
            gActiveLED->DimState++ ;
        else
            gActiveLED->DimState-- ;
        
        DIM_DEBUG(("DIM:Direction [%x], DimState:[%x], DimTime:[%x]\n", gActiveLED->DimDir, gActiveLED->DimState, gActiveLED->DimTime));
        
        lDim = (gActiveLED->DimState * (DIM_STEP_SIZE) ) ;
        
        MessageCancelAll ( &theSink.theLEDTask->task, (DIM_MSG_BASE + pPIO) ) ;                
        MessageSendLater ( &theSink.theLEDTask->task, (DIM_MSG_BASE + pPIO) , 0 , gActiveLED->DimTime ) ;    
    }    

#ifndef NO_LED2            
    if (pPIO == 14)
    {
        LedConfigure(LED_0, LED_DUTY_CYCLE, lDim);
        LedConfigure(LED_0, LED_PERIOD, DIM_PERIOD );  
        LedConfigure(LED_0, LED_ENABLE, TRUE ) ;
        
    }
    else if (pPIO ==15)
    {        
        LedConfigure(LED_1, LED_DUTY_CYCLE, lDim);
        LedConfigure(LED_1, LED_PERIOD, DIM_PERIOD );  
        LedConfigure(LED_1, LED_ENABLE, TRUE ) ;
    }
    else if (pPIO ==10)
    {        
        LedConfigure(LED_2, LED_DUTY_CYCLE, lDim);
        LedConfigure(LED_2, LED_PERIOD, DIM_PERIOD );  
        LedConfigure(LED_2, LED_ENABLE, TRUE ) ;
    }
#endif    
}
Пример #20
0
/****************************************************************************  
DESCRIPTION
 	function to handle a button press - informs button manager of a change
    currently makes direct call - may want to use message handling (tasks)
*/ 
static void ButtonsButtonDetected (  ButtonsTaskData * pButtonsTask, uint32 pButtonMask  , ButtonsTime_t pTime )
{
    B_DEBUG(("B:But Det[%lx]\n", pButtonMask)) ;
    
    if( pButtonMask == 0 )
    {
     	MessageCancelAll ( &pButtonsTask->task , B_REPEAT_TIMER ) ;
    }
    else
    {
        BMButtonDetected ( pButtonMask, pTime ) ;             
    } 
}
Пример #21
0
/****************************************************************************
NAME 
	hidDisconnectingRemoteExit
DESCRIPTION
	Called whenever the HID instance exits the remote disconnecting state.
	Sends a HID_DISCONNECT_IND message to the applications and stops the
	disconnect timer.
RETURNS
	void
*/
static void hidDisconnectingRemoteExit(HID *hid)
{
    MAKE_HID_MESSAGE(HID_DISCONNECT_IND);
	HID_PRINT(("hidDisconnectingRemoteExit\n"));

	/* Send HID_DISCONNECT_IND to application */
	message->hid = hid;
    message->status = hid->disconnect_status;
    MessageSend(hid->app_task, HID_DISCONNECT_IND, message);

	/* Stop disconnect timer */
    MessageCancelAll(&hid->task, HID_INTERNAL_DISCONNECT_TIMEOUT_IND);
}
Пример #22
0
static void scanner_scanning_state_exit(void) {
	
	Source source;
	
	DEBUG(( "scanner, scanning state exit... \n" ));
	
	MessageCancelAll(&scanner.task, SCANNER_SCANNING_TIMEOUT_IND);
	
	trigger_pull_up();	/** don't forget this, we may exit when pulling-down triggering line **/
	/** MessageCancelAll(&scanner.task, SCANNER_SCANNING_PULLDOWN_TIMEOUT_IND); **/
	
	source = StreamUartSource();
	if (source && SourceSize(source) > 0) {
		
		SourceDrop(source, SourceSize(source));
	}
	
	MessageCancelAll(&scanner.task, MESSAGE_MORE_DATA);
	MessageCancelAll(&scanner.task, MESSAGE_MORE_SPACE);
	
	/** clear barcode **/
	barcode_clear(&scanner.barcode);
}
Пример #23
0
/****************************************************************************
NAME    
    slcHandleLinkLossInd
    
DESCRIPTION
    Indication of change in link loss status.

RETURNS
    void
*/
void slcHandleLinkLossInd( const HFP_SLC_LINK_LOSS_IND_T *ind )
{
    typed_bdaddr ag_addr;

    Sink sink;
    /* Are we recovering or have we recovered? */
    if(ind->status == hfp_link_loss_recovery)
    {
        /* Send an event to notify the user */
        MessageCancelAll(&theSink.task , EventSysLinkLoss );
        MessageSend(&theSink.task , EventSysLinkLoss , 0);
        /* Go connectable if feature enabled */
        if(theSink.features.GoConnectableDuringLinkLoss)
            sinkEnableConnectable(); 
    }
    else if(ind->status == hfp_link_loss_none)
    {
        sink_attributes attributes;

        /* Get Sink and bdaddr for the link */
        HfpLinkGetSlcSink(ind->priority, &sink);
        SinkGetBdAddr(sink, &ag_addr);

            /* Carry out link setup */
        slcConnectionSetup(ind->priority, sink, &ag_addr.addr);
       
        /* Link loss recovered - disable connectable */
        if(theSink.features.GoConnectableDuringLinkLoss)
        {
#ifdef ENABLE_SUBWOOFER     
            if(SwatGetSignallingSink(theSink.rundata->subwoofer.dev_id))
            {
               sinkDisableConnectable();            
            }        
#else
        sinkDisableConnectable();            
#endif        
        }

        /* Reconnect A2DP if appropriate */
        if( theSink.features.EnableA2dpStreaming && 
            deviceManagerGetAttributes(&attributes, (const bdaddr *)&ag_addr.addr) && 
            (attributes.profiles & sink_a2dp) )
        {  
            SLC_DEBUG(("SLC: Reconnecting A2DP\n")) ;
            /* attempt reconnection to device supporting A2DP */
            A2dpSignallingConnectRequest((bdaddr *)&ag_addr.addr);
        }
    }
}
/****************************************************************************
NAME
    handleAppPowerOnReq

DESCRIPTION
    Handles the application power on request message.
    
*/
static void handleAppPowerOnReq(void)
{
    if(!(the_app->audioAdaptorPoweredOn) )
    {
        DEBUG_EVENT(("Powering on...\n"));
        /* Cancel the event message if there was one so it doesn't power off */
        MessageCancelAll ( &the_app->task, APP_LIMBO_TIMEOUT ) ;
        the_app->audioAdaptorPoweredOn = TRUE;
        the_app->PowerOffIsEnabled     = TRUE;
        
        /* Power on the Analogue Dongle when APP_POWERON_REQ Message is received */
/*        profileSlcStartConnectionProcess();*/
    }
}
Пример #25
0
/****************************************************************************
NAME 
	hidConnectingExit
DESCRIPTION
	Called whenever the HID instance exits either of the connecting states.
	Sends a HID_CONNECT_CFM to the application.
RETURNS
	void
*/
static void hidConnectingExit(HID *hid)
{
	MAKE_HID_MESSAGE(HID_CONNECT_CFM);
            
	HID_PRINT(("hidConnectingExit\n"));

    /* Cancel pending connection timer */
    MessageCancelAll(&hid->task, HID_INTERNAL_CONNECT_TIMEOUT_IND);

	/* Send HID_CONNECT_CFM to application */
    message->hid = hid;
    message->interrupt_sink = hid->connection[HID_CON_INTERRUPT].con.sink;
    message->status = hid->connect_status;
    MessageSend(hid->app_task, HID_CONNECT_CFM, message);
}
static void send_pio_enter_messages(PioState *pioState, InternalState state)
{
    uint16 init_count = enter_messages[state].count;
    uint16 count = init_count;
    const EnterMessage *p = enter_messages[state].send;
    while(count--)
    {
        if (p->double_tap)
        {
            if (pioState->pio_states.double_press == state)
            {
                if (MessageCancelAll(&pioState->task, double_pio_press_timer))
                {
                    pioState->pio_states.store_held = Unknown;
                    MessageSend(pioState->client, p->id, 0);
                }
                else
                    MessageSendLater(&pioState->task, double_pio_press_timer, 0, p->timeout);
            }
            else
            {
                pioState->pio_states.double_press = state;
                (void) MessageCancelAll(&pioState->task, double_pio_press_timer);
                MessageSendLater(&pioState->task, double_pio_press_timer, 0, p->timeout);
            }
        }
        else if (!p->release)
            MessageSend(pioState->client, p->id, 0);
        else
        {
            pioState->pio_states.store_held = state;
            pioState->pio_states.store_count = init_count - (count + 1);
        }
        p++;
    }
}
Пример #27
0
void CsrSubwooferPluginDisconnect(void)
{
    /* Disconnect the appropriate input to Kalimba */
    if (plugin_data->input == SUBWOOFER_INPUT_ADC)
    {
        PRINT(("[SW_PLUGIN : Disconnect ADC to Kalimba\n"));
        StreamDisconnect(plugin_data->audio_source, StreamKalimbaSink(DSP_INPUT_PORT_ADC));
    }
    else if (plugin_data->input == SUBWOOFER_INPUT_ESCO)
    {
        PRINT(("[SW_PLUGIN] Disconnect eSCO to Kalimba\n"));
        StreamDisconnect(plugin_data->audio_source, StreamKalimbaSink(DSP_INPUT_PORT_ESCO));
        StreamConnectDispose(plugin_data->audio_source);
    }
    else if (plugin_data->input == SUBWOOFER_INPUT_L2CAP)
    {
        PRINT(("[SW_PLUGIN] Disconnect L2CAP to Kalimba\n"));
        StreamDisconnect(plugin_data->audio_source, StreamKalimbaSink(DSP_INPUT_PORT_L2CAP));
        StreamConnectDispose(plugin_data->audio_source);
    }
    
    /* Disconnect the appropriate output from Kalimba */
    if (plugin_data->output == SUBWOOFER_OUTPUT_DAC)
    {
        PRINT(("[SW_PLUGIN] Disconnect Kalimba to DAC\n"));
        StreamDisconnect(StreamKalimbaSource(DSP_OUTPUT_PORT_DAC), plugin_data->codec_sink);
    }
    else if (plugin_data->output == SUBWOOFER_OUTPUT_I2S)
    {
        PRINT(("[SW_PLUGIN] Disconnect Kalimba to I2S\n"));
        CsrI2SAudioOutputDisconnect(TRUE);                                 
    }
    
    /* dispose of any remaining messages in the queue */
    (void) MessageCancelAll( (TaskData*)&csr_subwoofer_plugin, MESSAGE_FROM_KALIMBA);
    MessageKalimbaTask( NULL );
   
    /* Everything has been disconnected so power down Kalimba */
    KalimbaPowerOff();
    
    /* reset flags */
    SetAudioInUse(FALSE);
    SetCurrentDspStatus(DSP_NOT_LOADED);

    /* Free the memory allocated to use for the plugin as it's no longer valid */
    free(plugin_data);
    plugin_data = NULL;
}
Пример #28
0
/****************************************************************************
NAME	
	hfpHandleRfcommDisconnectInd

DESCRIPTION
	Indication that the RFCOMM connection has been disconnected.

RETURNS
	void
*/
void hfpHandleRfcommDisconnectInd(HFP *hfp, const CL_RFCOMM_DISCONNECT_IND_T *ind)
{
	if (hfp->state == hfpSlcConnecting)
	{   /* Rfcomm connection has been shutdown during the SLC connection process */
    	/* Cancel the AT response timeout message because we'll have no more AT cmds being sent */
    	(void) MessageCancelAll(&hfp->task, HFP_INTERNAL_WAIT_AT_TIMEOUT_IND);
    	
	    /* Report a failed connect attempt to app */
		hfpSendSlcConnectCfmToApp(hfp_connect_slc_failed, hfp);
	}
	else
	{   /* Convert the rfc disconnect status into its hfp counterpart and inform library */
    	MAKE_HFP_MESSAGE(HFP_INTERNAL_SLC_DISCONNECT_IND);
    	message->status = convertRfcommDisconnectStatus(ind->status);
    	MessageSend(&hfp->task, HFP_INTERNAL_SLC_DISCONNECT_IND, message);
    }
}
Пример #29
0
/****************************************************************************
NAME    
    hfpSendSlcDisconnectIndToApp

DESCRIPTION
    Send a HFP_SLC_DISCONNECT_IND message to the app notifying it that
    the SLC has been disconnected.

RETURNS
    void
*/
void hfpSendSlcDisconnectIndToApp(hfp_link_data* link, hfp_disconnect_status status)
{
    MAKE_HFP_MESSAGE(HFP_SLC_DISCONNECT_IND);
    message->status   = status;
    message->priority = hfpGetLinkPriority(link);
    (void)hfpGetLinkBdaddr(link, &message->bd_addr);
    
    /* Tidy up if valid link was disconnected */
    if(status != hfp_disconnect_no_slc)
    {
        /* Reset the connection related state */
        hfpLinkReset(link, TRUE);

        /* Cancel the AT response timeout message because we'll have no more AT cmds being sent */
        (void) MessageCancelAll(&theHfp->task, hfpGetLinkTimeoutMessage(link, HFP_INTERNAL_WAIT_AT_TIMEOUT_LINK_0_IND));
    }
    MessageSend(theHfp->clientTask, HFP_SLC_DISCONNECT_IND, message);
}
Пример #30
0
/****************************************************************************  
DESCRIPTION
    function to handle a button press - informs button manager of a change
    currently makes direct call - may want to use message handling (tasks)
*/ 
static void ButtonsButtonDetected (  ButtonsTaskData * pButtonsTask, uint32 pButtonMask  , ButtonsTime_t pTime )
{
    B_DEBUG(("B:But Det[%lx]\n", pButtonMask)) ;
    
    if( pButtonMask == 0 )
    {
        MessageCancelAll ( &pButtonsTask->task , B_REPEAT_TIMER ) ;
    }
    else
    {
        BMButtonDetected ( pButtonMask, pTime ) ;             
        
        if (stateManagerGetState() == deviceTestMode)
        {
            checkDUTKeyRelease(pButtonMask, pTime);
        }
    }
}