Mistake on this page?
Report an issue in GitHub or email us
NFCTarget.h
1 /* mbed Microcontroller Library
2  * Copyright (c) 2018 ARM Limited
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 #ifndef MBED_NFC_TARGET_H
18 #define MBED_NFC_TARGET_H
19 
20 #include <stdint.h>
21 
22 #include "NFCDefinitions.h"
23 #include "NFCNDEFCapable.h"
24 
25 #include "platform/Span.h"
26 
27 namespace mbed {
28 namespace nfc {
29 
30 /**
31  * @addtogroup nfc
32  * @{
33  */
34 
35 /**
36  * This class represents a NFC target (either a remote target when the local controller in in initiator mode, or a target connected through a wired connection).
37  *
38  * A target can be a NFC tag/card, a NFC-enabled phone or other NFC device capable of modulating a RF field.
39  */
40 class NFCTarget : public NFCNDEFCapable {
41 public:
42  /**
43  * Create a NFCTarget.
44  *
45  * @param[in] buffer a bytes array used to store NDEF messages
46  */
47  NFCTarget(const Span<uint8_t> &buffer);
48 
49  /**
50  * NFCTarget destructor
51  */
52  virtual ~NFCTarget();
53 
55  /**
56  * The NDEF message erasing request completed.
57  *
58  * @param[in] result NFC_OK or an error code on failure
59  */
60  virtual void on_ndef_message_erased(nfc_err_t result) {}
61 
62  /**
63  * The NDEF message writing request completed.
64  *
65  * @param[in] result NFC_OK or an error code on failure
66  */
67  virtual void on_ndef_message_written(nfc_err_t result) {}
68 
69  /**
70  * The NDEF message reading request completed.
71  *
72  * @param[in] result NFC_OK or an error code on failure
73  */
74  virtual void on_ndef_message_read(nfc_err_t result) {}
75 
76  protected:
77  ~Delegate() {}
78  };
79 
80  /**
81  * Write a NDEF message to the target.
82  *
83  * on_ndef_message_written() will be called on completion.
84  */
85  virtual void write_ndef_message() = 0;
86 
87  /**
88  * Read a NDEF message from the target.
89  *
90  * on_ndef_message_read() will be called on completion.
91  */
92  virtual void read_ndef_message() = 0;
93 
94  /**
95  * Erase the NDEF message in the target.
96  *
97  * on_ndef_message_erased() will be called on completion.
98  */
99  virtual void erase_ndef_message() = 0;
100 };
101 
102 /**
103  * @}
104  */
105 
106 } // namespace nfc
107 } // namespace mbed
108 
109 #endif
virtual void on_ndef_message_read(nfc_err_t result)
The NDEF message reading request completed.
Definition: NFCTarget.h:74
virtual void erase_ndef_message()=0
Erase the NDEF message in the target.
virtual void write_ndef_message()=0
Write a NDEF message to the target.
virtual void on_ndef_message_written(nfc_err_t result)
The NDEF message writing request completed.
Definition: NFCTarget.h:67
This class represents a NFC target (either a remote target when the local controller in in initiator ...
Definition: NFCTarget.h:40
virtual ~NFCTarget()
NFCTarget destructor.
virtual void read_ndef_message()=0
Read a NDEF message from the target.
virtual void on_ndef_message_erased(nfc_err_t result)
The NDEF message erasing request completed.
Definition: NFCTarget.h:60
The base class for all endpoints that can support NDEF content.
NFCTarget(const Span< uint8_t > &buffer)
Create a NFCTarget.
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.