Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
iso7816.h
00001 /* 00002 * Copyright (c) 2014-2018, ARM Limited, All Rights Reserved 00003 * SPDX-License-Identifier: Apache-2.0 00004 * 00005 * Licensed under the Apache License, Version 2.0 (the "License"); you may 00006 * not use this file except in compliance with the License. 00007 * You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 00013 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 */ 00017 /** 00018 * \file iso7816.h 00019 * \copyright Copyright (c) ARM Ltd 2014 00020 * \author Donatien Garnier 00021 */ 00022 00023 #ifndef ISO7816_H_ 00024 #define ISO7816_H_ 00025 00026 #include "stack/nfc_common.h" 00027 00028 #include "transceiver/protocols.h" 00029 #include "tech/isodep/isodep_target.h" 00030 00031 #ifdef __cplusplus 00032 extern "C" { 00033 #endif 00034 00035 struct nfc_tech_iso7816_c_apdu { 00036 uint8_t cla; 00037 uint8_t ins; 00038 uint8_t p1; 00039 uint8_t p2; 00040 ac_buffer_t dataIn; 00041 size_t maxRespLength; 00042 }; 00043 00044 struct nfc_tech_iso7816_r_apdu { 00045 ac_buffer_t dataOut; 00046 uint16_t sw; 00047 }; 00048 00049 #define ISO7816_RX_BUFFER_SIZE 256 00050 00051 typedef struct nfc_tech_iso7816_c_apdu nfc_tech_iso7816_c_apdu_t; 00052 typedef struct nfc_tech_iso7816_r_apdu nfc_tech_iso7816_r_apdu_t; 00053 00054 typedef struct nfc_tech_iso7816 nfc_tech_iso7816_t; 00055 00056 typedef void (*nfc_tech_iso7816_disconnected_cb)(nfc_tech_iso7816_t *pIso7816, void *pUserData); 00057 00058 struct nfc_tech_iso7816_app; 00059 typedef struct nfc_tech_iso7816_app nfc_tech_iso7816_app_t; 00060 00061 struct nfc_tech_iso7816 { 00062 nfc_tech_isodep_target_t isoDepTarget; 00063 00064 nfc_tech_iso7816_app_t *pAppList; 00065 nfc_tech_iso7816_app_t *pSelectedApp; 00066 00067 bool disconnected; 00068 00069 nfc_tech_iso7816_c_apdu_t cApdu; 00070 nfc_tech_iso7816_r_apdu_t rApdu; 00071 00072 bool responseReady; 00073 00074 nfc_tech_iso7816_disconnected_cb disconnectedCb; 00075 void *pUserData; 00076 00077 ac_buffer_t hist; //Historical bytes 00078 00079 ac_istream_t inputStream; 00080 ac_ostream_t outputStream; 00081 00082 //PDU buffer (tx) 00083 uint8_t txBuf[2]; 00084 ac_buffer_builder_t txBldr; 00085 00086 //Receive buffer 00087 uint8_t rxBuf[ISO7816_RX_BUFFER_SIZE]; 00088 ac_buffer_builder_t rxBldr; 00089 }; 00090 00091 void nfc_tech_iso7816_init(nfc_tech_iso7816_t *pIso7816, nfc_transceiver_t *pTransceiver, nfc_tech_iso7816_disconnected_cb disconnectedCb, void *pUserData); 00092 void nfc_tech_iso7816_add_app(nfc_tech_iso7816_t *pIso7816, nfc_tech_iso7816_app_t *pIso7816App); 00093 void nfc_tech_iso7816_connect(nfc_tech_iso7816_t *pIso7816); 00094 void nfc_tech_iso7816_disconnect(nfc_tech_iso7816_t *pIso7816); 00095 nfc_err_t nfc_tech_iso7816_reply(nfc_tech_iso7816_t *pIso7816); 00096 00097 inline static nfc_tech_iso7816_c_apdu_t *nfc_tech_iso7816_c_apdu(nfc_tech_iso7816_t *pIso7816) 00098 { 00099 return &pIso7816->cApdu; 00100 } 00101 00102 inline static nfc_tech_iso7816_r_apdu_t *nfc_tech_iso7816_r_apdu(nfc_tech_iso7816_t *pIso7816) 00103 { 00104 return &pIso7816->rApdu; 00105 } 00106 00107 #ifdef __cplusplus 00108 } 00109 #endif 00110 00111 #endif /* ISO7816_H_ */
Generated on Tue Aug 9 2022 00:37:09 by
1.7.2