示例#1
0
文件: sink_slc.c 项目: jrryu/HW--FW
/****************************************************************************
NAME    
    slcIsListIdAvailable
    
DESCRIPTION
    determine whether the ListID passed in is available in the PDL, the ID
    passed in could be out of range of the PDL so checks for that also

RETURNS
    true or false success status,
*/   
bool slcIsListIdAvailable(uint8 ListID)
{
    
    /* check ListID is a valid value within the range of the available devices in the PDL 
       and that it is not already connected */
    if((ListID < gSlcData.gPdlSize)&&(isPdlEntryAvailable(ListID)))
    {
        typed_bdaddr  ag_addr;
        sink_attributes attributes;      

        /* obtain attributes for passed in ID */   
        if(deviceManagerGetIndexedAttributes(ListID, &attributes, &ag_addr))
        {
            /* check whether device supports hfp, a2dp or avrcp */
            if(!(attributes.profiles & (sink_hfp | sink_a2dp | sink_avrcp)))
            {
                /* device does not support required profiles */
                SLC_DEBUG(("SLC: slcIsListIdAvailable - FALSE - no profile support - ListID = %x\n",ListID)) ;
                return FALSE;
            }
        }

        SLC_DEBUG(("SLC: slcIsListIdAvailable - TRUE - ListID = %x\n",ListID)) ;
        return TRUE;        
    }
    /* out of range value or already connected return failed status */
    else
    {
        SLC_DEBUG(("SLC: slcIsListIdAvailable - FALSE - ListID = %x\n",ListID)) ;
        return FALSE;
    }
}
示例#2
0
文件: sink_slc.c 项目: jrryu/HW--FW
/****************************************************************************
NAME    
    slcAttemptConnection
    
DESCRIPTION
    attemp connection to next item in pdl

RETURNS
    void
*/
void slcAttemptConnection(void)
{
    typed_bdaddr  ag_addr;
    sink_attributes attributes;      

    /* attempt to obtain the device attributes for the current ListID required */
    if(deviceManagerGetIndexedAttributes(gSlcData.gListID, &attributes, &ag_addr))
    {
        /* device exists, determine whether the device supports HFP/HSP, A2DP or both and connect
           as appropriate */
        SLC_DEBUG(("SLC: slcAttConn, listId = %d, attrib = %x\n",gSlcData.gListID,attributes.profiles)) ;

        /* ensure the device supports the required profiles before attempting to connect otherwise
           try to find another device */
        if((attributes.profiles & (sink_hfp | sink_a2dp | sink_avrcp))&&(IsSameBTAdrSALT(&ag_addr.addr)==FALSE))
        {
            /* attempt to connect to device */
            slcConnectDevice(&ag_addr.addr, attributes.profiles);
        }
        /* device does not support required profiles, try to find another device that does */
        else
        {
            /* attempts to find another paired device in the PDL */
            MessageCancelFirst(&theSink.task, EventSysContinueSlcConnectRequest);
            MessageSend(&theSink.task, EventSysContinueSlcConnectRequest, 0);
        }
    }
    else
    {
        /* attempts to find another paired device in the PDL */
        MessageCancelFirst(&theSink.task, EventSysContinueSlcConnectRequest);
        MessageSend(&theSink.task, EventSysContinueSlcConnectRequest, 0);
    }
    
    SLC_DEBUG(("SLC: slcAttConnm\n")) ;
                   
}
示例#3
0
/****************************************************************************
NAME
    deviceManagerSetPriority
    
DESCRIPTION
    Set a device's priority in the PDL

RETURNS
    new pdl listId of passed in src addr
*/
uint8 deviceManagerSetPriority(const bdaddr* dev_addr)
{
    conn_mask mask = deviceManagerProfilesConnected(dev_addr);
    uint8 ListId = 0;
    
    DEV_DEBUG(("DEV: Update PDL/MRU\n")) ;

    
    /* more than 1 connected device ? */
    if(deviceManagerNumConnectedDevs() > 1)
    {
        typed_bdaddr  typed_ag_addr;
        bdaddr ag_addr;
        sink_attributes attributes;      
 

        DEV_DEBUG(("DEV: Update MRU - two devices connected\n")) ;
        
        /* is this a connection of a2dp or hfp to the already connected primary device ? */            
        deviceManagerGetIndexedAttributes(0, &attributes, &typed_ag_addr);
        /* extract bluetooth address from packed structure */
        ag_addr = typed_ag_addr.addr;
        /* check if this is the primary device? */
        if(BdaddrIsSame(&ag_addr,dev_addr))
        {
            DEV_DEBUG(("DEV: Update MRU - two devices two profiles connected - primary device\n")) ;
            ListId = 0;
        }
        else
        {
            DEV_DEBUG(("DEV: Update MRU - two devices two profiles connected - secondary device\n")) ;
            /* Move the second device to top of the PDL */
            ConnectionSmUpdateMruDevice(dev_addr);      
            /* get bdaddr of the device that was previously the primary device but is
               now the secondary device */
            deviceManagerGetIndexedAttributes(1, &attributes, &typed_ag_addr);
            /* extract bluetooth address from packed structure */
            ag_addr = typed_ag_addr.addr;
            /* then move the what is now 'secondary device' back to the top of the PDL */                
            ConnectionSmUpdateMruDevice(&ag_addr);              
            /* this is the secondary device */
            ListId = 1;
            /* send connected event if not already done so */
            if(mask && !((mask & conn_hfp)&&(mask & conn_a2dp)))
            {
               MessageSend (&theSink.task , EventSecondaryDeviceConnected , NULL );        
            }
        }        
    }
    /* only 1 device so must be primary */
    else
    {
        /* Move device to top of the PDL */
        DEV_DEBUG(("DEV: Update MRU - primary device\n")) ;
        ConnectionSmUpdateMruDevice(dev_addr);    
        /* if this is the first profile for the device to be connected then send
           the primary device connected event */
        if(mask && !((mask & conn_hfp)&&(mask & conn_a2dp)))
        {
           MessageSend (&theSink.task , EventPrimaryDeviceConnected , NULL );        
        }
    }
   
    /* return current pdl list position of this device which is 0, top of list */        
    DEV_DEBUG(("DEV: Update MRU - ListId = %x\n",ListId)) ;
    return ListId;
}