This application provides a set of demos with X-NUCLEO-NFC01A1 expansion board.

Dependencies:   NDefLib X_NUCLEO_NFC01A1 mbed

Fork of X-MBED-NFC1 by Giovanni Visentini

This application provides a set of demos with X-NUCLEO-NFC01A1 expansion board.

The available demos are:

  • SAMPLE_WRITE_URL: write a tag with the ST home page URL
  • SAMPLE_COUNT_CLICK: create a custom tag to count and report the user button clicks.
  • SAMPLE_WRITE_AND_CHANGE_ALL: write a tag with all the supported records and update the tag contents when the user button is pressed.
  • SAMPLE_LOCK_TAG_CONTENT: use the M24SR component API to set the NFC tag as read-only.

To enable the different demos comment/uncomment the SAMPLE_* macros provided in main.cpp .

Committer:
giovannivisentini
Date:
Tue Dec 01 08:30:54 2015 +0000
Revision:
2:0648c1561eb2
Parent:
1:6d202b62ed68
change the tag content when the user press the button

Who changed what in which revision?

UserRevisionLine numberNew contents of line
giovannivisentini 1:6d202b62ed68 1 /**
giovannivisentini 1:6d202b62ed68 2 ******************************************************************************
giovannivisentini 1:6d202b62ed68 3 * @file Nfc_class.h
giovannivisentini 1:6d202b62ed68 4 * @author AST / EST
giovannivisentini 1:6d202b62ed68 5 * @version V0.0.1
giovannivisentini 1:6d202b62ed68 6 * @date 13-April-2015
giovannivisentini 1:6d202b62ed68 7 * @brief This file contains the abstract class describing the interface of a
giovannivisentini 1:6d202b62ed68 8 * nfc component.
giovannivisentini 1:6d202b62ed68 9 ******************************************************************************
giovannivisentini 1:6d202b62ed68 10 * @attention
giovannivisentini 1:6d202b62ed68 11 *
giovannivisentini 1:6d202b62ed68 12 * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
giovannivisentini 1:6d202b62ed68 13 *
giovannivisentini 1:6d202b62ed68 14 * Redistribution and use in source and binary forms, with or without modification,
giovannivisentini 1:6d202b62ed68 15 * are permitted provided that the following conditions are met:
giovannivisentini 1:6d202b62ed68 16 * 1. Redistributions of source code must retain the above copyright notice,
giovannivisentini 1:6d202b62ed68 17 * this list of conditions and the following disclaimer.
giovannivisentini 1:6d202b62ed68 18 * 2. Redistributions in binary form must reproduce the above copyright notice,
giovannivisentini 1:6d202b62ed68 19 * this list of conditions and the following disclaimer in the documentation
giovannivisentini 1:6d202b62ed68 20 * and/or other materials provided with the distribution.
giovannivisentini 1:6d202b62ed68 21 * 3. Neither the name of STMicroelectronics nor the names of its contributors
giovannivisentini 1:6d202b62ed68 22 * may be used to endorse or promote products derived from this software
giovannivisentini 1:6d202b62ed68 23 * without specific prior written permission.
giovannivisentini 1:6d202b62ed68 24 *
giovannivisentini 1:6d202b62ed68 25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
giovannivisentini 1:6d202b62ed68 26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
giovannivisentini 1:6d202b62ed68 27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
giovannivisentini 1:6d202b62ed68 28 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
giovannivisentini 1:6d202b62ed68 29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
giovannivisentini 1:6d202b62ed68 30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
giovannivisentini 1:6d202b62ed68 31 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
giovannivisentini 1:6d202b62ed68 32 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
giovannivisentini 1:6d202b62ed68 33 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
giovannivisentini 1:6d202b62ed68 34 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
giovannivisentini 1:6d202b62ed68 35 *
giovannivisentini 1:6d202b62ed68 36 ******************************************************************************
giovannivisentini 1:6d202b62ed68 37 */
giovannivisentini 1:6d202b62ed68 38
giovannivisentini 1:6d202b62ed68 39
giovannivisentini 1:6d202b62ed68 40 /* Generated with Stm32CubeTOO -----------------------------------------------*/
giovannivisentini 1:6d202b62ed68 41
giovannivisentini 1:6d202b62ed68 42 /* Define to prevent from recursive inclusion --------------------------------*/
giovannivisentini 1:6d202b62ed68 43
giovannivisentini 1:6d202b62ed68 44 #ifndef __NFC_CLASS_H
giovannivisentini 1:6d202b62ed68 45 #define __NFC_CLASS_H
giovannivisentini 1:6d202b62ed68 46
giovannivisentini 0:674813bd5ec9 47
giovannivisentini 1:6d202b62ed68 48 /* Includes ------------------------------------------------------------------*/
giovannivisentini 1:6d202b62ed68 49
giovannivisentini 1:6d202b62ed68 50 #include "Component_class.h"
giovannivisentini 1:6d202b62ed68 51
giovannivisentini 1:6d202b62ed68 52
giovannivisentini 1:6d202b62ed68 53 /* Classes ------------------------------------------------------------------*/
giovannivisentini 1:6d202b62ed68 54
giovannivisentini 1:6d202b62ed68 55 /** An abstract class for Nfc components.
giovannivisentini 1:6d202b62ed68 56 */
giovannivisentini 1:6d202b62ed68 57 class Nfc : public Component
giovannivisentini 1:6d202b62ed68 58 {
giovannivisentini 1:6d202b62ed68 59 public:
giovannivisentini 1:6d202b62ed68 60
giovannivisentini 2:0648c1561eb2 61 /**
giovannivisentini 2:0648c1561eb2 62 * possible password to set
giovannivisentini 2:0648c1561eb2 63 */
giovannivisentini 1:6d202b62ed68 64 typedef enum{
giovannivisentini 2:0648c1561eb2 65 ReadPwd=READ_PWD, //!< password to use before read the tag
giovannivisentini 2:0648c1561eb2 66 WritePwd=WRITE_PWD,//!< password to use before write the tag
giovannivisentini 2:0648c1561eb2 67 I2CPwd=I2C_PWD, //!< root password, used only thought nfc
giovannivisentini 1:6d202b62ed68 68 }PasswordType_t;
giovannivisentini 1:6d202b62ed68 69
giovannivisentini 2:0648c1561eb2 70
giovannivisentini 2:0648c1561eb2 71 /**
giovannivisentini 2:0648c1561eb2 72 * open a i2c connection with the tag if an RF connection isn't already open
giovannivisentini 2:0648c1561eb2 73 * @return operation status
giovannivisentini 2:0648c1561eb2 74 */
giovannivisentini 1:6d202b62ed68 75 virtual NFC_StatusTypeDef GetSession(void) = 0;
giovannivisentini 2:0648c1561eb2 76 /**
giovannivisentini 2:0648c1561eb2 77 * force to open an i2c connection , abort the RF connection
giovannivisentini 2:0648c1561eb2 78 * @return
giovannivisentini 2:0648c1561eb2 79 */
giovannivisentini 1:6d202b62ed68 80 virtual NFC_StatusTypeDef KillSession(void) = 0;
giovannivisentini 2:0648c1561eb2 81
giovannivisentini 2:0648c1561eb2 82 /**
giovannivisentini 2:0648c1561eb2 83 * close an i2c connection
giovannivisentini 2:0648c1561eb2 84 * @return
giovannivisentini 2:0648c1561eb2 85 */
giovannivisentini 1:6d202b62ed68 86 virtual NFC_StatusTypeDef Deselect(void) = 0;
giovannivisentini 2:0648c1561eb2 87
giovannivisentini 2:0648c1561eb2 88 /**
giovannivisentini 2:0648c1561eb2 89 * Select the application file
giovannivisentini 2:0648c1561eb2 90 * @return
giovannivisentini 2:0648c1561eb2 91 */
giovannivisentini 1:6d202b62ed68 92 virtual NFC_StatusTypeDef SelectApplication(void) = 0;
giovannivisentini 2:0648c1561eb2 93
giovannivisentini 2:0648c1561eb2 94 /**
giovannivisentini 2:0648c1561eb2 95 * select the CC file
giovannivisentini 2:0648c1561eb2 96 * @return
giovannivisentini 2:0648c1561eb2 97 */
giovannivisentini 1:6d202b62ed68 98 virtual NFC_StatusTypeDef SelectCCfile(void) = 0;
giovannivisentini 2:0648c1561eb2 99
giovannivisentini 2:0648c1561eb2 100 /**
giovannivisentini 2:0648c1561eb2 101 * select the ndef file
giovannivisentini 2:0648c1561eb2 102 * @param NDEFfileId file id to open
giovannivisentini 2:0648c1561eb2 103 * @return
giovannivisentini 2:0648c1561eb2 104 */
giovannivisentini 1:6d202b62ed68 105 virtual NFC_StatusTypeDef SelectNDEFfile(uint16_t NDEFfileId) = 0;
giovannivisentini 2:0648c1561eb2 106
giovannivisentini 2:0648c1561eb2 107 /**
giovannivisentini 2:0648c1561eb2 108 * select the system file
giovannivisentini 2:0648c1561eb2 109 * @return
giovannivisentini 2:0648c1561eb2 110 */
giovannivisentini 1:6d202b62ed68 111 virtual NFC_StatusTypeDef SelectSystemfile(void) = 0;
giovannivisentini 2:0648c1561eb2 112
giovannivisentini 2:0648c1561eb2 113 /**
giovannivisentini 2:0648c1561eb2 114 * read data from the tag
giovannivisentini 2:0648c1561eb2 115 * @param Offset offset where start to read
giovannivisentini 2:0648c1561eb2 116 * @param NbByteToRead number of byte to read
giovannivisentini 2:0648c1561eb2 117 * @param[out] pBufferRead buffer where store the read data
giovannivisentini 2:0648c1561eb2 118 * @return
giovannivisentini 2:0648c1561eb2 119 */
giovannivisentini 1:6d202b62ed68 120 virtual NFC_StatusTypeDef ReadBinary(uint16_t Offset, uint8_t NbByteToRead, uint8_t *pBufferRead) = 0;
giovannivisentini 2:0648c1561eb2 121
giovannivisentini 2:0648c1561eb2 122 /**
giovannivisentini 2:0648c1561eb2 123 * write data to the tag
giovannivisentini 2:0648c1561eb2 124 * @param Offset offset where start to write
giovannivisentini 2:0648c1561eb2 125 * @param NbByteToWrite number of byte to write
giovannivisentini 2:0648c1561eb2 126 * @param pDataToWrite buffer to write
giovannivisentini 2:0648c1561eb2 127 * @return
giovannivisentini 2:0648c1561eb2 128 */
giovannivisentini 1:6d202b62ed68 129 virtual NFC_StatusTypeDef UpdateBinary(uint16_t Offset, uint8_t NbByteToWrite, uint8_t *pDataToWrite) = 0;
giovannivisentini 2:0648c1561eb2 130
giovannivisentini 2:0648c1561eb2 131 /**
giovannivisentini 2:0648c1561eb2 132 * check that the password is correct
giovannivisentini 2:0648c1561eb2 133 * @param uPwdId password type
giovannivisentini 2:0648c1561eb2 134 * @param NbPwdByte password size ( must be 0x10)
giovannivisentini 2:0648c1561eb2 135 * @param pPwd password buffer
giovannivisentini 2:0648c1561eb2 136 * @return
giovannivisentini 2:0648c1561eb2 137 */
giovannivisentini 1:6d202b62ed68 138 virtual NFC_StatusTypeDef Verify(PasswordType_t uPwdId, uint8_t NbPwdByte,const uint8_t *pPwd) = 0;
giovannivisentini 2:0648c1561eb2 139
giovannivisentini 2:0648c1561eb2 140 /**
giovannivisentini 2:0648c1561eb2 141 * change the pa
giovannivisentini 2:0648c1561eb2 142 * @param uPwdId
giovannivisentini 2:0648c1561eb2 143 * @param pPwd
giovannivisentini 2:0648c1561eb2 144 * @return
giovannivisentini 2:0648c1561eb2 145 */
giovannivisentini 1:6d202b62ed68 146 virtual NFC_StatusTypeDef ChangeReferenceData(PasswordType_t uPwdId,const uint8_t *pPwd) = 0;
giovannivisentini 1:6d202b62ed68 147 virtual NFC_StatusTypeDef EnableVerificationRequirement(PasswordType_t uReadOrWrite) = 0;
giovannivisentini 1:6d202b62ed68 148 virtual NFC_StatusTypeDef DisableVerificationRequirement(PasswordType_t uReadOrWrite) = 0;
giovannivisentini 1:6d202b62ed68 149 virtual NFC_StatusTypeDef STReadBinary(uint16_t Offset, uint8_t NbByteToRead, uint8_t *pBufferRead) = 0;
giovannivisentini 1:6d202b62ed68 150 virtual NFC_StatusTypeDef EnablePermanentState(PasswordType_t uReadOrWrite) = 0;
giovannivisentini 1:6d202b62ed68 151 virtual NFC_StatusTypeDef DisablePermanentState(PasswordType_t uReadOrWrite) = 0;
giovannivisentini 1:6d202b62ed68 152 virtual NFC_StatusTypeDef StateControl(uint8_t uSetOrReset) = 0;
giovannivisentini 1:6d202b62ed68 153 virtual NFC_StatusTypeDef ManageI2CGPO(uint8_t GPO_I2Cconfig) = 0;
giovannivisentini 1:6d202b62ed68 154 virtual NFC_StatusTypeDef ManageRFGPO(uint8_t GPO_RFconfig) = 0;
giovannivisentini 1:6d202b62ed68 155 virtual NFC_StatusTypeDef RFConfig(uint8_t OnOffChoice) = 0;
giovannivisentini 1:6d202b62ed68 156
giovannivisentini 1:6d202b62ed68 157 virtual ~Nfc(){};
giovannivisentini 1:6d202b62ed68 158 };
giovannivisentini 1:6d202b62ed68 159
giovannivisentini 1:6d202b62ed68 160 #endif /* __NFC_CLASS_H */
giovannivisentini 1:6d202b62ed68 161
giovannivisentini 1:6d202b62ed68 162 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/