Fork for the GitHub
lib_NDEF_AAR.cpp@0:de13951f30f6, 2019-11-14 (annotated)
- Committer:
- DiegoOstuni
- Date:
- Thu Nov 14 10:34:11 2019 +0000
- Revision:
- 0:de13951f30f6
Add files
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
DiegoOstuni | 0:de13951f30f6 | 1 | /** |
DiegoOstuni | 0:de13951f30f6 | 2 | ****************************************************************************** |
DiegoOstuni | 0:de13951f30f6 | 3 | * @file lib_NDEF_AAR.c |
DiegoOstuni | 0:de13951f30f6 | 4 | * @author MMY Application Team |
DiegoOstuni | 0:de13951f30f6 | 5 | * @version $Revision: 3210 $ |
DiegoOstuni | 0:de13951f30f6 | 6 | * @date $Date: 2016-12-05 15:37:48 +0100 (Mon, 05 Dec 2016) $ |
DiegoOstuni | 0:de13951f30f6 | 7 | * @brief This file help to add AAR to NDEF file. |
DiegoOstuni | 0:de13951f30f6 | 8 | ****************************************************************************** |
DiegoOstuni | 0:de13951f30f6 | 9 | * @attention |
DiegoOstuni | 0:de13951f30f6 | 10 | * |
DiegoOstuni | 0:de13951f30f6 | 11 | * <h2><center>© COPYRIGHT 2015 STMicroelectronics</center></h2> |
DiegoOstuni | 0:de13951f30f6 | 12 | * |
DiegoOstuni | 0:de13951f30f6 | 13 | * Licensed under ST MYLIBERTY SOFTWARE LICENSE AGREEMENT (the "License"); |
DiegoOstuni | 0:de13951f30f6 | 14 | * You may not use this file except in compliance with the License. |
DiegoOstuni | 0:de13951f30f6 | 15 | * You may obtain a copy of the License at: |
DiegoOstuni | 0:de13951f30f6 | 16 | * |
DiegoOstuni | 0:de13951f30f6 | 17 | * http://www.st.com/myliberty |
DiegoOstuni | 0:de13951f30f6 | 18 | * |
DiegoOstuni | 0:de13951f30f6 | 19 | * Unless required by applicable law or agreed to in writing, software |
DiegoOstuni | 0:de13951f30f6 | 20 | * distributed under the License is distributed on an "AS IS" BASIS, |
DiegoOstuni | 0:de13951f30f6 | 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, |
DiegoOstuni | 0:de13951f30f6 | 22 | * AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY, |
DiegoOstuni | 0:de13951f30f6 | 23 | * FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. |
DiegoOstuni | 0:de13951f30f6 | 24 | * See the License for the specific language governing permissions and |
DiegoOstuni | 0:de13951f30f6 | 25 | * limitations under the License. |
DiegoOstuni | 0:de13951f30f6 | 26 | * |
DiegoOstuni | 0:de13951f30f6 | 27 | ****************************************************************************** |
DiegoOstuni | 0:de13951f30f6 | 28 | */ |
DiegoOstuni | 0:de13951f30f6 | 29 | /* Includes ------------------------------------------------------------------*/ |
DiegoOstuni | 0:de13951f30f6 | 30 | #include "lib_NDEF_AAR.h" |
DiegoOstuni | 0:de13951f30f6 | 31 | |
DiegoOstuni | 0:de13951f30f6 | 32 | /** @addtogroup NFC_libraries |
DiegoOstuni | 0:de13951f30f6 | 33 | * @{ |
DiegoOstuni | 0:de13951f30f6 | 34 | * @brief <b>This is the library used to manage the content of the TAG (data) |
DiegoOstuni | 0:de13951f30f6 | 35 | * But also the specific feature of the tag, for instance |
DiegoOstuni | 0:de13951f30f6 | 36 | * password, gpo... </b> |
DiegoOstuni | 0:de13951f30f6 | 37 | */ |
DiegoOstuni | 0:de13951f30f6 | 38 | |
DiegoOstuni | 0:de13951f30f6 | 39 | |
DiegoOstuni | 0:de13951f30f6 | 40 | /** @addtogroup libNFC_FORUM |
DiegoOstuni | 0:de13951f30f6 | 41 | * @{ |
DiegoOstuni | 0:de13951f30f6 | 42 | * @brief This part of the library manage data which follow NFC forum organisation. |
DiegoOstuni | 0:de13951f30f6 | 43 | */ |
DiegoOstuni | 0:de13951f30f6 | 44 | |
DiegoOstuni | 0:de13951f30f6 | 45 | /** |
DiegoOstuni | 0:de13951f30f6 | 46 | * @brief This buffer contains the data send/received by TAG |
DiegoOstuni | 0:de13951f30f6 | 47 | */ |
DiegoOstuni | 0:de13951f30f6 | 48 | extern uint8_t NDEF_Buffer []; |
DiegoOstuni | 0:de13951f30f6 | 49 | |
DiegoOstuni | 0:de13951f30f6 | 50 | /** @defgroup libAAR_Private_Functions |
DiegoOstuni | 0:de13951f30f6 | 51 | * @{ |
DiegoOstuni | 0:de13951f30f6 | 52 | */ |
DiegoOstuni | 0:de13951f30f6 | 53 | |
DiegoOstuni | 0:de13951f30f6 | 54 | /** |
DiegoOstuni | 0:de13951f30f6 | 55 | * @} |
DiegoOstuni | 0:de13951f30f6 | 56 | */ |
DiegoOstuni | 0:de13951f30f6 | 57 | |
DiegoOstuni | 0:de13951f30f6 | 58 | /** @defgroup libAAR_Public_Functions |
DiegoOstuni | 0:de13951f30f6 | 59 | * @{ |
DiegoOstuni | 0:de13951f30f6 | 60 | * @brief This file is used to manage AAR (stored or loaded in tag) |
DiegoOstuni | 0:de13951f30f6 | 61 | */ |
DiegoOstuni | 0:de13951f30f6 | 62 | |
DiegoOstuni | 0:de13951f30f6 | 63 | |
DiegoOstuni | 0:de13951f30f6 | 64 | /** |
DiegoOstuni | 0:de13951f30f6 | 65 | * @brief This function add AAR (Android Application Record) in the tag. |
DiegoOstuni | 0:de13951f30f6 | 66 | * @param pAARStruct : pointer on structure that contain AAR information. |
DiegoOstuni | 0:de13951f30f6 | 67 | * @retval NDEF_OK : AAR added. |
DiegoOstuni | 0:de13951f30f6 | 68 | * @retval NDEF_ERROR : not able to store NDEF in tag. |
DiegoOstuni | 0:de13951f30f6 | 69 | * @retval NDEF_ERROR_MEMORY_INTERNAL : Cannot write to tag. |
DiegoOstuni | 0:de13951f30f6 | 70 | * @retval NDEF_ERROR_NOT_FORMATED : CCFile data not supported or not present. |
DiegoOstuni | 0:de13951f30f6 | 71 | * @retval NDEF_ERROR_MEMORY_TAG : Size not compatible with memory. |
DiegoOstuni | 0:de13951f30f6 | 72 | * @retval NDEF_ERROR_LOCKED : Tag locked, cannot be write. |
DiegoOstuni | 0:de13951f30f6 | 73 | */ |
DiegoOstuni | 0:de13951f30f6 | 74 | uint16_t NDEF_AddAAR( const sAARInfo *pAARStruct, I2C* mi2cChannel ) |
DiegoOstuni | 0:de13951f30f6 | 75 | { |
DiegoOstuni | 0:de13951f30f6 | 76 | uint16_t status = NDEF_ERROR; |
DiegoOstuni | 0:de13951f30f6 | 77 | |
DiegoOstuni | 0:de13951f30f6 | 78 | /* AAR: External Type Record Header */ |
DiegoOstuni | 0:de13951f30f6 | 79 | /************************************/ |
DiegoOstuni | 0:de13951f30f6 | 80 | /* 7 | 6 | 5 | 4 | 3 | 2 1 0 */ |
DiegoOstuni | 0:de13951f30f6 | 81 | /*----------------------------------*/ |
DiegoOstuni | 0:de13951f30f6 | 82 | /* MB ME CF SR IL TNF */ /* <---- IL=0, CF=0 and SR=1 TNF=4 NFC Forum external type*/ |
DiegoOstuni | 0:de13951f30f6 | 83 | /*----------------------------------*/ |
DiegoOstuni | 0:de13951f30f6 | 84 | /* TYPE LENGTH */ |
DiegoOstuni | 0:de13951f30f6 | 85 | /*----------------------------------*/ |
DiegoOstuni | 0:de13951f30f6 | 86 | /* PAYLOAD LENGTH 3 */ /* <---- Not Used */ |
DiegoOstuni | 0:de13951f30f6 | 87 | /*----------------------------------*/ |
DiegoOstuni | 0:de13951f30f6 | 88 | /* PAYLOAD LENGTH 2 */ /* <---- Not Used */ |
DiegoOstuni | 0:de13951f30f6 | 89 | /*----------------------------------*/ |
DiegoOstuni | 0:de13951f30f6 | 90 | /* PAYLOAD LENGTH 1 */ /* <---- Not Used */ |
DiegoOstuni | 0:de13951f30f6 | 91 | /*----------------------------------*/ |
DiegoOstuni | 0:de13951f30f6 | 92 | /* PAYLOAD LENGTH 0 */ |
DiegoOstuni | 0:de13951f30f6 | 93 | /*----------------------------------*/ |
DiegoOstuni | 0:de13951f30f6 | 94 | /* ID LENGTH */ /* <---- Not Used */ |
DiegoOstuni | 0:de13951f30f6 | 95 | /*----------------------------------*/ |
DiegoOstuni | 0:de13951f30f6 | 96 | /* TYPE */ /* android.com:pkg */ |
DiegoOstuni | 0:de13951f30f6 | 97 | /*----------------------------------*/ |
DiegoOstuni | 0:de13951f30f6 | 98 | /* ID */ /* <---- Not Used */ |
DiegoOstuni | 0:de13951f30f6 | 99 | /************************************/ |
DiegoOstuni | 0:de13951f30f6 | 100 | |
DiegoOstuni | 0:de13951f30f6 | 101 | /* Do we have to add AAR to an existing NDEF message */ |
DiegoOstuni | 0:de13951f30f6 | 102 | /* retrieve current NDEF size and current record flag*/ |
DiegoOstuni | 0:de13951f30f6 | 103 | sRecordInfo_t AARrecord; |
DiegoOstuni | 0:de13951f30f6 | 104 | |
DiegoOstuni | 0:de13951f30f6 | 105 | /* fill AAR record header */ |
DiegoOstuni | 0:de13951f30f6 | 106 | AARrecord.RecordFlags = SR_Mask | TNF_NFCForumExternal; |
DiegoOstuni | 0:de13951f30f6 | 107 | AARrecord.TypeLength = AAR_TYPE_STRING_LENGTH; |
DiegoOstuni | 0:de13951f30f6 | 108 | |
DiegoOstuni | 0:de13951f30f6 | 109 | memcpy( AARrecord.Type, AAR_TYPE_STRING, AAR_TYPE_STRING_LENGTH ); |
DiegoOstuni | 0:de13951f30f6 | 110 | |
DiegoOstuni | 0:de13951f30f6 | 111 | /* fill AAR payload */ |
DiegoOstuni | 0:de13951f30f6 | 112 | AARrecord.PayloadBufferAdd = (uint8_t*)pAARStruct->PackageName; |
DiegoOstuni | 0:de13951f30f6 | 113 | AARrecord.PayloadLength= strlen(pAARStruct->PackageName) ; |
DiegoOstuni | 0:de13951f30f6 | 114 | |
DiegoOstuni | 0:de13951f30f6 | 115 | status = NDEF_AppendRecord(&AARrecord, mi2cChannel); |
DiegoOstuni | 0:de13951f30f6 | 116 | |
DiegoOstuni | 0:de13951f30f6 | 117 | return status; |
DiegoOstuni | 0:de13951f30f6 | 118 | } |
DiegoOstuni | 0:de13951f30f6 | 119 | |
DiegoOstuni | 0:de13951f30f6 | 120 | |
DiegoOstuni | 0:de13951f30f6 | 121 | /** |
DiegoOstuni | 0:de13951f30f6 | 122 | * @} |
DiegoOstuni | 0:de13951f30f6 | 123 | */ |
DiegoOstuni | 0:de13951f30f6 | 124 | |
DiegoOstuni | 0:de13951f30f6 | 125 | /** |
DiegoOstuni | 0:de13951f30f6 | 126 | * @} |
DiegoOstuni | 0:de13951f30f6 | 127 | */ |
DiegoOstuni | 0:de13951f30f6 | 128 | |
DiegoOstuni | 0:de13951f30f6 | 129 | /** |
DiegoOstuni | 0:de13951f30f6 | 130 | * @} |
DiegoOstuni | 0:de13951f30f6 | 131 | */ |
DiegoOstuni | 0:de13951f30f6 | 132 | |
DiegoOstuni | 0:de13951f30f6 | 133 | /******************* (C) COPYRIGHT 2015 STMicroelectronics *****END OF FILE****/ |