Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
BLEInstanceBase.h
00001 /* mbed Microcontroller Library 00002 * Copyright (c) 2006-2013 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 /** 00018 * @file 00019 */ 00020 00021 #ifndef MBED_BLE_DEVICE_INSTANCE_BASE__ 00022 #define MBED_BLE_DEVICE_INSTANCE_BASE__ 00023 00024 #include "Gap.h" 00025 #include "ble/SecurityManager.h" 00026 #include "ble/BLE.h" 00027 00028 /* Forward declarations. */ 00029 class GattServer; 00030 class GattClient; 00031 00032 /** 00033 * @addtogroup ble 00034 * @{ 00035 * @addtogroup porting 00036 * @{ 00037 */ 00038 00039 /** 00040 * Private interface used to implement the BLE class. 00041 * 00042 * The BLE class delegates all its abstract operations to an instance of this 00043 * abstract class, which every vendor port of Mbed BLE shall implement. 00044 * 00045 * The vendor port shall also define an implementation of the freestanding function 00046 * createBLEInstance(). The BLE API uses this singleton function to gain 00047 * access to a concrete implementation of this class defined in the vendor port. 00048 * 00049 * @attention This class is part of the porting API and is not meant to be used 00050 * by end users of BLE API. 00051 * 00052 * @see BLE 00053 */ 00054 class BLEInstanceBase 00055 { 00056 public: 00057 /** 00058 * Base constructor. 00059 */ 00060 BLEInstanceBase() {} 00061 00062 /** 00063 * Virtual destructor of the interface. 00064 */ 00065 virtual ~BLEInstanceBase(); 00066 00067 /** 00068 * Process ALL pending events living in the vendor BLE subsystem. 00069 * 00070 * Return once all pending events have been consumed. 00071 * 00072 * @see BLE::processEvents() 00073 */ 00074 virtual void processEvents() = 0; 00075 00076 /** 00077 * Signal to BLE that events needing processing are available. 00078 * 00079 * The vendor port shall call this function whenever there are events 00080 * ready to be processed in the internal stack or BLE subsystem. As a result 00081 * of this call, the callback registered by the end user via 00082 * BLE::onEventsToProcess will be invoked. 00083 * 00084 * @param[in] id: Identifier of the BLE instance, which does have events to 00085 * ready to be processed. 00086 */ 00087 void signalEventsToProcess(BLE::InstanceID_t id); 00088 00089 /** 00090 * Start the initialization of the vendor BLE subsystem. 00091 * 00092 * Calls to this function are initiated by BLE::init, instanceID identify 00093 * the BLE instance which issue that call while the initCallback is used to 00094 * signal asynchronously the completion of the initialization process. 00095 * 00096 * @param[in] instanceID Identifier of the BLE instance requesting 00097 * initialization. 00098 * @param[in] initCallback Callback which the vendor port shall invoke 00099 * when the initialization completes. 00100 * 00101 * This is an optional parameter set to NULL when not supplied. 00102 * 00103 * @return BLE_ERROR_NONE if the initialization procedure started 00104 * successfully. 00105 * 00106 * @post initCallback shall be invoked upon completion of the initialization 00107 * process. 00108 * 00109 * @post hasInitialized() shall return false until the initialization is 00110 * complete, and it shall return true after succesful completion of the 00111 * initialization process. 00112 * 00113 * @see BLE::init() 00114 */ 00115 virtual ble_error_t init( 00116 BLE::InstanceID_t instanceID, 00117 FunctionPointerWithContext<BLE::InitializationCompleteCallbackContext*> initCallback 00118 ) = 0; 00119 00120 /** 00121 * Check whether the vendor BLE subsystem has been initialized or not. 00122 * 00123 * @return true if the initialization has completed for the vendor BLE 00124 * subsystem. 00125 * 00126 * @note this function is invoked by BLE::hasInitialized() 00127 * 00128 * @see BLE::init() BLE::hasInitialized() 00129 */ 00130 virtual bool hasInitialized(void) const = 0; 00131 00132 /** 00133 * Shutdown the vendor BLE subsystem. 00134 * 00135 * This operation includes purging the stack of GATT and GAP state and 00136 * clearing all state from other BLE components, such as the SecurityManager. 00137 * Clearing all states may be realized by a call to Gap::reset(), 00138 * GattClient::reset(), GattServer::reset() and SecurityManager::reset(). 00139 * 00140 * BLE::init() must be called afterward to reinstantiate services and GAP 00141 * state. 00142 * 00143 * @return BLE_ERROR_NONE if the underlying stack and all other services of 00144 * the BLE API were shut down correctly. 00145 * 00146 * @post hasInitialized() shall return false. 00147 * 00148 * @note This function is invoked by BLE::shutdown(). 00149 * 00150 * @see BLE::shutdown() BLE::init() BLE::hasInitialized() Gap::reset() 00151 * GattClient::reset() GattServer::reset() SecurityManager::reset() . 00152 */ 00153 virtual ble_error_t shutdown(void) = 0; 00154 00155 /** 00156 * Fetches a NULL terminated string representation of the underlying BLE 00157 * vendor subsystem. 00158 * 00159 * @return A pointer to the NULL terminated string representation of the 00160 * underlying BLE stack's version. 00161 * 00162 * @see BLE::getVersion() 00163 */ 00164 virtual const char *getVersion(void) = 0; 00165 00166 /** 00167 * Accessor to the vendor implementation of the Gap interface. 00168 * 00169 * @return A reference to a Gap object associated to this BLEInstanceBase 00170 * instance. 00171 * 00172 * @see BLE::gap() Gap 00173 */ 00174 virtual Gap &getGap(void) = 0; 00175 00176 /** 00177 * Const alternative to getGap(). 00178 * 00179 * @return A const reference to a Gap object associated to this 00180 * BLEInstanceBase instance. 00181 * 00182 * @see BLE::gap() Gap 00183 */ 00184 virtual const Gap &getGap(void) const = 0; 00185 00186 /** 00187 * Accessor to the vendor implementation of the GattServer interface. 00188 * 00189 * @return A reference to a GattServer object associated to this 00190 * BLEInstanceBase instance. 00191 * 00192 * @see BLE::gattServer() GattServer 00193 */ 00194 virtual GattServer &getGattServer(void) = 0; 00195 00196 /** 00197 * A const alternative to getGattServer(). 00198 * 00199 * @return A const reference to a GattServer object associated to this 00200 * BLEInstanceBase instance. 00201 * 00202 * @see BLE::gattServer() GattServer 00203 */ 00204 virtual const GattServer &getGattServer(void) const = 0; 00205 00206 /** 00207 * Accessor to the vendor implementation of the GattClient interface. 00208 * 00209 * @return A reference to a GattClient object associated to this 00210 * BLEInstanceBase instance. 00211 * 00212 * @see BLE::gattClient() GattClient 00213 */ 00214 virtual GattClient &getGattClient(void) = 0; 00215 00216 /** 00217 * Accessor to the vendor implementation of the SecurityManager interface. 00218 * 00219 * @return A reference to a SecurityManager object associated to this 00220 * BLEInstanceBase instance. 00221 * 00222 * @see BLE::securityManager() SecurityManager 00223 */ 00224 virtual SecurityManager &getSecurityManager(void) = 0; 00225 00226 /** 00227 * A const alternative to getSecurityManager(). 00228 * 00229 * @return A const reference to a SecurityManager object associated to this 00230 * BLEInstancebase instance. 00231 * 00232 * @see BLE::securityManager() SecurityManager 00233 */ 00234 virtual const SecurityManager &getSecurityManager(void) const = 0; 00235 00236 /** 00237 * Process pending events present in the vendor subsystem; then, put the MCU 00238 * to sleep until an external source wakes it up. 00239 * 00240 * @attention This function is deprecated in the BLE class. It will be 00241 * removed from this interface once it is removed from BLE. 00242 * 00243 * @see BLE::waitForEvent() BLE::processEvents() 00244 */ 00245 virtual void waitForEvent(void) = 0; 00246 00247 private: 00248 // this class is not a value type. 00249 // prohibit copy construction and copy assignement 00250 BLEInstanceBase(const BLEInstanceBase&); 00251 BLEInstanceBase &operator=(const BLEInstanceBase&); 00252 }; 00253 00254 /** 00255 * Return the instance of the vendor implementation of BLEInstanceBase. 00256 * 00257 * @attention Contrary to its name, this function does not return a new instance 00258 * at each call. It rather acts like an accessor to a singleton. 00259 * 00260 * @attention The vendor library must provide an implementation for this function 00261 * library. Otherwise, there will be a linker error. 00262 */ 00263 extern BLEInstanceBase *createBLEInstance(void); 00264 00265 /** 00266 * @} 00267 * @} 00268 */ 00269 00270 #endif // ifndef MBED_BLE_DEVICE_INSTANCE_BASE__
Generated on Tue Jul 12 2022 14:23:26 by
