コード例 #1
0
/******************************************************************************
 This function configures the security settings for SDP service record 
 browsing. It function will configure outgoing connections to permit service 
 record to be browsed without the need for the devices concerned to be paired.
*/	
void ConnectionSmSetSdpSecurityOut(bool enable, const bdaddr *bd_addr)
{
#ifdef CONNECTION_DEBUG_LIB
    if ((enable != TRUE) && (enable != FALSE))
    {
        CL_DEBUG(("Out of range enable 0x%x\n", enable));
    }
    if(bd_addr == NULL)
    {
       CL_DEBUG(("Out of range Bluetooth Address 0x%p\n", (void *)bd_addr)); 
    }
#endif

	if (enable)
	{
        ConnectionSmRegisterOutgoingService(bd_addr, protocol_l2cap, UUID16_SDP, secl_none);
	}
	else
	{
        ConnectionSmUnRegisterOutgoingService(bd_addr, protocol_l2cap, UUID16_SDP);
	}
}
コード例 #2
0
ファイル: sink_mapc.c プロジェクト: jrryu/HW--FW
/****************************************************************************
NAME	
	mapcHandleServiceSearchAttributeCfm
    
DESCRIPTION
    confirmation of the service search for MAP support, if successful the 
    app will progress and attempt to connect to the message access service
    
PARAMS
    @cfm message
    
RETURNS
	void
*/
void mapcHandleServiceSearchAttributeCfm( const CL_SDP_SERVICE_SEARCH_ATTRIBUTE_CFM_T *cfm)
{
    uint8 *rfcomm_channels;	
    uint8 size_rfcomm_channels = 1;
    uint8 channels_found = 0;
    mapcState *state = NULL;
    
    mapc_link_priority device_id = mapcGetLinkFromBdAddr( &cfm->bd_addr );
    
    /* ensure device_id has been correctly retrieved */
    if(device_id != mapc_invalid_link)
        state = &(theSink.rundata->mapc_data.state[device_id]);
    
    /* if the service search has been successful, parse returned entries */
    if(cfm->status == sdp_response_success)
    {
        MAPC_DEBUG(("MAPC:\tReceived SDP Response of length %d\n", cfm->size_attributes));
    
        rfcomm_channels = mallocPanic(size_rfcomm_channels * sizeof(uint8));
             
        /* parse all returned reports */
        if (SdpParseGetMultipleRfcommServerChannels(
                            cfm->size_attributes, 
                            (uint8*)cfm->attributes, 
                            1, 
                            &rfcomm_channels, 
                            &channels_found) )
        {
            /* If receiving multiple responses, the first record will be stored in this application */
            if(state)
            {
                state->masChannel   = rfcomm_channels[0];
                state->bdAddr       = cfm->bd_addr;
                state->device_state = mapc_sdp_searched;
    
                /* set the link security requirements */
                ConnectionSmSetSdpSecurityOut(TRUE, &cfm->bd_addr); 
                    
                ConnectionSmRegisterOutgoingService(&theSink.task, 
                                                    &cfm->bd_addr, 
                                                    protocol_rfcomm,
                                                    state->masChannel,
                                                    sec4_out_level_2);                
    
                /* attempt to connect the message access service */
                MapcMasConnectRequest( &theSink.task, &cfm->bd_addr, state->masChannel );
            }
        }
        /* no channels were found, there reset the state of this connection */
        else
        {
            if(state)
                state->device_state = mapc_state_idle;
            
            MAPC_DEBUG(("MAPC:NO Channels found\n"));   
        }
        /* ensure memory used in sdp record parsing is free'd */
        freePanic(rfcomm_channels);
    }
    /* the sdp record search was not successful, no further action needs to be taken */
    else
    {
        /* reset current connection state so that it can be reused */
        if(state)        
            state->device_state = mapc_state_idle;

        MAPC_DEBUG(("MAPC:SDP Search Failed. Status = %x, more = %x, error = %x \n", cfm->status, cfm->more_to_come, cfm->error_code));
        
    }
}