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.
Fork of BLE_API by
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 #ifndef __BLE_DEVICE_INSTANCE_BASE__ 00018 #define __BLE_DEVICE_INSTANCE_BASE__ 00019 00020 #include "Gap.h" 00021 #include "ble/SecurityManager.h" 00022 #include "ble/BLE.h" 00023 00024 /* Forward declarations. */ 00025 class GattServer; 00026 class GattClient; 00027 00028 /** 00029 * The interface for the transport object to be created by the target library's 00030 * createBLEInstance(). 00031 * 00032 * @note This class is part of the interface of BLE API with the implementation; 00033 * therefore, it is meant to be used only by porters rather than normal 00034 * BLE API users. 00035 */ 00036 class BLEInstanceBase 00037 { 00038 public: 00039 /** 00040 * Initialize the underlying BLE stack. This should be called before 00041 * anything else in the BLE API. 00042 * 00043 * @param[in] instanceID 00044 * The ID of the instance to initialize. 00045 * @param[in] initCallback 00046 * A callback for when initialization completes for a BLE 00047 * instance. This is an optional parameter set to NULL when not 00048 * supplied. 00049 * 00050 * @return BLE_ERROR_NONE if the initialization procedure was started 00051 * successfully. 00052 */ 00053 virtual ble_error_t init(BLE::InstanceID_t instanceID, 00054 FunctionPointerWithContext<BLE::InitializationCompleteCallbackContext *> initCallback) = 0; 00055 00056 /** 00057 * Check whether the underlying stack has already been initialized, 00058 * possible with a call to init(). 00059 * 00060 * @return true if the initialization has completed for the underlying BLE 00061 * stack. 00062 */ 00063 virtual bool hasInitialized(void) const = 0; 00064 00065 /** 00066 * Shutdown the underlying BLE stack. This includes purging the stack of 00067 * GATT and GAP state and clearing all state from other BLE components 00068 * such as the SecurityManager. init() must be called afterwards to 00069 * re-instantiate services and GAP state. 00070 * 00071 * @return BLE_ERROR_NONE if the underlying stack and all other services of 00072 * the BLE API were shutdown correctly. 00073 */ 00074 virtual ble_error_t shutdown(void) = 0; 00075 00076 /** 00077 * Fetches a string representation of the underlying BLE stack's version. 00078 * 00079 * @return A pointer to the string representation of the underlying 00080 * BLE stack's version. 00081 */ 00082 virtual const char * getVersion(void) = 0; 00083 00084 /** 00085 * Accessor to Gap. This function is used by BLE::gap(). 00086 * 00087 * @return A reference to a Gap object associated to this BLE instance. 00088 */ 00089 virtual Gap& getGap() = 0; 00090 00091 /** 00092 * A const alternative to getGap(). 00093 * 00094 * @return A const reference to a Gap object associated to this BLE instance. 00095 */ 00096 virtual const Gap& getGap() const = 0; 00097 00098 /** 00099 * Accessor to GattServer. This function is used by BLE::gattServer(). 00100 * 00101 * @return A reference to a GattServer object associated to this BLE instance. 00102 */ 00103 virtual GattServer& getGattServer() = 0; 00104 00105 /** 00106 * A const alternative to getGattServer(). 00107 * 00108 * @return A const reference to a GattServer object associated to this BLE instance. 00109 */ 00110 virtual const GattServer& getGattServer() const = 0; 00111 00112 /** 00113 * Accessors to GattClient. This function is used by BLE::gattClient(). 00114 * 00115 * @return A reference to a GattClient object associated to this BLE instance. 00116 */ 00117 virtual GattClient& getGattClient() = 0; 00118 00119 /** 00120 * Accessors to SecurityManager. This function is used by BLE::securityManager(). 00121 * 00122 * @return A reference to a SecurityManager object associated to this BLE instance. 00123 */ 00124 virtual SecurityManager& getSecurityManager() = 0; 00125 00126 /** 00127 * A const alternative to getSecurityManager(). 00128 * 00129 * @return A const reference to a SecurityManager object associated to this BLE instance. 00130 */ 00131 virtual const SecurityManager& getSecurityManager() const = 0; 00132 00133 /** 00134 * Yield control to the BLE stack or to other tasks waiting for events. 00135 * refer to BLE::waitForEvent(). 00136 */ 00137 virtual void waitForEvent(void) = 0; 00138 }; 00139 00140 /** 00141 * BLE uses composition to hide an interface object encapsulating the 00142 * backend transport. 00143 * 00144 * The following API is used to create the singleton interface object. An 00145 * implementation for this function must be provided by the device-specific 00146 * library, otherwise there will be a linker error. 00147 */ 00148 extern BLEInstanceBase *createBLEInstance(void); 00149 00150 #endif // ifndef __BLE_DEVICE_INSTANCE_BASE__
Generated on Tue Jul 12 2022 19:31:53 by
1.7.2
