Home | History | Annotate | Download | only in common
      1 /*
      2  * Copyright (C) 2015 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 /*
     18  * NCI Interface
     19  */
     20 
     21 #ifndef PHNCINFCTYPES_H
     22 #define PHNCINFCTYPES_H
     23 
     24 /*
     25  ################################################################################
     26  ***************************** Header File Inclusion
     27  ****************************
     28  ################################################################################
     29  */
     30 #include <phNfcStatus.h>
     31 
     32 /*
     33  ################################################################################
     34  ****************************** Macro Definitions
     35  *******************************
     36  ################################################################################
     37  */
     38 #define PH_NCINFCTYPES_MAX_UID_LENGTH (0x0AU)
     39 /* Maximum length of ATR_RES (General Bytes) length expected */
     40 #define PH_NCINFCTYPES_MAX_ATR_LENGTH (0x30U)
     41 #define PH_NCINFCTYPES_ATQA_LENGTH (0x02U) /* ATQA length */
     42 #define PH_NCINFCTYPES_MAX_HIST_BYTES \
     43   (0x0FU) /* Max Historical bytes returned by Type A tag */
     44 
     45 /*
     46  * Enum definition contains supported RF Protocols
     47  */
     48 typedef enum {
     49   phNciNfc_e_RfProtocolsUnknownProtocol = 0x00, /* Protocol is not known */
     50   phNciNfc_e_RfProtocolsT1tProtocol = 0x01,     /* Type 1 Tag protocol */
     51   phNciNfc_e_RfProtocolsT2tProtocol = 0x02,     /* Type 2 Tag protocol */
     52   phNciNfc_e_RfProtocolsT3tProtocol = 0x03,     /* Type 3 Tag protocol */
     53   phNciNfc_e_RfProtocolsIsoDepProtocol = 0x04,  /* ISO DEP protocol */
     54   phNciNfc_e_RfProtocolsNfcDepProtocol = 0x05,  /* NFC DEP protocol */
     55   phNciNfc_e_RfProtocols15693Protocol = 0x06,   /* 15693 protocol */
     56   phNciNfc_e_RfProtocolsMifCProtocol = 0x80,    /* Mifare Classic protocol */
     57   phNciNfc_e_RfProtocolsHidProtocol = 0x81,     /* Hid protocol */
     58   phNciNfc_e_RfProtocolsEpcGen2Protocol = 0x82, /* EpcGen2 protocol */
     59   phNciNfc_e_RfProtocolsKovioProtocol = 0x83    /* Kovio protocol */
     60 } phNciNfc_RfProtocols_t;
     61 
     62 /*
     63  * Supported RF Interfaces
     64  */
     65 typedef enum {
     66   phNciNfc_e_RfInterfacesNfceeDirect_RF = 0x00, /* Nfcee Direct RF Interface */
     67   phNciNfc_e_RfInterfacesFrame_RF = 0x01,       /* Frame RF Interface */
     68   phNciNfc_e_RfInterfacesISODEP_RF = 0x02,      /* ISO DEP RF Interface */
     69   phNciNfc_e_RfInterfacesNFCDEP_RF = 0x03,      /* NFC DEP RF Interface */
     70   phNciNfc_e_RfInterfacesTagCmd_RF = 0x80, /* Tag-Cmd RF Interface (Nxp prop) */
     71   phNciNfc_e_RfInterfacesHID_RF = 0x81     /* Hid RF Interface (Nxp prop) */
     72 } phNciNfc_RfInterfaces_t;
     73 
     74 /*
     75  * Enum definition contains RF technology modes supported.
     76  * This information is a part of RF_DISCOVER_NTF or RF_INTF_ACTIVATED_NTF.
     77  */
     78 typedef enum {
     79   phNciNfc_NFCA_Poll = 0x00,        /* Nfc A Technology in Poll Mode */
     80   phNciNfc_NFCB_Poll = 0x01,        /* Nfc B Technology in Poll Mode */
     81   phNciNfc_NFCF_Poll = 0x02,        /* Nfc F Technology in Poll Mode */
     82   phNciNfc_NFCA_Active_Poll = 0x03, /* Nfc A Technology in Active Poll Mode */
     83   phNciNfc_NFCF_Active_Poll = 0x05, /* Nfc F Technology in Active Poll Mode */
     84   phNciNfc_NFCISO15693_Poll = 0x06, /* Nfc ISO15693 Technology in Poll Mode */
     85   phNciNfc_NxpProp_NFCHID_Poll = 0x70, /* Nfc Hid Technology in Poll Mode */
     86   phNciNfc_NxpProp_NFCEPFGEN2_Poll =
     87       0x71, /* Nfc EpcGen2 Technology in Poll Mode */
     88   phNciNfc_NxpProp_NFCKOVIO_Poll = 0x72, /* Nfc Kovio Technology in Poll Mode */
     89   phNciNfc_NFCA_Listen = 0x80,           /* Nfc A Technology in Listen Mode */
     90   phNciNfc_NFCB_Listen = 0x81,           /* Nfc B Technology in Listen Mode */
     91   phNciNfc_NFCF_Listen = 0x82,           /* Nfc F Technology in Listen Mode */
     92   phNciNfc_NFCA_Active_Listen =
     93       0x83, /* Nfc A Technology in Active Listen Mode */
     94   phNciNfc_NFCF_Active_Listen =
     95       0x85, /* Nfc F Technology in Active Listen Mode */
     96   phNciNfc_NFCISO15693_Active_Listen =
     97       0x86 /* Nfc ISO15693 Technology in Listen Mode */
     98 } phNciNfc_RfTechMode_t;
     99 
    100 /*
    101  * This is used to identify the exact device type
    102  */
    103 typedef enum {
    104   phNciNfc_eUnknown_DevType = 0x00U,
    105 
    106   /* Generic PICC Type */
    107   phNciNfc_ePICC_DevType,
    108   /* Specific PICC Devices */
    109   /* This PICC type explains that the card is compliant to the
    110    * ISO 14443-1 and 2A specification. This type can be used for the
    111    * cards that is supporting these specifications
    112    */
    113   phNciNfc_eISO14443_A_PICC,
    114   /* This PICC type explains that the card is compliant to the
    115    * ISO 14443-4A specification
    116    */
    117   phNciNfc_eISO14443_4A_PICC,
    118   /* This PICC type explains that the card is compliant to the
    119    * ISO 14443-3A specification
    120    */
    121   phNciNfc_eISO14443_3A_PICC,
    122   /* This PICC type explains that the card is Mifare UL/1k/4k and
    123    * also it is compliant to ISO 14443-3A. There can also be other
    124    * ISO 14443-3A cards, so the phNciNfc_eISO14443_3A_PICC is also used for
    125    * PICC detection
    126    */
    127   phNciNfc_eMifareUL_PICC,
    128   phNciNfc_eMifare1k_PICC,
    129   phNciNfc_eMifare4k_PICC,
    130   phNciNfc_eMifareMini_PICC,
    131   /* This PICC type explains that the card is compliant to the
    132    * ISO 14443-1, 2 and 3B specification
    133    */
    134   phNciNfc_eISO14443_B_PICC,
    135   /* This PICC type explains that the card is compliant to the
    136    * ISO 14443-4B specification
    137    */
    138   phNciNfc_eISO14443_4B_PICC,
    139   /* This PICC type explains that the card is B-Prime type */
    140   phNciNfc_eISO14443_BPrime_PICC,
    141   phNciNfc_eFelica_PICC,
    142   phNciNfc_eJewel_PICC,
    143   /* This PICC type explains that the card is ISO15693 type */
    144   phNciNfc_eISO15693_PICC,
    145   /* This PICC type explains that the card is EpcGen2 type */
    146   phNciNfc_eEpcGen_PICC,
    147 
    148   /* NFC-IP1 Device Types */
    149   phNciNfc_eNfcIP1_Target,
    150   phNciNfc_eNfcIP1_Initiator,
    151 
    152   /* Other Sources */
    153   phNciNfc_eInvalid_DevType
    154 
    155 } phNciNfc_RFDevType_t;
    156 
    157 /*
    158  * RATS Response Params structure
    159  */
    160 typedef struct phNciNfc_RATSResp {
    161   uint8_t bFormatByte;                              /* Format Byte */
    162   uint8_t bIByteTA;                                 /* Interface Byte TA(1) */
    163   uint8_t bIByteTB;                                 /* Interface Byte TB(1) */
    164   uint8_t bIByteTC;                                 /* Interface Byte TC(1) */
    165   uint8_t bHistByte[PH_NCINFCTYPES_MAX_HIST_BYTES]; /* Historical Bytes - Max
    166                                                        size 15 */
    167 } phNciNfc_RATSResp_t;
    168 
    169 /*
    170  * The Reader A structure includes the available information
    171  * related to the discovered ISO14443A remote device. This information
    172  * is updated for every device discovery.
    173  */
    174 typedef struct phNciNfc_Iso14443AInfo {
    175   uint8_t Uid[PH_NCINFCTYPES_MAX_UID_LENGTH]; /* UID information of the TYPE A
    176                                               Tag Discovered NFCID1 -
    177                                               Considering max size of NFCID1*/
    178   uint8_t UidLength; /* UID information length, shall not be greater
    179                      than PHNCINFC_MAX_UID_LENGTH i.e., 10 */
    180   uint8_t AppData[PH_NCINFCTYPES_MAX_ATR_LENGTH]; /* Application data
    181                                               information of the tag discovered
    182                                               (= Historical bytes for type A) */
    183   uint8_t AppDataLength;                          /* Application data length */
    184   uint8_t Sak; /* SAK information of the TYPE ATag Discovered
    185                Mapped to SEL_RES Response*/
    186   uint8_t AtqA[PH_NCINFCTYPES_ATQA_LENGTH]; /* ATQA information of the TYPE A
    187                                        Tag Discovered */
    188   uint8_t MaxDataRate;           /* Maximum data rate supported by the TYPE A
    189                                  Tag Discovered */
    190   uint8_t Fwi_Sfgt;              /* Frame waiting time and start up frame guard
    191                                  time as defined in ISO/IEC 14443-4[7] for type A */
    192   uint8_t bSensResResp[2];       /* SENS_RES Response */
    193   uint8_t bSelResRespLen;        /* SEL_RES Response Length */
    194   uint8_t bRatsRespLen;          /* Length of RATS Response */
    195   phNciNfc_RATSResp_t tRatsResp; /* RATS Response Info */
    196 } phNciNfc_Iso14443AInfo_t;
    197 
    198 /*
    199  * The Remote Device Information Union includes the available Remote Device
    200  * Information structures. Following the device detected, the corresponding data
    201  * structure is used.
    202  */
    203 typedef union phNciNfc_RemoteDevInfo {
    204   phNciNfc_Iso14443AInfo_t Iso14443A_Info; /* Type A tag Info */
    205 } phNciNfc_RemoteDevInfo_t;
    206 
    207 /* Contains Details of Discovered Target */
    208 typedef struct phNciNfc_RemoteDevInformation {
    209   uint8_t SessionOpened; /* Flag indicating the validity of the handle of the
    210                             remote device. */
    211   phNciNfc_RFDevType_t
    212       RemDevType;                /* Remote device type which says that remote
    213                                   is Reader A or Reader B or NFCIP or Felica or
    214                                   Reader B Prime or Jewel*/
    215   uint8_t bRfDiscId;             /* ID of the Tag */
    216   phNciNfc_RfInterfaces_t eRfIf; /* RF Interface */
    217   phNciNfc_RfProtocols_t eRFProtocol; /* RF protocol of the target */
    218   phNciNfc_RfTechMode_t
    219       eRFTechMode; /* RF Technology mode of the discovered/activated target */
    220   uint8_t bMaxPayLoadSize;       /* Max data payload size*/
    221   uint8_t bInitialCredit;        /* Initial credit*/
    222   uint8_t bTechSpecificParamLen; /* Technology Specific parameter length, for
    223                                     Debugging purpose only*/
    224   phNciNfc_RfTechMode_t
    225       eDataXchgRFTechMode; /* Data Exchange RF Technology mode of the activated
    226                               target */
    227   uint8_t bTransBitRate;   /* Transmit Bit Rate */
    228   uint8_t bRecvBitRate;    /* Receive Bit Rate */
    229   phNciNfc_RemoteDevInfo_t
    230       tRemoteDevInfo; /* Structure object to #phNciNfc_RemoteDevInfo_t*/
    231 } phNciNfc_RemoteDevInformation_t,
    232     *pphNciNfc_RemoteDevInformation_t; /* Pointer to Remote Dev Info*/
    233 
    234 /*
    235  * Structure contains buffer where payload of the received data packet
    236  * shall be stored and length of the payload stored in the buffer.
    237  */
    238 typedef struct phNciNfc_Data {
    239   uint8_t* pBuff; /* Buffer to store received data packet's payload */
    240   uint16_t wLen;  /* Length of the payload */
    241 } phNciNfc_Data_t, *pphNciNfc_Data_t;
    242 
    243 /*
    244  * Type 2 tag command list supported by NCI stack
    245  * It includes command lists applicable to Mifare family cards also
    246  */
    247 typedef enum phNciNfc_T2TCmdList {
    248   phNciNfc_eT2TRaw = 0x00, /* Performs Raw communication over T2T Tag*/
    249   phNciNfc_eT2TWriteN,     /* Write Multiple blocks to T2T tag*/
    250   phNciNfc_eT2TreadN,      /* Read Multiple blocks to T2T tag*/
    251   phNciNfc_eT2TSectorSel,  /* Sector Select for MifareStd Cards*/
    252   phNciNfc_eT2TAuth,       /* Sector Select for MifareStd Cards*/
    253   phNciNfc_eT2TProxCheck,  /* Proxy Check command for MF+*/
    254   phNciNfc_eT2TInvalidCmd  /* Invalid Command*/
    255 } phNciNfc_T2TCmdList_t;   /* Type2 Tag and Mifare specicific command list*/
    256 
    257 /* All command list for tag operation supported by NCI stack */
    258 typedef union phNciNfc_TagCmdList {
    259   phNciNfc_T2TCmdList_t T2TCmd; /* T2T Specific command*/
    260 } phNciNfc_TagCmdList_t;        /* Tag specific command */
    261 
    262 /* Transceive info */
    263 typedef struct phNciNfc_TransceiveInfo {
    264   phNciNfc_TagCmdList_t uCmd; /* Technology Specific commands */
    265   uint8_t bAddr; /* Start address to perform operation,Valid for T1T T2T T3T and
    266                     some Propriatery tags */
    267   uint8_t bNumBlock;         /* Number of blocks */
    268   uint16_t wTimeout;         /* Timeout value to be used during transceive */
    269   phNciNfc_Data_t tSendData; /* Buffer information for sending data */
    270   phNciNfc_Data_t tRecvData; /* Buffer information for receiving data */
    271   /* Details for Felica To be Added if Check and Update supported */
    272 } phNciNfc_TransceiveInfo_t,
    273     *pphNciNfc_TransceiveInfo_t; /* pointer to struct #phNciNfc_TransceiveInfo_t
    274                                   */
    275 
    276 #endif /* end of #ifndef PHNCINFCTYPES_H */
    277