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
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 .
Samples/MyRecord.h@18:d596eb3f575f, 2017-07-13 (annotated)
- Committer:
- Davidroid
- Date:
- Thu Jul 13 12:46:03 2017 +0000
- Revision:
- 18:d596eb3f575f
- Parent:
- 17:d8d3d2088cac
Aligning to ARM mbed coding style.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
giovannivisentini | 13:685d95525ec8 | 1 | /** |
giovannivisentini | 13:685d95525ec8 | 2 | ****************************************************************************** |
Davidroid | 18:d596eb3f575f | 3 | * @file MyRecord.h |
giovannivisentini | 13:685d95525ec8 | 4 | * @author ST / Central Labs |
giovannivisentini | 13:685d95525ec8 | 5 | * @date 03 Dic 2015 |
giovannivisentini | 13:685d95525ec8 | 6 | * @brief Simple castom record used in the countClick demo |
giovannivisentini | 13:685d95525ec8 | 7 | ****************************************************************************** |
giovannivisentini | 13:685d95525ec8 | 8 | * |
giovannivisentini | 13:685d95525ec8 | 9 | * COPYRIGHT(c) 2015 STMicroelectronics |
giovannivisentini | 13:685d95525ec8 | 10 | * |
giovannivisentini | 13:685d95525ec8 | 11 | * Redistribution and use in source and binary forms, with or without modification, |
giovannivisentini | 13:685d95525ec8 | 12 | * are permitted provided that the following conditions are met: |
giovannivisentini | 13:685d95525ec8 | 13 | * 1. Redistributions of source code must retain the above copyright notice, |
giovannivisentini | 13:685d95525ec8 | 14 | * this list of conditions and the following disclaimer. |
giovannivisentini | 13:685d95525ec8 | 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
giovannivisentini | 13:685d95525ec8 | 16 | * this list of conditions and the following disclaimer in the documentation |
giovannivisentini | 13:685d95525ec8 | 17 | * and/or other materials provided with the distribution. |
giovannivisentini | 13:685d95525ec8 | 18 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
giovannivisentini | 13:685d95525ec8 | 19 | * may be used to endorse or promote products derived from this software |
giovannivisentini | 13:685d95525ec8 | 20 | * without specific prior written permission. |
giovannivisentini | 13:685d95525ec8 | 21 | * |
giovannivisentini | 13:685d95525ec8 | 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
giovannivisentini | 13:685d95525ec8 | 23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
giovannivisentini | 13:685d95525ec8 | 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
giovannivisentini | 13:685d95525ec8 | 25 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
giovannivisentini | 13:685d95525ec8 | 26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
giovannivisentini | 13:685d95525ec8 | 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
giovannivisentini | 13:685d95525ec8 | 28 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
giovannivisentini | 13:685d95525ec8 | 29 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
giovannivisentini | 13:685d95525ec8 | 30 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
giovannivisentini | 13:685d95525ec8 | 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
giovannivisentini | 13:685d95525ec8 | 32 | * |
giovannivisentini | 13:685d95525ec8 | 33 | ****************************************************************************** |
giovannivisentini | 13:685d95525ec8 | 34 | */ |
giovannivisentini | 13:685d95525ec8 | 35 | |
giovannivisentini | 13:685d95525ec8 | 36 | #include "NDefLib/RecordType/RecordText.h" |
giovannivisentini | 13:685d95525ec8 | 37 | |
giovannivisentini | 13:685d95525ec8 | 38 | /** |
giovannivisentini | 13:685d95525ec8 | 39 | * Custom record that map an integer in a text record. |
giovannivisentini | 13:685d95525ec8 | 40 | */ |
giovannivisentini | 13:685d95525ec8 | 41 | class MyRecord : public NDefLib::RecordText{ |
giovannivisentini | 13:685d95525ec8 | 42 | |
giovannivisentini | 13:685d95525ec8 | 43 | private: |
giovannivisentini | 13:685d95525ec8 | 44 | char nClickStringBuffer[12]; ///buffer used for print the number |
giovannivisentini | 13:685d95525ec8 | 45 | uint32_t nClick; /// number to show |
giovannivisentini | 13:685d95525ec8 | 46 | |
giovannivisentini | 13:685d95525ec8 | 47 | /** |
giovannivisentini | 13:685d95525ec8 | 48 | * Convert the number in char and update the tag content. |
giovannivisentini | 13:685d95525ec8 | 49 | */ |
giovannivisentini | 17:d8d3d2088cac | 50 | void sync_text_value(){ |
giovannivisentini | 17:d8d3d2088cac | 51 | sprintf(nClickStringBuffer,"%u",nClick); |
giovannivisentini | 17:d8d3d2088cac | 52 | set_text(nClickStringBuffer); |
giovannivisentini | 13:685d95525ec8 | 53 | } |
giovannivisentini | 13:685d95525ec8 | 54 | |
giovannivisentini | 13:685d95525ec8 | 55 | public: |
giovannivisentini | 13:685d95525ec8 | 56 | |
giovannivisentini | 13:685d95525ec8 | 57 | MyRecord():nClick(0){ |
giovannivisentini | 17:d8d3d2088cac | 58 | sync_text_value(); |
giovannivisentini | 13:685d95525ec8 | 59 | } |
giovannivisentini | 13:685d95525ec8 | 60 | |
giovannivisentini | 13:685d95525ec8 | 61 | /** |
giovannivisentini | 13:685d95525ec8 | 62 | * Increment the stored number and update the racord content. |
giovannivisentini | 13:685d95525ec8 | 63 | */ |
giovannivisentini | 17:d8d3d2088cac | 64 | void increment_click(){ |
giovannivisentini | 13:685d95525ec8 | 65 | nClick++; |
giovannivisentini | 17:d8d3d2088cac | 66 | sync_text_value(); |
giovannivisentini | 13:685d95525ec8 | 67 | } |
giovannivisentini | 13:685d95525ec8 | 68 | |
giovannivisentini | 13:685d95525ec8 | 69 | }; |