Vous êtes sur la page 1sur 5

A30-B IOS API

Static library
libAudioInteraction.a

interface
1. send:(NSData*)data Time:(unsigned long)timeout_ms tag(int)tag; data: data message Time:overtime 2. StopComm stop the communication between A30-b and phone 3. RegisterCallback(id<iposDrvCallback>)callback; init a callback function,it is the first step to start the app. 4. UnregisterCallback; logoff the callback function. 5onReceive:(NSString* )data Tag:(int)tag; receive the return message. 6OnError:(int)error Tag:(int)tag; manage the error message. tag:tag

When you develop the demo,you may use the system lib:
AudioToolbox.framework AvFoundation.framework MediaPlayer.framework

About

send:(NSData*)data Time:(unsigned long)timeout_ms tag(int)tag;

data format S/N 1 Offset 0 Byte 2 Meaning SSC Value Hex xxxx

Device type 0SE moder 1reader other:developing cmd Cmd length

NN

3 4

3 5

2 2

xxxx 00

Init order: 00010101050000 Magiccardread order:00010102030000 Password order:00010102040000 Ic_read order: 00010102050000

For example in a30demo Magiccard read

- (IBAction)magic_read:(id)sender { unsignedcharbuf[7] = {0}; buf[0] = 0x00; buf[1] = 0x01; buf[2] = 0x01; buf[3] = 0x02; buf[4] = 0x03; buf[5] = 0x00; buf[6] = 0x00; NSData *senddata=nil; senddata=[[NSDataalloc] initWithBytes:buflength:7]; // send send message and set overtime is 20s int status=[m_IPosControllerSend:senddataTime:20000Tag:1]; //whether call the callback function if (status==SEND_STATUS_SUCCESS) { [selfoutputMsg:[NSStringstringWithFormat:@"send data:%@",senddata ]]; } else [selfoutputMsg:@"no init the callback funciton!"];

then use the on Receive() to get the return message ,then analysis the message to get the useful message. -(void)onReceive:(NSData* )data Tag:(int)tag { //type==1 magiccard type==2 passord type==3 iccard if (Type==1) { NSMutableString *murStr = [[NSMutableStringalloc] init]; [murStrappendString:@"received data:"]; unsignedchar* recvbuf=(unsignedchar*)[data bytes]; intrecvlen=[data length]; for (inti = 9; i<recvlen; i++) { NSString *str = [NSStringstringWithFormat:@"%c",recvbuf[i]]; [murStrappendString:str]; if (recvbuf[i+1]==0x3d) { break; } } [selfperformSelectorOnMainThread:@selector(outputMsg:) withObject:murStrwaitUntilDone:NO]; } //ic card read if(Type==3){ NSMutableString *murStr = [[NSMutableString alloc] init]; [murStr appendString:@"received:"]; unsigned char* recvbuf=(unsigned char*)[data bytes]; int recvlen=[data length]; NSString *ATR=@"\nATR:"; [murStr appendFormat:ATR]; //get ic card ATR for (int i = 7; i < 7+recvbuf[5]; i++) { NSString *str = [NSString stringWithFormat:@"%c",recvbuf[i]]; [murStr appendString:str]; } NSString *RST=@"\nRST:"; [murStr appendFormat:RST]; //get ic card RST for(int i = 7+recvbuf[5];i<recvlen;i++){ NSString *RST = [NSString stringWithFormat:@"%c",recvbuf[i]]; [murStr appendString:RST];

} // performSelectorOnMainThread [self performSelectorOnMainThread:@selector(outputMsg:) withObject:murStr waitUntilDone:NO]; } }

About the Demo

Firstly: Init the callback function:

After this operation, you can commucite with A30

For example:magicrad:

The default overtime is 20s,if during the time you want to cancel the operation,you can click stop button.and if you haven`t click this button,when you click other buttons,it will show you the message Call conflict.

Vous aimerez peut-être aussi