示例#1
0
static int l3_init(int protocol)
{
	printf("running layer3 (ats)\n");
	ph = rfid_protocol_init(l2h, protocol);
	if (!ph) {
		fprintf(stderr, "error during protocol_init\n");
		return -1;
	}
	if (rfid_protocol_open(ph) < 0) {
		fprintf(stderr, "error during protocol_open\n");
		return -1;
	}

	printf("we now have layer3 up and running\n");

	return 0;
}
示例#2
0
文件: openpcd.c 项目: dpavlin/librfid
EXPORT int EXPORT_CONVENTION openpcd_select_card(MIFARE_HANDLE handle)
{
    int res;
    struct openpcd_state *state;
        
    if(!handle)
	return PCDERROR_INVALID_PARAMETER;
    state=(struct openpcd_state*)handle;
    
    state->l2h = rfid_layer2_init(state->rh,RFID_LAYER2_ISO14443A);
    if(!state->l2h)
	res=PCDERROR_LAYER2_INIT;
    else
    {        
	if( rfid_layer2_open(state->l2h)>=0 ) 
	{
    	    state->ph = rfid_protocol_init(state->l2h,RFID_PROTOCOL_MIFARE_CLASSIC);
	
	    if(state->ph)
    	    {
		if(rfid_protocol_open(state->ph)>=0)
	    	    return PCDERROR_NONE;
		
		rfid_protocol_fini(state->ph);
		state->ph=NULL;
	
		res=PCDERROR_LAYER3_OPEN;
	    }
	    else
		res=PCDERROR_LAYER3_INIT;

	    rfid_layer2_close(state->l2h);	
        }
	else
    	    res=PCDERROR_LAYER2_OPEN;
    }
    
    rfid_layer2_fini(state->l2h);
    state->l2h=NULL;
    
    return res;	
}