Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers NFCRemoteEndpoint.h Source File

NFCRemoteEndpoint.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_REMOTE_ENDPOINT_H
00018 #define MBED_NFC_REMOTE_ENDPOINT_H
00019 
00020 #include <stdint.h>
00021 
00022 #include "NFCDefinitions.h"
00023 
00024 namespace mbed {
00025 namespace nfc {
00026 
00027 /**
00028  * @addtogroup nfc
00029  * @{
00030  */
00031 
00032 class NFCController;
00033 
00034 /**
00035  * This is the base class for all remote endpoints (initiators and targets)
00036  * addressable over the air interface.
00037  */
00038 class NFCRemoteEndpoint {
00039 public:
00040     /**
00041      * Create a NFCRemoteEndpointinstance
00042      * @param[in] controller the NFCController instance that detected this endpoint
00043      */
00044     NFCRemoteEndpoint(NFCController *controller);
00045 
00046     /**
00047      * Destructor
00048      */
00049     virtual ~NFCRemoteEndpoint();
00050 
00051     /**
00052      * The NFCRemoteEndpoint base delegate.
00053      */
00054     struct Delegate {
00055         /**
00056          * This method is called when the endpoint is connected
00057          */
00058         virtual void on_connected() {}
00059 
00060         /**
00061          * This method is called when the endpoint is lost (air interface link disconnnected)
00062          */
00063         virtual void on_disconnected() {}
00064 
00065     protected:
00066         ~Delegate() {}
00067     };
00068 
00069     /**
00070      * Connect the remote endpoint
00071      *
00072      * @return NFC_OK or an error code
00073      */
00074     virtual nfc_err_t connect() = 0;
00075 
00076     /**
00077      * Disconnect the remote endpoint
00078      *
00079      * @return NFC_OK or an error code
00080      */
00081     virtual nfc_err_t disconnect() = 0;
00082 
00083     /**
00084      * Check if the endpoint is connected.
00085      * @return whether the endpoint is connected
00086      */
00087     virtual bool is_connected() const = 0;
00088 
00089     /**
00090      * Check if the endpoint is disconnected/lost.
00091      * @return whether the endpoint has been disconnected
00092      */
00093     virtual bool is_disconnected() const = 0;
00094 
00095     /**
00096      * Get the list of RF protocols supported and activated over the air interface.
00097      * @return a bitmask of activated protocols
00098      */
00099     virtual nfc_rf_protocols_bitmask_t rf_protocols() = 0;
00100 
00101 protected:
00102     /**
00103      * Mark endpoint as connected
00104      */
00105     virtual void connected() = 0;
00106 
00107     /**
00108      * Mark endpoint as disconnected
00109      */
00110     virtual void disconnected() = 0;
00111 
00112     /**
00113      * Retrieve NFCController instance
00114      * @return a pointer to the NFController instance that created this endpoint.
00115      */
00116     NFCController *nfc_controller();
00117 
00118     /**
00119      * Retrieve NFCController instance
00120      * @return a pointer to the NFController instance that created this endpoint.
00121      */
00122     const NFCController *nfc_controller() const;
00123 
00124 private:
00125     NFCController *_controller;
00126 };
00127 
00128 /**
00129  * @}
00130  */
00131 
00132 } // namespace nfc
00133 } // namespace mbed
00134 
00135 #endif