/****************************************************************************
NAME
    scanWriteEirData

DESCRIPTION
    Write media dongle EIR data.
    
*/
void scanWriteEirData (CL_DM_LOCAL_NAME_COMPLETE_T *message)
{
#define SIZE_UUIDS (size_uuids ? size_uuids + 1 : 0)
    
/* Length of EIR data with all fields complete */
#define EIR_DATA_SIZE_FULL (message->size_local_name + 2 + SIZE_UUIDS + 1 + INQUIRY_TX_DATA_SIZE + 1)

/* Whether the EIR data is shortened or not. */
#define EIR_DATA_SHORTENED (EIR_DATA_SIZE_FULL > EIR_MAX_SIZE)

/* Maximum length the local name can be to fit EIR data into DH1 */
#define EIR_NAME_MAX_SIZE (EIR_MAX_SIZE - (2 + SIZE_UUIDS + 1 + INQUIRY_TX_DATA_SIZE + 1))

/* Actual length of the local name put into the EIR data */
#define EIR_NAME_SIZE (EIR_DATA_SHORTENED ? EIR_NAME_MAX_SIZE : message->size_local_name)

    uint8 size_uuids = mvdSizeUuids(the_app->supported_profiles);
    
    /* Determine length of EIR data */
    uint16 size = EIR_DATA_SHORTENED ? EIR_MAX_SIZE : EIR_DATA_SIZE_FULL;
    
    /* Just enough for the UUID16, Inquiry Tx and name fields and null termination */
    uint8 *const eir = (uint8 *)PanicUnlessMalloc(size * sizeof(uint8));
    uint8 *p = eir;    
    
    *p++ = EIR_NAME_SIZE + 1;  /* Device Name Length Field */
    *p++ = EIR_DATA_SHORTENED ? EIR_TYPE_LOCAL_NAME_SHORTENED : EIR_TYPE_LOCAL_NAME_COMPLETE;
    memcpy(p, message->local_name, EIR_NAME_SIZE);
    p += EIR_NAME_SIZE;
        
    *p++ = INQUIRY_TX_DATA_SIZE;      /* Inquiry Tx Length Field */
    *p++ = EIR_TYPE_INQUIRY_TX;
    *p++ = the_app->inquiry_tx;
       
    if (size_uuids)
    {
        *p++ = size_uuids; /* UUIDs length field */
        mvdSetUuids (p, the_app->supported_profiles);
        p += size_uuids;
    }
    
    *p++ = 0x00; /* Termination. p ends up pointing one off the end */
    
    ConnectionWriteEirData(FALSE, size, eir);
        
    /* Free the EIR data */
    free(eir);
}
Esempio n. 2
0
/****************************************************************************
NAME    
    inquiry_write_eir_data - Write devices EIR data
*/ 
void inquiry_write_eir_data(const CL_DM_LOCAL_NAME_COMPLETE_T *data)
{
    /* Determine length of EIR data */
    uint16 total_eir_size = 0;
    uint16 size_uuids = 0;
    uint8 *eir = NULL;

    if (AGHFP_PROFILE_IS_ENABLED)
    {
        size_uuids += sizeof(eir_hfp_uuids);
    }
    if (A2DP_PROFILE_IS_ENABLED)
    {
        size_uuids += sizeof(eir_a2dp_uuids);
    }
    if (AVRCP_PROFILE_IS_ENABLED)
    {
        size_uuids += sizeof(eir_avrcp_uuids);
    }
    
    total_eir_size = EIR_BLOCK_SIZE(EIR_DATA_SIZE_FULL(data->size_local_name) + 
                    EIR_DATA_SIZE_FULL(sizeof(uint8)) + EIR_DATA_SIZE_FULL(size_uuids));
    
    /* Allocate space for EIR data */
    eir = (uint8 *)memory_create(total_eir_size);
    
    if (eir)
    {
        uint8 *p = eir;
            
        /* Device Name Field */
        *p++ = EIR_DATA_SIZE(data->size_local_name);  
        *p++ = EIR_TYPE_LOCAL_NAME_COMPLETE;
        memmove(p, data->local_name, data->size_local_name);
        p += data->size_local_name;
            
        /* Inquiry Tx Field */
        *p++ = EIR_DATA_SIZE(sizeof(int8));
        *p++ = EIR_TYPE_INQUIRY_TX;
        *p++ = theSource->inquiry_mode.inquiry_tx;
            
        /* UUID16 field */
        *p++ = EIR_DATA_SIZE(sizeof(eir_uuids));
        *p++ = EIR_TYPE_UUID16_COMPLETE;
        
        if (AGHFP_PROFILE_IS_ENABLED)
        {
            memmove(p, eir_hfp_uuids, sizeof(eir_hfp_uuids));
            p += sizeof(eir_hfp_uuids);
        }
        if (A2DP_PROFILE_IS_ENABLED)
        {
            memmove(p, eir_a2dp_uuids, sizeof(eir_a2dp_uuids));
            p += sizeof(eir_a2dp_uuids);
        }
        if (AVRCP_PROFILE_IS_ENABLED)
        {
            memmove(p, eir_avrcp_uuids, sizeof(eir_avrcp_uuids));
            p += sizeof(eir_avrcp_uuids);
        }
            
        /* NULL Termination */
        *p++ = 0x00; 
            
        /* Register and free EIR data */
        ConnectionWriteEirData(FALSE, total_eir_size, eir);
        memory_free(eir);
        
        INQUIRY_DEBUG(("INQUIRY: inquiry_write_eir_data\n"));
    }
}
Esempio n. 3
0
/****************************************************************************
NAME    
    sinkWriteEirData
    
DESCRIPTION
    Writes the local name, inquiry tx power and device UUIDs into device 
    EIR data

RETURNS
    void
*/
void sinkWriteEirData( CL_DM_LOCAL_NAME_COMPLETE_T *message )
{
    uint16 size_uuids = 0;
    uint16 size = 0;
    
    uint8 *eir = NULL;
    uint8 *p = NULL;
    
    /* Determine length of EIR data */
    size_uuids = SIZE_A2DP_UUIDS + SIZE_AVRCP_UUIDS + SIZE_PBAP_UUIDS + SIZE_HFP_UUIDS + SIZE_HSP_UUIDS;
    
    size = GetDeviceIdEirDataSize() + EIR_BLOCK_SIZE(EIR_DATA_SIZE_FULL(size_uuids) + EIR_DATA_SIZE_FULL(message->size_local_name) + EIR_DATA_SIZE_FULL(sizeof(uint8)));    
    
    /* Allocate space for EIR data */
    eir = (uint8 *)mallocPanic(size * sizeof(uint8));
    p = eir;    
    
    /* Device Id Record */
    p += WriteDeviceIdEirData( p );
    
    /* Inquiry Tx Field */
    *p++ = EIR_DATA_SIZE(sizeof(int8));
    *p++ = EIR_TYPE_INQUIRY_TX;
    *p++ = theSink.inquiry_tx;
    
    /* UUID16 field */
    *p++ = EIR_DATA_SIZE(size_uuids);
    *p++ = EIR_TYPE_UUID16_PARTIAL;

    if(theSink.features.EnableA2dpStreaming)
    {
        memmove(p, a2dp_uuids, sizeof(a2dp_uuids));
        p += sizeof(a2dp_uuids);
    }  
    
#ifdef ENABLE_AVRCP 
    if (theSink.features.avrcp_enabled)
    {
        memmove(p, avrcp_uuids, sizeof(avrcp_uuids));
        p += sizeof(avrcp_uuids);
    }
#endif      

#ifdef ENABLE_PBAP
    if (theSink.features.pbap_enabled)
    {
        memmove(p, pbap_uuids, sizeof(pbap_uuids));
        p += sizeof(pbap_uuids);
    }
#endif

    if(theSink.hfp_profiles & hfp_handsfree_all)
    {
        memmove(p, hfp_uuids, sizeof(hfp_uuids));
        p += sizeof(hfp_uuids);
    }
    if(theSink.hfp_profiles & hfp_headset_all)
    {
        memmove(p, hsp_uuids, sizeof(hsp_uuids));
        p += sizeof(hsp_uuids);
    }
    
    /* Device Name Field */
    *p++ = EIR_DATA_SIZE(message->size_local_name);  
    *p++ = EIR_TYPE_LOCAL_NAME_COMPLETE;
    memmove(p, message->local_name, message->size_local_name);
    p += message->size_local_name;
    
    /* NULL Termination */
    *p++ = 0x00; 
    
    /* Register and free EIR data */
    ConnectionWriteEirData(FALSE, size, eir);
    freePanic(eir);
}