Marco Zecchini
/
Example_RTOS
Rtos API example
mbed-os/features/FEATURE_BLE/ble/BLE.h@0:9fca2b23d0ba, 2019-02-23 (annotated)
- Committer:
- marcozecchini
- Date:
- Sat Feb 23 12:13:36 2019 +0000
- Revision:
- 0:9fca2b23d0ba
final commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
marcozecchini | 0:9fca2b23d0ba | 1 | /* mbed Microcontroller Library |
marcozecchini | 0:9fca2b23d0ba | 2 | * Copyright (c) 2006-2013 ARM Limited |
marcozecchini | 0:9fca2b23d0ba | 3 | * |
marcozecchini | 0:9fca2b23d0ba | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
marcozecchini | 0:9fca2b23d0ba | 5 | * you may not use this file except in compliance with the License. |
marcozecchini | 0:9fca2b23d0ba | 6 | * You may obtain a copy of the License at |
marcozecchini | 0:9fca2b23d0ba | 7 | * |
marcozecchini | 0:9fca2b23d0ba | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
marcozecchini | 0:9fca2b23d0ba | 9 | * |
marcozecchini | 0:9fca2b23d0ba | 10 | * Unless required by applicable law or agreed to in writing, software |
marcozecchini | 0:9fca2b23d0ba | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
marcozecchini | 0:9fca2b23d0ba | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
marcozecchini | 0:9fca2b23d0ba | 13 | * See the License for the specific language governing permissions and |
marcozecchini | 0:9fca2b23d0ba | 14 | * limitations under the License. |
marcozecchini | 0:9fca2b23d0ba | 15 | */ |
marcozecchini | 0:9fca2b23d0ba | 16 | |
marcozecchini | 0:9fca2b23d0ba | 17 | #ifndef MBED_BLE_H__ |
marcozecchini | 0:9fca2b23d0ba | 18 | #define MBED_BLE_H__ |
marcozecchini | 0:9fca2b23d0ba | 19 | |
marcozecchini | 0:9fca2b23d0ba | 20 | #include "blecommon.h" |
marcozecchini | 0:9fca2b23d0ba | 21 | #include "Gap.h" |
marcozecchini | 0:9fca2b23d0ba | 22 | #include "GattServer.h" |
marcozecchini | 0:9fca2b23d0ba | 23 | #include "GattClient.h" |
marcozecchini | 0:9fca2b23d0ba | 24 | #include "SecurityManager.h" |
marcozecchini | 0:9fca2b23d0ba | 25 | |
marcozecchini | 0:9fca2b23d0ba | 26 | #include "ble/FunctionPointerWithContext.h" |
marcozecchini | 0:9fca2b23d0ba | 27 | |
marcozecchini | 0:9fca2b23d0ba | 28 | #ifdef YOTTA_CFG_MBED_OS |
marcozecchini | 0:9fca2b23d0ba | 29 | #include "mbed-drivers/mbed_error.h" |
marcozecchini | 0:9fca2b23d0ba | 30 | #else |
marcozecchini | 0:9fca2b23d0ba | 31 | #include "mbed_error.h" |
marcozecchini | 0:9fca2b23d0ba | 32 | #endif |
marcozecchini | 0:9fca2b23d0ba | 33 | |
marcozecchini | 0:9fca2b23d0ba | 34 | #include "platform/mbed_toolchain.h" |
marcozecchini | 0:9fca2b23d0ba | 35 | |
marcozecchini | 0:9fca2b23d0ba | 36 | /* Forward declaration for the implementation class */ |
marcozecchini | 0:9fca2b23d0ba | 37 | class BLEInstanceBase; |
marcozecchini | 0:9fca2b23d0ba | 38 | |
marcozecchini | 0:9fca2b23d0ba | 39 | /** |
marcozecchini | 0:9fca2b23d0ba | 40 | * @addtogroup ble |
marcozecchini | 0:9fca2b23d0ba | 41 | * @{ |
marcozecchini | 0:9fca2b23d0ba | 42 | */ |
marcozecchini | 0:9fca2b23d0ba | 43 | |
marcozecchini | 0:9fca2b23d0ba | 44 | /** |
marcozecchini | 0:9fca2b23d0ba | 45 | * Abstract away BLE-capable radio transceivers or SOCs. |
marcozecchini | 0:9fca2b23d0ba | 46 | * |
marcozecchini | 0:9fca2b23d0ba | 47 | * Instances of this class have three responsibilities: |
marcozecchini | 0:9fca2b23d0ba | 48 | * - Initialize the inner BLE subsystem. |
marcozecchini | 0:9fca2b23d0ba | 49 | * - Signal user code that BLE events are available and an API to process them. |
marcozecchini | 0:9fca2b23d0ba | 50 | * - Manage access to the instances abstracting each BLE layer: |
marcozecchini | 0:9fca2b23d0ba | 51 | * + GAP: Handle advertising and scan, as well as connection and |
marcozecchini | 0:9fca2b23d0ba | 52 | * disconnection. |
marcozecchini | 0:9fca2b23d0ba | 53 | * + GATTServer: API to construct and manage a GATT server, which connected peers can |
marcozecchini | 0:9fca2b23d0ba | 54 | * access. |
marcozecchini | 0:9fca2b23d0ba | 55 | * + GATTClient: API to interact with a peer GATT server. |
marcozecchini | 0:9fca2b23d0ba | 56 | * + SecurityManager: API to manage security. |
marcozecchini | 0:9fca2b23d0ba | 57 | * |
marcozecchini | 0:9fca2b23d0ba | 58 | * The user should not create BLE instances directly but rather access to the |
marcozecchini | 0:9fca2b23d0ba | 59 | * singleton(s) holding the BLE interfaces present in the system by using the |
marcozecchini | 0:9fca2b23d0ba | 60 | * static function Instance(). |
marcozecchini | 0:9fca2b23d0ba | 61 | * |
marcozecchini | 0:9fca2b23d0ba | 62 | * @code |
marcozecchini | 0:9fca2b23d0ba | 63 | * #include "ble/BLE.h" |
marcozecchini | 0:9fca2b23d0ba | 64 | * |
marcozecchini | 0:9fca2b23d0ba | 65 | * BLE& ble_interface = BLE::Instance(); |
marcozecchini | 0:9fca2b23d0ba | 66 | * @endcode |
marcozecchini | 0:9fca2b23d0ba | 67 | * |
marcozecchini | 0:9fca2b23d0ba | 68 | * Next, the signal handling/process mechanism should be set up. By design, |
marcozecchini | 0:9fca2b23d0ba | 69 | * Mbed BLE does not impose to the user an event handling/processing mechanism; |
marcozecchini | 0:9fca2b23d0ba | 70 | * however, it exposes APIs, which allows an application to compose its own: |
marcozecchini | 0:9fca2b23d0ba | 71 | * - onEventsToProcess(), whichs register a callback that |
marcozecchini | 0:9fca2b23d0ba | 72 | * the BLE subsystem will call when there is an event ready to be processed. |
marcozecchini | 0:9fca2b23d0ba | 73 | * - processEvents(), which processes all the events present in the BLE subsystem. |
marcozecchini | 0:9fca2b23d0ba | 74 | * |
marcozecchini | 0:9fca2b23d0ba | 75 | * It is common to bind BLE event mechanism with Mbed EventQueue: |
marcozecchini | 0:9fca2b23d0ba | 76 | * |
marcozecchini | 0:9fca2b23d0ba | 77 | * @code |
marcozecchini | 0:9fca2b23d0ba | 78 | * #include <events/mbed_events.h> |
marcozecchini | 0:9fca2b23d0ba | 79 | * #include "ble/BLE.h" |
marcozecchini | 0:9fca2b23d0ba | 80 | * |
marcozecchini | 0:9fca2b23d0ba | 81 | * // declare the event queue, which the whole application will share. |
marcozecchini | 0:9fca2b23d0ba | 82 | * static EventQueue event_queue( 4 * EVENTS_EVENT_SIZE); |
marcozecchini | 0:9fca2b23d0ba | 83 | * |
marcozecchini | 0:9fca2b23d0ba | 84 | * // Function invoked when there is a BLE event available. |
marcozecchini | 0:9fca2b23d0ba | 85 | * // It put into the event queue the processing of the event(s) |
marcozecchini | 0:9fca2b23d0ba | 86 | * void schedule_ble_processing(BLE::OnEventsToProcessCallbackContext* context) { |
marcozecchini | 0:9fca2b23d0ba | 87 | * event_queue.call(callback(&(context->ble), &BLE::processEvents)); |
marcozecchini | 0:9fca2b23d0ba | 88 | * } |
marcozecchini | 0:9fca2b23d0ba | 89 | * |
marcozecchini | 0:9fca2b23d0ba | 90 | * int main() |
marcozecchini | 0:9fca2b23d0ba | 91 | * { |
marcozecchini | 0:9fca2b23d0ba | 92 | * BLE &ble_interface = BLE::Instance(); |
marcozecchini | 0:9fca2b23d0ba | 93 | * |
marcozecchini | 0:9fca2b23d0ba | 94 | * // Bind event signaling to schedule_ble_processing |
marcozecchini | 0:9fca2b23d0ba | 95 | * ble_interface.onEventsToProcess(schedule_ble_processing); |
marcozecchini | 0:9fca2b23d0ba | 96 | * |
marcozecchini | 0:9fca2b23d0ba | 97 | * // Launch BLE initialisation |
marcozecchini | 0:9fca2b23d0ba | 98 | * |
marcozecchini | 0:9fca2b23d0ba | 99 | * // Dispatch events in the event queue |
marcozecchini | 0:9fca2b23d0ba | 100 | * event_queue.dispatch_forever(); |
marcozecchini | 0:9fca2b23d0ba | 101 | * return 0; |
marcozecchini | 0:9fca2b23d0ba | 102 | * } |
marcozecchini | 0:9fca2b23d0ba | 103 | * @endcode |
marcozecchini | 0:9fca2b23d0ba | 104 | * |
marcozecchini | 0:9fca2b23d0ba | 105 | * Once the event processing mechanism is in place, the Bluetooth subsystem can |
marcozecchini | 0:9fca2b23d0ba | 106 | * be initialized with the init() function. That function accepts in input a |
marcozecchini | 0:9fca2b23d0ba | 107 | * callback, which will be invoked once the initialization process has finished. |
marcozecchini | 0:9fca2b23d0ba | 108 | * |
marcozecchini | 0:9fca2b23d0ba | 109 | * @code |
marcozecchini | 0:9fca2b23d0ba | 110 | * void on_ble_init_complete(BLE::InitializationCompleteCallbackContext *context) |
marcozecchini | 0:9fca2b23d0ba | 111 | * { |
marcozecchini | 0:9fca2b23d0ba | 112 | * BLE& ble_interface = context->ble; |
marcozecchini | 0:9fca2b23d0ba | 113 | * ble_error_t initialization_error = context->error; |
marcozecchini | 0:9fca2b23d0ba | 114 | * |
marcozecchini | 0:9fca2b23d0ba | 115 | * if (initialization_error) { |
marcozecchini | 0:9fca2b23d0ba | 116 | * // handle error |
marcozecchini | 0:9fca2b23d0ba | 117 | * return; |
marcozecchini | 0:9fca2b23d0ba | 118 | * } |
marcozecchini | 0:9fca2b23d0ba | 119 | * |
marcozecchini | 0:9fca2b23d0ba | 120 | * // The BLE interface can be accessed now. |
marcozecchini | 0:9fca2b23d0ba | 121 | * } |
marcozecchini | 0:9fca2b23d0ba | 122 | * |
marcozecchini | 0:9fca2b23d0ba | 123 | * int main() { |
marcozecchini | 0:9fca2b23d0ba | 124 | * BLE &ble_interface = BLE::Instance(); |
marcozecchini | 0:9fca2b23d0ba | 125 | * ble_interface.onEventsToProcess(schedule_ble_processing); |
marcozecchini | 0:9fca2b23d0ba | 126 | * |
marcozecchini | 0:9fca2b23d0ba | 127 | * // Initialize the BLE interface |
marcozecchini | 0:9fca2b23d0ba | 128 | * ble_interface.init(on_ble_init_complete); |
marcozecchini | 0:9fca2b23d0ba | 129 | * |
marcozecchini | 0:9fca2b23d0ba | 130 | * event_queue.dispatch_forever(); |
marcozecchini | 0:9fca2b23d0ba | 131 | * return 0; |
marcozecchini | 0:9fca2b23d0ba | 132 | * } |
marcozecchini | 0:9fca2b23d0ba | 133 | * @endcode |
marcozecchini | 0:9fca2b23d0ba | 134 | */ |
marcozecchini | 0:9fca2b23d0ba | 135 | class BLE |
marcozecchini | 0:9fca2b23d0ba | 136 | { |
marcozecchini | 0:9fca2b23d0ba | 137 | public: |
marcozecchini | 0:9fca2b23d0ba | 138 | /** |
marcozecchini | 0:9fca2b23d0ba | 139 | * Opaque type used to store the ID of a BLE instance. |
marcozecchini | 0:9fca2b23d0ba | 140 | */ |
marcozecchini | 0:9fca2b23d0ba | 141 | typedef unsigned InstanceID_t; |
marcozecchini | 0:9fca2b23d0ba | 142 | |
marcozecchini | 0:9fca2b23d0ba | 143 | /** |
marcozecchini | 0:9fca2b23d0ba | 144 | * The value of the BLE::InstanceID_t for the default BLE instance. |
marcozecchini | 0:9fca2b23d0ba | 145 | */ |
marcozecchini | 0:9fca2b23d0ba | 146 | static const InstanceID_t DEFAULT_INSTANCE = 0; |
marcozecchini | 0:9fca2b23d0ba | 147 | |
marcozecchini | 0:9fca2b23d0ba | 148 | #ifndef YOTTA_CFG_BLE_INSTANCES_COUNT |
marcozecchini | 0:9fca2b23d0ba | 149 | /** |
marcozecchini | 0:9fca2b23d0ba | 150 | * The number of permitted BLE instances for the application. |
marcozecchini | 0:9fca2b23d0ba | 151 | */ |
marcozecchini | 0:9fca2b23d0ba | 152 | static const InstanceID_t NUM_INSTANCES = 1; |
marcozecchini | 0:9fca2b23d0ba | 153 | #else |
marcozecchini | 0:9fca2b23d0ba | 154 | /** |
marcozecchini | 0:9fca2b23d0ba | 155 | * The number of permitted BLE instances for the application. |
marcozecchini | 0:9fca2b23d0ba | 156 | */ |
marcozecchini | 0:9fca2b23d0ba | 157 | static const InstanceID_t NUM_INSTANCES = YOTTA_CFG_BLE_INSTANCES_COUNT; |
marcozecchini | 0:9fca2b23d0ba | 158 | #endif |
marcozecchini | 0:9fca2b23d0ba | 159 | |
marcozecchini | 0:9fca2b23d0ba | 160 | /** |
marcozecchini | 0:9fca2b23d0ba | 161 | * Get a reference to the BLE singleton corresponding to a given interface. |
marcozecchini | 0:9fca2b23d0ba | 162 | * |
marcozecchini | 0:9fca2b23d0ba | 163 | * There is a static array of BLE singletons. |
marcozecchini | 0:9fca2b23d0ba | 164 | * |
marcozecchini | 0:9fca2b23d0ba | 165 | * @note Calling Instance() is preferred over constructing a BLE object |
marcozecchini | 0:9fca2b23d0ba | 166 | * directly because it returns references to singletons. |
marcozecchini | 0:9fca2b23d0ba | 167 | * |
marcozecchini | 0:9fca2b23d0ba | 168 | * @param[in] id BLE Instance ID to get. |
marcozecchini | 0:9fca2b23d0ba | 169 | * |
marcozecchini | 0:9fca2b23d0ba | 170 | * @return A reference to a single object. |
marcozecchini | 0:9fca2b23d0ba | 171 | * |
marcozecchini | 0:9fca2b23d0ba | 172 | * @pre id shall be less than NUM_INSTANCES. |
marcozecchini | 0:9fca2b23d0ba | 173 | */ |
marcozecchini | 0:9fca2b23d0ba | 174 | static BLE &Instance(InstanceID_t id = DEFAULT_INSTANCE); |
marcozecchini | 0:9fca2b23d0ba | 175 | |
marcozecchini | 0:9fca2b23d0ba | 176 | /** |
marcozecchini | 0:9fca2b23d0ba | 177 | * Fetch the ID of a BLE instance. |
marcozecchini | 0:9fca2b23d0ba | 178 | * |
marcozecchini | 0:9fca2b23d0ba | 179 | * @return Instance id of this BLE instance. |
marcozecchini | 0:9fca2b23d0ba | 180 | */ |
marcozecchini | 0:9fca2b23d0ba | 181 | InstanceID_t getInstanceID(void) const { |
marcozecchini | 0:9fca2b23d0ba | 182 | return instanceID; |
marcozecchini | 0:9fca2b23d0ba | 183 | } |
marcozecchini | 0:9fca2b23d0ba | 184 | |
marcozecchini | 0:9fca2b23d0ba | 185 | /** |
marcozecchini | 0:9fca2b23d0ba | 186 | * Events to process event. |
marcozecchini | 0:9fca2b23d0ba | 187 | * |
marcozecchini | 0:9fca2b23d0ba | 188 | * Instances of OnEventsToProcessCallbackContext are passed to the event |
marcozecchini | 0:9fca2b23d0ba | 189 | * handler registered with onEventsToProcess(). |
marcozecchini | 0:9fca2b23d0ba | 190 | */ |
marcozecchini | 0:9fca2b23d0ba | 191 | struct OnEventsToProcessCallbackContext { |
marcozecchini | 0:9fca2b23d0ba | 192 | /** |
marcozecchini | 0:9fca2b23d0ba | 193 | * The ble instance which have events to process. |
marcozecchini | 0:9fca2b23d0ba | 194 | */ |
marcozecchini | 0:9fca2b23d0ba | 195 | BLE& ble; |
marcozecchini | 0:9fca2b23d0ba | 196 | }; |
marcozecchini | 0:9fca2b23d0ba | 197 | |
marcozecchini | 0:9fca2b23d0ba | 198 | /** |
marcozecchini | 0:9fca2b23d0ba | 199 | * Events to process event handler |
marcozecchini | 0:9fca2b23d0ba | 200 | */ |
marcozecchini | 0:9fca2b23d0ba | 201 | typedef FunctionPointerWithContext<OnEventsToProcessCallbackContext*> |
marcozecchini | 0:9fca2b23d0ba | 202 | OnEventsToProcessCallback_t; |
marcozecchini | 0:9fca2b23d0ba | 203 | |
marcozecchini | 0:9fca2b23d0ba | 204 | /** |
marcozecchini | 0:9fca2b23d0ba | 205 | * Register a callback called when the BLE stack has pending work. |
marcozecchini | 0:9fca2b23d0ba | 206 | * |
marcozecchini | 0:9fca2b23d0ba | 207 | * By registering a callback, application code can know when event processing |
marcozecchini | 0:9fca2b23d0ba | 208 | * has to be scheduled. |
marcozecchini | 0:9fca2b23d0ba | 209 | * |
marcozecchini | 0:9fca2b23d0ba | 210 | * @param on_event_cb Callback invoked when there are new events to process. |
marcozecchini | 0:9fca2b23d0ba | 211 | */ |
marcozecchini | 0:9fca2b23d0ba | 212 | void onEventsToProcess(const OnEventsToProcessCallback_t& on_event_cb); |
marcozecchini | 0:9fca2b23d0ba | 213 | |
marcozecchini | 0:9fca2b23d0ba | 214 | /** |
marcozecchini | 0:9fca2b23d0ba | 215 | * Process ALL pending events living in the BLE stack and return once all |
marcozecchini | 0:9fca2b23d0ba | 216 | * events have been consumed. |
marcozecchini | 0:9fca2b23d0ba | 217 | * |
marcozecchini | 0:9fca2b23d0ba | 218 | * @see onEventsToProcess() |
marcozecchini | 0:9fca2b23d0ba | 219 | */ |
marcozecchini | 0:9fca2b23d0ba | 220 | void processEvents(); |
marcozecchini | 0:9fca2b23d0ba | 221 | |
marcozecchini | 0:9fca2b23d0ba | 222 | /** |
marcozecchini | 0:9fca2b23d0ba | 223 | * Initialization complete event. |
marcozecchini | 0:9fca2b23d0ba | 224 | * |
marcozecchini | 0:9fca2b23d0ba | 225 | * This event is generated at the end of the init() procedure and is passed |
marcozecchini | 0:9fca2b23d0ba | 226 | * to the completion callback passed to init(). |
marcozecchini | 0:9fca2b23d0ba | 227 | */ |
marcozecchini | 0:9fca2b23d0ba | 228 | struct InitializationCompleteCallbackContext { |
marcozecchini | 0:9fca2b23d0ba | 229 | /** |
marcozecchini | 0:9fca2b23d0ba | 230 | * Reference to the BLE object that has been initialized |
marcozecchini | 0:9fca2b23d0ba | 231 | */ |
marcozecchini | 0:9fca2b23d0ba | 232 | BLE& ble; |
marcozecchini | 0:9fca2b23d0ba | 233 | |
marcozecchini | 0:9fca2b23d0ba | 234 | /** |
marcozecchini | 0:9fca2b23d0ba | 235 | * Error status of the initialization. |
marcozecchini | 0:9fca2b23d0ba | 236 | * |
marcozecchini | 0:9fca2b23d0ba | 237 | * That value is set to BLE_ERROR_NONE if initialization completed |
marcozecchini | 0:9fca2b23d0ba | 238 | * successfully or the appropriate error code otherwise. |
marcozecchini | 0:9fca2b23d0ba | 239 | * */ |
marcozecchini | 0:9fca2b23d0ba | 240 | ble_error_t error; |
marcozecchini | 0:9fca2b23d0ba | 241 | }; |
marcozecchini | 0:9fca2b23d0ba | 242 | |
marcozecchini | 0:9fca2b23d0ba | 243 | /** |
marcozecchini | 0:9fca2b23d0ba | 244 | * Initialization complete event handler. |
marcozecchini | 0:9fca2b23d0ba | 245 | * |
marcozecchini | 0:9fca2b23d0ba | 246 | * @note There are two versions of init(). In addition to the |
marcozecchini | 0:9fca2b23d0ba | 247 | * function-pointer, init() can also take an <Object, member> tuple as its |
marcozecchini | 0:9fca2b23d0ba | 248 | * callback target. In case of the latter, the following declaration doesn't |
marcozecchini | 0:9fca2b23d0ba | 249 | * apply. |
marcozecchini | 0:9fca2b23d0ba | 250 | */ |
marcozecchini | 0:9fca2b23d0ba | 251 | typedef void (*InitializationCompleteCallback_t)( |
marcozecchini | 0:9fca2b23d0ba | 252 | InitializationCompleteCallbackContext *context |
marcozecchini | 0:9fca2b23d0ba | 253 | ); |
marcozecchini | 0:9fca2b23d0ba | 254 | |
marcozecchini | 0:9fca2b23d0ba | 255 | /** |
marcozecchini | 0:9fca2b23d0ba | 256 | * Initialize the BLE controller/stack. |
marcozecchini | 0:9fca2b23d0ba | 257 | * |
marcozecchini | 0:9fca2b23d0ba | 258 | * init() hands control to the underlying BLE module to accomplish |
marcozecchini | 0:9fca2b23d0ba | 259 | * initialization. This initialization may tacitly depend on other hardware |
marcozecchini | 0:9fca2b23d0ba | 260 | * setup (such as clocks or power-modes) that happens early on during system |
marcozecchini | 0:9fca2b23d0ba | 261 | * startup. It may not be safe to call init() from a global static context |
marcozecchini | 0:9fca2b23d0ba | 262 | * where ordering is compiler-specific and can't be guaranteed - it is safe |
marcozecchini | 0:9fca2b23d0ba | 263 | * to call BLE::init() from within main(). |
marcozecchini | 0:9fca2b23d0ba | 264 | * |
marcozecchini | 0:9fca2b23d0ba | 265 | * @param[in] completion_cb A callback for when initialization completes for |
marcozecchini | 0:9fca2b23d0ba | 266 | * a BLE instance. This is an optional parameter; if no callback is set up, |
marcozecchini | 0:9fca2b23d0ba | 267 | * the application can still determine the status of initialization using |
marcozecchini | 0:9fca2b23d0ba | 268 | * BLE::hasInitialized() (see below). |
marcozecchini | 0:9fca2b23d0ba | 269 | * |
marcozecchini | 0:9fca2b23d0ba | 270 | * @return BLE_ERROR_NONE if the initialization procedure started |
marcozecchini | 0:9fca2b23d0ba | 271 | * successfully. |
marcozecchini | 0:9fca2b23d0ba | 272 | * |
marcozecchini | 0:9fca2b23d0ba | 273 | * @note If init() returns BLE_ERROR_NONE, the underlying stack must invoke |
marcozecchini | 0:9fca2b23d0ba | 274 | * the initialization completion callback at some point. |
marcozecchini | 0:9fca2b23d0ba | 275 | * |
marcozecchini | 0:9fca2b23d0ba | 276 | * @note Nearly all BLE APIs would return BLE_ERROR_INITIALIZATION_INCOMPLETE |
marcozecchini | 0:9fca2b23d0ba | 277 | * if used on an instance before the corresponding transport is initialized. |
marcozecchini | 0:9fca2b23d0ba | 278 | * |
marcozecchini | 0:9fca2b23d0ba | 279 | * @note There are two versions of init(). In addition to the |
marcozecchini | 0:9fca2b23d0ba | 280 | * function-pointer, init() can also take an <Object, member> pair as its |
marcozecchini | 0:9fca2b23d0ba | 281 | * callback target. |
marcozecchini | 0:9fca2b23d0ba | 282 | * |
marcozecchini | 0:9fca2b23d0ba | 283 | * @important This should be called before using anything else in the BLE |
marcozecchini | 0:9fca2b23d0ba | 284 | * API. |
marcozecchini | 0:9fca2b23d0ba | 285 | */ |
marcozecchini | 0:9fca2b23d0ba | 286 | ble_error_t init(InitializationCompleteCallback_t completion_cb = NULL) { |
marcozecchini | 0:9fca2b23d0ba | 287 | FunctionPointerWithContext<InitializationCompleteCallbackContext *> callback(completion_cb); |
marcozecchini | 0:9fca2b23d0ba | 288 | return initImplementation(callback); |
marcozecchini | 0:9fca2b23d0ba | 289 | } |
marcozecchini | 0:9fca2b23d0ba | 290 | |
marcozecchini | 0:9fca2b23d0ba | 291 | /** |
marcozecchini | 0:9fca2b23d0ba | 292 | * Initialize the BLE controller/stack. |
marcozecchini | 0:9fca2b23d0ba | 293 | * |
marcozecchini | 0:9fca2b23d0ba | 294 | * This is an alternate declaration for init(). This one takes an |
marcozecchini | 0:9fca2b23d0ba | 295 | * <Object, member> pair as its callback target. |
marcozecchini | 0:9fca2b23d0ba | 296 | * |
marcozecchini | 0:9fca2b23d0ba | 297 | * @param[in] object Object, which will be used to invoke the completion callback. |
marcozecchini | 0:9fca2b23d0ba | 298 | * @param[in] completion_cb Member function pointer, which will be invoked when |
marcozecchini | 0:9fca2b23d0ba | 299 | * initialization is complete. |
marcozecchini | 0:9fca2b23d0ba | 300 | */ |
marcozecchini | 0:9fca2b23d0ba | 301 | template<typename T> |
marcozecchini | 0:9fca2b23d0ba | 302 | ble_error_t init(T *object, void (T::*completion_cb)(InitializationCompleteCallbackContext *context)) { |
marcozecchini | 0:9fca2b23d0ba | 303 | FunctionPointerWithContext<InitializationCompleteCallbackContext *> callback(object, completion_cb); |
marcozecchini | 0:9fca2b23d0ba | 304 | return initImplementation(callback); |
marcozecchini | 0:9fca2b23d0ba | 305 | } |
marcozecchini | 0:9fca2b23d0ba | 306 | |
marcozecchini | 0:9fca2b23d0ba | 307 | /** |
marcozecchini | 0:9fca2b23d0ba | 308 | * Indicate if the BLE instance has been initialized. |
marcozecchini | 0:9fca2b23d0ba | 309 | * |
marcozecchini | 0:9fca2b23d0ba | 310 | * @return true if initialization has completed for the underlying BLE |
marcozecchini | 0:9fca2b23d0ba | 311 | * transport. |
marcozecchini | 0:9fca2b23d0ba | 312 | * |
marcozecchini | 0:9fca2b23d0ba | 313 | * @note The application should set up a callback to signal completion of |
marcozecchini | 0:9fca2b23d0ba | 314 | * initialization when using init(). |
marcozecchini | 0:9fca2b23d0ba | 315 | */ |
marcozecchini | 0:9fca2b23d0ba | 316 | bool hasInitialized(void) const; |
marcozecchini | 0:9fca2b23d0ba | 317 | |
marcozecchini | 0:9fca2b23d0ba | 318 | /** |
marcozecchini | 0:9fca2b23d0ba | 319 | * Shut down the underlying stack, and reset state of this BLE instance. |
marcozecchini | 0:9fca2b23d0ba | 320 | * |
marcozecchini | 0:9fca2b23d0ba | 321 | * @return BLE_ERROR_NONE if the instance was shut down without error or the |
marcozecchini | 0:9fca2b23d0ba | 322 | * appropriate error code. |
marcozecchini | 0:9fca2b23d0ba | 323 | * |
marcozecchini | 0:9fca2b23d0ba | 324 | * @important init() must be called afterward to reinstate services and |
marcozecchini | 0:9fca2b23d0ba | 325 | * GAP state. This API offers a way to repopulate the GATT database with new |
marcozecchini | 0:9fca2b23d0ba | 326 | * services and characteristics. |
marcozecchini | 0:9fca2b23d0ba | 327 | */ |
marcozecchini | 0:9fca2b23d0ba | 328 | ble_error_t shutdown(void); |
marcozecchini | 0:9fca2b23d0ba | 329 | |
marcozecchini | 0:9fca2b23d0ba | 330 | /** |
marcozecchini | 0:9fca2b23d0ba | 331 | * This call allows the application to get the BLE stack version information. |
marcozecchini | 0:9fca2b23d0ba | 332 | * |
marcozecchini | 0:9fca2b23d0ba | 333 | * @return A pointer to a const string representing the version. |
marcozecchini | 0:9fca2b23d0ba | 334 | * |
marcozecchini | 0:9fca2b23d0ba | 335 | * @note The BLE API owns the string returned. |
marcozecchini | 0:9fca2b23d0ba | 336 | */ |
marcozecchini | 0:9fca2b23d0ba | 337 | const char *getVersion(void); |
marcozecchini | 0:9fca2b23d0ba | 338 | |
marcozecchini | 0:9fca2b23d0ba | 339 | /** |
marcozecchini | 0:9fca2b23d0ba | 340 | * Accessor to Gap. All Gap-related functionality requires going through |
marcozecchini | 0:9fca2b23d0ba | 341 | * this accessor. |
marcozecchini | 0:9fca2b23d0ba | 342 | * |
marcozecchini | 0:9fca2b23d0ba | 343 | * @return A reference to a Gap object associated to this BLE instance. |
marcozecchini | 0:9fca2b23d0ba | 344 | */ |
marcozecchini | 0:9fca2b23d0ba | 345 | Gap &gap(); |
marcozecchini | 0:9fca2b23d0ba | 346 | |
marcozecchini | 0:9fca2b23d0ba | 347 | /** |
marcozecchini | 0:9fca2b23d0ba | 348 | * A const alternative to gap(). |
marcozecchini | 0:9fca2b23d0ba | 349 | * |
marcozecchini | 0:9fca2b23d0ba | 350 | * @return A const reference to a Gap object associated to this BLE instance. |
marcozecchini | 0:9fca2b23d0ba | 351 | */ |
marcozecchini | 0:9fca2b23d0ba | 352 | const Gap &gap() const; |
marcozecchini | 0:9fca2b23d0ba | 353 | |
marcozecchini | 0:9fca2b23d0ba | 354 | /** |
marcozecchini | 0:9fca2b23d0ba | 355 | * Accessor to GattServer. All GattServer related functionality requires |
marcozecchini | 0:9fca2b23d0ba | 356 | * going through this accessor. |
marcozecchini | 0:9fca2b23d0ba | 357 | * |
marcozecchini | 0:9fca2b23d0ba | 358 | * @return A reference to a GattServer object associated to this BLE instance. |
marcozecchini | 0:9fca2b23d0ba | 359 | */ |
marcozecchini | 0:9fca2b23d0ba | 360 | GattServer& gattServer(); |
marcozecchini | 0:9fca2b23d0ba | 361 | |
marcozecchini | 0:9fca2b23d0ba | 362 | /** |
marcozecchini | 0:9fca2b23d0ba | 363 | * A const alternative to gattServer(). |
marcozecchini | 0:9fca2b23d0ba | 364 | * |
marcozecchini | 0:9fca2b23d0ba | 365 | * @return A const reference to a GattServer object associated to this BLE |
marcozecchini | 0:9fca2b23d0ba | 366 | * instance. |
marcozecchini | 0:9fca2b23d0ba | 367 | */ |
marcozecchini | 0:9fca2b23d0ba | 368 | const GattServer& gattServer() const; |
marcozecchini | 0:9fca2b23d0ba | 369 | |
marcozecchini | 0:9fca2b23d0ba | 370 | /** |
marcozecchini | 0:9fca2b23d0ba | 371 | * Accessors to GattClient. All GattClient related functionality requires |
marcozecchini | 0:9fca2b23d0ba | 372 | * going through this accessor. |
marcozecchini | 0:9fca2b23d0ba | 373 | * |
marcozecchini | 0:9fca2b23d0ba | 374 | * @return A reference to a GattClient object associated to this BLE instance. |
marcozecchini | 0:9fca2b23d0ba | 375 | */ |
marcozecchini | 0:9fca2b23d0ba | 376 | GattClient& gattClient(); |
marcozecchini | 0:9fca2b23d0ba | 377 | |
marcozecchini | 0:9fca2b23d0ba | 378 | /** |
marcozecchini | 0:9fca2b23d0ba | 379 | * A const alternative to gattClient(). |
marcozecchini | 0:9fca2b23d0ba | 380 | * |
marcozecchini | 0:9fca2b23d0ba | 381 | * @return A const reference to a GattClient object associated to this BLE |
marcozecchini | 0:9fca2b23d0ba | 382 | * instance. |
marcozecchini | 0:9fca2b23d0ba | 383 | */ |
marcozecchini | 0:9fca2b23d0ba | 384 | const GattClient& gattClient() const; |
marcozecchini | 0:9fca2b23d0ba | 385 | |
marcozecchini | 0:9fca2b23d0ba | 386 | /** |
marcozecchini | 0:9fca2b23d0ba | 387 | * Accessors to SecurityManager. All SecurityManager-related functionality |
marcozecchini | 0:9fca2b23d0ba | 388 | * requires going through this accessor. |
marcozecchini | 0:9fca2b23d0ba | 389 | * |
marcozecchini | 0:9fca2b23d0ba | 390 | * @return A reference to a SecurityManager object associated to this BLE |
marcozecchini | 0:9fca2b23d0ba | 391 | * instance. |
marcozecchini | 0:9fca2b23d0ba | 392 | */ |
marcozecchini | 0:9fca2b23d0ba | 393 | SecurityManager& securityManager(); |
marcozecchini | 0:9fca2b23d0ba | 394 | |
marcozecchini | 0:9fca2b23d0ba | 395 | /** |
marcozecchini | 0:9fca2b23d0ba | 396 | * A const alternative to securityManager(). |
marcozecchini | 0:9fca2b23d0ba | 397 | * |
marcozecchini | 0:9fca2b23d0ba | 398 | * @return A const reference to a SecurityManager object associated to this |
marcozecchini | 0:9fca2b23d0ba | 399 | * BLE instance. |
marcozecchini | 0:9fca2b23d0ba | 400 | */ |
marcozecchini | 0:9fca2b23d0ba | 401 | const SecurityManager& securityManager() const; |
marcozecchini | 0:9fca2b23d0ba | 402 | |
marcozecchini | 0:9fca2b23d0ba | 403 | /* |
marcozecchini | 0:9fca2b23d0ba | 404 | * Deprecation alert! |
marcozecchini | 0:9fca2b23d0ba | 405 | * All of the following are deprecated and may be dropped in a future |
marcozecchini | 0:9fca2b23d0ba | 406 | * release. Documentation should refer to alternative APIs. |
marcozecchini | 0:9fca2b23d0ba | 407 | */ |
marcozecchini | 0:9fca2b23d0ba | 408 | public: |
marcozecchini | 0:9fca2b23d0ba | 409 | /** |
marcozecchini | 0:9fca2b23d0ba | 410 | * Constructor for a handle to a BLE instance (the BLE stack). BLE handles |
marcozecchini | 0:9fca2b23d0ba | 411 | * are thin wrappers around a transport object (that is, ptr. to |
marcozecchini | 0:9fca2b23d0ba | 412 | * BLEInstanceBase). |
marcozecchini | 0:9fca2b23d0ba | 413 | * |
marcozecchini | 0:9fca2b23d0ba | 414 | * It is better to create BLE objects as singletons accessed through the |
marcozecchini | 0:9fca2b23d0ba | 415 | * Instance() method. If multiple BLE handles are constructed for the same |
marcozecchini | 0:9fca2b23d0ba | 416 | * interface (using this constructor), they share the same underlying |
marcozecchini | 0:9fca2b23d0ba | 417 | * transport object. |
marcozecchini | 0:9fca2b23d0ba | 418 | * |
marcozecchini | 0:9fca2b23d0ba | 419 | * @deprecated Use the Instance() function instead of the constructor. |
marcozecchini | 0:9fca2b23d0ba | 420 | */ |
marcozecchini | 0:9fca2b23d0ba | 421 | MBED_DEPRECATED("Use BLE::Instance() instead of BLE constructor.") |
marcozecchini | 0:9fca2b23d0ba | 422 | BLE(InstanceID_t instanceID = DEFAULT_INSTANCE); |
marcozecchini | 0:9fca2b23d0ba | 423 | |
marcozecchini | 0:9fca2b23d0ba | 424 | /** |
marcozecchini | 0:9fca2b23d0ba | 425 | * Yield control to the BLE stack or to other tasks waiting for events. |
marcozecchini | 0:9fca2b23d0ba | 426 | * |
marcozecchini | 0:9fca2b23d0ba | 427 | * This is a sleep function that returns when there is an application-specific |
marcozecchini | 0:9fca2b23d0ba | 428 | * interrupt. This is not interchangeable with WFE() considering that the |
marcozecchini | 0:9fca2b23d0ba | 429 | * MCU might wake up several times to service the stack before returning |
marcozecchini | 0:9fca2b23d0ba | 430 | * control to the caller. |
marcozecchini | 0:9fca2b23d0ba | 431 | * |
marcozecchini | 0:9fca2b23d0ba | 432 | * @deprecated This function block the CPU prefer to use the pair |
marcozecchini | 0:9fca2b23d0ba | 433 | * onEventsToProcess() and processEvents(). |
marcozecchini | 0:9fca2b23d0ba | 434 | */ |
marcozecchini | 0:9fca2b23d0ba | 435 | MBED_DEPRECATED("Use BLE::processEvents() and BLE::onEventsToProcess().") |
marcozecchini | 0:9fca2b23d0ba | 436 | void waitForEvent(void); |
marcozecchini | 0:9fca2b23d0ba | 437 | |
marcozecchini | 0:9fca2b23d0ba | 438 | /** |
marcozecchini | 0:9fca2b23d0ba | 439 | * Set the BTLE MAC address and type. |
marcozecchini | 0:9fca2b23d0ba | 440 | * |
marcozecchini | 0:9fca2b23d0ba | 441 | * @return BLE_ERROR_NONE on success. |
marcozecchini | 0:9fca2b23d0ba | 442 | * |
marcozecchini | 0:9fca2b23d0ba | 443 | * @deprecated You should use the parallel API from Gap directly, refer to |
marcozecchini | 0:9fca2b23d0ba | 444 | * Gap::setAddress(). A former call to ble.setAddress(...) should be |
marcozecchini | 0:9fca2b23d0ba | 445 | * replaced with ble.gap().setAddress(...). |
marcozecchini | 0:9fca2b23d0ba | 446 | */ |
marcozecchini | 0:9fca2b23d0ba | 447 | MBED_DEPRECATED("Use ble.gap().setAddress(...)") |
marcozecchini | 0:9fca2b23d0ba | 448 | ble_error_t setAddress( |
marcozecchini | 0:9fca2b23d0ba | 449 | BLEProtocol::AddressType_t type, |
marcozecchini | 0:9fca2b23d0ba | 450 | const BLEProtocol::AddressBytes_t address |
marcozecchini | 0:9fca2b23d0ba | 451 | ) { |
marcozecchini | 0:9fca2b23d0ba | 452 | return gap().setAddress(type, address); |
marcozecchini | 0:9fca2b23d0ba | 453 | } |
marcozecchini | 0:9fca2b23d0ba | 454 | |
marcozecchini | 0:9fca2b23d0ba | 455 | /** |
marcozecchini | 0:9fca2b23d0ba | 456 | * Fetch the Bluetooth Low Energy MAC address and type. |
marcozecchini | 0:9fca2b23d0ba | 457 | * |
marcozecchini | 0:9fca2b23d0ba | 458 | * @return BLE_ERROR_NONE on success. |
marcozecchini | 0:9fca2b23d0ba | 459 | * |
marcozecchini | 0:9fca2b23d0ba | 460 | * @deprecated You should use the parallel API from Gap directly and refer to |
marcozecchini | 0:9fca2b23d0ba | 461 | * Gap::getAddress(). A former call to ble.getAddress(...) should be |
marcozecchini | 0:9fca2b23d0ba | 462 | * replaced with ble.gap().getAddress(...). |
marcozecchini | 0:9fca2b23d0ba | 463 | */ |
marcozecchini | 0:9fca2b23d0ba | 464 | MBED_DEPRECATED("Use ble.gap().getAddress(...)") |
marcozecchini | 0:9fca2b23d0ba | 465 | ble_error_t getAddress( |
marcozecchini | 0:9fca2b23d0ba | 466 | BLEProtocol::AddressType_t *typeP, BLEProtocol::AddressBytes_t address |
marcozecchini | 0:9fca2b23d0ba | 467 | ) { |
marcozecchini | 0:9fca2b23d0ba | 468 | return gap().getAddress(typeP, address); |
marcozecchini | 0:9fca2b23d0ba | 469 | } |
marcozecchini | 0:9fca2b23d0ba | 470 | |
marcozecchini | 0:9fca2b23d0ba | 471 | /** |
marcozecchini | 0:9fca2b23d0ba | 472 | * Set the GAP advertising mode to use for this device. |
marcozecchini | 0:9fca2b23d0ba | 473 | * |
marcozecchini | 0:9fca2b23d0ba | 474 | * @deprecated You should use the parallel API from Gap directly and refer to |
marcozecchini | 0:9fca2b23d0ba | 475 | * Gap::setAdvertisingType(). A former call to |
marcozecchini | 0:9fca2b23d0ba | 476 | * ble.setAdvertisingType(...) should be replaced with |
marcozecchini | 0:9fca2b23d0ba | 477 | * ble.gap().setAdvertisingType(...). |
marcozecchini | 0:9fca2b23d0ba | 478 | */ |
marcozecchini | 0:9fca2b23d0ba | 479 | MBED_DEPRECATED("Use ble.gap().setAdvertisingType(...)") |
marcozecchini | 0:9fca2b23d0ba | 480 | void setAdvertisingType(GapAdvertisingParams::AdvertisingType advType) { |
marcozecchini | 0:9fca2b23d0ba | 481 | gap().setAdvertisingType(advType); |
marcozecchini | 0:9fca2b23d0ba | 482 | } |
marcozecchini | 0:9fca2b23d0ba | 483 | |
marcozecchini | 0:9fca2b23d0ba | 484 | /** |
marcozecchini | 0:9fca2b23d0ba | 485 | * @param[in] interval |
marcozecchini | 0:9fca2b23d0ba | 486 | * Advertising interval in units of milliseconds. Advertising |
marcozecchini | 0:9fca2b23d0ba | 487 | * is disabled if interval is 0. If interval is smaller than |
marcozecchini | 0:9fca2b23d0ba | 488 | * the minimum supported value, then the minimum supported |
marcozecchini | 0:9fca2b23d0ba | 489 | * value is used instead. This minimum value can be discovered |
marcozecchini | 0:9fca2b23d0ba | 490 | * using getMinAdvertisingInterval(). |
marcozecchini | 0:9fca2b23d0ba | 491 | * |
marcozecchini | 0:9fca2b23d0ba | 492 | * This field must be set to 0 if connectionMode is equal |
marcozecchini | 0:9fca2b23d0ba | 493 | * to ADV_CONNECTABLE_DIRECTED. |
marcozecchini | 0:9fca2b23d0ba | 494 | * |
marcozecchini | 0:9fca2b23d0ba | 495 | * @note Decreasing this value allows central devices to detect a |
marcozecchini | 0:9fca2b23d0ba | 496 | * peripheral faster at the expense of more power being used by the radio |
marcozecchini | 0:9fca2b23d0ba | 497 | * due to the higher data transmit rate. |
marcozecchini | 0:9fca2b23d0ba | 498 | * |
marcozecchini | 0:9fca2b23d0ba | 499 | * @deprecated You should use the parallel API from Gap directly and refer to |
marcozecchini | 0:9fca2b23d0ba | 500 | * Gap::setAdvertisingInterval(). A former call to |
marcozecchini | 0:9fca2b23d0ba | 501 | * ble.setAdvertisingInterval(...) should be replaced with |
marcozecchini | 0:9fca2b23d0ba | 502 | * ble.gap().setAdvertisingInterval(...). |
marcozecchini | 0:9fca2b23d0ba | 503 | * |
marcozecchini | 0:9fca2b23d0ba | 504 | * @note WARNING: This API previously used 0.625ms as the unit for its |
marcozecchini | 0:9fca2b23d0ba | 505 | * 'interval' argument. That required an explicit conversion from |
marcozecchini | 0:9fca2b23d0ba | 506 | * milliseconds using Gap::MSEC_TO_GAP_DURATION_UNITS(). This conversion is |
marcozecchini | 0:9fca2b23d0ba | 507 | * no longer required as the new units are milliseconds. Any application |
marcozecchini | 0:9fca2b23d0ba | 508 | * code depending on the old semantics needs to be updated accordingly. |
marcozecchini | 0:9fca2b23d0ba | 509 | */ |
marcozecchini | 0:9fca2b23d0ba | 510 | MBED_DEPRECATED("Use ble.gap().setAdvertisingInterval(...)") |
marcozecchini | 0:9fca2b23d0ba | 511 | void setAdvertisingInterval(uint16_t interval) { |
marcozecchini | 0:9fca2b23d0ba | 512 | gap().setAdvertisingInterval(interval); |
marcozecchini | 0:9fca2b23d0ba | 513 | } |
marcozecchini | 0:9fca2b23d0ba | 514 | |
marcozecchini | 0:9fca2b23d0ba | 515 | /** |
marcozecchini | 0:9fca2b23d0ba | 516 | * @return Minimum Advertising interval in milliseconds. |
marcozecchini | 0:9fca2b23d0ba | 517 | * |
marcozecchini | 0:9fca2b23d0ba | 518 | * @deprecated You should use the parallel API from Gap directly, refer to |
marcozecchini | 0:9fca2b23d0ba | 519 | * Gap::getMinAdvertisingInterval(). A former call to |
marcozecchini | 0:9fca2b23d0ba | 520 | * ble.getMinAdvertisingInterval(...) should be replaced with |
marcozecchini | 0:9fca2b23d0ba | 521 | * ble.gap().getMinAdvertisingInterval(...). |
marcozecchini | 0:9fca2b23d0ba | 522 | */ |
marcozecchini | 0:9fca2b23d0ba | 523 | MBED_DEPRECATED("Use ble.gap().getMinAdvertisingInterval(...)") |
marcozecchini | 0:9fca2b23d0ba | 524 | uint16_t getMinAdvertisingInterval(void) const { |
marcozecchini | 0:9fca2b23d0ba | 525 | return gap().getMinAdvertisingInterval(); |
marcozecchini | 0:9fca2b23d0ba | 526 | } |
marcozecchini | 0:9fca2b23d0ba | 527 | |
marcozecchini | 0:9fca2b23d0ba | 528 | /** |
marcozecchini | 0:9fca2b23d0ba | 529 | * @return Minimum Advertising interval in milliseconds for nonconnectible mode. |
marcozecchini | 0:9fca2b23d0ba | 530 | * |
marcozecchini | 0:9fca2b23d0ba | 531 | * @deprecated You should use the parallel API from Gap directly, refer to |
marcozecchini | 0:9fca2b23d0ba | 532 | * Gap::MinNonConnectableAdvertisingInterval(). A former call to |
marcozecchini | 0:9fca2b23d0ba | 533 | * ble.getMinNonConnectableAdvertisingInterval(...) should be replaced with |
marcozecchini | 0:9fca2b23d0ba | 534 | * ble.gap().getMinNonConnectableAdvertisingInterval(...). |
marcozecchini | 0:9fca2b23d0ba | 535 | */ |
marcozecchini | 0:9fca2b23d0ba | 536 | MBED_DEPRECATED("Use ble.gap().getMinNonConnectableAdvertisingInterval(...)") |
marcozecchini | 0:9fca2b23d0ba | 537 | uint16_t getMinNonConnectableAdvertisingInterval(void) const { |
marcozecchini | 0:9fca2b23d0ba | 538 | return gap().getMinNonConnectableAdvertisingInterval(); |
marcozecchini | 0:9fca2b23d0ba | 539 | } |
marcozecchini | 0:9fca2b23d0ba | 540 | |
marcozecchini | 0:9fca2b23d0ba | 541 | /** |
marcozecchini | 0:9fca2b23d0ba | 542 | * @return Maximum Advertising interval in milliseconds. |
marcozecchini | 0:9fca2b23d0ba | 543 | * |
marcozecchini | 0:9fca2b23d0ba | 544 | * @deprecated You should use the parallel API from Gap directly, refer to |
marcozecchini | 0:9fca2b23d0ba | 545 | * Gap::getMaxAdvertisingInterval(). A former call to |
marcozecchini | 0:9fca2b23d0ba | 546 | * ble.getMaxAdvertisingInterval(...) should be replaced with |
marcozecchini | 0:9fca2b23d0ba | 547 | * ble.gap().getMaxAdvertisingInterval(...). |
marcozecchini | 0:9fca2b23d0ba | 548 | */ |
marcozecchini | 0:9fca2b23d0ba | 549 | MBED_DEPRECATED("Use ble.gap().getMaxAdvertisingInterval(...)") |
marcozecchini | 0:9fca2b23d0ba | 550 | uint16_t getMaxAdvertisingInterval(void) const { |
marcozecchini | 0:9fca2b23d0ba | 551 | return gap().getMaxAdvertisingInterval(); |
marcozecchini | 0:9fca2b23d0ba | 552 | } |
marcozecchini | 0:9fca2b23d0ba | 553 | |
marcozecchini | 0:9fca2b23d0ba | 554 | /** |
marcozecchini | 0:9fca2b23d0ba | 555 | * @param[in] timeout |
marcozecchini | 0:9fca2b23d0ba | 556 | * Advertising timeout (in seconds) between 0x1 and 0x3FFF (1 |
marcozecchini | 0:9fca2b23d0ba | 557 | * and 16383). Use 0 to disable the advertising timeout. |
marcozecchini | 0:9fca2b23d0ba | 558 | * |
marcozecchini | 0:9fca2b23d0ba | 559 | * @deprecated You should use the parallel API from Gap directly and refer to |
marcozecchini | 0:9fca2b23d0ba | 560 | * Gap::setAdvertisingTimeout(). A former call to |
marcozecchini | 0:9fca2b23d0ba | 561 | * ble.setAdvertisingTimeout(...) should be replaced with |
marcozecchini | 0:9fca2b23d0ba | 562 | * ble.gap().setAdvertisingTimeout(...). |
marcozecchini | 0:9fca2b23d0ba | 563 | */ |
marcozecchini | 0:9fca2b23d0ba | 564 | MBED_DEPRECATED("Use ble.gap().setAdvertisingTimeout(...)") |
marcozecchini | 0:9fca2b23d0ba | 565 | void setAdvertisingTimeout(uint16_t timeout) { |
marcozecchini | 0:9fca2b23d0ba | 566 | gap().setAdvertisingTimeout(timeout); |
marcozecchini | 0:9fca2b23d0ba | 567 | } |
marcozecchini | 0:9fca2b23d0ba | 568 | |
marcozecchini | 0:9fca2b23d0ba | 569 | /** |
marcozecchini | 0:9fca2b23d0ba | 570 | * Set up a particular, user-constructed set of advertisement parameters for |
marcozecchini | 0:9fca2b23d0ba | 571 | * the underlying stack. It would be uncommon for this API to be used |
marcozecchini | 0:9fca2b23d0ba | 572 | * directly; there are other APIs to tweak advertisement parameters |
marcozecchini | 0:9fca2b23d0ba | 573 | * individually (see above). |
marcozecchini | 0:9fca2b23d0ba | 574 | * |
marcozecchini | 0:9fca2b23d0ba | 575 | * @deprecated You should use the parallel API from Gap directly and refer to |
marcozecchini | 0:9fca2b23d0ba | 576 | * Gap::setAdvertisingParams(). A former call to |
marcozecchini | 0:9fca2b23d0ba | 577 | * ble.setAdvertisingParams(...) should be replaced with |
marcozecchini | 0:9fca2b23d0ba | 578 | * ble.gap().setAdvertisingParams(...). |
marcozecchini | 0:9fca2b23d0ba | 579 | */ |
marcozecchini | 0:9fca2b23d0ba | 580 | MBED_DEPRECATED("Use ble.gap().setAdvertisingParams(...)") |
marcozecchini | 0:9fca2b23d0ba | 581 | void setAdvertisingParams(const GapAdvertisingParams &advParams) { |
marcozecchini | 0:9fca2b23d0ba | 582 | gap().setAdvertisingParams(advParams); |
marcozecchini | 0:9fca2b23d0ba | 583 | } |
marcozecchini | 0:9fca2b23d0ba | 584 | |
marcozecchini | 0:9fca2b23d0ba | 585 | /** |
marcozecchini | 0:9fca2b23d0ba | 586 | * @return Read back advertising parameters. Useful for storing and |
marcozecchini | 0:9fca2b23d0ba | 587 | * restoring parameters rapidly. |
marcozecchini | 0:9fca2b23d0ba | 588 | * |
marcozecchini | 0:9fca2b23d0ba | 589 | * @deprecated You should use the parallel API from Gap directly and refer to |
marcozecchini | 0:9fca2b23d0ba | 590 | * Gap::getAdvertisingParams(). A former call to |
marcozecchini | 0:9fca2b23d0ba | 591 | * ble.getAdvertisingParams(...) should be replaced with |
marcozecchini | 0:9fca2b23d0ba | 592 | * ble.gap().getAdvertisingParams(...). |
marcozecchini | 0:9fca2b23d0ba | 593 | */ |
marcozecchini | 0:9fca2b23d0ba | 594 | MBED_DEPRECATED("Use ble.gap().getAdvertisingParams(...)") |
marcozecchini | 0:9fca2b23d0ba | 595 | const GapAdvertisingParams &getAdvertisingParams(void) const { |
marcozecchini | 0:9fca2b23d0ba | 596 | return gap().getAdvertisingParams(); |
marcozecchini | 0:9fca2b23d0ba | 597 | } |
marcozecchini | 0:9fca2b23d0ba | 598 | |
marcozecchini | 0:9fca2b23d0ba | 599 | /** |
marcozecchini | 0:9fca2b23d0ba | 600 | * Accumulate an AD structure in the advertising payload. Please note that |
marcozecchini | 0:9fca2b23d0ba | 601 | * the payload is limited to 31 bytes. The SCAN_RESPONSE message may be used |
marcozecchini | 0:9fca2b23d0ba | 602 | * as an additional 31 bytes if the advertising payload is too |
marcozecchini | 0:9fca2b23d0ba | 603 | * small. |
marcozecchini | 0:9fca2b23d0ba | 604 | * |
marcozecchini | 0:9fca2b23d0ba | 605 | * @param[in] flags |
marcozecchini | 0:9fca2b23d0ba | 606 | * The flags to add. Please refer to |
marcozecchini | 0:9fca2b23d0ba | 607 | * GapAdvertisingData::Flags for valid flags. Multiple |
marcozecchini | 0:9fca2b23d0ba | 608 | * flags may be specified in combination. |
marcozecchini | 0:9fca2b23d0ba | 609 | * |
marcozecchini | 0:9fca2b23d0ba | 610 | * @deprecated You should use the parallel API from Gap directly, refer to |
marcozecchini | 0:9fca2b23d0ba | 611 | * Gap::accumulateAdvertisingPayload(uint8_t). A former call to |
marcozecchini | 0:9fca2b23d0ba | 612 | * ble.accumulateAdvertisingPayload(flags) should be replaced with |
marcozecchini | 0:9fca2b23d0ba | 613 | * ble.gap().accumulateAdvertisingPayload(flags). |
marcozecchini | 0:9fca2b23d0ba | 614 | */ |
marcozecchini | 0:9fca2b23d0ba | 615 | MBED_DEPRECATED("Use ble.gap().accumulateAdvertisingPayload(flags)") |
marcozecchini | 0:9fca2b23d0ba | 616 | ble_error_t accumulateAdvertisingPayload(uint8_t flags) { |
marcozecchini | 0:9fca2b23d0ba | 617 | return gap().accumulateAdvertisingPayload(flags); |
marcozecchini | 0:9fca2b23d0ba | 618 | } |
marcozecchini | 0:9fca2b23d0ba | 619 | |
marcozecchini | 0:9fca2b23d0ba | 620 | /** |
marcozecchini | 0:9fca2b23d0ba | 621 | * Accumulate an AD structure in the advertising payload. Please note that |
marcozecchini | 0:9fca2b23d0ba | 622 | * the payload is limited to 31 bytes. The SCAN_RESPONSE message may be used |
marcozecchini | 0:9fca2b23d0ba | 623 | * as an additional 31 bytes if the advertising payload is too |
marcozecchini | 0:9fca2b23d0ba | 624 | * small. |
marcozecchini | 0:9fca2b23d0ba | 625 | * |
marcozecchini | 0:9fca2b23d0ba | 626 | * @param[in] app |
marcozecchini | 0:9fca2b23d0ba | 627 | * The appearance of the peripheral. |
marcozecchini | 0:9fca2b23d0ba | 628 | * |
marcozecchini | 0:9fca2b23d0ba | 629 | * @deprecated You should use the parallel API from Gap directly and refer to |
marcozecchini | 0:9fca2b23d0ba | 630 | * Gap::accumulateAdvertisingPayload(GapAdvertisingData::Appearance). |
marcozecchini | 0:9fca2b23d0ba | 631 | * A former call to ble.accumulateAdvertisingPayload(appearance) |
marcozecchini | 0:9fca2b23d0ba | 632 | * should be replaced with |
marcozecchini | 0:9fca2b23d0ba | 633 | * ble.gap().accumulateAdvertisingPayload(appearance). |
marcozecchini | 0:9fca2b23d0ba | 634 | */ |
marcozecchini | 0:9fca2b23d0ba | 635 | MBED_DEPRECATED("Use ble.gap().accumulateAdvertisingPayload(appearance)") |
marcozecchini | 0:9fca2b23d0ba | 636 | ble_error_t accumulateAdvertisingPayload(GapAdvertisingData::Appearance app) { |
marcozecchini | 0:9fca2b23d0ba | 637 | return gap().accumulateAdvertisingPayload(app); |
marcozecchini | 0:9fca2b23d0ba | 638 | } |
marcozecchini | 0:9fca2b23d0ba | 639 | |
marcozecchini | 0:9fca2b23d0ba | 640 | /** |
marcozecchini | 0:9fca2b23d0ba | 641 | * Accumulate an AD structure in the advertising payload. Please note that |
marcozecchini | 0:9fca2b23d0ba | 642 | * the payload is limited to 31 bytes. The SCAN_RESPONSE message may be used |
marcozecchini | 0:9fca2b23d0ba | 643 | * as an additional 31 bytes if the advertising payload is too |
marcozecchini | 0:9fca2b23d0ba | 644 | * small. |
marcozecchini | 0:9fca2b23d0ba | 645 | * |
marcozecchini | 0:9fca2b23d0ba | 646 | * @param[in] power |
marcozecchini | 0:9fca2b23d0ba | 647 | * The max transmit power to be used by the controller. This |
marcozecchini | 0:9fca2b23d0ba | 648 | * is only a hint. |
marcozecchini | 0:9fca2b23d0ba | 649 | * |
marcozecchini | 0:9fca2b23d0ba | 650 | * @deprecated You should use the parallel API from Gap directly and refer to |
marcozecchini | 0:9fca2b23d0ba | 651 | * Gap::accumulateAdvertisingPayloadTxPower(). A former call to |
marcozecchini | 0:9fca2b23d0ba | 652 | * ble.accumulateAdvertisingPayloadTxPower(txPower) should be replaced with |
marcozecchini | 0:9fca2b23d0ba | 653 | * ble.gap().accumulateAdvertisingPayloadTxPower(txPower). |
marcozecchini | 0:9fca2b23d0ba | 654 | */ |
marcozecchini | 0:9fca2b23d0ba | 655 | MBED_DEPRECATED("Use ble.gap().accumulateAdvertisingPayloadTxPower(...)") |
marcozecchini | 0:9fca2b23d0ba | 656 | ble_error_t accumulateAdvertisingPayloadTxPower(int8_t power) { |
marcozecchini | 0:9fca2b23d0ba | 657 | return gap().accumulateAdvertisingPayloadTxPower(power); |
marcozecchini | 0:9fca2b23d0ba | 658 | } |
marcozecchini | 0:9fca2b23d0ba | 659 | |
marcozecchini | 0:9fca2b23d0ba | 660 | /** |
marcozecchini | 0:9fca2b23d0ba | 661 | * Accumulate a variable length byte-stream as an AD structure in the |
marcozecchini | 0:9fca2b23d0ba | 662 | * advertising payload. Please note that the payload is limited to 31 bytes. |
marcozecchini | 0:9fca2b23d0ba | 663 | * The SCAN_RESPONSE message may be used as an additional 31 bytes if the |
marcozecchini | 0:9fca2b23d0ba | 664 | * advertising payload is too small. |
marcozecchini | 0:9fca2b23d0ba | 665 | * |
marcozecchini | 0:9fca2b23d0ba | 666 | * @param type The type that describes the variable length data. |
marcozecchini | 0:9fca2b23d0ba | 667 | * @param data Data bytes. |
marcozecchini | 0:9fca2b23d0ba | 668 | * @param len Data length. |
marcozecchini | 0:9fca2b23d0ba | 669 | * |
marcozecchini | 0:9fca2b23d0ba | 670 | * @deprecated You should use the parallel API from Gap directly, refer to |
marcozecchini | 0:9fca2b23d0ba | 671 | * Gap::accumulateAdvertisingPayload(GapAdvertisingData::DataType, const uint8_t, uint8_t). |
marcozecchini | 0:9fca2b23d0ba | 672 | * A former call to ble.accumulateAdvertisingPayload(...) should |
marcozecchini | 0:9fca2b23d0ba | 673 | * be replaced with ble.gap().accumulateAdvertisingPayload(...). |
marcozecchini | 0:9fca2b23d0ba | 674 | */ |
marcozecchini | 0:9fca2b23d0ba | 675 | MBED_DEPRECATED("Use ble.gap().accumulateAdvertisingPayload(...)") |
marcozecchini | 0:9fca2b23d0ba | 676 | ble_error_t accumulateAdvertisingPayload(GapAdvertisingData::DataType type, const uint8_t *data, uint8_t len) { |
marcozecchini | 0:9fca2b23d0ba | 677 | return gap().accumulateAdvertisingPayload(type, data, len); |
marcozecchini | 0:9fca2b23d0ba | 678 | } |
marcozecchini | 0:9fca2b23d0ba | 679 | |
marcozecchini | 0:9fca2b23d0ba | 680 | /** |
marcozecchini | 0:9fca2b23d0ba | 681 | * Set up a particular, user-constructed advertisement payload for the |
marcozecchini | 0:9fca2b23d0ba | 682 | * underlying stack. It would be uncommon for this API to be used directly; |
marcozecchini | 0:9fca2b23d0ba | 683 | * there are other APIs to build an advertisement payload (see above). |
marcozecchini | 0:9fca2b23d0ba | 684 | * |
marcozecchini | 0:9fca2b23d0ba | 685 | * @deprecated You should use the parallel API from Gap directly, refer to |
marcozecchini | 0:9fca2b23d0ba | 686 | * Gap::setAdvertisingData(). A former call to |
marcozecchini | 0:9fca2b23d0ba | 687 | * ble.setAdvertisingData(...) should be replaced with |
marcozecchini | 0:9fca2b23d0ba | 688 | * ble.gap().setAdvertisingPayload(...). |
marcozecchini | 0:9fca2b23d0ba | 689 | */ |
marcozecchini | 0:9fca2b23d0ba | 690 | MBED_DEPRECATED("Use ble.gap().setAdvertisingData(...)") |
marcozecchini | 0:9fca2b23d0ba | 691 | ble_error_t setAdvertisingData(const GapAdvertisingData &advData) { |
marcozecchini | 0:9fca2b23d0ba | 692 | return gap().setAdvertisingPayload(advData); |
marcozecchini | 0:9fca2b23d0ba | 693 | } |
marcozecchini | 0:9fca2b23d0ba | 694 | |
marcozecchini | 0:9fca2b23d0ba | 695 | /** |
marcozecchini | 0:9fca2b23d0ba | 696 | * @return Read back advertising data. Useful for storing and |
marcozecchini | 0:9fca2b23d0ba | 697 | * restoring payload. |
marcozecchini | 0:9fca2b23d0ba | 698 | * |
marcozecchini | 0:9fca2b23d0ba | 699 | * @deprecated You should use the parallel API from Gap directly, refer to |
marcozecchini | 0:9fca2b23d0ba | 700 | * Gap::getAdvertisingData(). A former call to |
marcozecchini | 0:9fca2b23d0ba | 701 | * ble.getAdvertisingData(...) should be replaced with |
marcozecchini | 0:9fca2b23d0ba | 702 | * ble.gap().getAdvertisingPayload()(...). |
marcozecchini | 0:9fca2b23d0ba | 703 | */ |
marcozecchini | 0:9fca2b23d0ba | 704 | MBED_DEPRECATED("Use ble.gap().getAdvertisingData(...)") |
marcozecchini | 0:9fca2b23d0ba | 705 | const GapAdvertisingData &getAdvertisingData(void) const { |
marcozecchini | 0:9fca2b23d0ba | 706 | return gap().getAdvertisingPayload(); |
marcozecchini | 0:9fca2b23d0ba | 707 | } |
marcozecchini | 0:9fca2b23d0ba | 708 | |
marcozecchini | 0:9fca2b23d0ba | 709 | /** |
marcozecchini | 0:9fca2b23d0ba | 710 | * Reset any advertising payload prepared from prior calls to |
marcozecchini | 0:9fca2b23d0ba | 711 | * accumulateAdvertisingPayload(). This automatically propagates the re- |
marcozecchini | 0:9fca2b23d0ba | 712 | * initialized advertising payload to the underlying stack. |
marcozecchini | 0:9fca2b23d0ba | 713 | * |
marcozecchini | 0:9fca2b23d0ba | 714 | * @deprecated You should use the parallel API from Gap directly and refer to |
marcozecchini | 0:9fca2b23d0ba | 715 | * Gap::clearAdvertisingPayload(). A former call to |
marcozecchini | 0:9fca2b23d0ba | 716 | * ble.clearAdvertisingPayload(...) should be replaced with |
marcozecchini | 0:9fca2b23d0ba | 717 | * ble.gap().clearAdvertisingPayload(...). |
marcozecchini | 0:9fca2b23d0ba | 718 | */ |
marcozecchini | 0:9fca2b23d0ba | 719 | MBED_DEPRECATED("Use ble.gap().clearAdvertisingPayload(...)") |
marcozecchini | 0:9fca2b23d0ba | 720 | void clearAdvertisingPayload(void) { |
marcozecchini | 0:9fca2b23d0ba | 721 | gap().clearAdvertisingPayload(); |
marcozecchini | 0:9fca2b23d0ba | 722 | } |
marcozecchini | 0:9fca2b23d0ba | 723 | |
marcozecchini | 0:9fca2b23d0ba | 724 | /** |
marcozecchini | 0:9fca2b23d0ba | 725 | * Dynamically reset the accumulated advertising |
marcozecchini | 0:9fca2b23d0ba | 726 | * payload and scanResponse. The application must clear and re- |
marcozecchini | 0:9fca2b23d0ba | 727 | * accumulate a new advertising payload (and scanResponse) before using this |
marcozecchini | 0:9fca2b23d0ba | 728 | * API. |
marcozecchini | 0:9fca2b23d0ba | 729 | * |
marcozecchini | 0:9fca2b23d0ba | 730 | * @return BLE_ERROR_NONE when the advertising payload is set successfully. |
marcozecchini | 0:9fca2b23d0ba | 731 | * |
marcozecchini | 0:9fca2b23d0ba | 732 | * @deprecated You should use the parallel API from Gap directly, refer to |
marcozecchini | 0:9fca2b23d0ba | 733 | * Gap::setAdvertisingPayload(). |
marcozecchini | 0:9fca2b23d0ba | 734 | * |
marcozecchini | 0:9fca2b23d0ba | 735 | * @note The new APIs in Gap update the underlying advertisement payload |
marcozecchini | 0:9fca2b23d0ba | 736 | * implicitly. |
marcozecchini | 0:9fca2b23d0ba | 737 | */ |
marcozecchini | 0:9fca2b23d0ba | 738 | MBED_DEPRECATED("Use ble.gap().setAdvertisingPayload(...)") |
marcozecchini | 0:9fca2b23d0ba | 739 | ble_error_t setAdvertisingPayload(void) { |
marcozecchini | 0:9fca2b23d0ba | 740 | return BLE_ERROR_NONE; |
marcozecchini | 0:9fca2b23d0ba | 741 | } |
marcozecchini | 0:9fca2b23d0ba | 742 | |
marcozecchini | 0:9fca2b23d0ba | 743 | /** |
marcozecchini | 0:9fca2b23d0ba | 744 | * Accumulate a variable length byte-stream as an AD structure in the |
marcozecchini | 0:9fca2b23d0ba | 745 | * scanResponse payload. |
marcozecchini | 0:9fca2b23d0ba | 746 | * |
marcozecchini | 0:9fca2b23d0ba | 747 | * @param[in] type The type that describes the variable length data. |
marcozecchini | 0:9fca2b23d0ba | 748 | * @param[in] data Data bytes. |
marcozecchini | 0:9fca2b23d0ba | 749 | * @param[in] len Data length. |
marcozecchini | 0:9fca2b23d0ba | 750 | * |
marcozecchini | 0:9fca2b23d0ba | 751 | * @deprecated You should use the parallel API from Gap directly and refer to |
marcozecchini | 0:9fca2b23d0ba | 752 | * Gap::accumulateScanResponse(). A former call to |
marcozecchini | 0:9fca2b23d0ba | 753 | * ble.accumulateScanResponse(...) should be replaced with |
marcozecchini | 0:9fca2b23d0ba | 754 | * ble.gap().accumulateScanResponse(...). |
marcozecchini | 0:9fca2b23d0ba | 755 | */ |
marcozecchini | 0:9fca2b23d0ba | 756 | MBED_DEPRECATED("Use ble.gap().accumulateScanResponse(...)") |
marcozecchini | 0:9fca2b23d0ba | 757 | ble_error_t accumulateScanResponse(GapAdvertisingData::DataType type, const uint8_t *data, uint8_t len) { |
marcozecchini | 0:9fca2b23d0ba | 758 | return gap().accumulateScanResponse(type, data, len); |
marcozecchini | 0:9fca2b23d0ba | 759 | } |
marcozecchini | 0:9fca2b23d0ba | 760 | |
marcozecchini | 0:9fca2b23d0ba | 761 | /** |
marcozecchini | 0:9fca2b23d0ba | 762 | * Reset any scan response prepared from prior calls to |
marcozecchini | 0:9fca2b23d0ba | 763 | * accumulateScanResponse(). |
marcozecchini | 0:9fca2b23d0ba | 764 | * |
marcozecchini | 0:9fca2b23d0ba | 765 | * @deprecated You should use the parallel API from Gap directly and refer to |
marcozecchini | 0:9fca2b23d0ba | 766 | * Gap::clearScanResponse(). A former call to |
marcozecchini | 0:9fca2b23d0ba | 767 | * ble.clearScanResponse(...) should be replaced with |
marcozecchini | 0:9fca2b23d0ba | 768 | * ble.gap().clearScanResponse(...). |
marcozecchini | 0:9fca2b23d0ba | 769 | */ |
marcozecchini | 0:9fca2b23d0ba | 770 | MBED_DEPRECATED("Use ble.gap().clearScanResponse(...)") |
marcozecchini | 0:9fca2b23d0ba | 771 | void clearScanResponse(void) { |
marcozecchini | 0:9fca2b23d0ba | 772 | gap().clearScanResponse(); |
marcozecchini | 0:9fca2b23d0ba | 773 | } |
marcozecchini | 0:9fca2b23d0ba | 774 | |
marcozecchini | 0:9fca2b23d0ba | 775 | /** |
marcozecchini | 0:9fca2b23d0ba | 776 | * Start advertising. |
marcozecchini | 0:9fca2b23d0ba | 777 | * |
marcozecchini | 0:9fca2b23d0ba | 778 | * @deprecated You should use the parallel API from Gap directly and refer to |
marcozecchini | 0:9fca2b23d0ba | 779 | * Gap::startAdvertising(). A former call to |
marcozecchini | 0:9fca2b23d0ba | 780 | * ble.startAdvertising(...) should be replaced with |
marcozecchini | 0:9fca2b23d0ba | 781 | * ble.gap().startAdvertising(...). |
marcozecchini | 0:9fca2b23d0ba | 782 | */ |
marcozecchini | 0:9fca2b23d0ba | 783 | MBED_DEPRECATED("Use ble.gap().startAdvertising(...)") |
marcozecchini | 0:9fca2b23d0ba | 784 | ble_error_t startAdvertising(void) { |
marcozecchini | 0:9fca2b23d0ba | 785 | return gap().startAdvertising(); |
marcozecchini | 0:9fca2b23d0ba | 786 | } |
marcozecchini | 0:9fca2b23d0ba | 787 | |
marcozecchini | 0:9fca2b23d0ba | 788 | /** |
marcozecchini | 0:9fca2b23d0ba | 789 | * Stop advertising. |
marcozecchini | 0:9fca2b23d0ba | 790 | * |
marcozecchini | 0:9fca2b23d0ba | 791 | * @deprecated You should use the parallel API from Gap directly and refer to |
marcozecchini | 0:9fca2b23d0ba | 792 | * Gap::stopAdvertising(). A former call to |
marcozecchini | 0:9fca2b23d0ba | 793 | * ble.stopAdvertising(...) should be replaced with |
marcozecchini | 0:9fca2b23d0ba | 794 | * ble.gap().stopAdvertising(...). |
marcozecchini | 0:9fca2b23d0ba | 795 | */ |
marcozecchini | 0:9fca2b23d0ba | 796 | MBED_DEPRECATED("Use ble.gap().stopAdvertising(...)") |
marcozecchini | 0:9fca2b23d0ba | 797 | ble_error_t stopAdvertising(void) { |
marcozecchini | 0:9fca2b23d0ba | 798 | return gap().stopAdvertising(); |
marcozecchini | 0:9fca2b23d0ba | 799 | } |
marcozecchini | 0:9fca2b23d0ba | 800 | |
marcozecchini | 0:9fca2b23d0ba | 801 | /** |
marcozecchini | 0:9fca2b23d0ba | 802 | * Set up parameters for GAP scanning (observer mode). |
marcozecchini | 0:9fca2b23d0ba | 803 | * @param[in] interval |
marcozecchini | 0:9fca2b23d0ba | 804 | * Scan interval (in milliseconds) [valid values lie between 2.5ms and 10.24s]. |
marcozecchini | 0:9fca2b23d0ba | 805 | * @param[in] window |
marcozecchini | 0:9fca2b23d0ba | 806 | * Scan Window (in milliseconds) [valid values lie between 2.5ms and 10.24s]. |
marcozecchini | 0:9fca2b23d0ba | 807 | * @param[in] timeout |
marcozecchini | 0:9fca2b23d0ba | 808 | * Scan timeout (in seconds) between 0x0001 and 0xFFFF; 0x0000 disables timeout. |
marcozecchini | 0:9fca2b23d0ba | 809 | * @param[in] activeScanning |
marcozecchini | 0:9fca2b23d0ba | 810 | * Set to True if active-scanning is required. This is used to fetch the |
marcozecchini | 0:9fca2b23d0ba | 811 | * scan response from a peer if possible. |
marcozecchini | 0:9fca2b23d0ba | 812 | * |
marcozecchini | 0:9fca2b23d0ba | 813 | * The scanning window divided by the interval determines the duty cycle for |
marcozecchini | 0:9fca2b23d0ba | 814 | * scanning. For example, if the interval is 100ms and the window is 10ms, |
marcozecchini | 0:9fca2b23d0ba | 815 | * then the controller will scan for 10 percent of the time. It is possible |
marcozecchini | 0:9fca2b23d0ba | 816 | * to have the interval and window set to the same value. In this case, |
marcozecchini | 0:9fca2b23d0ba | 817 | * scanning is continuous, with a change of scanning frequency once every |
marcozecchini | 0:9fca2b23d0ba | 818 | * interval. |
marcozecchini | 0:9fca2b23d0ba | 819 | * |
marcozecchini | 0:9fca2b23d0ba | 820 | * Once the scanning parameters have been configured, scanning can be |
marcozecchini | 0:9fca2b23d0ba | 821 | * enabled by using startScan(). |
marcozecchini | 0:9fca2b23d0ba | 822 | * |
marcozecchini | 0:9fca2b23d0ba | 823 | * @note The scan interval and window are recommendations to the BLE stack. |
marcozecchini | 0:9fca2b23d0ba | 824 | * |
marcozecchini | 0:9fca2b23d0ba | 825 | * @deprecated You should use the parallel API from Gap directly and refer to |
marcozecchini | 0:9fca2b23d0ba | 826 | * Gap::setScanParams(). A former call to |
marcozecchini | 0:9fca2b23d0ba | 827 | * ble.setScanParams(...) should be replaced with |
marcozecchini | 0:9fca2b23d0ba | 828 | * ble.gap().setScanParams(...). |
marcozecchini | 0:9fca2b23d0ba | 829 | */ |
marcozecchini | 0:9fca2b23d0ba | 830 | MBED_DEPRECATED("Use ble.gap().setScanParams(...)") |
marcozecchini | 0:9fca2b23d0ba | 831 | ble_error_t setScanParams(uint16_t interval = GapScanningParams::SCAN_INTERVAL_MAX, |
marcozecchini | 0:9fca2b23d0ba | 832 | uint16_t window = GapScanningParams::SCAN_WINDOW_MAX, |
marcozecchini | 0:9fca2b23d0ba | 833 | uint16_t timeout = 0, |
marcozecchini | 0:9fca2b23d0ba | 834 | bool activeScanning = false) { |
marcozecchini | 0:9fca2b23d0ba | 835 | return gap().setScanParams(interval, window, timeout, activeScanning); |
marcozecchini | 0:9fca2b23d0ba | 836 | } |
marcozecchini | 0:9fca2b23d0ba | 837 | |
marcozecchini | 0:9fca2b23d0ba | 838 | /** |
marcozecchini | 0:9fca2b23d0ba | 839 | * Set up the scanInterval parameter for GAP scanning (observer mode). |
marcozecchini | 0:9fca2b23d0ba | 840 | * @param[in] interval |
marcozecchini | 0:9fca2b23d0ba | 841 | * Scan interval (in milliseconds) [valid values lie between 2.5ms and 10.24s]. |
marcozecchini | 0:9fca2b23d0ba | 842 | * |
marcozecchini | 0:9fca2b23d0ba | 843 | * The scanning window divided by the interval determines the duty cycle for |
marcozecchini | 0:9fca2b23d0ba | 844 | * scanning. For example, if the interval is 100ms and the window is 10ms, |
marcozecchini | 0:9fca2b23d0ba | 845 | * then the controller will scan for 10 percent of the time. It is possible |
marcozecchini | 0:9fca2b23d0ba | 846 | * to have the interval and window set to the same value. In this case, |
marcozecchini | 0:9fca2b23d0ba | 847 | * scanning is continuous, with a change of scanning frequency once every |
marcozecchini | 0:9fca2b23d0ba | 848 | * interval. |
marcozecchini | 0:9fca2b23d0ba | 849 | * |
marcozecchini | 0:9fca2b23d0ba | 850 | * Once the scanning parameters have been configured, scanning can be |
marcozecchini | 0:9fca2b23d0ba | 851 | * enabled by using startScan(). |
marcozecchini | 0:9fca2b23d0ba | 852 | * |
marcozecchini | 0:9fca2b23d0ba | 853 | * @deprecated You should use the parallel API from Gap directly and refer to |
marcozecchini | 0:9fca2b23d0ba | 854 | * Gap::setScanInterval(). A former call to |
marcozecchini | 0:9fca2b23d0ba | 855 | * ble.setScanInterval(interval) should be replaced with |
marcozecchini | 0:9fca2b23d0ba | 856 | * ble.gap().setScanInterval(interval). |
marcozecchini | 0:9fca2b23d0ba | 857 | */ |
marcozecchini | 0:9fca2b23d0ba | 858 | MBED_DEPRECATED("Use ble.gap().setScanInterval(...)") |
marcozecchini | 0:9fca2b23d0ba | 859 | ble_error_t setScanInterval(uint16_t interval) { |
marcozecchini | 0:9fca2b23d0ba | 860 | return gap().setScanInterval(interval); |
marcozecchini | 0:9fca2b23d0ba | 861 | } |
marcozecchini | 0:9fca2b23d0ba | 862 | |
marcozecchini | 0:9fca2b23d0ba | 863 | /** |
marcozecchini | 0:9fca2b23d0ba | 864 | * Set up the scanWindow parameter for GAP scanning (observer mode). |
marcozecchini | 0:9fca2b23d0ba | 865 | * @param[in] window |
marcozecchini | 0:9fca2b23d0ba | 866 | * Scan Window (in milliseconds) [valid values lie between 2.5ms and 10.24s]. |
marcozecchini | 0:9fca2b23d0ba | 867 | * |
marcozecchini | 0:9fca2b23d0ba | 868 | * The scanning window divided by the interval determines the duty cycle for |
marcozecchini | 0:9fca2b23d0ba | 869 | * scanning. For example, if the interval is 100ms and the window is 10ms, |
marcozecchini | 0:9fca2b23d0ba | 870 | * then the controller will scan for 10 percent of the time. It is possible |
marcozecchini | 0:9fca2b23d0ba | 871 | * to have the interval and window set to the same value. In this case, |
marcozecchini | 0:9fca2b23d0ba | 872 | * scanning is continuous, with a change of scanning frequency once every |
marcozecchini | 0:9fca2b23d0ba | 873 | * interval. |
marcozecchini | 0:9fca2b23d0ba | 874 | * |
marcozecchini | 0:9fca2b23d0ba | 875 | * Once the scanning parameters have been configured, scanning can be |
marcozecchini | 0:9fca2b23d0ba | 876 | * enabled by using startScan(). |
marcozecchini | 0:9fca2b23d0ba | 877 | * |
marcozecchini | 0:9fca2b23d0ba | 878 | * @deprecated You should use the parallel API from Gap directly and refer to |
marcozecchini | 0:9fca2b23d0ba | 879 | * Gap::setScanWindow(). A former call to |
marcozecchini | 0:9fca2b23d0ba | 880 | * ble.setScanWindow(window) should be replaced with |
marcozecchini | 0:9fca2b23d0ba | 881 | * ble.gap().setScanWindow(window). |
marcozecchini | 0:9fca2b23d0ba | 882 | */ |
marcozecchini | 0:9fca2b23d0ba | 883 | MBED_DEPRECATED("Use ble.gap().setScanWindow(...)") |
marcozecchini | 0:9fca2b23d0ba | 884 | ble_error_t setScanWindow(uint16_t window) { |
marcozecchini | 0:9fca2b23d0ba | 885 | return gap().setScanWindow(window); |
marcozecchini | 0:9fca2b23d0ba | 886 | } |
marcozecchini | 0:9fca2b23d0ba | 887 | |
marcozecchini | 0:9fca2b23d0ba | 888 | /** |
marcozecchini | 0:9fca2b23d0ba | 889 | * Set up parameters for GAP scanning (observer mode). |
marcozecchini | 0:9fca2b23d0ba | 890 | * @param[in] timeout |
marcozecchini | 0:9fca2b23d0ba | 891 | * Scan timeout (in seconds) between 0x0001 and 0xFFFF; 0x0000 disables timeout. |
marcozecchini | 0:9fca2b23d0ba | 892 | * |
marcozecchini | 0:9fca2b23d0ba | 893 | * The scanning window divided by the interval determines the duty cycle for |
marcozecchini | 0:9fca2b23d0ba | 894 | * scanning. For example, if the interval is 100ms and the window is 10ms, |
marcozecchini | 0:9fca2b23d0ba | 895 | * then the controller will scan for 10 percent of the time. It is possible |
marcozecchini | 0:9fca2b23d0ba | 896 | * to have the interval and window set to the same value. In this case, |
marcozecchini | 0:9fca2b23d0ba | 897 | * scanning is continuous, with a change of scanning frequency once every |
marcozecchini | 0:9fca2b23d0ba | 898 | * interval. |
marcozecchini | 0:9fca2b23d0ba | 899 | * |
marcozecchini | 0:9fca2b23d0ba | 900 | * Once the scanning parameters have been configured, scanning can be |
marcozecchini | 0:9fca2b23d0ba | 901 | * enabled by using startScan(). |
marcozecchini | 0:9fca2b23d0ba | 902 | * |
marcozecchini | 0:9fca2b23d0ba | 903 | * @note The scan interval and window are recommendations to the BLE stack. |
marcozecchini | 0:9fca2b23d0ba | 904 | * |
marcozecchini | 0:9fca2b23d0ba | 905 | * @deprecated You should use the parallel API from Gap directly and refer to |
marcozecchini | 0:9fca2b23d0ba | 906 | * Gap::setScanTimeout(). A former call to |
marcozecchini | 0:9fca2b23d0ba | 907 | * ble.setScanTimeout(...) should be replaced with |
marcozecchini | 0:9fca2b23d0ba | 908 | * ble.gap().setScanTimeout(...). |
marcozecchini | 0:9fca2b23d0ba | 909 | */ |
marcozecchini | 0:9fca2b23d0ba | 910 | MBED_DEPRECATED("Use ble.gap().setScanTimeout(...)") |
marcozecchini | 0:9fca2b23d0ba | 911 | ble_error_t setScanTimeout(uint16_t timeout) { |
marcozecchini | 0:9fca2b23d0ba | 912 | return gap().setScanTimeout(timeout); |
marcozecchini | 0:9fca2b23d0ba | 913 | } |
marcozecchini | 0:9fca2b23d0ba | 914 | |
marcozecchini | 0:9fca2b23d0ba | 915 | /** |
marcozecchini | 0:9fca2b23d0ba | 916 | * Set up parameters for GAP scanning (observer mode). |
marcozecchini | 0:9fca2b23d0ba | 917 | * @param[in] activeScanning |
marcozecchini | 0:9fca2b23d0ba | 918 | * Set to True if active-scanning is required. This is used to fetch the |
marcozecchini | 0:9fca2b23d0ba | 919 | * scan response from a peer if possible. |
marcozecchini | 0:9fca2b23d0ba | 920 | * |
marcozecchini | 0:9fca2b23d0ba | 921 | * Once the scanning parameters have been configured, scanning can be |
marcozecchini | 0:9fca2b23d0ba | 922 | * enabled by using startScan(). |
marcozecchini | 0:9fca2b23d0ba | 923 | * |
marcozecchini | 0:9fca2b23d0ba | 924 | * @deprecated You should use the parallel API from Gap directly, refer to |
marcozecchini | 0:9fca2b23d0ba | 925 | * Gap::setActiveScan(). A former call to |
marcozecchini | 0:9fca2b23d0ba | 926 | * ble.setActiveScan(...) should be replaced with |
marcozecchini | 0:9fca2b23d0ba | 927 | * ble.gap().setActiveScanning(...). |
marcozecchini | 0:9fca2b23d0ba | 928 | */ |
marcozecchini | 0:9fca2b23d0ba | 929 | MBED_DEPRECATED("Use ble.gap().setActiveScan(...)") |
marcozecchini | 0:9fca2b23d0ba | 930 | void setActiveScan(bool activeScanning) { |
marcozecchini | 0:9fca2b23d0ba | 931 | gap().setActiveScanning(activeScanning); |
marcozecchini | 0:9fca2b23d0ba | 932 | } |
marcozecchini | 0:9fca2b23d0ba | 933 | |
marcozecchini | 0:9fca2b23d0ba | 934 | /** |
marcozecchini | 0:9fca2b23d0ba | 935 | * Start scanning (Observer Procedure) based on the parameters currently in |
marcozecchini | 0:9fca2b23d0ba | 936 | * effect. |
marcozecchini | 0:9fca2b23d0ba | 937 | * |
marcozecchini | 0:9fca2b23d0ba | 938 | * @param[in] callback |
marcozecchini | 0:9fca2b23d0ba | 939 | * The application-specific callback to be invoked upon |
marcozecchini | 0:9fca2b23d0ba | 940 | * receiving every advertisement report. This can be passed in |
marcozecchini | 0:9fca2b23d0ba | 941 | * as NULL, in which case scanning may not be enabled at all. |
marcozecchini | 0:9fca2b23d0ba | 942 | * |
marcozecchini | 0:9fca2b23d0ba | 943 | * @deprecated You should use the parallel API from Gap directly, refer to |
marcozecchini | 0:9fca2b23d0ba | 944 | * Gap::startScan(). A former call to |
marcozecchini | 0:9fca2b23d0ba | 945 | * ble.startScan(callback) should be replaced with |
marcozecchini | 0:9fca2b23d0ba | 946 | * ble.gap().startScan(callback). |
marcozecchini | 0:9fca2b23d0ba | 947 | */ |
marcozecchini | 0:9fca2b23d0ba | 948 | MBED_DEPRECATED("Use ble.gap().startScan(callback)") |
marcozecchini | 0:9fca2b23d0ba | 949 | ble_error_t startScan(void (*callback)(const Gap::AdvertisementCallbackParams_t *params)) { |
marcozecchini | 0:9fca2b23d0ba | 950 | return gap().startScan(callback); |
marcozecchini | 0:9fca2b23d0ba | 951 | } |
marcozecchini | 0:9fca2b23d0ba | 952 | |
marcozecchini | 0:9fca2b23d0ba | 953 | /** |
marcozecchini | 0:9fca2b23d0ba | 954 | * Same as above, but this takes an (object, method) pair for a callback. |
marcozecchini | 0:9fca2b23d0ba | 955 | * |
marcozecchini | 0:9fca2b23d0ba | 956 | * @deprecated You should use the parallel API from Gap directly, refer to |
marcozecchini | 0:9fca2b23d0ba | 957 | * Gap::startScan(). A former call to |
marcozecchini | 0:9fca2b23d0ba | 958 | * ble.startScan(callback) should be replaced with |
marcozecchini | 0:9fca2b23d0ba | 959 | * ble.gap().startScan(object, callback). |
marcozecchini | 0:9fca2b23d0ba | 960 | */ |
marcozecchini | 0:9fca2b23d0ba | 961 | template<typename T> |
marcozecchini | 0:9fca2b23d0ba | 962 | MBED_DEPRECATED("Use ble.gap().startScan(object, callback)") |
marcozecchini | 0:9fca2b23d0ba | 963 | ble_error_t startScan(T *object, void (T::*memberCallback)(const Gap::AdvertisementCallbackParams_t *params)); |
marcozecchini | 0:9fca2b23d0ba | 964 | |
marcozecchini | 0:9fca2b23d0ba | 965 | /** |
marcozecchini | 0:9fca2b23d0ba | 966 | * Stop scanning. The current scanning parameters remain in effect. |
marcozecchini | 0:9fca2b23d0ba | 967 | * |
marcozecchini | 0:9fca2b23d0ba | 968 | * @retval BLE_ERROR_NONE if successfully stopped scanning procedure. |
marcozecchini | 0:9fca2b23d0ba | 969 | * |
marcozecchini | 0:9fca2b23d0ba | 970 | * @deprecated You should use the parallel API from Gap directly and refer to |
marcozecchini | 0:9fca2b23d0ba | 971 | * Gap::stopScan(). A former call to |
marcozecchini | 0:9fca2b23d0ba | 972 | * ble.stopScan() should be replaced with |
marcozecchini | 0:9fca2b23d0ba | 973 | * ble.gap().stopScan(). |
marcozecchini | 0:9fca2b23d0ba | 974 | */ |
marcozecchini | 0:9fca2b23d0ba | 975 | MBED_DEPRECATED("Use ble.gap().stopScan()") |
marcozecchini | 0:9fca2b23d0ba | 976 | ble_error_t stopScan(void) { |
marcozecchini | 0:9fca2b23d0ba | 977 | return gap().stopScan(); |
marcozecchini | 0:9fca2b23d0ba | 978 | } |
marcozecchini | 0:9fca2b23d0ba | 979 | |
marcozecchini | 0:9fca2b23d0ba | 980 | /** |
marcozecchini | 0:9fca2b23d0ba | 981 | * Create a connection (GAP Link Establishment). |
marcozecchini | 0:9fca2b23d0ba | 982 | * @param peerAddr |
marcozecchini | 0:9fca2b23d0ba | 983 | * 48-bit address, LSB format. |
marcozecchini | 0:9fca2b23d0ba | 984 | * @param peerAddrType |
marcozecchini | 0:9fca2b23d0ba | 985 | * Address type of the peer. |
marcozecchini | 0:9fca2b23d0ba | 986 | * @param connectionParams |
marcozecchini | 0:9fca2b23d0ba | 987 | * Connection parameters. |
marcozecchini | 0:9fca2b23d0ba | 988 | * @param scanParams |
marcozecchini | 0:9fca2b23d0ba | 989 | * Parameters to use while scanning for the peer. |
marcozecchini | 0:9fca2b23d0ba | 990 | * @return BLE_ERROR_NONE if connection establishment procedure is started |
marcozecchini | 0:9fca2b23d0ba | 991 | * successfully. The onConnection callback (if set) is invoked upon |
marcozecchini | 0:9fca2b23d0ba | 992 | * a connection event. |
marcozecchini | 0:9fca2b23d0ba | 993 | * |
marcozecchini | 0:9fca2b23d0ba | 994 | * @deprecated You should use the parallel API from Gap directly and refer to |
marcozecchini | 0:9fca2b23d0ba | 995 | * Gap::connect(). A former call to |
marcozecchini | 0:9fca2b23d0ba | 996 | * ble.connect(...) should be replaced with |
marcozecchini | 0:9fca2b23d0ba | 997 | * ble.gap().connect(...). |
marcozecchini | 0:9fca2b23d0ba | 998 | */ |
marcozecchini | 0:9fca2b23d0ba | 999 | MBED_DEPRECATED("Use ble.gap().connect(...)") |
marcozecchini | 0:9fca2b23d0ba | 1000 | ble_error_t connect(const BLEProtocol::AddressBytes_t peerAddr, |
marcozecchini | 0:9fca2b23d0ba | 1001 | BLEProtocol::AddressType_t peerAddrType = BLEProtocol::AddressType::RANDOM_STATIC, |
marcozecchini | 0:9fca2b23d0ba | 1002 | const Gap::ConnectionParams_t *connectionParams = NULL, |
marcozecchini | 0:9fca2b23d0ba | 1003 | const GapScanningParams *scanParams = NULL) { |
marcozecchini | 0:9fca2b23d0ba | 1004 | return gap().connect(peerAddr, peerAddrType, connectionParams, scanParams); |
marcozecchini | 0:9fca2b23d0ba | 1005 | } |
marcozecchini | 0:9fca2b23d0ba | 1006 | |
marcozecchini | 0:9fca2b23d0ba | 1007 | /** |
marcozecchini | 0:9fca2b23d0ba | 1008 | * This call initiates the disconnection procedure, and its completion is |
marcozecchini | 0:9fca2b23d0ba | 1009 | * communicated to the application with an invocation of the |
marcozecchini | 0:9fca2b23d0ba | 1010 | * onDisconnection callback. |
marcozecchini | 0:9fca2b23d0ba | 1011 | * |
marcozecchini | 0:9fca2b23d0ba | 1012 | * @param[in] connectionHandle |
marcozecchini | 0:9fca2b23d0ba | 1013 | * @param[in] reason |
marcozecchini | 0:9fca2b23d0ba | 1014 | * The reason for disconnection; sent back to the peer. |
marcozecchini | 0:9fca2b23d0ba | 1015 | */ |
marcozecchini | 0:9fca2b23d0ba | 1016 | MBED_DEPRECATED("Use ble.gap().disconnect(...)") |
marcozecchini | 0:9fca2b23d0ba | 1017 | ble_error_t disconnect(Gap::Handle_t connectionHandle, Gap::DisconnectionReason_t reason) { |
marcozecchini | 0:9fca2b23d0ba | 1018 | return gap().disconnect(connectionHandle, reason); |
marcozecchini | 0:9fca2b23d0ba | 1019 | } |
marcozecchini | 0:9fca2b23d0ba | 1020 | |
marcozecchini | 0:9fca2b23d0ba | 1021 | /** |
marcozecchini | 0:9fca2b23d0ba | 1022 | * This call initiates the disconnection procedure, and its completion |
marcozecchini | 0:9fca2b23d0ba | 1023 | * is communicated to the application with an invocation of the |
marcozecchini | 0:9fca2b23d0ba | 1024 | * onDisconnection callback. |
marcozecchini | 0:9fca2b23d0ba | 1025 | * |
marcozecchini | 0:9fca2b23d0ba | 1026 | * @param reason |
marcozecchini | 0:9fca2b23d0ba | 1027 | * The reason for disconnection; sent back to the peer. |
marcozecchini | 0:9fca2b23d0ba | 1028 | * |
marcozecchini | 0:9fca2b23d0ba | 1029 | * @deprecated You should use the parallel API from Gap directly and refer to |
marcozecchini | 0:9fca2b23d0ba | 1030 | * Gap::disconnect(). A former call to |
marcozecchini | 0:9fca2b23d0ba | 1031 | * ble.disconnect(reason) should be replaced with |
marcozecchini | 0:9fca2b23d0ba | 1032 | * ble.gap().disconnect(reason). |
marcozecchini | 0:9fca2b23d0ba | 1033 | * |
marcozecchini | 0:9fca2b23d0ba | 1034 | * @note This version of disconnect() doesn't take a connection handle. It |
marcozecchini | 0:9fca2b23d0ba | 1035 | * works reliably only for stacks that are limited to a single |
marcozecchini | 0:9fca2b23d0ba | 1036 | * connection. |
marcozecchini | 0:9fca2b23d0ba | 1037 | */ |
marcozecchini | 0:9fca2b23d0ba | 1038 | MBED_DEPRECATED("Use ble.gap().disconnect(...)") |
marcozecchini | 0:9fca2b23d0ba | 1039 | ble_error_t disconnect(Gap::DisconnectionReason_t reason) { |
marcozecchini | 0:9fca2b23d0ba | 1040 | return gap().disconnect(reason); |
marcozecchini | 0:9fca2b23d0ba | 1041 | } |
marcozecchini | 0:9fca2b23d0ba | 1042 | |
marcozecchini | 0:9fca2b23d0ba | 1043 | /** |
marcozecchini | 0:9fca2b23d0ba | 1044 | * Returns the current Gap state of the device using a bitmask that |
marcozecchini | 0:9fca2b23d0ba | 1045 | * describes whether the device is advertising or connected. |
marcozecchini | 0:9fca2b23d0ba | 1046 | * |
marcozecchini | 0:9fca2b23d0ba | 1047 | * @deprecated You should use the parallel API from Gap directly and refer to |
marcozecchini | 0:9fca2b23d0ba | 1048 | * Gap::getState(). A former call to |
marcozecchini | 0:9fca2b23d0ba | 1049 | * ble.getGapState() should be replaced with |
marcozecchini | 0:9fca2b23d0ba | 1050 | * ble.gap().getState(). |
marcozecchini | 0:9fca2b23d0ba | 1051 | */ |
marcozecchini | 0:9fca2b23d0ba | 1052 | MBED_DEPRECATED("Use ble.gap().getGapState(...)") |
marcozecchini | 0:9fca2b23d0ba | 1053 | Gap::GapState_t getGapState(void) const { |
marcozecchini | 0:9fca2b23d0ba | 1054 | return gap().getState(); |
marcozecchini | 0:9fca2b23d0ba | 1055 | } |
marcozecchini | 0:9fca2b23d0ba | 1056 | |
marcozecchini | 0:9fca2b23d0ba | 1057 | /** |
marcozecchini | 0:9fca2b23d0ba | 1058 | * Get the GAP peripheral's preferred connection parameters. These are the |
marcozecchini | 0:9fca2b23d0ba | 1059 | * defaults that the peripheral would like to have in a connection. The |
marcozecchini | 0:9fca2b23d0ba | 1060 | * choice of the connection parameters is eventually up to the central. |
marcozecchini | 0:9fca2b23d0ba | 1061 | * |
marcozecchini | 0:9fca2b23d0ba | 1062 | * @param[out] params |
marcozecchini | 0:9fca2b23d0ba | 1063 | * The structure where the parameters will be stored. The caller owns memory |
marcozecchini | 0:9fca2b23d0ba | 1064 | * for this. |
marcozecchini | 0:9fca2b23d0ba | 1065 | * |
marcozecchini | 0:9fca2b23d0ba | 1066 | * @return BLE_ERROR_NONE if the parameters were successfully filled into |
marcozecchini | 0:9fca2b23d0ba | 1067 | * the given structure pointed to by params. |
marcozecchini | 0:9fca2b23d0ba | 1068 | * |
marcozecchini | 0:9fca2b23d0ba | 1069 | * @deprecated You should use the parallel API from Gap directly and refer to |
marcozecchini | 0:9fca2b23d0ba | 1070 | * Gap::getPreferredConnectionParams(). A former call to |
marcozecchini | 0:9fca2b23d0ba | 1071 | * ble.getPreferredConnectionParams() should be replaced with |
marcozecchini | 0:9fca2b23d0ba | 1072 | * ble.gap().getPreferredConnectionParams(). |
marcozecchini | 0:9fca2b23d0ba | 1073 | */ |
marcozecchini | 0:9fca2b23d0ba | 1074 | MBED_DEPRECATED("Use ble.gap().getPreferredConnectionParams(...)") |
marcozecchini | 0:9fca2b23d0ba | 1075 | ble_error_t getPreferredConnectionParams(Gap::ConnectionParams_t *params) { |
marcozecchini | 0:9fca2b23d0ba | 1076 | return gap().getPreferredConnectionParams(params); |
marcozecchini | 0:9fca2b23d0ba | 1077 | } |
marcozecchini | 0:9fca2b23d0ba | 1078 | |
marcozecchini | 0:9fca2b23d0ba | 1079 | /** |
marcozecchini | 0:9fca2b23d0ba | 1080 | * Set the GAP peripheral's preferred connection parameters. These are the |
marcozecchini | 0:9fca2b23d0ba | 1081 | * defaults that the peripheral would like to have in a connection. The |
marcozecchini | 0:9fca2b23d0ba | 1082 | * choice of the connection parameters is eventually up to the central. |
marcozecchini | 0:9fca2b23d0ba | 1083 | * |
marcozecchini | 0:9fca2b23d0ba | 1084 | * @param[in] params |
marcozecchini | 0:9fca2b23d0ba | 1085 | * The structure containing the desired parameters. |
marcozecchini | 0:9fca2b23d0ba | 1086 | * |
marcozecchini | 0:9fca2b23d0ba | 1087 | * @deprecated You should use the parallel API from Gap directly and refer to |
marcozecchini | 0:9fca2b23d0ba | 1088 | * Gap::setPreferredConnectionParams(). A former call to |
marcozecchini | 0:9fca2b23d0ba | 1089 | * ble.setPreferredConnectionParams() should be replaced with |
marcozecchini | 0:9fca2b23d0ba | 1090 | * ble.gap().setPreferredConnectionParams(). |
marcozecchini | 0:9fca2b23d0ba | 1091 | */ |
marcozecchini | 0:9fca2b23d0ba | 1092 | MBED_DEPRECATED("Use ble.gap().setPreferredConnectionParams(...)") |
marcozecchini | 0:9fca2b23d0ba | 1093 | ble_error_t setPreferredConnectionParams(const Gap::ConnectionParams_t *params) { |
marcozecchini | 0:9fca2b23d0ba | 1094 | return gap().setPreferredConnectionParams(params); |
marcozecchini | 0:9fca2b23d0ba | 1095 | } |
marcozecchini | 0:9fca2b23d0ba | 1096 | |
marcozecchini | 0:9fca2b23d0ba | 1097 | /** |
marcozecchini | 0:9fca2b23d0ba | 1098 | * Update connection parameters while in the peripheral role. |
marcozecchini | 0:9fca2b23d0ba | 1099 | * @details In the peripheral role, this will send the corresponding L2CAP request to the connected peer and wait for |
marcozecchini | 0:9fca2b23d0ba | 1100 | * the central to perform the procedure. |
marcozecchini | 0:9fca2b23d0ba | 1101 | * @param[in] handle |
marcozecchini | 0:9fca2b23d0ba | 1102 | * Connection Handle |
marcozecchini | 0:9fca2b23d0ba | 1103 | * @param[in] params |
marcozecchini | 0:9fca2b23d0ba | 1104 | * Pointer to desired connection parameters. If NULL is provided on a peripheral role, |
marcozecchini | 0:9fca2b23d0ba | 1105 | * the parameters in the PPCP characteristic of the GAP service will be used instead. |
marcozecchini | 0:9fca2b23d0ba | 1106 | * |
marcozecchini | 0:9fca2b23d0ba | 1107 | * @deprecated You should use the parallel API from Gap directly and refer to |
marcozecchini | 0:9fca2b23d0ba | 1108 | * Gap::updateConnectionParams(). A former call to |
marcozecchini | 0:9fca2b23d0ba | 1109 | * ble.updateConnectionParams() should be replaced with |
marcozecchini | 0:9fca2b23d0ba | 1110 | * ble.gap().updateConnectionParams(). |
marcozecchini | 0:9fca2b23d0ba | 1111 | */ |
marcozecchini | 0:9fca2b23d0ba | 1112 | MBED_DEPRECATED("Use ble.gap().updateConnectionParams(...)") |
marcozecchini | 0:9fca2b23d0ba | 1113 | ble_error_t updateConnectionParams(Gap::Handle_t handle, const Gap::ConnectionParams_t *params) { |
marcozecchini | 0:9fca2b23d0ba | 1114 | return gap().updateConnectionParams(handle, params); |
marcozecchini | 0:9fca2b23d0ba | 1115 | } |
marcozecchini | 0:9fca2b23d0ba | 1116 | |
marcozecchini | 0:9fca2b23d0ba | 1117 | /** |
marcozecchini | 0:9fca2b23d0ba | 1118 | * Set the device name characteristic in the Gap service. |
marcozecchini | 0:9fca2b23d0ba | 1119 | * @param[in] deviceName |
marcozecchini | 0:9fca2b23d0ba | 1120 | * The new value for the device-name. This is a UTF-8 encoded, <b>NULL-terminated</b> string. |
marcozecchini | 0:9fca2b23d0ba | 1121 | * |
marcozecchini | 0:9fca2b23d0ba | 1122 | * @deprecated You should use the parallel API from Gap directly and refer to |
marcozecchini | 0:9fca2b23d0ba | 1123 | * Gap::setDeviceName(). A former call to |
marcozecchini | 0:9fca2b23d0ba | 1124 | * ble.setDeviceName() should be replaced with |
marcozecchini | 0:9fca2b23d0ba | 1125 | * ble.gap().setDeviceName(). |
marcozecchini | 0:9fca2b23d0ba | 1126 | */ |
marcozecchini | 0:9fca2b23d0ba | 1127 | MBED_DEPRECATED("Use ble.gap().setDeviceName(...)") |
marcozecchini | 0:9fca2b23d0ba | 1128 | ble_error_t setDeviceName(const uint8_t *deviceName) { |
marcozecchini | 0:9fca2b23d0ba | 1129 | return gap().setDeviceName(deviceName); |
marcozecchini | 0:9fca2b23d0ba | 1130 | } |
marcozecchini | 0:9fca2b23d0ba | 1131 | |
marcozecchini | 0:9fca2b23d0ba | 1132 | /** |
marcozecchini | 0:9fca2b23d0ba | 1133 | * Get the value of the device name characteristic in the Gap service. |
marcozecchini | 0:9fca2b23d0ba | 1134 | * @param[out] deviceName |
marcozecchini | 0:9fca2b23d0ba | 1135 | * Pointer to an empty buffer where the UTF-8 *non NULL- |
marcozecchini | 0:9fca2b23d0ba | 1136 | * terminated* string will be placed. Set this |
marcozecchini | 0:9fca2b23d0ba | 1137 | * value to NULL to obtain the deviceName-length |
marcozecchini | 0:9fca2b23d0ba | 1138 | * from the 'length' parameter. |
marcozecchini | 0:9fca2b23d0ba | 1139 | * |
marcozecchini | 0:9fca2b23d0ba | 1140 | * @param[in,out] lengthP |
marcozecchini | 0:9fca2b23d0ba | 1141 | * (on input) Length of the buffer pointed to by deviceName; |
marcozecchini | 0:9fca2b23d0ba | 1142 | * (on output) the complete device name length (without the |
marcozecchini | 0:9fca2b23d0ba | 1143 | * null terminator). |
marcozecchini | 0:9fca2b23d0ba | 1144 | * |
marcozecchini | 0:9fca2b23d0ba | 1145 | * @note If the device name is longer than the size of the supplied buffer, |
marcozecchini | 0:9fca2b23d0ba | 1146 | * the length will return the complete device name length and not the |
marcozecchini | 0:9fca2b23d0ba | 1147 | * number of bytes actually returned in deviceName. The application may |
marcozecchini | 0:9fca2b23d0ba | 1148 | * use this information to retry with a suitable buffer size. |
marcozecchini | 0:9fca2b23d0ba | 1149 | * |
marcozecchini | 0:9fca2b23d0ba | 1150 | * @deprecated You should use the parallel API from Gap directly and refer to |
marcozecchini | 0:9fca2b23d0ba | 1151 | * Gap::getDeviceName(). A former call to |
marcozecchini | 0:9fca2b23d0ba | 1152 | * ble.getDeviceName() should be replaced with |
marcozecchini | 0:9fca2b23d0ba | 1153 | * ble.gap().getDeviceName(). |
marcozecchini | 0:9fca2b23d0ba | 1154 | */ |
marcozecchini | 0:9fca2b23d0ba | 1155 | MBED_DEPRECATED("Use ble.gap().getDeviceName(...)") |
marcozecchini | 0:9fca2b23d0ba | 1156 | ble_error_t getDeviceName(uint8_t *deviceName, unsigned *lengthP) { |
marcozecchini | 0:9fca2b23d0ba | 1157 | return gap().getDeviceName(deviceName, lengthP); |
marcozecchini | 0:9fca2b23d0ba | 1158 | } |
marcozecchini | 0:9fca2b23d0ba | 1159 | |
marcozecchini | 0:9fca2b23d0ba | 1160 | /** |
marcozecchini | 0:9fca2b23d0ba | 1161 | * Set the appearance characteristic in the Gap service. |
marcozecchini | 0:9fca2b23d0ba | 1162 | * @param[in] appearance |
marcozecchini | 0:9fca2b23d0ba | 1163 | * The new value for the device-appearance. |
marcozecchini | 0:9fca2b23d0ba | 1164 | * |
marcozecchini | 0:9fca2b23d0ba | 1165 | * @deprecated You should use the parallel API from Gap directly and refer to |
marcozecchini | 0:9fca2b23d0ba | 1166 | * Gap::setAppearance(). A former call to |
marcozecchini | 0:9fca2b23d0ba | 1167 | * ble.setAppearance() should be replaced with |
marcozecchini | 0:9fca2b23d0ba | 1168 | * ble.gap().setAppearance(). |
marcozecchini | 0:9fca2b23d0ba | 1169 | */ |
marcozecchini | 0:9fca2b23d0ba | 1170 | MBED_DEPRECATED("Use ble.gap().setAppearance(...)") |
marcozecchini | 0:9fca2b23d0ba | 1171 | ble_error_t setAppearance(GapAdvertisingData::Appearance appearance) { |
marcozecchini | 0:9fca2b23d0ba | 1172 | return gap().setAppearance(appearance); |
marcozecchini | 0:9fca2b23d0ba | 1173 | } |
marcozecchini | 0:9fca2b23d0ba | 1174 | |
marcozecchini | 0:9fca2b23d0ba | 1175 | /** |
marcozecchini | 0:9fca2b23d0ba | 1176 | * Get the appearance characteristic in the Gap service. |
marcozecchini | 0:9fca2b23d0ba | 1177 | * @param[out] appearanceP |
marcozecchini | 0:9fca2b23d0ba | 1178 | * The new value for the device-appearance. |
marcozecchini | 0:9fca2b23d0ba | 1179 | * |
marcozecchini | 0:9fca2b23d0ba | 1180 | * @deprecated You should use the parallel API from Gap directly, refer to |
marcozecchini | 0:9fca2b23d0ba | 1181 | * Gap::getAppearance(). A former call to |
marcozecchini | 0:9fca2b23d0ba | 1182 | * ble.getAppearance() should be replaced with |
marcozecchini | 0:9fca2b23d0ba | 1183 | * ble.gap().getAppearance(). |
marcozecchini | 0:9fca2b23d0ba | 1184 | */ |
marcozecchini | 0:9fca2b23d0ba | 1185 | MBED_DEPRECATED("Use ble.gap().getAppearance(...)") |
marcozecchini | 0:9fca2b23d0ba | 1186 | ble_error_t getAppearance(GapAdvertisingData::Appearance *appearanceP) { |
marcozecchini | 0:9fca2b23d0ba | 1187 | return gap().getAppearance(appearanceP); |
marcozecchini | 0:9fca2b23d0ba | 1188 | } |
marcozecchini | 0:9fca2b23d0ba | 1189 | |
marcozecchini | 0:9fca2b23d0ba | 1190 | /** |
marcozecchini | 0:9fca2b23d0ba | 1191 | * Set the radio's transmit power. |
marcozecchini | 0:9fca2b23d0ba | 1192 | * @param[in] txPower Radio transmit power in dBm. |
marcozecchini | 0:9fca2b23d0ba | 1193 | * |
marcozecchini | 0:9fca2b23d0ba | 1194 | * @deprecated You should use the parallel API from Gap directly and refer to |
marcozecchini | 0:9fca2b23d0ba | 1195 | * Gap::setTxPower(). A former call to |
marcozecchini | 0:9fca2b23d0ba | 1196 | * ble.setTxPower() should be replaced with |
marcozecchini | 0:9fca2b23d0ba | 1197 | * ble.gap().setTxPower(). |
marcozecchini | 0:9fca2b23d0ba | 1198 | */ |
marcozecchini | 0:9fca2b23d0ba | 1199 | MBED_DEPRECATED("Use ble.gap().setTxPower(...)") |
marcozecchini | 0:9fca2b23d0ba | 1200 | ble_error_t setTxPower(int8_t txPower) { |
marcozecchini | 0:9fca2b23d0ba | 1201 | return gap().setTxPower(txPower); |
marcozecchini | 0:9fca2b23d0ba | 1202 | } |
marcozecchini | 0:9fca2b23d0ba | 1203 | |
marcozecchini | 0:9fca2b23d0ba | 1204 | /** |
marcozecchini | 0:9fca2b23d0ba | 1205 | * Query the underlying stack for permitted arguments for setTxPower(). |
marcozecchini | 0:9fca2b23d0ba | 1206 | * |
marcozecchini | 0:9fca2b23d0ba | 1207 | * @param[out] valueArrayPP |
marcozecchini | 0:9fca2b23d0ba | 1208 | * Out parameter to receive the immutable array of Tx values. |
marcozecchini | 0:9fca2b23d0ba | 1209 | * @param[out] countP |
marcozecchini | 0:9fca2b23d0ba | 1210 | * Out parameter to receive the array's size. |
marcozecchini | 0:9fca2b23d0ba | 1211 | * |
marcozecchini | 0:9fca2b23d0ba | 1212 | * @deprecated You should use the parallel API from Gap directly, refer to |
marcozecchini | 0:9fca2b23d0ba | 1213 | * Gap::getPermittedTxPowerValues(). A former call to |
marcozecchini | 0:9fca2b23d0ba | 1214 | * ble.getPermittedTxPowerValues() should be replaced with |
marcozecchini | 0:9fca2b23d0ba | 1215 | * ble.gap().getPermittedTxPowerValues(). |
marcozecchini | 0:9fca2b23d0ba | 1216 | */ |
marcozecchini | 0:9fca2b23d0ba | 1217 | MBED_DEPRECATED("Use ble.gap().getPermittedTxPowerValues(...)") |
marcozecchini | 0:9fca2b23d0ba | 1218 | void getPermittedTxPowerValues(const int8_t **valueArrayPP, size_t *countP) { |
marcozecchini | 0:9fca2b23d0ba | 1219 | gap().getPermittedTxPowerValues(valueArrayPP, countP); |
marcozecchini | 0:9fca2b23d0ba | 1220 | } |
marcozecchini | 0:9fca2b23d0ba | 1221 | |
marcozecchini | 0:9fca2b23d0ba | 1222 | /** |
marcozecchini | 0:9fca2b23d0ba | 1223 | * Add a service declaration to the local server ATT table. Also add the |
marcozecchini | 0:9fca2b23d0ba | 1224 | * characteristics contained within. |
marcozecchini | 0:9fca2b23d0ba | 1225 | * |
marcozecchini | 0:9fca2b23d0ba | 1226 | * @deprecated You should use the parallel API from GattServer directly, refer to |
marcozecchini | 0:9fca2b23d0ba | 1227 | * GattServer::addService(). A former call |
marcozecchini | 0:9fca2b23d0ba | 1228 | * to ble.addService() should be replaced with |
marcozecchini | 0:9fca2b23d0ba | 1229 | * ble.gattServer().addService(). |
marcozecchini | 0:9fca2b23d0ba | 1230 | */ |
marcozecchini | 0:9fca2b23d0ba | 1231 | MBED_DEPRECATED("Use ble.gattServer().addService(...)") |
marcozecchini | 0:9fca2b23d0ba | 1232 | ble_error_t addService(GattService &service) { |
marcozecchini | 0:9fca2b23d0ba | 1233 | return gattServer().addService(service); |
marcozecchini | 0:9fca2b23d0ba | 1234 | } |
marcozecchini | 0:9fca2b23d0ba | 1235 | |
marcozecchini | 0:9fca2b23d0ba | 1236 | /** |
marcozecchini | 0:9fca2b23d0ba | 1237 | * Read the value of a characteristic from the local GattServer. |
marcozecchini | 0:9fca2b23d0ba | 1238 | * @param[in] attributeHandle |
marcozecchini | 0:9fca2b23d0ba | 1239 | * Attribute handle for the value attribute of the characteristic. |
marcozecchini | 0:9fca2b23d0ba | 1240 | * @param[out] buffer |
marcozecchini | 0:9fca2b23d0ba | 1241 | * A buffer to hold the value being read. |
marcozecchini | 0:9fca2b23d0ba | 1242 | * @param[in,out] lengthP |
marcozecchini | 0:9fca2b23d0ba | 1243 | * Length of the buffer being supplied. If the attribute |
marcozecchini | 0:9fca2b23d0ba | 1244 | * value is longer than the size of the supplied buffer, |
marcozecchini | 0:9fca2b23d0ba | 1245 | * this variable will return the total attribute value length |
marcozecchini | 0:9fca2b23d0ba | 1246 | * (excluding offset). The application may use this |
marcozecchini | 0:9fca2b23d0ba | 1247 | * information to allocate a suitable buffer size. |
marcozecchini | 0:9fca2b23d0ba | 1248 | * |
marcozecchini | 0:9fca2b23d0ba | 1249 | * @return BLE_ERROR_NONE if a value was read successfully into the buffer. |
marcozecchini | 0:9fca2b23d0ba | 1250 | * |
marcozecchini | 0:9fca2b23d0ba | 1251 | * @deprecated You should use the parallel API from GattServer directly, |
marcozecchini | 0:9fca2b23d0ba | 1252 | * GattServer::read(GattAttribute::Handle_t,uint8_t,uint16_t). A former call |
marcozecchini | 0:9fca2b23d0ba | 1253 | * to ble.readCharacteristicValue() should be replaced with |
marcozecchini | 0:9fca2b23d0ba | 1254 | * ble.gattServer().read(). |
marcozecchini | 0:9fca2b23d0ba | 1255 | */ |
marcozecchini | 0:9fca2b23d0ba | 1256 | MBED_DEPRECATED("Use ble.gattServer().read(...)") |
marcozecchini | 0:9fca2b23d0ba | 1257 | ble_error_t readCharacteristicValue(GattAttribute::Handle_t attributeHandle, uint8_t *buffer, uint16_t *lengthP) { |
marcozecchini | 0:9fca2b23d0ba | 1258 | return gattServer().read(attributeHandle, buffer, lengthP); |
marcozecchini | 0:9fca2b23d0ba | 1259 | } |
marcozecchini | 0:9fca2b23d0ba | 1260 | |
marcozecchini | 0:9fca2b23d0ba | 1261 | /** |
marcozecchini | 0:9fca2b23d0ba | 1262 | * Read the value of a characteristic from the local GattServer. |
marcozecchini | 0:9fca2b23d0ba | 1263 | * @param[in] connectionHandle |
marcozecchini | 0:9fca2b23d0ba | 1264 | * Connection Handle. |
marcozecchini | 0:9fca2b23d0ba | 1265 | * @param[in] attributeHandle |
marcozecchini | 0:9fca2b23d0ba | 1266 | * Attribute handle for the value attribute of the characteristic. |
marcozecchini | 0:9fca2b23d0ba | 1267 | * @param[out] buffer |
marcozecchini | 0:9fca2b23d0ba | 1268 | * A buffer to hold the value being read. |
marcozecchini | 0:9fca2b23d0ba | 1269 | * @param[in,out] lengthP |
marcozecchini | 0:9fca2b23d0ba | 1270 | * Length of the buffer being supplied. If the attribute |
marcozecchini | 0:9fca2b23d0ba | 1271 | * value is longer than the size of the supplied buffer, |
marcozecchini | 0:9fca2b23d0ba | 1272 | * this variable will return the total attribute value length |
marcozecchini | 0:9fca2b23d0ba | 1273 | * (excluding offset). The application may use this |
marcozecchini | 0:9fca2b23d0ba | 1274 | * information to allocate a suitable buffer size. |
marcozecchini | 0:9fca2b23d0ba | 1275 | * |
marcozecchini | 0:9fca2b23d0ba | 1276 | * @return BLE_ERROR_NONE if a value was read successfully into the buffer. |
marcozecchini | 0:9fca2b23d0ba | 1277 | * |
marcozecchini | 0:9fca2b23d0ba | 1278 | * @note This API is a version of the above, with an additional connection handle |
marcozecchini | 0:9fca2b23d0ba | 1279 | * parameter to allow fetches for connection-specific multivalued |
marcozecchini | 0:9fca2b23d0ba | 1280 | * attributes (such as the CCCDs). |
marcozecchini | 0:9fca2b23d0ba | 1281 | * |
marcozecchini | 0:9fca2b23d0ba | 1282 | * @deprecated You should use the parallel API from GattServer directly, refer to |
marcozecchini | 0:9fca2b23d0ba | 1283 | * GattServer::read(Gap::Handle_t,GattAttribute::Handle_t,uint8_t,uint16_t). |
marcozecchini | 0:9fca2b23d0ba | 1284 | * A former call to ble.readCharacteristicValue() should be replaced with |
marcozecchini | 0:9fca2b23d0ba | 1285 | * ble.gattServer().read(). |
marcozecchini | 0:9fca2b23d0ba | 1286 | */ |
marcozecchini | 0:9fca2b23d0ba | 1287 | MBED_DEPRECATED("Use ble.gattServer().read(...)") |
marcozecchini | 0:9fca2b23d0ba | 1288 | ble_error_t readCharacteristicValue(Gap::Handle_t connectionHandle, GattAttribute::Handle_t attributeHandle, uint8_t *buffer, uint16_t *lengthP) { |
marcozecchini | 0:9fca2b23d0ba | 1289 | return gattServer().read(connectionHandle, attributeHandle, buffer, lengthP); |
marcozecchini | 0:9fca2b23d0ba | 1290 | } |
marcozecchini | 0:9fca2b23d0ba | 1291 | |
marcozecchini | 0:9fca2b23d0ba | 1292 | /** |
marcozecchini | 0:9fca2b23d0ba | 1293 | * Update the value of a characteristic on the local GattServer. |
marcozecchini | 0:9fca2b23d0ba | 1294 | * |
marcozecchini | 0:9fca2b23d0ba | 1295 | * @param[in] attributeHandle |
marcozecchini | 0:9fca2b23d0ba | 1296 | * Handle for the value attribute of the characteristic. |
marcozecchini | 0:9fca2b23d0ba | 1297 | * @param[in] value |
marcozecchini | 0:9fca2b23d0ba | 1298 | * A pointer to a buffer holding the new value. |
marcozecchini | 0:9fca2b23d0ba | 1299 | * @param[in] size |
marcozecchini | 0:9fca2b23d0ba | 1300 | * Size of the new value (in bytes). |
marcozecchini | 0:9fca2b23d0ba | 1301 | * @param[in] localOnly |
marcozecchini | 0:9fca2b23d0ba | 1302 | * Should this update be kept on the local |
marcozecchini | 0:9fca2b23d0ba | 1303 | * GattServer regardless of the state of the |
marcozecchini | 0:9fca2b23d0ba | 1304 | * notify/indicate flag in the CCCD for this |
marcozecchini | 0:9fca2b23d0ba | 1305 | * characteristic? If set to true, no notification |
marcozecchini | 0:9fca2b23d0ba | 1306 | * or indication is generated. |
marcozecchini | 0:9fca2b23d0ba | 1307 | * |
marcozecchini | 0:9fca2b23d0ba | 1308 | * @return BLE_ERROR_NONE if we have successfully set the value of the attribute. |
marcozecchini | 0:9fca2b23d0ba | 1309 | * |
marcozecchini | 0:9fca2b23d0ba | 1310 | * @deprecated You should use the parallel API from GattServer directly and refer to |
marcozecchini | 0:9fca2b23d0ba | 1311 | * GattServer::write(GattAttribute::Handle_t,const uint8_t,uint16_t,bool). |
marcozecchini | 0:9fca2b23d0ba | 1312 | * A former call to ble.updateCharacteristicValue() should be replaced with |
marcozecchini | 0:9fca2b23d0ba | 1313 | * ble.gattServer().write(). |
marcozecchini | 0:9fca2b23d0ba | 1314 | */ |
marcozecchini | 0:9fca2b23d0ba | 1315 | MBED_DEPRECATED("Use ble.gattServer().write(...)") |
marcozecchini | 0:9fca2b23d0ba | 1316 | ble_error_t updateCharacteristicValue(GattAttribute::Handle_t attributeHandle, |
marcozecchini | 0:9fca2b23d0ba | 1317 | const uint8_t *value, |
marcozecchini | 0:9fca2b23d0ba | 1318 | uint16_t size, |
marcozecchini | 0:9fca2b23d0ba | 1319 | bool localOnly = false) { |
marcozecchini | 0:9fca2b23d0ba | 1320 | return gattServer().write(attributeHandle, value, size, localOnly); |
marcozecchini | 0:9fca2b23d0ba | 1321 | } |
marcozecchini | 0:9fca2b23d0ba | 1322 | |
marcozecchini | 0:9fca2b23d0ba | 1323 | /** |
marcozecchini | 0:9fca2b23d0ba | 1324 | * Update the value of a characteristic on the local GattServer. A version |
marcozecchini | 0:9fca2b23d0ba | 1325 | * of the above, with a connection handle parameter to allow updates |
marcozecchini | 0:9fca2b23d0ba | 1326 | * for connection-specific multivalued attributes (such as the CCCDs). |
marcozecchini | 0:9fca2b23d0ba | 1327 | * |
marcozecchini | 0:9fca2b23d0ba | 1328 | * @param[in] connectionHandle |
marcozecchini | 0:9fca2b23d0ba | 1329 | * Connection Handle. |
marcozecchini | 0:9fca2b23d0ba | 1330 | * @param[in] attributeHandle |
marcozecchini | 0:9fca2b23d0ba | 1331 | * Handle for the value attribute of the Characteristic. |
marcozecchini | 0:9fca2b23d0ba | 1332 | * @param[in] value |
marcozecchini | 0:9fca2b23d0ba | 1333 | * A pointer to a buffer holding the new value. |
marcozecchini | 0:9fca2b23d0ba | 1334 | * @param[in] size |
marcozecchini | 0:9fca2b23d0ba | 1335 | * Size of the new value (in bytes). |
marcozecchini | 0:9fca2b23d0ba | 1336 | * @param[in] localOnly |
marcozecchini | 0:9fca2b23d0ba | 1337 | * Should this update be kept on the local |
marcozecchini | 0:9fca2b23d0ba | 1338 | * GattServer regardless of the state of the |
marcozecchini | 0:9fca2b23d0ba | 1339 | * notify/indicate flag in the CCCD for this |
marcozecchini | 0:9fca2b23d0ba | 1340 | * Characteristic? If set to true, no notification |
marcozecchini | 0:9fca2b23d0ba | 1341 | * or indication is generated. |
marcozecchini | 0:9fca2b23d0ba | 1342 | * |
marcozecchini | 0:9fca2b23d0ba | 1343 | * @return BLE_ERROR_NONE if we have successfully set the value of the attribute. |
marcozecchini | 0:9fca2b23d0ba | 1344 | * |
marcozecchini | 0:9fca2b23d0ba | 1345 | * @deprecated You should use the parallel API from GattServer directly and refer to |
marcozecchini | 0:9fca2b23d0ba | 1346 | * GattServer::write(Gap::Handle_t,GattAttribute::Handle_t,const uint8_t,uint16_t,bool). |
marcozecchini | 0:9fca2b23d0ba | 1347 | * A former call to ble.updateCharacteristicValue() should be replaced with |
marcozecchini | 0:9fca2b23d0ba | 1348 | * ble.gattServer().write(). |
marcozecchini | 0:9fca2b23d0ba | 1349 | */ |
marcozecchini | 0:9fca2b23d0ba | 1350 | MBED_DEPRECATED("Use ble.gattServer().write(...)") |
marcozecchini | 0:9fca2b23d0ba | 1351 | ble_error_t updateCharacteristicValue(Gap::Handle_t connectionHandle, |
marcozecchini | 0:9fca2b23d0ba | 1352 | GattAttribute::Handle_t attributeHandle, |
marcozecchini | 0:9fca2b23d0ba | 1353 | const uint8_t *value, |
marcozecchini | 0:9fca2b23d0ba | 1354 | uint16_t size, |
marcozecchini | 0:9fca2b23d0ba | 1355 | bool localOnly = false) { |
marcozecchini | 0:9fca2b23d0ba | 1356 | return gattServer().write(connectionHandle, attributeHandle, value, size, localOnly); |
marcozecchini | 0:9fca2b23d0ba | 1357 | } |
marcozecchini | 0:9fca2b23d0ba | 1358 | |
marcozecchini | 0:9fca2b23d0ba | 1359 | /** |
marcozecchini | 0:9fca2b23d0ba | 1360 | * Enable the BLE stack's Security Manager. The Security Manager implements |
marcozecchini | 0:9fca2b23d0ba | 1361 | * the cryptographic algorithms and protocol exchanges that allow two |
marcozecchini | 0:9fca2b23d0ba | 1362 | * devices to securely exchange data and privately detect each other. |
marcozecchini | 0:9fca2b23d0ba | 1363 | * Calling this API is a prerequisite for encryption and pairing (bonding). |
marcozecchini | 0:9fca2b23d0ba | 1364 | * |
marcozecchini | 0:9fca2b23d0ba | 1365 | * @param[in] enableBonding Allow for bonding. |
marcozecchini | 0:9fca2b23d0ba | 1366 | * @param[in] requireMITM Require protection against man-in-the-middle attacks. |
marcozecchini | 0:9fca2b23d0ba | 1367 | * @param[in] iocaps To specify the I/O capabilities of this peripheral, |
marcozecchini | 0:9fca2b23d0ba | 1368 | * such as availability of a display or keyboard, to |
marcozecchini | 0:9fca2b23d0ba | 1369 | * support out-of-band exchanges of security data. |
marcozecchini | 0:9fca2b23d0ba | 1370 | * @param[in] passkey To specify a static passkey. |
marcozecchini | 0:9fca2b23d0ba | 1371 | * |
marcozecchini | 0:9fca2b23d0ba | 1372 | * @return BLE_ERROR_NONE on success. |
marcozecchini | 0:9fca2b23d0ba | 1373 | * |
marcozecchini | 0:9fca2b23d0ba | 1374 | * @deprecated You should use the parallel API from SecurityManager directly, refer to |
marcozecchini | 0:9fca2b23d0ba | 1375 | * SecurityManager.init(). A former |
marcozecchini | 0:9fca2b23d0ba | 1376 | * call to ble.initializeSecurity(...) should be replaced with |
marcozecchini | 0:9fca2b23d0ba | 1377 | * ble.securityManager().init(...). |
marcozecchini | 0:9fca2b23d0ba | 1378 | */ |
marcozecchini | 0:9fca2b23d0ba | 1379 | MBED_DEPRECATED("Use ble.gattServer().write(...)") |
marcozecchini | 0:9fca2b23d0ba | 1380 | ble_error_t initializeSecurity(bool enableBonding = true, |
marcozecchini | 0:9fca2b23d0ba | 1381 | bool requireMITM = true, |
marcozecchini | 0:9fca2b23d0ba | 1382 | SecurityManager::SecurityIOCapabilities_t iocaps = SecurityManager::IO_CAPS_NONE, |
marcozecchini | 0:9fca2b23d0ba | 1383 | const SecurityManager::Passkey_t passkey = NULL) { |
marcozecchini | 0:9fca2b23d0ba | 1384 | return securityManager().init(enableBonding, requireMITM, iocaps, passkey); |
marcozecchini | 0:9fca2b23d0ba | 1385 | } |
marcozecchini | 0:9fca2b23d0ba | 1386 | |
marcozecchini | 0:9fca2b23d0ba | 1387 | /** |
marcozecchini | 0:9fca2b23d0ba | 1388 | * Get the security status of a connection. |
marcozecchini | 0:9fca2b23d0ba | 1389 | * |
marcozecchini | 0:9fca2b23d0ba | 1390 | * @param[in] connectionHandle Handle to identify the connection. |
marcozecchini | 0:9fca2b23d0ba | 1391 | * @param[out] securityStatusP Security status. |
marcozecchini | 0:9fca2b23d0ba | 1392 | * |
marcozecchini | 0:9fca2b23d0ba | 1393 | * @return BLE_SUCCESS or appropriate error code indicating the reason of failure. |
marcozecchini | 0:9fca2b23d0ba | 1394 | * |
marcozecchini | 0:9fca2b23d0ba | 1395 | * @deprecated You should use the parallel API from SecurityManager directly, refer to |
marcozecchini | 0:9fca2b23d0ba | 1396 | * SecurityManager::getLinkSecurity(). A former |
marcozecchini | 0:9fca2b23d0ba | 1397 | * call to ble.getLinkSecurity(...) should be replaced with |
marcozecchini | 0:9fca2b23d0ba | 1398 | * ble.securityManager().getLinkSecurity(...). |
marcozecchini | 0:9fca2b23d0ba | 1399 | */ |
marcozecchini | 0:9fca2b23d0ba | 1400 | MBED_DEPRECATED("ble.securityManager().getLinkSecurity(...)") |
marcozecchini | 0:9fca2b23d0ba | 1401 | ble_error_t getLinkSecurity(Gap::Handle_t connectionHandle, SecurityManager::LinkSecurityStatus_t *securityStatusP) { |
marcozecchini | 0:9fca2b23d0ba | 1402 | return securityManager().getLinkSecurity(connectionHandle, securityStatusP); |
marcozecchini | 0:9fca2b23d0ba | 1403 | } |
marcozecchini | 0:9fca2b23d0ba | 1404 | |
marcozecchini | 0:9fca2b23d0ba | 1405 | /** |
marcozecchini | 0:9fca2b23d0ba | 1406 | * Delete all peer device context and all related bonding information from |
marcozecchini | 0:9fca2b23d0ba | 1407 | * the database within the security manager. |
marcozecchini | 0:9fca2b23d0ba | 1408 | * |
marcozecchini | 0:9fca2b23d0ba | 1409 | * @retval BLE_ERROR_NONE On success; else returns an error code indicating the reason for the failure. |
marcozecchini | 0:9fca2b23d0ba | 1410 | * @retval BLE_ERROR_INVALID_STATE If the API is called without module initialization or |
marcozecchini | 0:9fca2b23d0ba | 1411 | * application registration. |
marcozecchini | 0:9fca2b23d0ba | 1412 | * |
marcozecchini | 0:9fca2b23d0ba | 1413 | * @deprecated You should use the parallel API from SecurityManager directly and refer to |
marcozecchini | 0:9fca2b23d0ba | 1414 | * SecurityManager::purgeAllBondingState(). A former |
marcozecchini | 0:9fca2b23d0ba | 1415 | * call to ble.purgeAllBondingState() should be replaced with |
marcozecchini | 0:9fca2b23d0ba | 1416 | * ble.securityManager().purgeAllBondingState(). |
marcozecchini | 0:9fca2b23d0ba | 1417 | */ |
marcozecchini | 0:9fca2b23d0ba | 1418 | MBED_DEPRECATED("ble.securityManager().purgeAllBondingState(...)") |
marcozecchini | 0:9fca2b23d0ba | 1419 | ble_error_t purgeAllBondingState(void) { |
marcozecchini | 0:9fca2b23d0ba | 1420 | return securityManager().purgeAllBondingState(); |
marcozecchini | 0:9fca2b23d0ba | 1421 | } |
marcozecchini | 0:9fca2b23d0ba | 1422 | |
marcozecchini | 0:9fca2b23d0ba | 1423 | /** |
marcozecchini | 0:9fca2b23d0ba | 1424 | * Set up a callback for timeout events. Refer to Gap::TimeoutSource_t for |
marcozecchini | 0:9fca2b23d0ba | 1425 | * possible event types. |
marcozecchini | 0:9fca2b23d0ba | 1426 | * |
marcozecchini | 0:9fca2b23d0ba | 1427 | * @deprecated You should use the parallel API from Gap directly and refer to |
marcozecchini | 0:9fca2b23d0ba | 1428 | * Gap::onTimeout(). A former call |
marcozecchini | 0:9fca2b23d0ba | 1429 | * to ble.onTimeout(callback) should be replaced with |
marcozecchini | 0:9fca2b23d0ba | 1430 | * ble.gap().onTimeout(callback). |
marcozecchini | 0:9fca2b23d0ba | 1431 | */ |
marcozecchini | 0:9fca2b23d0ba | 1432 | MBED_DEPRECATED("ble.gap().onTimeout(callback)") |
marcozecchini | 0:9fca2b23d0ba | 1433 | void onTimeout(Gap::TimeoutEventCallback_t timeoutCallback) { |
marcozecchini | 0:9fca2b23d0ba | 1434 | gap().onTimeout(timeoutCallback); |
marcozecchini | 0:9fca2b23d0ba | 1435 | } |
marcozecchini | 0:9fca2b23d0ba | 1436 | |
marcozecchini | 0:9fca2b23d0ba | 1437 | /** |
marcozecchini | 0:9fca2b23d0ba | 1438 | * Set up a callback for connection events. Refer to Gap::ConnectionEventCallback_t. |
marcozecchini | 0:9fca2b23d0ba | 1439 | * |
marcozecchini | 0:9fca2b23d0ba | 1440 | * @deprecated You should use the parallel API from Gap directly, refer to |
marcozecchini | 0:9fca2b23d0ba | 1441 | * Gap::onConnection(). A former call |
marcozecchini | 0:9fca2b23d0ba | 1442 | * to ble.onConnection(callback) should be replaced with |
marcozecchini | 0:9fca2b23d0ba | 1443 | * ble.gap().onConnection(callback). |
marcozecchini | 0:9fca2b23d0ba | 1444 | */ |
marcozecchini | 0:9fca2b23d0ba | 1445 | MBED_DEPRECATED("ble.gap().onConnection(callback)") |
marcozecchini | 0:9fca2b23d0ba | 1446 | void onConnection(Gap::ConnectionEventCallback_t connectionCallback) { |
marcozecchini | 0:9fca2b23d0ba | 1447 | gap().onConnection(connectionCallback); |
marcozecchini | 0:9fca2b23d0ba | 1448 | } |
marcozecchini | 0:9fca2b23d0ba | 1449 | |
marcozecchini | 0:9fca2b23d0ba | 1450 | /** |
marcozecchini | 0:9fca2b23d0ba | 1451 | * Append to a chain of callbacks to be invoked upon GAP disconnection. |
marcozecchini | 0:9fca2b23d0ba | 1452 | * |
marcozecchini | 0:9fca2b23d0ba | 1453 | * @deprecated You should use the parallel API from Gap directly and refer to |
marcozecchini | 0:9fca2b23d0ba | 1454 | * Gap::onDisconnection(). A former call |
marcozecchini | 0:9fca2b23d0ba | 1455 | * to ble.onDisconnection(callback) should be replaced with |
marcozecchini | 0:9fca2b23d0ba | 1456 | * ble.gap().onDisconnection(callback). |
marcozecchini | 0:9fca2b23d0ba | 1457 | */ |
marcozecchini | 0:9fca2b23d0ba | 1458 | MBED_DEPRECATED("ble.gap().onDisconnection(callback)") |
marcozecchini | 0:9fca2b23d0ba | 1459 | void onDisconnection(Gap::DisconnectionEventCallback_t disconnectionCallback) { |
marcozecchini | 0:9fca2b23d0ba | 1460 | gap().onDisconnection(disconnectionCallback); |
marcozecchini | 0:9fca2b23d0ba | 1461 | } |
marcozecchini | 0:9fca2b23d0ba | 1462 | |
marcozecchini | 0:9fca2b23d0ba | 1463 | /** |
marcozecchini | 0:9fca2b23d0ba | 1464 | * The same as onDisconnection() but allows an object reference and member function |
marcozecchini | 0:9fca2b23d0ba | 1465 | * to be added to the chain of callbacks. |
marcozecchini | 0:9fca2b23d0ba | 1466 | * |
marcozecchini | 0:9fca2b23d0ba | 1467 | * @deprecated You should use the parallel API from Gap directly and refer to |
marcozecchini | 0:9fca2b23d0ba | 1468 | * Gap::onDisconnection(). A former call |
marcozecchini | 0:9fca2b23d0ba | 1469 | * to ble.onDisconnection(callback) should be replaced with |
marcozecchini | 0:9fca2b23d0ba | 1470 | * ble.gap().onDisconnection(callback). |
marcozecchini | 0:9fca2b23d0ba | 1471 | */ |
marcozecchini | 0:9fca2b23d0ba | 1472 | template<typename T> |
marcozecchini | 0:9fca2b23d0ba | 1473 | MBED_DEPRECATED("ble.gap().onDisconnection(callback)") |
marcozecchini | 0:9fca2b23d0ba | 1474 | void onDisconnection(T *tptr, void (T::*mptr)(const Gap::DisconnectionCallbackParams_t*)) { |
marcozecchini | 0:9fca2b23d0ba | 1475 | gap().onDisconnection(tptr, mptr); |
marcozecchini | 0:9fca2b23d0ba | 1476 | } |
marcozecchini | 0:9fca2b23d0ba | 1477 | |
marcozecchini | 0:9fca2b23d0ba | 1478 | /** |
marcozecchini | 0:9fca2b23d0ba | 1479 | * Radio Notification is a feature that enables ACTIVE and INACTIVE |
marcozecchini | 0:9fca2b23d0ba | 1480 | * (nACTIVE) signals from the stack. These notify the application when the |
marcozecchini | 0:9fca2b23d0ba | 1481 | * radio is in use. The signal is sent using software interrupt. |
marcozecchini | 0:9fca2b23d0ba | 1482 | * |
marcozecchini | 0:9fca2b23d0ba | 1483 | * The ACTIVE signal is sent before the radio event starts. The nACTIVE |
marcozecchini | 0:9fca2b23d0ba | 1484 | * signal is sent at the end of the radio event. These signals can be used |
marcozecchini | 0:9fca2b23d0ba | 1485 | * by the application programmer to synchronize application logic with radio |
marcozecchini | 0:9fca2b23d0ba | 1486 | * activity. For example, the ACTIVE signal can be used to shut off external |
marcozecchini | 0:9fca2b23d0ba | 1487 | * devices to manage peak current drawn during periods when the radio is on, |
marcozecchini | 0:9fca2b23d0ba | 1488 | * or to trigger sensor data collection for transmission in the radio event. |
marcozecchini | 0:9fca2b23d0ba | 1489 | * |
marcozecchini | 0:9fca2b23d0ba | 1490 | * @param callback |
marcozecchini | 0:9fca2b23d0ba | 1491 | * The application handler to be invoked in response to a radio |
marcozecchini | 0:9fca2b23d0ba | 1492 | * ACTIVE/INACTIVE event. |
marcozecchini | 0:9fca2b23d0ba | 1493 | * |
marcozecchini | 0:9fca2b23d0ba | 1494 | * @deprecated You should use the parallel API from Gap directly, refer to |
marcozecchini | 0:9fca2b23d0ba | 1495 | * Gap::onRadioNotification(). A former call |
marcozecchini | 0:9fca2b23d0ba | 1496 | * to ble.onRadioNotification(...) should be replaced with |
marcozecchini | 0:9fca2b23d0ba | 1497 | * ble.gap().onRadioNotification(...). |
marcozecchini | 0:9fca2b23d0ba | 1498 | */ |
marcozecchini | 0:9fca2b23d0ba | 1499 | MBED_DEPRECATED("ble.gap().onRadioNotification(...)") |
marcozecchini | 0:9fca2b23d0ba | 1500 | void onRadioNotification(void (*callback)(bool)) { |
marcozecchini | 0:9fca2b23d0ba | 1501 | gap().onRadioNotification(callback); |
marcozecchini | 0:9fca2b23d0ba | 1502 | } |
marcozecchini | 0:9fca2b23d0ba | 1503 | |
marcozecchini | 0:9fca2b23d0ba | 1504 | /** |
marcozecchini | 0:9fca2b23d0ba | 1505 | * Add a callback for the GATT event DATA_SENT (which is triggered when |
marcozecchini | 0:9fca2b23d0ba | 1506 | * updates are sent out by GATT in the form of notifications). |
marcozecchini | 0:9fca2b23d0ba | 1507 | * |
marcozecchini | 0:9fca2b23d0ba | 1508 | * @note It is possible to chain together multiple onDataSent callbacks |
marcozecchini | 0:9fca2b23d0ba | 1509 | * (potentially from different modules of an application) to receive updates |
marcozecchini | 0:9fca2b23d0ba | 1510 | * to characteristics. |
marcozecchini | 0:9fca2b23d0ba | 1511 | * |
marcozecchini | 0:9fca2b23d0ba | 1512 | * @note It is also possible to set up a callback into a member function of |
marcozecchini | 0:9fca2b23d0ba | 1513 | * some object. |
marcozecchini | 0:9fca2b23d0ba | 1514 | * |
marcozecchini | 0:9fca2b23d0ba | 1515 | * @deprecated You should use the parallel API from GattServer directly and refer to |
marcozecchini | 0:9fca2b23d0ba | 1516 | * GattServer::onDataSent(). A former call |
marcozecchini | 0:9fca2b23d0ba | 1517 | * to ble.onDataSent(...) should be replaced with |
marcozecchini | 0:9fca2b23d0ba | 1518 | * ble.gattServer().onDataSent(...). |
marcozecchini | 0:9fca2b23d0ba | 1519 | */ |
marcozecchini | 0:9fca2b23d0ba | 1520 | MBED_DEPRECATED("ble.gattServer().onDataSent(...)") |
marcozecchini | 0:9fca2b23d0ba | 1521 | void onDataSent(void (*callback)(unsigned count)) { |
marcozecchini | 0:9fca2b23d0ba | 1522 | gattServer().onDataSent(callback); |
marcozecchini | 0:9fca2b23d0ba | 1523 | } |
marcozecchini | 0:9fca2b23d0ba | 1524 | |
marcozecchini | 0:9fca2b23d0ba | 1525 | /** |
marcozecchini | 0:9fca2b23d0ba | 1526 | * The same as onDataSent() but allows an object reference and member function |
marcozecchini | 0:9fca2b23d0ba | 1527 | * to be added to the chain of callbacks. |
marcozecchini | 0:9fca2b23d0ba | 1528 | * |
marcozecchini | 0:9fca2b23d0ba | 1529 | * @deprecated You should use the parallel API from GattServer directly and refer to |
marcozecchini | 0:9fca2b23d0ba | 1530 | * GattServer::onDataSent(). A former call |
marcozecchini | 0:9fca2b23d0ba | 1531 | * to ble.onDataSent(...) should be replaced with |
marcozecchini | 0:9fca2b23d0ba | 1532 | * ble.gattServer().onDataSent(...). |
marcozecchini | 0:9fca2b23d0ba | 1533 | */ |
marcozecchini | 0:9fca2b23d0ba | 1534 | template <typename T> |
marcozecchini | 0:9fca2b23d0ba | 1535 | MBED_DEPRECATED("ble.gattServer().onDataSent(...)") |
marcozecchini | 0:9fca2b23d0ba | 1536 | void onDataSent(T * objPtr, void (T::*memberPtr)(unsigned count)) { |
marcozecchini | 0:9fca2b23d0ba | 1537 | gattServer().onDataSent(objPtr, memberPtr); |
marcozecchini | 0:9fca2b23d0ba | 1538 | } |
marcozecchini | 0:9fca2b23d0ba | 1539 | |
marcozecchini | 0:9fca2b23d0ba | 1540 | /** |
marcozecchini | 0:9fca2b23d0ba | 1541 | * Set up a callback for when an attribute has its value updated by or at the |
marcozecchini | 0:9fca2b23d0ba | 1542 | * connected peer. For a peripheral, this callback is triggered when the local |
marcozecchini | 0:9fca2b23d0ba | 1543 | * GATT server has an attribute updated by a write command from the peer. |
marcozecchini | 0:9fca2b23d0ba | 1544 | * For a Central, this callback is triggered when a response is received for |
marcozecchini | 0:9fca2b23d0ba | 1545 | * a write request. |
marcozecchini | 0:9fca2b23d0ba | 1546 | * |
marcozecchini | 0:9fca2b23d0ba | 1547 | * @note It is possible to chain together multiple onDataWritten callbacks |
marcozecchini | 0:9fca2b23d0ba | 1548 | * (potentially from different modules of an application) to receive updates |
marcozecchini | 0:9fca2b23d0ba | 1549 | * to characteristics. Many services, such as DFU and UART, add their own |
marcozecchini | 0:9fca2b23d0ba | 1550 | * onDataWritten callbacks behind the scenes to trap interesting events. |
marcozecchini | 0:9fca2b23d0ba | 1551 | * |
marcozecchini | 0:9fca2b23d0ba | 1552 | * @note It is also possible to set up a callback into a member function of |
marcozecchini | 0:9fca2b23d0ba | 1553 | * some object. |
marcozecchini | 0:9fca2b23d0ba | 1554 | * |
marcozecchini | 0:9fca2b23d0ba | 1555 | * @deprecated You should use the parallel API from GattServer directly and refer to |
marcozecchini | 0:9fca2b23d0ba | 1556 | * GattServer::onDataWritten(). A former call |
marcozecchini | 0:9fca2b23d0ba | 1557 | * to ble.onDataWritten(...) should be replaced with |
marcozecchini | 0:9fca2b23d0ba | 1558 | * ble.gattServer().onDataWritten(...). |
marcozecchini | 0:9fca2b23d0ba | 1559 | */ |
marcozecchini | 0:9fca2b23d0ba | 1560 | MBED_DEPRECATED("ble.gattServer().onDataWritten(...)") |
marcozecchini | 0:9fca2b23d0ba | 1561 | void onDataWritten(void (*callback)(const GattWriteCallbackParams *eventDataP)) { |
marcozecchini | 0:9fca2b23d0ba | 1562 | gattServer().onDataWritten(callback); |
marcozecchini | 0:9fca2b23d0ba | 1563 | } |
marcozecchini | 0:9fca2b23d0ba | 1564 | |
marcozecchini | 0:9fca2b23d0ba | 1565 | /** |
marcozecchini | 0:9fca2b23d0ba | 1566 | * The same as onDataWritten() but allows an object reference and member function |
marcozecchini | 0:9fca2b23d0ba | 1567 | * to be added to the chain of callbacks. |
marcozecchini | 0:9fca2b23d0ba | 1568 | * |
marcozecchini | 0:9fca2b23d0ba | 1569 | * @deprecated You should use the parallel API from GattServer directly, refer to |
marcozecchini | 0:9fca2b23d0ba | 1570 | * GattServer::onDataWritten(). A former call |
marcozecchini | 0:9fca2b23d0ba | 1571 | * to ble.onDataWritten(...) should be replaced with |
marcozecchini | 0:9fca2b23d0ba | 1572 | * ble.gattServer().onDataWritten(...). |
marcozecchini | 0:9fca2b23d0ba | 1573 | */ |
marcozecchini | 0:9fca2b23d0ba | 1574 | template <typename T> |
marcozecchini | 0:9fca2b23d0ba | 1575 | MBED_DEPRECATED("ble.gattServer().onDataWritten(...)") |
marcozecchini | 0:9fca2b23d0ba | 1576 | void onDataWritten(T * objPtr, void (T::*memberPtr)(const GattWriteCallbackParams *context)) { |
marcozecchini | 0:9fca2b23d0ba | 1577 | gattServer().onDataWritten(objPtr, memberPtr); |
marcozecchini | 0:9fca2b23d0ba | 1578 | } |
marcozecchini | 0:9fca2b23d0ba | 1579 | |
marcozecchini | 0:9fca2b23d0ba | 1580 | /** |
marcozecchini | 0:9fca2b23d0ba | 1581 | * Set up a callback to be invoked on the peripheral when an attribute is |
marcozecchini | 0:9fca2b23d0ba | 1582 | * being read by a remote client. |
marcozecchini | 0:9fca2b23d0ba | 1583 | * |
marcozecchini | 0:9fca2b23d0ba | 1584 | * @note This functionality may not be available on all underlying stacks. |
marcozecchini | 0:9fca2b23d0ba | 1585 | * You could use GattCharacteristic::setReadAuthorizationCallback() as an |
marcozecchini | 0:9fca2b23d0ba | 1586 | * alternative. |
marcozecchini | 0:9fca2b23d0ba | 1587 | * |
marcozecchini | 0:9fca2b23d0ba | 1588 | * @note It is possible to chain together multiple onDataRead callbacks |
marcozecchini | 0:9fca2b23d0ba | 1589 | * (potentially from different modules of an application) to receive updates |
marcozecchini | 0:9fca2b23d0ba | 1590 | * to characteristics. Services may add their own onDataRead callbacks |
marcozecchini | 0:9fca2b23d0ba | 1591 | * behind the scenes to trap interesting events. |
marcozecchini | 0:9fca2b23d0ba | 1592 | * |
marcozecchini | 0:9fca2b23d0ba | 1593 | * @note It is also possible to set up a callback into a member function of |
marcozecchini | 0:9fca2b23d0ba | 1594 | * some object. |
marcozecchini | 0:9fca2b23d0ba | 1595 | * |
marcozecchini | 0:9fca2b23d0ba | 1596 | * @return BLE_ERROR_NOT_IMPLEMENTED if this functionality isn't available; |
marcozecchini | 0:9fca2b23d0ba | 1597 | * else BLE_ERROR_NONE. |
marcozecchini | 0:9fca2b23d0ba | 1598 | * |
marcozecchini | 0:9fca2b23d0ba | 1599 | * @deprecated You should use the parallel API from GattServer directly and refer to |
marcozecchini | 0:9fca2b23d0ba | 1600 | * GattServer::onDataRead(). A former call |
marcozecchini | 0:9fca2b23d0ba | 1601 | * to ble.onDataRead(...) should be replaced with |
marcozecchini | 0:9fca2b23d0ba | 1602 | * ble.gattServer().onDataRead(...). |
marcozecchini | 0:9fca2b23d0ba | 1603 | */ |
marcozecchini | 0:9fca2b23d0ba | 1604 | MBED_DEPRECATED("ble.gattServer().onDataRead(...)") |
marcozecchini | 0:9fca2b23d0ba | 1605 | ble_error_t onDataRead(void (*callback)(const GattReadCallbackParams *eventDataP)) { |
marcozecchini | 0:9fca2b23d0ba | 1606 | return gattServer().onDataRead(callback); |
marcozecchini | 0:9fca2b23d0ba | 1607 | } |
marcozecchini | 0:9fca2b23d0ba | 1608 | |
marcozecchini | 0:9fca2b23d0ba | 1609 | /** |
marcozecchini | 0:9fca2b23d0ba | 1610 | * The same as onDataRead() but allows an object reference and member function |
marcozecchini | 0:9fca2b23d0ba | 1611 | * to be added to the chain of callbacks. |
marcozecchini | 0:9fca2b23d0ba | 1612 | * |
marcozecchini | 0:9fca2b23d0ba | 1613 | * @deprecated You should use the parallel API from GattServer directly and refer to |
marcozecchini | 0:9fca2b23d0ba | 1614 | * GattServer::onDataRead(). A former call |
marcozecchini | 0:9fca2b23d0ba | 1615 | * to ble.onDataRead(...) should be replaced with |
marcozecchini | 0:9fca2b23d0ba | 1616 | * ble.gattServer().onDataRead(...). |
marcozecchini | 0:9fca2b23d0ba | 1617 | */ |
marcozecchini | 0:9fca2b23d0ba | 1618 | template <typename T> |
marcozecchini | 0:9fca2b23d0ba | 1619 | MBED_DEPRECATED("ble.gattServer().onDataRead(...)") |
marcozecchini | 0:9fca2b23d0ba | 1620 | ble_error_t onDataRead(T * objPtr, void (T::*memberPtr)(const GattReadCallbackParams *context)) { |
marcozecchini | 0:9fca2b23d0ba | 1621 | return gattServer().onDataRead(objPtr, memberPtr); |
marcozecchini | 0:9fca2b23d0ba | 1622 | } |
marcozecchini | 0:9fca2b23d0ba | 1623 | |
marcozecchini | 0:9fca2b23d0ba | 1624 | /** |
marcozecchini | 0:9fca2b23d0ba | 1625 | * Set up a callback for when notifications or indications are enabled for a |
marcozecchini | 0:9fca2b23d0ba | 1626 | * characteristic on the local GattServer. |
marcozecchini | 0:9fca2b23d0ba | 1627 | * |
marcozecchini | 0:9fca2b23d0ba | 1628 | * @deprecated You should use the parallel API from GattServer directly and refer to |
marcozecchini | 0:9fca2b23d0ba | 1629 | * GattServer::onUpdatesEnabled(). A former call |
marcozecchini | 0:9fca2b23d0ba | 1630 | * to ble.onUpdatesEnabled(callback) should be replaced with |
marcozecchini | 0:9fca2b23d0ba | 1631 | * ble.gattServer().onUpdatesEnabled(callback). |
marcozecchini | 0:9fca2b23d0ba | 1632 | */ |
marcozecchini | 0:9fca2b23d0ba | 1633 | MBED_DEPRECATED("ble.gattServer().onUpdatesEnabled(...)") |
marcozecchini | 0:9fca2b23d0ba | 1634 | void onUpdatesEnabled(GattServer::EventCallback_t callback) { |
marcozecchini | 0:9fca2b23d0ba | 1635 | gattServer().onUpdatesEnabled(callback); |
marcozecchini | 0:9fca2b23d0ba | 1636 | } |
marcozecchini | 0:9fca2b23d0ba | 1637 | |
marcozecchini | 0:9fca2b23d0ba | 1638 | /** |
marcozecchini | 0:9fca2b23d0ba | 1639 | * Set up a callback for when notifications or indications are disabled for a |
marcozecchini | 0:9fca2b23d0ba | 1640 | * characteristic on the local GattServer. |
marcozecchini | 0:9fca2b23d0ba | 1641 | * |
marcozecchini | 0:9fca2b23d0ba | 1642 | * @deprecated You should use the parallel API from GattServer directly and refer to |
marcozecchini | 0:9fca2b23d0ba | 1643 | * GattServer::onUpdatesDisabled(). A former call |
marcozecchini | 0:9fca2b23d0ba | 1644 | * to ble.onUpdatesDisabled(callback) should be replaced with |
marcozecchini | 0:9fca2b23d0ba | 1645 | * ble.gattServer().onUpdatesDisabled(callback). |
marcozecchini | 0:9fca2b23d0ba | 1646 | */ |
marcozecchini | 0:9fca2b23d0ba | 1647 | MBED_DEPRECATED("ble.gattServer().onUpdatesDisabled(...)") |
marcozecchini | 0:9fca2b23d0ba | 1648 | void onUpdatesDisabled(GattServer::EventCallback_t callback) { |
marcozecchini | 0:9fca2b23d0ba | 1649 | gattServer().onUpdatesDisabled(callback); |
marcozecchini | 0:9fca2b23d0ba | 1650 | } |
marcozecchini | 0:9fca2b23d0ba | 1651 | |
marcozecchini | 0:9fca2b23d0ba | 1652 | /** |
marcozecchini | 0:9fca2b23d0ba | 1653 | * Set up a callback for when the GATT server receives a response for an |
marcozecchini | 0:9fca2b23d0ba | 1654 | * indication event sent previously. |
marcozecchini | 0:9fca2b23d0ba | 1655 | * |
marcozecchini | 0:9fca2b23d0ba | 1656 | * @deprecated You should use the parallel API from GattServer directly and refer to |
marcozecchini | 0:9fca2b23d0ba | 1657 | * GattServer::onConfirmationReceived(). A former call |
marcozecchini | 0:9fca2b23d0ba | 1658 | * to ble.onConfirmationReceived(callback) should be replaced with |
marcozecchini | 0:9fca2b23d0ba | 1659 | * ble.gattServer().onConfirmationReceived(callback). |
marcozecchini | 0:9fca2b23d0ba | 1660 | */ |
marcozecchini | 0:9fca2b23d0ba | 1661 | MBED_DEPRECATED("ble.gattServer().onConfirmationReceived(...)") |
marcozecchini | 0:9fca2b23d0ba | 1662 | void onConfirmationReceived(GattServer::EventCallback_t callback) { |
marcozecchini | 0:9fca2b23d0ba | 1663 | gattServer().onConfirmationReceived(callback); |
marcozecchini | 0:9fca2b23d0ba | 1664 | } |
marcozecchini | 0:9fca2b23d0ba | 1665 | |
marcozecchini | 0:9fca2b23d0ba | 1666 | /** |
marcozecchini | 0:9fca2b23d0ba | 1667 | * Set up a callback for when the security setup procedure (key generation |
marcozecchini | 0:9fca2b23d0ba | 1668 | * and exchange) for a link has started. This will be skipped for bonded |
marcozecchini | 0:9fca2b23d0ba | 1669 | * devices. The callback is passed in parameters received from the peer's |
marcozecchini | 0:9fca2b23d0ba | 1670 | * security request: bool allowBonding, bool requireMITM and |
marcozecchini | 0:9fca2b23d0ba | 1671 | * SecurityIOCapabilities_t. |
marcozecchini | 0:9fca2b23d0ba | 1672 | * |
marcozecchini | 0:9fca2b23d0ba | 1673 | * @deprecated You should use the parallel API from SecurityManager directly and refer to |
marcozecchini | 0:9fca2b23d0ba | 1674 | * SecurityManager::onSecuritySetupInitiated(). A former |
marcozecchini | 0:9fca2b23d0ba | 1675 | * call to ble.onSecuritySetupInitiated(callback) should be replaced with |
marcozecchini | 0:9fca2b23d0ba | 1676 | * ble.securityManager().onSecuritySetupInitiated(callback). |
marcozecchini | 0:9fca2b23d0ba | 1677 | */ |
marcozecchini | 0:9fca2b23d0ba | 1678 | MBED_DEPRECATED("ble.securityManager().onSecuritySetupInitiated(callback)") |
marcozecchini | 0:9fca2b23d0ba | 1679 | void onSecuritySetupInitiated(SecurityManager::SecuritySetupInitiatedCallback_t callback) { |
marcozecchini | 0:9fca2b23d0ba | 1680 | securityManager().onSecuritySetupInitiated(callback); |
marcozecchini | 0:9fca2b23d0ba | 1681 | } |
marcozecchini | 0:9fca2b23d0ba | 1682 | |
marcozecchini | 0:9fca2b23d0ba | 1683 | /** |
marcozecchini | 0:9fca2b23d0ba | 1684 | * Set up a callback for when the security setup procedure (key generation |
marcozecchini | 0:9fca2b23d0ba | 1685 | * and exchange) for a link has completed. This will be skipped for bonded |
marcozecchini | 0:9fca2b23d0ba | 1686 | * devices. The callback is passed in the success/failure status of the |
marcozecchini | 0:9fca2b23d0ba | 1687 | * security setup procedure. |
marcozecchini | 0:9fca2b23d0ba | 1688 | * |
marcozecchini | 0:9fca2b23d0ba | 1689 | * @deprecated You should use the parallel API from SecurityManager directly and refer to |
marcozecchini | 0:9fca2b23d0ba | 1690 | * SecurityManager::onSecuritySetupCompleted(). A former |
marcozecchini | 0:9fca2b23d0ba | 1691 | * call to ble.onSecuritySetupCompleted(callback) should be replaced with |
marcozecchini | 0:9fca2b23d0ba | 1692 | * ble.securityManager().onSecuritySetupCompleted(callback). |
marcozecchini | 0:9fca2b23d0ba | 1693 | */ |
marcozecchini | 0:9fca2b23d0ba | 1694 | MBED_DEPRECATED("ble.securityManager().onSecuritySetupCompleted(callback)") |
marcozecchini | 0:9fca2b23d0ba | 1695 | void onSecuritySetupCompleted(SecurityManager::SecuritySetupCompletedCallback_t callback) { |
marcozecchini | 0:9fca2b23d0ba | 1696 | securityManager().onSecuritySetupCompleted(callback); |
marcozecchini | 0:9fca2b23d0ba | 1697 | } |
marcozecchini | 0:9fca2b23d0ba | 1698 | |
marcozecchini | 0:9fca2b23d0ba | 1699 | /** |
marcozecchini | 0:9fca2b23d0ba | 1700 | * Set up a callback for when a link with the peer is secured. For bonded |
marcozecchini | 0:9fca2b23d0ba | 1701 | * devices, subsequent reconnections with a bonded peer will result only in |
marcozecchini | 0:9fca2b23d0ba | 1702 | * this callback when the link is secured, and setup procedures will not |
marcozecchini | 0:9fca2b23d0ba | 1703 | * occur unless the bonding information is either lost or deleted on either |
marcozecchini | 0:9fca2b23d0ba | 1704 | * or both sides. The callback is passed in a SecurityManager::SecurityMode_t according |
marcozecchini | 0:9fca2b23d0ba | 1705 | * to the level of security in effect for the secured link. |
marcozecchini | 0:9fca2b23d0ba | 1706 | * |
marcozecchini | 0:9fca2b23d0ba | 1707 | * @deprecated You should use the parallel API from SecurityManager directly and refer to |
marcozecchini | 0:9fca2b23d0ba | 1708 | * SecurityManager::onLinkSecured(). A former |
marcozecchini | 0:9fca2b23d0ba | 1709 | * call to ble.onLinkSecured(callback) should be replaced with |
marcozecchini | 0:9fca2b23d0ba | 1710 | * ble.securityManager().onLinkSecured(callback). |
marcozecchini | 0:9fca2b23d0ba | 1711 | */ |
marcozecchini | 0:9fca2b23d0ba | 1712 | MBED_DEPRECATED("ble.securityManager().onLinkSecured(callback)") |
marcozecchini | 0:9fca2b23d0ba | 1713 | void onLinkSecured(SecurityManager::LinkSecuredCallback_t callback) { |
marcozecchini | 0:9fca2b23d0ba | 1714 | securityManager().onLinkSecured(callback); |
marcozecchini | 0:9fca2b23d0ba | 1715 | } |
marcozecchini | 0:9fca2b23d0ba | 1716 | |
marcozecchini | 0:9fca2b23d0ba | 1717 | /** |
marcozecchini | 0:9fca2b23d0ba | 1718 | * Set up a callback for successful bonding, meaning that link-specific security |
marcozecchini | 0:9fca2b23d0ba | 1719 | * context is stored persistently for a peer device. |
marcozecchini | 0:9fca2b23d0ba | 1720 | * |
marcozecchini | 0:9fca2b23d0ba | 1721 | * @deprecated You should use the parallel API from SecurityManager directly and refer to |
marcozecchini | 0:9fca2b23d0ba | 1722 | * SecurityManager::onSecurityContextStored(). A former |
marcozecchini | 0:9fca2b23d0ba | 1723 | * call to ble.onSecurityContextStored(callback) should be replaced with |
marcozecchini | 0:9fca2b23d0ba | 1724 | * ble.securityManager().onSecurityContextStored(callback). |
marcozecchini | 0:9fca2b23d0ba | 1725 | */ |
marcozecchini | 0:9fca2b23d0ba | 1726 | MBED_DEPRECATED("ble.securityManager().onSecurityContextStored(callback)") |
marcozecchini | 0:9fca2b23d0ba | 1727 | void onSecurityContextStored(SecurityManager::HandleSpecificEvent_t callback) { |
marcozecchini | 0:9fca2b23d0ba | 1728 | securityManager().onSecurityContextStored(callback); |
marcozecchini | 0:9fca2b23d0ba | 1729 | } |
marcozecchini | 0:9fca2b23d0ba | 1730 | |
marcozecchini | 0:9fca2b23d0ba | 1731 | /** |
marcozecchini | 0:9fca2b23d0ba | 1732 | * Set up a callback for when the passkey needs to be displayed on a |
marcozecchini | 0:9fca2b23d0ba | 1733 | * peripheral with DISPLAY capability. This happens when security is |
marcozecchini | 0:9fca2b23d0ba | 1734 | * configured to prevent man-in-the-middle attacks, and the peers need to exchange |
marcozecchini | 0:9fca2b23d0ba | 1735 | * a passkey (or PIN) to authenticate the connection |
marcozecchini | 0:9fca2b23d0ba | 1736 | * attempt. |
marcozecchini | 0:9fca2b23d0ba | 1737 | * |
marcozecchini | 0:9fca2b23d0ba | 1738 | * @deprecated You should use the parallel API from SecurityManager directly and refer to |
marcozecchini | 0:9fca2b23d0ba | 1739 | * SecurityManager::onPasskeyDisplay(). A former |
marcozecchini | 0:9fca2b23d0ba | 1740 | * call to ble.onPasskeyDisplay(callback) should be replaced with |
marcozecchini | 0:9fca2b23d0ba | 1741 | * ble.securityManager().onPasskeyDisplay(callback). |
marcozecchini | 0:9fca2b23d0ba | 1742 | */ |
marcozecchini | 0:9fca2b23d0ba | 1743 | MBED_DEPRECATED("ble.securityManager().onPasskeyDisplay(callback)") |
marcozecchini | 0:9fca2b23d0ba | 1744 | void onPasskeyDisplay(SecurityManager::PasskeyDisplayCallback_t callback) { |
marcozecchini | 0:9fca2b23d0ba | 1745 | return securityManager().onPasskeyDisplay(callback); |
marcozecchini | 0:9fca2b23d0ba | 1746 | } |
marcozecchini | 0:9fca2b23d0ba | 1747 | |
marcozecchini | 0:9fca2b23d0ba | 1748 | private: |
marcozecchini | 0:9fca2b23d0ba | 1749 | friend class BLEInstanceBase; |
marcozecchini | 0:9fca2b23d0ba | 1750 | |
marcozecchini | 0:9fca2b23d0ba | 1751 | /** |
marcozecchini | 0:9fca2b23d0ba | 1752 | * This function allows the BLE stack to signal that there is work to do and |
marcozecchini | 0:9fca2b23d0ba | 1753 | * event processing should be done (BLE::processEvent()). |
marcozecchini | 0:9fca2b23d0ba | 1754 | * |
marcozecchini | 0:9fca2b23d0ba | 1755 | * @note This function should be called by the port of BLE_API. It is not |
marcozecchini | 0:9fca2b23d0ba | 1756 | * meant to be used by end users. |
marcozecchini | 0:9fca2b23d0ba | 1757 | */ |
marcozecchini | 0:9fca2b23d0ba | 1758 | void signalEventsToProcess(); |
marcozecchini | 0:9fca2b23d0ba | 1759 | |
marcozecchini | 0:9fca2b23d0ba | 1760 | /** |
marcozecchini | 0:9fca2b23d0ba | 1761 | * Implementation of init() [internal to BLE_API]. |
marcozecchini | 0:9fca2b23d0ba | 1762 | * |
marcozecchini | 0:9fca2b23d0ba | 1763 | * The implementation is separated into a private method because it isn't |
marcozecchini | 0:9fca2b23d0ba | 1764 | * suitable to be included in the header. |
marcozecchini | 0:9fca2b23d0ba | 1765 | */ |
marcozecchini | 0:9fca2b23d0ba | 1766 | ble_error_t initImplementation( |
marcozecchini | 0:9fca2b23d0ba | 1767 | FunctionPointerWithContext<InitializationCompleteCallbackContext *> callback |
marcozecchini | 0:9fca2b23d0ba | 1768 | ); |
marcozecchini | 0:9fca2b23d0ba | 1769 | |
marcozecchini | 0:9fca2b23d0ba | 1770 | private: |
marcozecchini | 0:9fca2b23d0ba | 1771 | // Prevent copy construction and copy assignment of BLE. |
marcozecchini | 0:9fca2b23d0ba | 1772 | BLE(const BLE&); |
marcozecchini | 0:9fca2b23d0ba | 1773 | BLE &operator=(const BLE &); |
marcozecchini | 0:9fca2b23d0ba | 1774 | |
marcozecchini | 0:9fca2b23d0ba | 1775 | private: |
marcozecchini | 0:9fca2b23d0ba | 1776 | InstanceID_t instanceID; |
marcozecchini | 0:9fca2b23d0ba | 1777 | BLEInstanceBase *transport; /* The device-specific backend */ |
marcozecchini | 0:9fca2b23d0ba | 1778 | OnEventsToProcessCallback_t whenEventsToProcess; |
marcozecchini | 0:9fca2b23d0ba | 1779 | bool event_signaled; |
marcozecchini | 0:9fca2b23d0ba | 1780 | }; |
marcozecchini | 0:9fca2b23d0ba | 1781 | |
marcozecchini | 0:9fca2b23d0ba | 1782 | /** |
marcozecchini | 0:9fca2b23d0ba | 1783 | * @deprecated This type alias is retained for the sake of compatibility with |
marcozecchini | 0:9fca2b23d0ba | 1784 | * older code. This will be dropped at some point. |
marcozecchini | 0:9fca2b23d0ba | 1785 | */ |
marcozecchini | 0:9fca2b23d0ba | 1786 | typedef BLE BLEDevice; |
marcozecchini | 0:9fca2b23d0ba | 1787 | |
marcozecchini | 0:9fca2b23d0ba | 1788 | /** |
marcozecchini | 0:9fca2b23d0ba | 1789 | * @namespace ble Entry namespace for all %BLE API definitions. |
marcozecchini | 0:9fca2b23d0ba | 1790 | */ |
marcozecchini | 0:9fca2b23d0ba | 1791 | |
marcozecchini | 0:9fca2b23d0ba | 1792 | /** |
marcozecchini | 0:9fca2b23d0ba | 1793 | * @} |
marcozecchini | 0:9fca2b23d0ba | 1794 | */ |
marcozecchini | 0:9fca2b23d0ba | 1795 | |
marcozecchini | 0:9fca2b23d0ba | 1796 | #endif /* ifndef MBED_BLE_H__ */ |