Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers NFCTarget.h Source File

NFCTarget.h

00001 /* mbed Microcontroller Library
00002  * Copyright (c) 2018 ARM Limited
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 #ifndef MBED_NFC_TARGET_H
00018 #define MBED_NFC_TARGET_H
00019 
00020 #include <stdint.h>
00021 
00022 #include "NFCDefinitions.h"
00023 #include "NFCNDEFCapable.h"
00024 
00025 #include "platform/Span.h"
00026 
00027 namespace mbed {
00028 namespace nfc {
00029 
00030 /**
00031  * @addtogroup nfc
00032  * @{
00033  */
00034 
00035 /**
00036  * 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).
00037  *
00038  * A target can be a NFC tag/card, a NFC-enabled phone or other NFC device capable of modulating a RF field.
00039  */
00040 class NFCTarget : public NFCNDEFCapable {
00041 public:
00042     /**
00043      * Create a NFCTarget.
00044      *
00045      * @param[in] buffer a bytes array used to store NDEF messages
00046      */
00047     NFCTarget(const Span<uint8_t>  &buffer);
00048 
00049     /**
00050      * NFCTarget destructor
00051      */
00052     virtual ~NFCTarget();
00053 
00054     struct Delegate : NFCNDEFCapable::Delegate {
00055         /**
00056          * The NDEF message erasing request completed.
00057          *
00058          * @param[in] result NFC_OK or an error code on failure
00059          */
00060         virtual void on_ndef_message_erased(nfc_err_t result) {}
00061 
00062         /**
00063          * The NDEF message writing request completed.
00064          *
00065          * @param[in] result NFC_OK or an error code on failure
00066          */
00067         virtual void on_ndef_message_written(nfc_err_t result) {}
00068 
00069         /**
00070          * The NDEF message reading request completed.
00071          *
00072          * @param[in] result NFC_OK or an error code on failure
00073          */
00074         virtual void on_ndef_message_read(nfc_err_t result) {}
00075 
00076     protected:
00077         ~Delegate() {}
00078     };
00079 
00080     /**
00081      * Write a NDEF message to the target.
00082      *
00083      * on_ndef_message_written() will be called on completion.
00084      */
00085     virtual void write_ndef_message() = 0;
00086 
00087     /**
00088      * Read a NDEF message from the target.
00089      *
00090      * on_ndef_message_read() will be called on completion.
00091      */
00092     virtual void read_ndef_message() = 0;
00093 
00094     /**
00095      * Erase the NDEF message in the target.
00096      *
00097      * on_ndef_message_erased() will be called on completion.
00098      */
00099     virtual void erase_ndef_message() = 0;
00100 };
00101 
00102 /**
00103  * @}
00104  */
00105 
00106 } // namespace nfc
00107 } // namespace mbed
00108 
00109 #endif