mbed-os5 only for TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Committer:
kenjiArai
Date:
Tue Dec 31 06:02:27 2019 +0000
Revision:
1:9db0e321a9f4
Parent:
0:5b88d5760320
updated based on mbed-os5.15.0

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kenjiArai 0:5b88d5760320 1 /* mbed Microcontroller Library
kenjiArai 0:5b88d5760320 2 * Copyright (c) 2017-2017 ARM Limited
kenjiArai 0:5b88d5760320 3 *
kenjiArai 0:5b88d5760320 4 * Licensed under the Apache License, Version 2.0 (the "License");
kenjiArai 0:5b88d5760320 5 * you may not use this file except in compliance with the License.
kenjiArai 0:5b88d5760320 6 * You may obtain a copy of the License at
kenjiArai 0:5b88d5760320 7 *
kenjiArai 0:5b88d5760320 8 * http://www.apache.org/licenses/LICENSE-2.0
kenjiArai 0:5b88d5760320 9 *
kenjiArai 0:5b88d5760320 10 * Unless required by applicable law or agreed to in writing, software
kenjiArai 0:5b88d5760320 11 * distributed under the License is distributed on an "AS IS" BASIS,
kenjiArai 0:5b88d5760320 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
kenjiArai 0:5b88d5760320 13 * See the License for the specific language governing permissions and
kenjiArai 0:5b88d5760320 14 * limitations under the License.
kenjiArai 0:5b88d5760320 15 */
kenjiArai 0:5b88d5760320 16
kenjiArai 0:5b88d5760320 17 #ifndef MBED_BLE_GENERIC_GAP
kenjiArai 0:5b88d5760320 18 #define MBED_BLE_GENERIC_GAP
kenjiArai 0:5b88d5760320 19
kenjiArai 0:5b88d5760320 20 #include <algorithm>
kenjiArai 0:5b88d5760320 21
kenjiArai 0:5b88d5760320 22 #include "ble/BLEProtocol.h"
kenjiArai 0:5b88d5760320 23 #include "ble/Gap.h"
kenjiArai 0:5b88d5760320 24 #include "ble/pal/PalGap.h"
kenjiArai 0:5b88d5760320 25 #include "ble/pal/GapEvents.h"
kenjiArai 0:5b88d5760320 26 #include "ble/pal/GapTypes.h"
kenjiArai 0:5b88d5760320 27 #include "ble/BLETypes.h"
kenjiArai 0:5b88d5760320 28 #include "ble/pal/GenericAccessService.h"
kenjiArai 0:5b88d5760320 29 #include "ble/pal/EventQueue.h"
kenjiArai 0:5b88d5760320 30 #include "ble/pal/ConnectionEventMonitor.h"
kenjiArai 0:5b88d5760320 31 #include "ble/pal/Deprecated.h"
kenjiArai 0:5b88d5760320 32
kenjiArai 0:5b88d5760320 33 #include "drivers/LowPowerTimeout.h"
kenjiArai 0:5b88d5760320 34 #include "drivers/LowPowerTicker.h"
kenjiArai 0:5b88d5760320 35 #include "platform/mbed_error.h"
kenjiArai 0:5b88d5760320 36
kenjiArai 0:5b88d5760320 37 namespace ble {
kenjiArai 0:5b88d5760320 38 namespace generic {
kenjiArai 0:5b88d5760320 39 /**
kenjiArai 0:5b88d5760320 40 * Generic implementation of the Gap class.
kenjiArai 0:5b88d5760320 41 * It requires a pal::Gap and a pal::GenericAccessService injected at
kenjiArai 0:5b88d5760320 42 * construction site.
kenjiArai 0:5b88d5760320 43 *
kenjiArai 0:5b88d5760320 44 * @attention: Not part of the public interface of BLE API.
kenjiArai 0:5b88d5760320 45 */
kenjiArai 0:5b88d5760320 46 template<
kenjiArai 0:5b88d5760320 47 template<class> class TPalGap,
kenjiArai 0:5b88d5760320 48 class PalSecurityManager,
kenjiArai 0:5b88d5760320 49 class ConnectionEventMonitorEventHandler
kenjiArai 0:5b88d5760320 50 >
kenjiArai 0:5b88d5760320 51 class GenericGap :
kenjiArai 0:5b88d5760320 52 public interface::LegacyGap<
kenjiArai 0:5b88d5760320 53 GenericGap<TPalGap, PalSecurityManager, ConnectionEventMonitorEventHandler>
kenjiArai 0:5b88d5760320 54 >,
kenjiArai 0:5b88d5760320 55 public pal::ConnectionEventMonitor<
kenjiArai 0:5b88d5760320 56 ConnectionEventMonitorEventHandler
kenjiArai 0:5b88d5760320 57 >,
kenjiArai 0:5b88d5760320 58 public pal::GapEventHandler<
kenjiArai 0:5b88d5760320 59 GenericGap<TPalGap, PalSecurityManager, ConnectionEventMonitorEventHandler>
kenjiArai 0:5b88d5760320 60 >
kenjiArai 0:5b88d5760320 61 {
kenjiArai 0:5b88d5760320 62 // Typedef of base and companion classes .
kenjiArai 0:5b88d5760320 63 typedef ::ble::interface::LegacyGap<GenericGap> LegacyGap;
kenjiArai 0:5b88d5760320 64 typedef ::ble::interface::Gap<GenericGap> Gap;
kenjiArai 0:5b88d5760320 65 typedef pal::ConnectionEventMonitor<ConnectionEventMonitorEventHandler> ConnectionEventMonitor;
kenjiArai 0:5b88d5760320 66 typedef TPalGap<GenericGap> PalGap;
kenjiArai 0:5b88d5760320 67 typedef pal::GapEventHandler<GenericGap> PalGapEventHandler;
kenjiArai 0:5b88d5760320 68
kenjiArai 0:5b88d5760320 69 // Friendship with base classes
kenjiArai 0:5b88d5760320 70 friend LegacyGap;
kenjiArai 0:5b88d5760320 71 friend Gap;
kenjiArai 0:5b88d5760320 72 friend ConnectionEventMonitor;
kenjiArai 0:5b88d5760320 73 friend pal::GapEventHandler<GenericGap>;
kenjiArai 0:5b88d5760320 74 friend PalGap;
kenjiArai 0:5b88d5760320 75
kenjiArai 0:5b88d5760320 76 // Imports from LegacyGap
kenjiArai 0:5b88d5760320 77 using LegacyGap::_eventHandler;
kenjiArai 0:5b88d5760320 78 using LegacyGap::default_peripheral_privacy_configuration;
kenjiArai 0:5b88d5760320 79 using LegacyGap::default_central_privacy_configuration;
kenjiArai 0:5b88d5760320 80 using LegacyGap::state;
kenjiArai 0:5b88d5760320 81
kenjiArai 0:5b88d5760320 82 typedef typename LegacyGap::Address_t Address_t;
kenjiArai 0:5b88d5760320 83 typedef typename LegacyGap::PeerAddressType_t PeerAddressType_t;
kenjiArai 0:5b88d5760320 84 typedef typename LegacyGap::ConnectionParams_t ConnectionParams_t;
kenjiArai 0:5b88d5760320 85 typedef typename LegacyGap::Handle_t Handle_t;
kenjiArai 0:5b88d5760320 86 typedef typename LegacyGap::CodedSymbolPerBit_t CodedSymbolPerBit_t;
kenjiArai 0:5b88d5760320 87 typedef typename LegacyGap::Whitelist_t Whitelist_t;
kenjiArai 0:5b88d5760320 88 typedef typename LegacyGap::DisconnectionReason_t DisconnectionReason_t;
kenjiArai 0:5b88d5760320 89 typedef typename LegacyGap::AdvertisingPolicyMode_t AdvertisingPolicyMode_t;
kenjiArai 0:5b88d5760320 90 typedef typename LegacyGap::ScanningPolicyMode_t ScanningPolicyMode_t;
kenjiArai 0:5b88d5760320 91 typedef typename LegacyGap::InitiatorPolicyMode_t InitiatorPolicyMode_t;
kenjiArai 0:5b88d5760320 92 typedef typename LegacyGap::PeripheralPrivacyConfiguration_t PeripheralPrivacyConfiguration_t;
kenjiArai 0:5b88d5760320 93 typedef typename LegacyGap::CentralPrivacyConfiguration_t CentralPrivacyConfiguration_t;
kenjiArai 0:5b88d5760320 94 typedef typename LegacyGap::Role_t Role_t;
kenjiArai 0:5b88d5760320 95
kenjiArai 0:5b88d5760320 96 // Imports from Gap
kenjiArai 0:5b88d5760320 97 #if BLE_ROLE_BROADCASTER
kenjiArai 0:5b88d5760320 98 using ble::interface::Gap<GenericGap>::getMaxAdvertisingSetNumber;
kenjiArai 0:5b88d5760320 99 using ble::interface::Gap<GenericGap>::getMaxAdvertisingDataLength;
kenjiArai 0:5b88d5760320 100 #endif // BLE_ROLE_BROADCASTER
kenjiArai 0:5b88d5760320 101 using ble::interface::Gap<GenericGap>::isFeatureSupported;
kenjiArai 0:5b88d5760320 102 using ble::interface::Gap<GenericGap>::useVersionOneAPI;
kenjiArai 0:5b88d5760320 103 using ble::interface::Gap<GenericGap>::useVersionTwoAPI;
kenjiArai 0:5b88d5760320 104
kenjiArai 0:5b88d5760320 105 // Imports from PalGap EventHandler
kenjiArai 0:5b88d5760320 106 using PalGapEventHandler::on_scan_timeout;
kenjiArai 0:5b88d5760320 107
kenjiArai 0:5b88d5760320 108 // Imports from ConnectionEventMonitor
kenjiArai 0:5b88d5760320 109 using ConnectionEventMonitor::_connection_event_handler;
kenjiArai 0:5b88d5760320 110 using ConnectionEventMonitor::set_connection_event_handler;
kenjiArai 0:5b88d5760320 111
kenjiArai 0:5b88d5760320 112 public:
kenjiArai 0:5b88d5760320 113 /* TODO: move to config */
kenjiArai 0:5b88d5760320 114 static const uint8_t MAX_ADVERTISING_SETS = 15;
kenjiArai 0:5b88d5760320 115
kenjiArai 0:5b88d5760320 116 /**
kenjiArai 0:5b88d5760320 117 * Construct a GenericGap.
kenjiArai 0:5b88d5760320 118 *
kenjiArai 0:5b88d5760320 119 * @param event_queue Event queue used to serialise execution.
kenjiArai 0:5b88d5760320 120 *
kenjiArai 0:5b88d5760320 121 * @param pal_gap GAP Platform abstraction instance containing the base GAP
kenjiArai 0:5b88d5760320 122 * primitives.
kenjiArai 0:5b88d5760320 123 *
kenjiArai 0:5b88d5760320 124 * @param generic_access_service Platform abstraction instance managing
kenjiArai 0:5b88d5760320 125 * the GATT generic access service.
kenjiArai 0:5b88d5760320 126 *
kenjiArai 0:5b88d5760320 127 * @param pal_sm Security Manager Platform abstraction instance containing the base
kenjiArai 0:5b88d5760320 128 * Security Manager primitives.
kenjiArai 0:5b88d5760320 129 */
kenjiArai 0:5b88d5760320 130 GenericGap(
kenjiArai 0:5b88d5760320 131 pal::EventQueue &event_queue,
kenjiArai 0:5b88d5760320 132 PalGap &pal_gap,
kenjiArai 0:5b88d5760320 133 pal::GenericAccessService &generic_access_service,
kenjiArai 0:5b88d5760320 134 PalSecurityManager &pal_sm
kenjiArai 0:5b88d5760320 135 );
kenjiArai 0:5b88d5760320 136
kenjiArai 0:5b88d5760320 137 /**
kenjiArai 0:5b88d5760320 138 * @see Gap::~Gap
kenjiArai 0:5b88d5760320 139 */
kenjiArai 0:5b88d5760320 140 ~GenericGap();
kenjiArai 0:5b88d5760320 141
kenjiArai 0:5b88d5760320 142 /** @copydoc Gap::IsFeatureSupported
kenjiArai 0:5b88d5760320 143 */
kenjiArai 0:5b88d5760320 144 bool isFeatureSupported_(
kenjiArai 0:5b88d5760320 145 controller_supported_features_t feature
kenjiArai 0:5b88d5760320 146 );
kenjiArai 0:5b88d5760320 147
kenjiArai 0:5b88d5760320 148 /** @copydoc Gap::getMaxAdvertisingSetNumber
kenjiArai 0:5b88d5760320 149 */
kenjiArai 0:5b88d5760320 150 uint8_t getMaxAdvertisingSetNumber_();
kenjiArai 0:5b88d5760320 151
kenjiArai 0:5b88d5760320 152 /** @copydoc Gap::getMaxAdvertisingDataLength
kenjiArai 0:5b88d5760320 153 */
kenjiArai 0:5b88d5760320 154 uint16_t getMaxAdvertisingDataLength_();
kenjiArai 0:5b88d5760320 155
kenjiArai 0:5b88d5760320 156 /** @copydoc Gap::getMaxConnectableAdvertisingDataLength
kenjiArai 0:5b88d5760320 157 */
kenjiArai 0:5b88d5760320 158 uint16_t getMaxConnectableAdvertisingDataLength_();
kenjiArai 0:5b88d5760320 159
kenjiArai 0:5b88d5760320 160 /** @copydoc Gap::getMaxActiveSetAdvertisingDataLength
kenjiArai 0:5b88d5760320 161 */
kenjiArai 0:5b88d5760320 162 uint16_t getMaxActiveSetAdvertisingDataLength_();
kenjiArai 0:5b88d5760320 163
kenjiArai 0:5b88d5760320 164 /** @copydoc Gap::createAdvertisingSet
kenjiArai 0:5b88d5760320 165 */
kenjiArai 0:5b88d5760320 166 ble_error_t createAdvertisingSet_(
kenjiArai 0:5b88d5760320 167 advertising_handle_t *handle,
kenjiArai 0:5b88d5760320 168 const AdvertisingParameters &parameters
kenjiArai 0:5b88d5760320 169 );
kenjiArai 0:5b88d5760320 170
kenjiArai 0:5b88d5760320 171 /** @copydoc Gap::destroyAdvertisingSet
kenjiArai 0:5b88d5760320 172 */
kenjiArai 0:5b88d5760320 173 ble_error_t destroyAdvertisingSet_(advertising_handle_t handle);
kenjiArai 0:5b88d5760320 174
kenjiArai 0:5b88d5760320 175 /** @copydoc Gap::setAdvertisingParams
kenjiArai 0:5b88d5760320 176 */
kenjiArai 0:5b88d5760320 177 ble_error_t setAdvertisingParameters_(
kenjiArai 0:5b88d5760320 178 advertising_handle_t handle,
kenjiArai 0:5b88d5760320 179 const AdvertisingParameters &params
kenjiArai 0:5b88d5760320 180 );
kenjiArai 0:5b88d5760320 181
kenjiArai 0:5b88d5760320 182 /** @copydoc Gap::setAdvertisingPayload
kenjiArai 0:5b88d5760320 183 */
kenjiArai 0:5b88d5760320 184 ble_error_t setAdvertisingPayload_(
kenjiArai 0:5b88d5760320 185 advertising_handle_t handle,
kenjiArai 0:5b88d5760320 186 Span<const uint8_t> payload
kenjiArai 0:5b88d5760320 187 );
kenjiArai 0:5b88d5760320 188
kenjiArai 0:5b88d5760320 189 /** @copydoc Gap::setAdvertisingScanResponse
kenjiArai 0:5b88d5760320 190 */
kenjiArai 0:5b88d5760320 191 ble_error_t setAdvertisingScanResponse_(
kenjiArai 0:5b88d5760320 192 advertising_handle_t handle,
kenjiArai 0:5b88d5760320 193 Span<const uint8_t> response
kenjiArai 0:5b88d5760320 194 );
kenjiArai 0:5b88d5760320 195
kenjiArai 0:5b88d5760320 196 /** @copydoc Gap::startAdvertising
kenjiArai 0:5b88d5760320 197 */
kenjiArai 0:5b88d5760320 198 ble_error_t startAdvertising_(
kenjiArai 0:5b88d5760320 199 advertising_handle_t handle,
kenjiArai 0:5b88d5760320 200 adv_duration_t maxDuration,
kenjiArai 0:5b88d5760320 201 uint8_t maxEvents
kenjiArai 0:5b88d5760320 202 );
kenjiArai 0:5b88d5760320 203
kenjiArai 0:5b88d5760320 204 /** @copydoc Gap::stopAdvertising
kenjiArai 0:5b88d5760320 205 */
kenjiArai 0:5b88d5760320 206 ble_error_t stopAdvertising_(advertising_handle_t handle);
kenjiArai 0:5b88d5760320 207
kenjiArai 0:5b88d5760320 208 /** @copydoc Gap::isAdvertisingActive
kenjiArai 0:5b88d5760320 209 */
kenjiArai 0:5b88d5760320 210 bool isAdvertisingActive_(advertising_handle_t handle);
kenjiArai 0:5b88d5760320 211
kenjiArai 0:5b88d5760320 212 /** @copydoc Gap::setPeriodicAdvertisingParameters
kenjiArai 0:5b88d5760320 213 */
kenjiArai 0:5b88d5760320 214 ble_error_t setPeriodicAdvertisingParameters_(
kenjiArai 0:5b88d5760320 215 advertising_handle_t handle,
kenjiArai 0:5b88d5760320 216 periodic_interval_t periodicAdvertisingIntervalMin,
kenjiArai 0:5b88d5760320 217 periodic_interval_t periodicAdvertisingIntervalMax,
kenjiArai 0:5b88d5760320 218 bool advertiseTxPower
kenjiArai 0:5b88d5760320 219 );
kenjiArai 0:5b88d5760320 220
kenjiArai 0:5b88d5760320 221 /** @copydoc Gap::setPeriodicAdvertisingPayload
kenjiArai 0:5b88d5760320 222 */
kenjiArai 0:5b88d5760320 223 ble_error_t setPeriodicAdvertisingPayload_(
kenjiArai 0:5b88d5760320 224 advertising_handle_t handle,
kenjiArai 0:5b88d5760320 225 Span<const uint8_t> payload
kenjiArai 0:5b88d5760320 226 );
kenjiArai 0:5b88d5760320 227
kenjiArai 0:5b88d5760320 228 /** @copydoc Gap::startPeriodicAdvertising
kenjiArai 0:5b88d5760320 229 */
kenjiArai 0:5b88d5760320 230 ble_error_t startPeriodicAdvertising_(advertising_handle_t handle);
kenjiArai 0:5b88d5760320 231
kenjiArai 0:5b88d5760320 232 /** @copydoc Gap::stopPeriodicAdvertising
kenjiArai 0:5b88d5760320 233 */
kenjiArai 0:5b88d5760320 234 ble_error_t stopPeriodicAdvertising_(advertising_handle_t handle);
kenjiArai 0:5b88d5760320 235
kenjiArai 0:5b88d5760320 236 /** @copydoc Gap::isPeriodicAdvertisingActive
kenjiArai 0:5b88d5760320 237 */
kenjiArai 0:5b88d5760320 238 bool isPeriodicAdvertisingActive_(advertising_handle_t handle);
kenjiArai 0:5b88d5760320 239
kenjiArai 0:5b88d5760320 240 /** @copydoc Gap::setScanParameters
kenjiArai 0:5b88d5760320 241 */
kenjiArai 0:5b88d5760320 242 ble_error_t setScanParameters_(const ScanParameters &params);
kenjiArai 0:5b88d5760320 243
kenjiArai 0:5b88d5760320 244 /** @copydoc Gap::startScan
kenjiArai 0:5b88d5760320 245 */
kenjiArai 0:5b88d5760320 246 ble_error_t startScan_(
kenjiArai 0:5b88d5760320 247 scan_duration_t duration,
kenjiArai 0:5b88d5760320 248 duplicates_filter_t filtering,
kenjiArai 0:5b88d5760320 249 scan_period_t period
kenjiArai 0:5b88d5760320 250 );
kenjiArai 0:5b88d5760320 251
kenjiArai 0:5b88d5760320 252 /** @copydoc Gap::createSync
kenjiArai 0:5b88d5760320 253 */
kenjiArai 0:5b88d5760320 254 ble_error_t createSync_(
kenjiArai 0:5b88d5760320 255 peer_address_type_t peerAddressType,
kenjiArai 0:5b88d5760320 256 const ble::address_t &peerAddress,
kenjiArai 0:5b88d5760320 257 advertising_sid_t sid,
kenjiArai 0:5b88d5760320 258 slave_latency_t maxPacketSkip,
kenjiArai 0:5b88d5760320 259 sync_timeout_t timeout
kenjiArai 0:5b88d5760320 260 );
kenjiArai 0:5b88d5760320 261
kenjiArai 0:5b88d5760320 262 /** @copydoc Gap::createSync
kenjiArai 0:5b88d5760320 263 */
kenjiArai 0:5b88d5760320 264 ble_error_t createSync_(
kenjiArai 0:5b88d5760320 265 slave_latency_t maxPacketSkip,
kenjiArai 0:5b88d5760320 266 sync_timeout_t timeout
kenjiArai 0:5b88d5760320 267 );
kenjiArai 0:5b88d5760320 268
kenjiArai 0:5b88d5760320 269 /** @copydoc Gap::cancelCreateSync
kenjiArai 0:5b88d5760320 270 */
kenjiArai 0:5b88d5760320 271 ble_error_t cancelCreateSync_();
kenjiArai 0:5b88d5760320 272
kenjiArai 0:5b88d5760320 273 /** @copydoc Gap::terminateSync
kenjiArai 0:5b88d5760320 274 */
kenjiArai 0:5b88d5760320 275 ble_error_t terminateSync_(periodic_sync_handle_t handle);
kenjiArai 0:5b88d5760320 276
kenjiArai 0:5b88d5760320 277 /** @copydoc Gap::addDeviceToPeriodicAdvertiserList
kenjiArai 0:5b88d5760320 278 */
kenjiArai 0:5b88d5760320 279 ble_error_t addDeviceToPeriodicAdvertiserList_(
kenjiArai 0:5b88d5760320 280 peer_address_type_t peerAddressType,
kenjiArai 0:5b88d5760320 281 const ble::address_t &peerAddress,
kenjiArai 0:5b88d5760320 282 advertising_sid_t sid
kenjiArai 0:5b88d5760320 283 );
kenjiArai 0:5b88d5760320 284
kenjiArai 0:5b88d5760320 285 /** @copydoc Gap::removeDeviceFromPeriodicAdvertiserList
kenjiArai 0:5b88d5760320 286 */
kenjiArai 0:5b88d5760320 287 ble_error_t removeDeviceFromPeriodicAdvertiserList_(
kenjiArai 0:5b88d5760320 288 peer_address_type_t peerAddressType,
kenjiArai 0:5b88d5760320 289 const ble::address_t &peerAddress,
kenjiArai 0:5b88d5760320 290 advertising_sid_t sid
kenjiArai 0:5b88d5760320 291 );
kenjiArai 0:5b88d5760320 292
kenjiArai 0:5b88d5760320 293 /** @copydoc Gap::clearPeriodicAdvertiserList
kenjiArai 0:5b88d5760320 294 */
kenjiArai 0:5b88d5760320 295 ble_error_t clearPeriodicAdvertiserList_();
kenjiArai 0:5b88d5760320 296
kenjiArai 0:5b88d5760320 297 /** @copydoc Gap::getMaxPeriodicAdvertiserListSize
kenjiArai 0:5b88d5760320 298 */
kenjiArai 0:5b88d5760320 299 uint8_t getMaxPeriodicAdvertiserListSize_();
kenjiArai 0:5b88d5760320 300
kenjiArai 0:5b88d5760320 301 /**
kenjiArai 0:5b88d5760320 302 * @see Gap::setAddress
kenjiArai 0:5b88d5760320 303 */
kenjiArai 0:5b88d5760320 304 ble_error_t setAddress_(
kenjiArai 0:5b88d5760320 305 BLEProtocol::AddressType_t type,
kenjiArai 0:5b88d5760320 306 const BLEProtocol::AddressBytes_t address
kenjiArai 0:5b88d5760320 307 );
kenjiArai 0:5b88d5760320 308
kenjiArai 0:5b88d5760320 309 /**
kenjiArai 0:5b88d5760320 310 * @see Gap::getAddress
kenjiArai 0:5b88d5760320 311 */
kenjiArai 0:5b88d5760320 312 ble_error_t getAddress_(
kenjiArai 0:5b88d5760320 313 BLEProtocol::AddressType_t *type,
kenjiArai 0:5b88d5760320 314 BLEProtocol::AddressBytes_t address
kenjiArai 0:5b88d5760320 315 );
kenjiArai 0:5b88d5760320 316
kenjiArai 0:5b88d5760320 317 /**
kenjiArai 0:5b88d5760320 318 * @see Gap::getMinAdvertisingInterval
kenjiArai 0:5b88d5760320 319 */
kenjiArai 0:5b88d5760320 320 uint16_t getMinAdvertisingInterval_() const;
kenjiArai 0:5b88d5760320 321
kenjiArai 0:5b88d5760320 322 /**
kenjiArai 0:5b88d5760320 323 * @see Gap::getMinNonConnectableAdvertisingInterval
kenjiArai 0:5b88d5760320 324 */
kenjiArai 0:5b88d5760320 325 uint16_t getMinNonConnectableAdvertisingInterval_() const;
kenjiArai 0:5b88d5760320 326
kenjiArai 0:5b88d5760320 327 /**
kenjiArai 0:5b88d5760320 328 * @see Gap::getMaxAdvertisingInterval
kenjiArai 0:5b88d5760320 329 */
kenjiArai 0:5b88d5760320 330 uint16_t getMaxAdvertisingInterval_() const;
kenjiArai 0:5b88d5760320 331
kenjiArai 0:5b88d5760320 332 /**
kenjiArai 0:5b88d5760320 333 * @see Gap::stopAdvertising
kenjiArai 0:5b88d5760320 334 */
kenjiArai 0:5b88d5760320 335 ble_error_t stopAdvertising_();
kenjiArai 0:5b88d5760320 336
kenjiArai 0:5b88d5760320 337 /**
kenjiArai 0:5b88d5760320 338 * @see Gap::stopScan
kenjiArai 0:5b88d5760320 339 */
kenjiArai 0:5b88d5760320 340 ble_error_t stopScan_();
kenjiArai 0:5b88d5760320 341
kenjiArai 0:5b88d5760320 342 /**
kenjiArai 0:5b88d5760320 343 * @see Gap::connect
kenjiArai 0:5b88d5760320 344 */
kenjiArai 0:5b88d5760320 345 ble_error_t connect_(
kenjiArai 0:5b88d5760320 346 const BLEProtocol::AddressBytes_t peerAddr,
kenjiArai 0:5b88d5760320 347 PeerAddressType_t peerAddrType,
kenjiArai 0:5b88d5760320 348 const ConnectionParams_t *connectionParams,
kenjiArai 0:5b88d5760320 349 const GapScanningParams *scanParams
kenjiArai 0:5b88d5760320 350 );
kenjiArai 0:5b88d5760320 351
kenjiArai 0:5b88d5760320 352 /**
kenjiArai 0:5b88d5760320 353 * @see Gap::connect
kenjiArai 0:5b88d5760320 354 */
kenjiArai 0:5b88d5760320 355 ble_error_t connect_(
kenjiArai 0:5b88d5760320 356 const BLEProtocol::AddressBytes_t peerAddr,
kenjiArai 0:5b88d5760320 357 BLEProtocol::AddressType_t peerAddrType,
kenjiArai 0:5b88d5760320 358 const ConnectionParams_t *connectionParams,
kenjiArai 0:5b88d5760320 359 const GapScanningParams *scanParams
kenjiArai 0:5b88d5760320 360 );
kenjiArai 0:5b88d5760320 361
kenjiArai 0:5b88d5760320 362 /**
kenjiArai 0:5b88d5760320 363 * @see Gap::connect
kenjiArai 0:5b88d5760320 364 */
kenjiArai 0:5b88d5760320 365 ble_error_t connect_(
kenjiArai 0:5b88d5760320 366 peer_address_type_t peerAddressType,
kenjiArai 0:5b88d5760320 367 const ble::address_t &peerAddress,
kenjiArai 0:5b88d5760320 368 const ConnectionParameters &connectionParams
kenjiArai 0:5b88d5760320 369 );
kenjiArai 0:5b88d5760320 370
kenjiArai 0:5b88d5760320 371 /**
kenjiArai 0:5b88d5760320 372 * @see Gap::cancelConnect
kenjiArai 0:5b88d5760320 373 */
kenjiArai 0:5b88d5760320 374 ble_error_t cancelConnect_();
kenjiArai 0:5b88d5760320 375
kenjiArai 0:5b88d5760320 376 ble_error_t manageConnectionParametersUpdateRequest_(
kenjiArai 0:5b88d5760320 377 bool userManageConnectionUpdateRequest
kenjiArai 0:5b88d5760320 378 );
kenjiArai 0:5b88d5760320 379
kenjiArai 0:5b88d5760320 380 ble_error_t updateConnectionParameters_(
kenjiArai 0:5b88d5760320 381 connection_handle_t connectionHandle,
kenjiArai 0:5b88d5760320 382 conn_interval_t minConnectionInterval,
kenjiArai 0:5b88d5760320 383 conn_interval_t maxConnectionInterval,
kenjiArai 0:5b88d5760320 384 slave_latency_t slaveLatency,
kenjiArai 0:5b88d5760320 385 supervision_timeout_t supervisionTimeout,
kenjiArai 0:5b88d5760320 386 conn_event_length_t minConnectionEventLength,
kenjiArai 0:5b88d5760320 387 conn_event_length_t maxConnectionEventLength
kenjiArai 0:5b88d5760320 388 );
kenjiArai 0:5b88d5760320 389
kenjiArai 0:5b88d5760320 390 ble_error_t acceptConnectionParametersUpdate_(
kenjiArai 0:5b88d5760320 391 connection_handle_t connectionHandle,
kenjiArai 0:5b88d5760320 392 conn_interval_t minConnectionInterval,
kenjiArai 0:5b88d5760320 393 conn_interval_t maxConnectionInterval,
kenjiArai 0:5b88d5760320 394 slave_latency_t slaveLatency,
kenjiArai 0:5b88d5760320 395 supervision_timeout_t supervisionTimeout,
kenjiArai 0:5b88d5760320 396 conn_event_length_t minConnectionEventLength,
kenjiArai 0:5b88d5760320 397 conn_event_length_t maxConnectionEventLength
kenjiArai 0:5b88d5760320 398 );
kenjiArai 0:5b88d5760320 399
kenjiArai 0:5b88d5760320 400 ble_error_t rejectConnectionParametersUpdate_(
kenjiArai 0:5b88d5760320 401 connection_handle_t connectionHandle
kenjiArai 0:5b88d5760320 402 );
kenjiArai 0:5b88d5760320 403
kenjiArai 0:5b88d5760320 404 /**
kenjiArai 0:5b88d5760320 405 * @see Gap::readPhy
kenjiArai 0:5b88d5760320 406 */
kenjiArai 0:5b88d5760320 407 ble_error_t readPhy_(Handle_t connection);
kenjiArai 0:5b88d5760320 408
kenjiArai 0:5b88d5760320 409 /**
kenjiArai 0:5b88d5760320 410 * @see Gap::setPreferredPhys
kenjiArai 0:5b88d5760320 411 */
kenjiArai 0:5b88d5760320 412 ble_error_t setPreferredPhys_(
kenjiArai 0:5b88d5760320 413 const phy_set_t *txPhys,
kenjiArai 0:5b88d5760320 414 const phy_set_t *rxPhys
kenjiArai 0:5b88d5760320 415 );
kenjiArai 0:5b88d5760320 416
kenjiArai 0:5b88d5760320 417 /**
kenjiArai 0:5b88d5760320 418 * @see Gap::setPhy
kenjiArai 0:5b88d5760320 419 */
kenjiArai 0:5b88d5760320 420 ble_error_t setPhy_(
kenjiArai 0:5b88d5760320 421 Handle_t connection,
kenjiArai 0:5b88d5760320 422 const phy_set_t *txPhys,
kenjiArai 0:5b88d5760320 423 const phy_set_t *rxPhys,
kenjiArai 0:5b88d5760320 424 CodedSymbolPerBit_t codedSymbol
kenjiArai 0:5b88d5760320 425 );
kenjiArai 0:5b88d5760320 426
kenjiArai 0:5b88d5760320 427 ble_error_t disconnect_(
kenjiArai 0:5b88d5760320 428 connection_handle_t connectionHandle,
kenjiArai 0:5b88d5760320 429 local_disconnection_reason_t reason
kenjiArai 0:5b88d5760320 430 );
kenjiArai 0:5b88d5760320 431
kenjiArai 0:5b88d5760320 432 /**
kenjiArai 0:5b88d5760320 433 * @see Gap::disconnect
kenjiArai 0:5b88d5760320 434 */
kenjiArai 0:5b88d5760320 435 ble_error_t disconnect_(
kenjiArai 0:5b88d5760320 436 Handle_t connectionHandle,
kenjiArai 0:5b88d5760320 437 DisconnectionReason_t reason
kenjiArai 0:5b88d5760320 438 );
kenjiArai 0:5b88d5760320 439
kenjiArai 0:5b88d5760320 440 /**
kenjiArai 0:5b88d5760320 441 * @see Gap::disconnect
kenjiArai 0:5b88d5760320 442 */
kenjiArai 0:5b88d5760320 443 ble_error_t disconnect_(DisconnectionReason_t reason);
kenjiArai 0:5b88d5760320 444
kenjiArai 0:5b88d5760320 445 /**
kenjiArai 0:5b88d5760320 446 * @see Gap::updateConnectionParams
kenjiArai 0:5b88d5760320 447 */
kenjiArai 0:5b88d5760320 448 ble_error_t updateConnectionParams_(
kenjiArai 0:5b88d5760320 449 Handle_t handle,
kenjiArai 0:5b88d5760320 450 const ConnectionParams_t *params
kenjiArai 0:5b88d5760320 451 );
kenjiArai 0:5b88d5760320 452
kenjiArai 0:5b88d5760320 453 /**
kenjiArai 0:5b88d5760320 454 * @see Gap::getPreferredConnectionParams
kenjiArai 0:5b88d5760320 455 */
kenjiArai 0:5b88d5760320 456 ble_error_t getPreferredConnectionParams_(
kenjiArai 0:5b88d5760320 457 ConnectionParams_t *params
kenjiArai 0:5b88d5760320 458 );
kenjiArai 0:5b88d5760320 459
kenjiArai 0:5b88d5760320 460 /**
kenjiArai 0:5b88d5760320 461 * @see Gap::setPreferredConnectionParams
kenjiArai 0:5b88d5760320 462 */
kenjiArai 0:5b88d5760320 463 ble_error_t setPreferredConnectionParams_(
kenjiArai 0:5b88d5760320 464 const ConnectionParams_t *params
kenjiArai 0:5b88d5760320 465 );
kenjiArai 0:5b88d5760320 466
kenjiArai 0:5b88d5760320 467 /**
kenjiArai 0:5b88d5760320 468 * @see Gap::setDeviceName
kenjiArai 0:5b88d5760320 469 */
kenjiArai 0:5b88d5760320 470 ble_error_t setDeviceName_(const uint8_t *deviceName);
kenjiArai 0:5b88d5760320 471
kenjiArai 0:5b88d5760320 472 /**
kenjiArai 0:5b88d5760320 473 * @see Gap::getDeviceName
kenjiArai 0:5b88d5760320 474 */
kenjiArai 0:5b88d5760320 475 ble_error_t getDeviceName_(uint8_t *deviceName, unsigned *lengthP);
kenjiArai 0:5b88d5760320 476
kenjiArai 0:5b88d5760320 477 /**
kenjiArai 0:5b88d5760320 478 * @see Gap::setAppearance
kenjiArai 0:5b88d5760320 479 */
kenjiArai 0:5b88d5760320 480 ble_error_t setAppearance_(GapAdvertisingData::Appearance appearance);
kenjiArai 0:5b88d5760320 481
kenjiArai 0:5b88d5760320 482 /**
kenjiArai 0:5b88d5760320 483 * @see Gap::getAppearance
kenjiArai 0:5b88d5760320 484 */
kenjiArai 0:5b88d5760320 485 ble_error_t getAppearance_(GapAdvertisingData::Appearance *appearanceP);
kenjiArai 0:5b88d5760320 486
kenjiArai 0:5b88d5760320 487 /**
kenjiArai 0:5b88d5760320 488 * @see Gap::setTxPower
kenjiArai 0:5b88d5760320 489 */
kenjiArai 0:5b88d5760320 490 ble_error_t setTxPower_(int8_t txPower);
kenjiArai 0:5b88d5760320 491
kenjiArai 0:5b88d5760320 492 /**
kenjiArai 0:5b88d5760320 493 * @see Gap::getPermittedTxPowerValues
kenjiArai 0:5b88d5760320 494 */
kenjiArai 0:5b88d5760320 495 void getPermittedTxPowerValues_(const int8_t **valueArrayPP, size_t *countP);
kenjiArai 0:5b88d5760320 496
kenjiArai 0:5b88d5760320 497 /**
kenjiArai 0:5b88d5760320 498 * @see Gap::getMaxWhitelistSize
kenjiArai 0:5b88d5760320 499 */
kenjiArai 0:5b88d5760320 500 uint8_t getMaxWhitelistSize_(void) const;
kenjiArai 0:5b88d5760320 501
kenjiArai 0:5b88d5760320 502 /**
kenjiArai 0:5b88d5760320 503 * @see Gap::getWhitelist
kenjiArai 0:5b88d5760320 504 */
kenjiArai 0:5b88d5760320 505 ble_error_t getWhitelist_(Whitelist_t &whitelist) const;
kenjiArai 0:5b88d5760320 506
kenjiArai 0:5b88d5760320 507 /**
kenjiArai 0:5b88d5760320 508 * @see Gap::setWhitelist
kenjiArai 0:5b88d5760320 509 */
kenjiArai 0:5b88d5760320 510 ble_error_t setWhitelist_(const Whitelist_t &whitelist);
kenjiArai 0:5b88d5760320 511
kenjiArai 0:5b88d5760320 512 /**
kenjiArai 0:5b88d5760320 513 * @see Gap::setAdvertisingPolicyMode
kenjiArai 0:5b88d5760320 514 */
kenjiArai 0:5b88d5760320 515 ble_error_t setAdvertisingPolicyMode_(AdvertisingPolicyMode_t mode);
kenjiArai 0:5b88d5760320 516
kenjiArai 0:5b88d5760320 517 /**
kenjiArai 0:5b88d5760320 518 * @see Gap::setScanningPolicyMode
kenjiArai 0:5b88d5760320 519 */
kenjiArai 0:5b88d5760320 520 ble_error_t setScanningPolicyMode_(ScanningPolicyMode_t mode);
kenjiArai 0:5b88d5760320 521
kenjiArai 0:5b88d5760320 522 /**
kenjiArai 0:5b88d5760320 523 * @see Gap::setInitiatorPolicyMode
kenjiArai 0:5b88d5760320 524 */
kenjiArai 0:5b88d5760320 525 ble_error_t setInitiatorPolicyMode_(InitiatorPolicyMode_t mode);
kenjiArai 0:5b88d5760320 526
kenjiArai 0:5b88d5760320 527 /**
kenjiArai 0:5b88d5760320 528 * @see Gap::getAdvertisingPolicyMode
kenjiArai 0:5b88d5760320 529 */
kenjiArai 0:5b88d5760320 530 AdvertisingPolicyMode_t getAdvertisingPolicyMode_(void) const;
kenjiArai 0:5b88d5760320 531
kenjiArai 0:5b88d5760320 532 /**
kenjiArai 0:5b88d5760320 533 * @see Gap::getScanningPolicyMode
kenjiArai 0:5b88d5760320 534 */
kenjiArai 0:5b88d5760320 535 ScanningPolicyMode_t getScanningPolicyMode_(void) const;
kenjiArai 0:5b88d5760320 536
kenjiArai 0:5b88d5760320 537 /**
kenjiArai 0:5b88d5760320 538 * @see Gap::getInitiatorPolicyMode
kenjiArai 0:5b88d5760320 539 */
kenjiArai 0:5b88d5760320 540 InitiatorPolicyMode_t getInitiatorPolicyMode_(void) const;
kenjiArai 0:5b88d5760320 541
kenjiArai 0:5b88d5760320 542 /**
kenjiArai 0:5b88d5760320 543 * @see Gap::startRadioScan
kenjiArai 0:5b88d5760320 544 */
kenjiArai 0:5b88d5760320 545 ble_error_t startRadioScan_(const GapScanningParams &scanningParams);
kenjiArai 0:5b88d5760320 546
kenjiArai 0:5b88d5760320 547 /**
kenjiArai 0:5b88d5760320 548 * @see Gap::initRadioNotification
kenjiArai 0:5b88d5760320 549 */
kenjiArai 0:5b88d5760320 550 ble_error_t initRadioNotification_(void);
kenjiArai 0:5b88d5760320 551
kenjiArai 0:5b88d5760320 552 /**
kenjiArai 0:5b88d5760320 553 * @see Gap::enablePrivacy
kenjiArai 0:5b88d5760320 554 */
kenjiArai 0:5b88d5760320 555 ble_error_t enablePrivacy_(bool enable);
kenjiArai 0:5b88d5760320 556
kenjiArai 0:5b88d5760320 557 /**
kenjiArai 0:5b88d5760320 558 * @see Gap::setPeripheralPrivacyConfiguration
kenjiArai 0:5b88d5760320 559 */
kenjiArai 0:5b88d5760320 560 ble_error_t setPeripheralPrivacyConfiguration_(
kenjiArai 0:5b88d5760320 561 const PeripheralPrivacyConfiguration_t *configuration
kenjiArai 0:5b88d5760320 562 );
kenjiArai 0:5b88d5760320 563
kenjiArai 0:5b88d5760320 564 /**
kenjiArai 0:5b88d5760320 565 * @see Gap::getPeripheralPrivacyConfiguration
kenjiArai 0:5b88d5760320 566 */
kenjiArai 0:5b88d5760320 567 ble_error_t getPeripheralPrivacyConfiguration_(
kenjiArai 0:5b88d5760320 568 PeripheralPrivacyConfiguration_t *configuration
kenjiArai 0:5b88d5760320 569 );
kenjiArai 0:5b88d5760320 570
kenjiArai 0:5b88d5760320 571 /**
kenjiArai 0:5b88d5760320 572 * @see Gap::setCentralPrivacyConfiguration
kenjiArai 0:5b88d5760320 573 */
kenjiArai 0:5b88d5760320 574 ble_error_t setCentralPrivacyConfiguration_(
kenjiArai 0:5b88d5760320 575 const CentralPrivacyConfiguration_t *configuration
kenjiArai 0:5b88d5760320 576 );
kenjiArai 0:5b88d5760320 577
kenjiArai 0:5b88d5760320 578 /**
kenjiArai 0:5b88d5760320 579 * @see Gap::getCentralPrivacyConfiguration
kenjiArai 0:5b88d5760320 580 */
kenjiArai 0:5b88d5760320 581 ble_error_t getCentralPrivacyConfiguration_(
kenjiArai 0:5b88d5760320 582 CentralPrivacyConfiguration_t *configuration
kenjiArai 0:5b88d5760320 583 );
kenjiArai 0:5b88d5760320 584
kenjiArai 0:5b88d5760320 585 /**
kenjiArai 0:5b88d5760320 586 * @see Gap::setAdvertisingData
kenjiArai 0:5b88d5760320 587 */
kenjiArai 0:5b88d5760320 588 ble_error_t setAdvertisingData_(
kenjiArai 0:5b88d5760320 589 const GapAdvertisingData &advData,
kenjiArai 0:5b88d5760320 590 const GapAdvertisingData &scanResponse
kenjiArai 0:5b88d5760320 591 );
kenjiArai 0:5b88d5760320 592
kenjiArai 0:5b88d5760320 593 /**
kenjiArai 0:5b88d5760320 594 * @see Gap::startAdvertising
kenjiArai 0:5b88d5760320 595 */
kenjiArai 0:5b88d5760320 596 ble_error_t startAdvertising_(const GapAdvertisingParams &params);
kenjiArai 0:5b88d5760320 597
kenjiArai 0:5b88d5760320 598 /**
kenjiArai 0:5b88d5760320 599 * @see Gap::reset
kenjiArai 0:5b88d5760320 600 */
kenjiArai 0:5b88d5760320 601 ble_error_t reset_(void);
kenjiArai 0:5b88d5760320 602
kenjiArai 0:5b88d5760320 603 /**
kenjiArai 0:5b88d5760320 604 * @copydoc ::Gap::processConnectionEvent
kenjiArai 0:5b88d5760320 605 */
kenjiArai 0:5b88d5760320 606 void processConnectionEvent(
kenjiArai 0:5b88d5760320 607 Handle_t handle,
kenjiArai 0:5b88d5760320 608 Role_t role,
kenjiArai 0:5b88d5760320 609 peer_address_type_t peerAddrType,
kenjiArai 0:5b88d5760320 610 const BLEProtocol::AddressBytes_t peerAddr,
kenjiArai 0:5b88d5760320 611 BLEProtocol::AddressType_t ownAddrType,
kenjiArai 0:5b88d5760320 612 const BLEProtocol::AddressBytes_t ownAddr,
kenjiArai 0:5b88d5760320 613 const ConnectionParams_t *connectionParams,
kenjiArai 0:5b88d5760320 614 const uint8_t *peerResolvableAddr,
kenjiArai 0:5b88d5760320 615 const uint8_t *localResolvableAddr
kenjiArai 0:5b88d5760320 616 );
kenjiArai 0:5b88d5760320 617
kenjiArai 0:5b88d5760320 618 /**
kenjiArai 0:5b88d5760320 619 * @copydoc ::Gap::processDisconnectionEvent
kenjiArai 0:5b88d5760320 620 */
kenjiArai 0:5b88d5760320 621 void processDisconnectionEvent(
kenjiArai 0:5b88d5760320 622 Handle_t handle,
kenjiArai 0:5b88d5760320 623 DisconnectionReason_t reason
kenjiArai 0:5b88d5760320 624 );
kenjiArai 0:5b88d5760320 625
kenjiArai 0:5b88d5760320 626 private:
kenjiArai 0:5b88d5760320 627 ble_error_t setAdvertisingData(
kenjiArai 0:5b88d5760320 628 advertising_handle_t handle,
kenjiArai 0:5b88d5760320 629 Span<const uint8_t> payload,
kenjiArai 0:5b88d5760320 630 bool minimiseFragmentation,
kenjiArai 0:5b88d5760320 631 bool scan_response
kenjiArai 0:5b88d5760320 632 );
kenjiArai 0:5b88d5760320 633
kenjiArai 0:5b88d5760320 634 void process_scan_timeout();
kenjiArai 0:5b88d5760320 635
kenjiArai 0:5b88d5760320 636 void on_advertising_timeout();
kenjiArai 0:5b88d5760320 637
kenjiArai 0:5b88d5760320 638 void process_advertising_timeout();
kenjiArai 0:5b88d5760320 639
kenjiArai 0:5b88d5760320 640 void on_gap_event_received(const pal::GapEvent &e);
kenjiArai 0:5b88d5760320 641
kenjiArai 0:5b88d5760320 642 void on_advertising_report(const pal::GapAdvertisingReportEvent &e);
kenjiArai 0:5b88d5760320 643
kenjiArai 0:5b88d5760320 644 void on_connection_complete(const pal::GapConnectionCompleteEvent &e);
kenjiArai 0:5b88d5760320 645
kenjiArai 0:5b88d5760320 646 void on_disconnection_complete(const pal::GapDisconnectionCompleteEvent &e);
kenjiArai 0:5b88d5760320 647
kenjiArai 0:5b88d5760320 648 void on_connection_parameter_request(
kenjiArai 0:5b88d5760320 649 const pal::GapRemoteConnectionParameterRequestEvent &e
kenjiArai 0:5b88d5760320 650 );
kenjiArai 0:5b88d5760320 651
kenjiArai 0:5b88d5760320 652 void on_connection_update(const pal::GapConnectionUpdateEvent &e);
kenjiArai 0:5b88d5760320 653
kenjiArai 0:5b88d5760320 654 void on_unexpected_error(const pal::GapUnexpectedErrorEvent &e);
kenjiArai 0:5b88d5760320 655
kenjiArai 0:5b88d5760320 656 enum AddressUseType_t {
kenjiArai 0:5b88d5760320 657 CENTRAL_CONNECTION,
kenjiArai 0:5b88d5760320 658 CENTRAL_SCAN,
kenjiArai 0:5b88d5760320 659 PERIPHERAL_CONNECTABLE,
kenjiArai 0:5b88d5760320 660 PERIPHERAL_NON_CONNECTABLE
kenjiArai 0:5b88d5760320 661 };
kenjiArai 0:5b88d5760320 662
kenjiArai 0:5b88d5760320 663 pal::own_address_type_t get_own_address_type(AddressUseType_t address_use_type);
kenjiArai 0:5b88d5760320 664
kenjiArai 0:5b88d5760320 665 bool initialize_whitelist() const;
kenjiArai 0:5b88d5760320 666
kenjiArai 0:5b88d5760320 667 ble_error_t update_address_resolution_setting();
kenjiArai 0:5b88d5760320 668
kenjiArai 0:5b88d5760320 669 void set_random_address_rotation(bool enable);
kenjiArai 0:5b88d5760320 670
kenjiArai 0:5b88d5760320 671 void update_random_address();
kenjiArai 0:5b88d5760320 672
kenjiArai 0:5b88d5760320 673 bool getUnresolvableRandomAddress(ble::address_t &address);
kenjiArai 0:5b88d5760320 674
kenjiArai 0:5b88d5760320 675 void on_address_rotation_timeout();
kenjiArai 0:5b88d5760320 676
kenjiArai 0:5b88d5760320 677 void useVersionOneAPI_() const;
kenjiArai 0:5b88d5760320 678
kenjiArai 0:5b88d5760320 679 void useVersionTwoAPI_() const;
kenjiArai 0:5b88d5760320 680
kenjiArai 0:5b88d5760320 681 /* implements pal::Gap::EventHandler */
kenjiArai 0:5b88d5760320 682 private:
kenjiArai 0:5b88d5760320 683 void on_read_phy_(
kenjiArai 0:5b88d5760320 684 pal::hci_error_code_t hci_status,
kenjiArai 0:5b88d5760320 685 Handle_t connection_handle,
kenjiArai 0:5b88d5760320 686 phy_t tx_phy,
kenjiArai 0:5b88d5760320 687 phy_t rx_phy
kenjiArai 0:5b88d5760320 688 );
kenjiArai 0:5b88d5760320 689
kenjiArai 0:5b88d5760320 690 void on_data_length_change_(
kenjiArai 0:5b88d5760320 691 connection_handle_t connection_handle,
kenjiArai 0:5b88d5760320 692 uint16_t tx_size,
kenjiArai 0:5b88d5760320 693 uint16_t rx_size
kenjiArai 0:5b88d5760320 694 );
kenjiArai 0:5b88d5760320 695
kenjiArai 0:5b88d5760320 696 void on_phy_update_complete_(
kenjiArai 0:5b88d5760320 697 pal::hci_error_code_t hci_status,
kenjiArai 0:5b88d5760320 698 Handle_t connection_handle,
kenjiArai 0:5b88d5760320 699 phy_t tx_phy,
kenjiArai 0:5b88d5760320 700 phy_t rx_phy
kenjiArai 0:5b88d5760320 701 );
kenjiArai 0:5b88d5760320 702
kenjiArai 0:5b88d5760320 703 void on_enhanced_connection_complete_(
kenjiArai 0:5b88d5760320 704 pal::hci_error_code_t status,
kenjiArai 0:5b88d5760320 705 connection_handle_t connection_handle,
kenjiArai 0:5b88d5760320 706 pal::connection_role_t own_role,
kenjiArai 0:5b88d5760320 707 pal::connection_peer_address_type_t peer_address_type,
kenjiArai 0:5b88d5760320 708 const ble::address_t &peer_address,
kenjiArai 0:5b88d5760320 709 const ble::address_t &local_resolvable_private_address,
kenjiArai 0:5b88d5760320 710 const ble::address_t &peer_resolvable_private_address,
kenjiArai 0:5b88d5760320 711 uint16_t connection_interval,
kenjiArai 0:5b88d5760320 712 uint16_t connection_latency,
kenjiArai 0:5b88d5760320 713 uint16_t supervision_timeout,
kenjiArai 0:5b88d5760320 714 pal::clock_accuracy_t master_clock_accuracy
kenjiArai 0:5b88d5760320 715 );
kenjiArai 0:5b88d5760320 716
kenjiArai 0:5b88d5760320 717 void on_extended_advertising_report_(
kenjiArai 0:5b88d5760320 718 advertising_event_t event_type,
kenjiArai 0:5b88d5760320 719 const pal::connection_peer_address_type_t *address_type,
kenjiArai 0:5b88d5760320 720 const ble::address_t &address,
kenjiArai 0:5b88d5760320 721 phy_t primary_phy,
kenjiArai 0:5b88d5760320 722 const phy_t *secondary_phy,
kenjiArai 0:5b88d5760320 723 advertising_sid_t advertising_sid,
kenjiArai 0:5b88d5760320 724 pal::advertising_power_t tx_power,
kenjiArai 0:5b88d5760320 725 pal::rssi_t rssi,
kenjiArai 0:5b88d5760320 726 uint16_t periodic_advertising_interval,
kenjiArai 0:5b88d5760320 727 pal::direct_address_type_t direct_address_type,
kenjiArai 0:5b88d5760320 728 const ble::address_t &direct_address,
kenjiArai 0:5b88d5760320 729 uint8_t data_length,
kenjiArai 0:5b88d5760320 730 const uint8_t *data
kenjiArai 0:5b88d5760320 731 );
kenjiArai 0:5b88d5760320 732
kenjiArai 0:5b88d5760320 733 void on_periodic_advertising_sync_established_(
kenjiArai 0:5b88d5760320 734 pal::hci_error_code_t error,
kenjiArai 0:5b88d5760320 735 pal::sync_handle_t sync_handle,
kenjiArai 0:5b88d5760320 736 advertising_sid_t advertising_sid,
kenjiArai 0:5b88d5760320 737 pal::connection_peer_address_type_t advertiser_address_type,
kenjiArai 0:5b88d5760320 738 const ble::address_t &advertiser_address,
kenjiArai 0:5b88d5760320 739 phy_t advertiser_phy,
kenjiArai 0:5b88d5760320 740 uint16_t periodic_advertising_interval,
kenjiArai 0:5b88d5760320 741 pal::clock_accuracy_t clock_accuracy
kenjiArai 0:5b88d5760320 742 );
kenjiArai 0:5b88d5760320 743
kenjiArai 0:5b88d5760320 744 void on_periodic_advertising_report_(
kenjiArai 0:5b88d5760320 745 pal::sync_handle_t sync_handle,
kenjiArai 0:5b88d5760320 746 pal::advertising_power_t tx_power,
kenjiArai 0:5b88d5760320 747 pal::rssi_t rssi,
kenjiArai 0:5b88d5760320 748 pal::advertising_data_status_t data_status,
kenjiArai 0:5b88d5760320 749 uint8_t data_length,
kenjiArai 0:5b88d5760320 750 const uint8_t *data
kenjiArai 0:5b88d5760320 751 );
kenjiArai 0:5b88d5760320 752
kenjiArai 0:5b88d5760320 753 void on_periodic_advertising_sync_loss_(pal::sync_handle_t sync_handle);
kenjiArai 0:5b88d5760320 754
kenjiArai 0:5b88d5760320 755 void on_advertising_set_terminated_(
kenjiArai 0:5b88d5760320 756 pal::hci_error_code_t status,
kenjiArai 0:5b88d5760320 757 advertising_handle_t advertising_handle,
kenjiArai 0:5b88d5760320 758 connection_handle_t connection_handle,
kenjiArai 0:5b88d5760320 759 uint8_t number_of_completed_extended_advertising_events
kenjiArai 0:5b88d5760320 760 );
kenjiArai 0:5b88d5760320 761
kenjiArai 0:5b88d5760320 762 void on_scan_request_received_(
kenjiArai 0:5b88d5760320 763 advertising_handle_t advertising_handle,
kenjiArai 0:5b88d5760320 764 pal::connection_peer_address_type_t scanner_address_type,
kenjiArai 0:5b88d5760320 765 const ble::address_t &address
kenjiArai 0:5b88d5760320 766 );
kenjiArai 0:5b88d5760320 767
kenjiArai 0:5b88d5760320 768 void on_connection_update_complete_(
kenjiArai 0:5b88d5760320 769 pal::hci_error_code_t status,
kenjiArai 0:5b88d5760320 770 connection_handle_t connection_handle,
kenjiArai 0:5b88d5760320 771 uint16_t connection_interval,
kenjiArai 0:5b88d5760320 772 uint16_t connection_latency,
kenjiArai 0:5b88d5760320 773 uint16_t supervision_timeout
kenjiArai 0:5b88d5760320 774 );
kenjiArai 0:5b88d5760320 775
kenjiArai 0:5b88d5760320 776 void on_remote_connection_parameter_(
kenjiArai 0:5b88d5760320 777 connection_handle_t connection_handle,
kenjiArai 0:5b88d5760320 778 uint16_t connection_interval_min,
kenjiArai 0:5b88d5760320 779 uint16_t connection_interval_max,
kenjiArai 0:5b88d5760320 780 uint16_t connection_latency,
kenjiArai 0:5b88d5760320 781 uint16_t supervision_timeout
kenjiArai 0:5b88d5760320 782 );
kenjiArai 0:5b88d5760320 783
kenjiArai 0:5b88d5760320 784 void on_scan_timeout_();
kenjiArai 0:5b88d5760320 785 void process_legacy_scan_timeout();
kenjiArai 0:5b88d5760320 786
kenjiArai 0:5b88d5760320 787 private:
kenjiArai 0:5b88d5760320 788 pal::EventQueue &_event_queue;
kenjiArai 0:5b88d5760320 789 PalGap &_pal_gap;
kenjiArai 0:5b88d5760320 790 pal::GenericAccessService &_gap_service;
kenjiArai 0:5b88d5760320 791 PalSecurityManager &_pal_sm;
kenjiArai 0:5b88d5760320 792 BLEProtocol::AddressType_t _address_type;
kenjiArai 0:5b88d5760320 793 ble::address_t _address;
kenjiArai 0:5b88d5760320 794 pal::initiator_policy_t _initiator_policy_mode;
kenjiArai 0:5b88d5760320 795 pal::scanning_filter_policy_t _scanning_filter_policy;
kenjiArai 0:5b88d5760320 796 pal::advertising_filter_policy_t _advertising_filter_policy;
kenjiArai 0:5b88d5760320 797 mutable Whitelist_t _whitelist;
kenjiArai 0:5b88d5760320 798
kenjiArai 0:5b88d5760320 799 bool _privacy_enabled;
kenjiArai 0:5b88d5760320 800 PeripheralPrivacyConfiguration_t _peripheral_privacy_configuration;
kenjiArai 0:5b88d5760320 801 CentralPrivacyConfiguration_t _central_privacy_configuration;
kenjiArai 0:5b88d5760320 802 ble::address_t _random_static_identity_address;
kenjiArai 0:5b88d5760320 803 bool _random_address_rotating;
kenjiArai 0:5b88d5760320 804
kenjiArai 0:5b88d5760320 805 bool _scan_enabled;
kenjiArai 0:5b88d5760320 806 mbed::LowPowerTimeout _advertising_timeout;
kenjiArai 0:5b88d5760320 807 mbed::LowPowerTimeout _scan_timeout;
kenjiArai 0:5b88d5760320 808 mbed::LowPowerTicker _address_rotation_ticker;
kenjiArai 0:5b88d5760320 809
kenjiArai 0:5b88d5760320 810 template<size_t bit_size>
kenjiArai 0:5b88d5760320 811 struct BitArray {
kenjiArai 0:5b88d5760320 812 BitArray() : data()
kenjiArai 0:5b88d5760320 813 {
kenjiArai 0:5b88d5760320 814 }
kenjiArai 0:5b88d5760320 815
kenjiArai 0:5b88d5760320 816 bool get(size_t index) const
kenjiArai 0:5b88d5760320 817 {
kenjiArai 0:5b88d5760320 818 position p(index);
kenjiArai 0:5b88d5760320 819 return (data[p.byte_index] >> p.bit_index) & 0x01;
kenjiArai 0:5b88d5760320 820 }
kenjiArai 0:5b88d5760320 821
kenjiArai 0:5b88d5760320 822 void set(size_t index)
kenjiArai 0:5b88d5760320 823 {
kenjiArai 0:5b88d5760320 824 position p(index);
kenjiArai 0:5b88d5760320 825 data[p.byte_index] |= (0x01 << p.bit_index);
kenjiArai 0:5b88d5760320 826 }
kenjiArai 0:5b88d5760320 827
kenjiArai 0:5b88d5760320 828 void clear(size_t index)
kenjiArai 0:5b88d5760320 829 {
kenjiArai 0:5b88d5760320 830 position p(index);
kenjiArai 0:5b88d5760320 831 data[p.byte_index] &= ~(0x01 << p.bit_index);
kenjiArai 0:5b88d5760320 832 }
kenjiArai 0:5b88d5760320 833
kenjiArai 0:5b88d5760320 834 void clear()
kenjiArai 0:5b88d5760320 835 {
kenjiArai 0:5b88d5760320 836 for (size_t i = 0; i < (bit_size / 8 + 1); ++i) {
kenjiArai 0:5b88d5760320 837 data[i] = 0;
kenjiArai 0:5b88d5760320 838 }
kenjiArai 0:5b88d5760320 839 }
kenjiArai 0:5b88d5760320 840
kenjiArai 0:5b88d5760320 841 private:
kenjiArai 0:5b88d5760320 842 struct position {
kenjiArai 0:5b88d5760320 843 position(size_t bit_number) :
kenjiArai 0:5b88d5760320 844 byte_index(bit_number / 8),
kenjiArai 0:5b88d5760320 845 bit_index(bit_number % 8)
kenjiArai 0:5b88d5760320 846 {
kenjiArai 0:5b88d5760320 847 }
kenjiArai 0:5b88d5760320 848
kenjiArai 0:5b88d5760320 849 size_t byte_index;
kenjiArai 0:5b88d5760320 850 uint8_t bit_index;
kenjiArai 0:5b88d5760320 851 };
kenjiArai 0:5b88d5760320 852
kenjiArai 0:5b88d5760320 853 uint8_t data[bit_size / 8 + 1];
kenjiArai 0:5b88d5760320 854 };
kenjiArai 0:5b88d5760320 855
kenjiArai 0:5b88d5760320 856 BitArray<MAX_ADVERTISING_SETS> _existing_sets;
kenjiArai 0:5b88d5760320 857 BitArray<MAX_ADVERTISING_SETS> _active_sets;
kenjiArai 0:5b88d5760320 858 BitArray<MAX_ADVERTISING_SETS> _active_periodic_sets;
kenjiArai 0:5b88d5760320 859 BitArray<MAX_ADVERTISING_SETS> _connectable_payload_size_exceeded;
kenjiArai 0:5b88d5760320 860 BitArray<MAX_ADVERTISING_SETS> _set_is_connectable;
kenjiArai 0:5b88d5760320 861
kenjiArai 0:5b88d5760320 862 // deprecation flags
kenjiArai 0:5b88d5760320 863 mutable bool _deprecated_scan_api_used : 1;
kenjiArai 0:5b88d5760320 864 mutable bool _non_deprecated_scan_api_used : 1;
kenjiArai 0:5b88d5760320 865 bool _user_manage_connection_parameter_requests : 1;
kenjiArai 0:5b88d5760320 866
kenjiArai 0:5b88d5760320 867 private:
kenjiArai 0:5b88d5760320 868 ble_error_t setExtendedAdvertisingParameters(
kenjiArai 0:5b88d5760320 869 advertising_handle_t handle,
kenjiArai 0:5b88d5760320 870 const AdvertisingParameters &parameters
kenjiArai 0:5b88d5760320 871 );
kenjiArai 0:5b88d5760320 872
kenjiArai 0:5b88d5760320 873 bool is_extended_advertising_available();
kenjiArai 0:5b88d5760320 874 };
kenjiArai 0:5b88d5760320 875
kenjiArai 0:5b88d5760320 876 } // namespace generic
kenjiArai 0:5b88d5760320 877 } // namespace ble
kenjiArai 0:5b88d5760320 878
kenjiArai 0:5b88d5760320 879 #endif /* MBED_BLE_GENERIC_GAP */