Bluetooth® Sample Application Programmer's Reference: Smart card processing

Bluetooth

Bluetooth® Sample Application Programmer's Reference

Presentation

Functions

int iccStart (unsigned char rdr)
 Open Integrated Circuit Card perypheral. More...
 
int iccStop (unsigned char rdr)
 Close Integrated Circuit Card perypheral. More...
 
int iccDetect (unsigned char rdr)
 Detect card. More...
 
int iccCommand (unsigned char rdr, const unsigned char *cmd, const unsigned char *dat, unsigned char *rsp)
 Send a command and data to a smart card and retrieve the response. More...
 

Enumerations

enum  eIcc {
  iccBeg, iccCardRemoved, iccCardMute, iccCardPb,
  iccDriverPb, iccReadFailure, iccKO
}
 

Function Documentation

int iccStart ( unsigned char  rdr)

Open Integrated Circuit Card perypheral.

Open the associated channel for the default card reader.

Parameters
rdr(I)
  • right nibble: Reader number, 0..4
  • left nibble: 0 for EMV cards, 1 for ICC7816
Returns
non-negative value if OK; negative otherwise Utilities.h Peripherals.c
int iccStop ( unsigned char  rdr)

Close Integrated Circuit Card perypheral.

Close the associated channel.

Parameters
rdr(I) Reader number, 0..4
Returns
non-negative value if OK; negative otherwise Utilities.h Peripherals.c
int iccDetect ( unsigned char  rdr)

Detect card.

Check if ICC is present/inserted.

Parameters
rdr(I) Reader number, 0..4
Returns
1 if ICC is present, 0 otherwise. Utilities.h Peripherals.c
int iccCommand ( unsigned char  rdr,
const unsigned char *  cmd,
const unsigned char *  dat,
unsigned char *  rsp 
)

Send a command and data to a smart card and retrieve the response.

Send a command cmd followed by data dat to the card; capture the result into rsp.

The command cmd consists of 5 bytes:

  • 0) TYP is the command type, can take values in the range 0..4:
    • 0: without any protocol
    • 1: no input, no output
    • 2: no input, some output
    • 3: some input, no ouput
    • 4: some input, some output
  • 1) CLA: class byte
  • 2) INS: instruction byte
  • 3) P1: parameter 1 byte
  • 4) P1: parameter 2 byte The data dat consists of the length of data and the data itself.

So:

  • the length of input data, if any, is given in the first byte of dat array
  • the length of output data, if any, is given in the cmdLC byte of command

The pointers can take NULL values:

  • If cmd is zero, it means POWER ON command
  • If dat is zero, it means that there is no data (the type byte should take proper value in this case)
  • If rsp is zero, it means that no output is expected

Response length can be given as the first byte of rsp; zero means: get all data

Parameters
rdr(I) Reader number, 0..4
cmd(I) Command to send, consists of 6 bytes: TYP,CLA,INS,P1,P2,LC; for POWER ON command the pointer cmd should be zero
dat(I) Data to send; zero pointer if there is no data. The first byte is the length of the data; after that the data array follows
rsp(O) Buffer to capture card response, this size of the buffer should be 260
Returns
  • (-eIcc code) if failure.
  • length of response if OK.
  • Zero return value means that there is not card inserted (no response). Utilities.h Peripherals.c

Enumeration Type Documentation

enum eIcc
Enumerator
iccBeg 

Smart card error processing codes.

start sentinel

iccCardRemoved 

card removed

iccCardMute 

card mute

iccCardPb 

other card problem

iccDriverPb 

driver problem

iccReadFailure 

Read error.

iccKO 

unknown error


Ingenico