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  * SPDX-License-Identifier: Apache-2.0
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef MBED_NFC_TARGET_H
19 #define MBED_NFC_TARGET_H
20 
21 #include <stdint.h>
22 
23 #include "NFCDefinitions.h"
24 #include "NFCNDEFCapable.h"
25 
26 #include "platform/Span.h"
27 
28 namespace mbed {
29 namespace nfc {
30 
31 /**
32  * @addtogroup nfc
33  * @{
34  */
35 
36 /**
37  * 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).
38  *
39  * A target can be a NFC tag/card, a NFC-enabled phone or other NFC device capable of modulating a RF field.
40  */
41 class NFCTarget : public NFCNDEFCapable {
42 public:
43  /**
44  * Create a NFCTarget.
45  *
46  * @param[in] buffer a bytes array used to store NDEF messages
47  */
48  NFCTarget(const Span<uint8_t> &buffer);
49 
50  /**
51  * NFCTarget destructor
52  */
53  virtual ~NFCTarget();
54 
56  /**
57  * The NDEF message erasing request completed.
58  *
59  * @param[in] result NFC_OK or an error code on failure
60  */
61  virtual void on_ndef_message_erased(nfc_err_t result) {}
62 
63  /**
64  * The NDEF message writing request completed.
65  *
66  * @param[in] result NFC_OK or an error code on failure
67  */
68  virtual void on_ndef_message_written(nfc_err_t result) {}
69 
70  /**
71  * The NDEF message reading request completed.
72  *
73  * @param[in] result NFC_OK or an error code on failure
74  */
75  virtual void on_ndef_message_read(nfc_err_t result) {}
76 
77  protected:
78  ~Delegate() {}
79  };
80 
81  /**
82  * Write a NDEF message to the target.
83  *
84  * on_ndef_message_written() will be called on completion.
85  */
86  virtual void write_ndef_message() = 0;
87 
88  /**
89  * Read a NDEF message from the target.
90  *
91  * on_ndef_message_read() will be called on completion.
92  */
93  virtual void read_ndef_message() = 0;
94 
95  /**
96  * Erase the NDEF message in the target.
97  *
98  * on_ndef_message_erased() will be called on completion.
99  */
100  virtual void erase_ndef_message() = 0;
101 };
102 
103 /**
104  * @}
105  */
106 
107 } // namespace nfc
108 } // namespace mbed
109 
110 #endif
virtual void on_ndef_message_read(nfc_err_t result)
The NDEF message reading request completed.
Definition: NFCTarget.h:75
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:68
This class represents a NFC target (either a remote target when the local controller in in initiator ...
Definition: NFCTarget.h:41
virtual ~NFCTarget()
NFCTarget destructor.
virtual void read_ndef_message()=0
Read a NDEF message from the target.
int nfc_err_t
Type for NFC errors.
Definition: nfc_errors.h:59
virtual void on_ndef_message_erased(nfc_err_t result)
The NDEF message erasing request completed.
Definition: NFCTarget.h:61
The base class for all endpoints that can support NDEF content.
NFCTarget(const Span< uint8_t > &buffer)
Create a NFCTarget.
Definition: ATHandler.h:46
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.