mbed-os5 only for TYBLE16
Dependents: TYBLE16_simple_data_logger TYBLE16_MP3_Air
features/FEATURE_BLE/ble/pal/GapEvents.h@1:9db0e321a9f4, 2019-12-31 (annotated)
- 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?
User | Revision | Line number | New 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 BLE_PAL_GAP_MESSAGE_H_ |
kenjiArai | 0:5b88d5760320 | 18 | #define BLE_PAL_GAP_MESSAGE_H_ |
kenjiArai | 0:5b88d5760320 | 19 | |
kenjiArai | 0:5b88d5760320 | 20 | #include "GapTypes.h" |
kenjiArai | 0:5b88d5760320 | 21 | #include "ble/BLETypes.h" |
kenjiArai | 0:5b88d5760320 | 22 | |
kenjiArai | 0:5b88d5760320 | 23 | namespace ble { |
kenjiArai | 0:5b88d5760320 | 24 | namespace pal { |
kenjiArai | 0:5b88d5760320 | 25 | |
kenjiArai | 0:5b88d5760320 | 26 | /** |
kenjiArai | 0:5b88d5760320 | 27 | * Enumeration of GAP event types |
kenjiArai | 0:5b88d5760320 | 28 | */ |
kenjiArai | 0:5b88d5760320 | 29 | struct GapEventType : SafeEnum<GapEventType, uint8_t> { |
kenjiArai | 0:5b88d5760320 | 30 | enum type { |
kenjiArai | 0:5b88d5760320 | 31 | /** |
kenjiArai | 0:5b88d5760320 | 32 | * Event type used by GapUnexpectedErrorEvent |
kenjiArai | 0:5b88d5760320 | 33 | */ |
kenjiArai | 0:5b88d5760320 | 34 | UNEXPECTED_ERROR, |
kenjiArai | 0:5b88d5760320 | 35 | |
kenjiArai | 0:5b88d5760320 | 36 | /** |
kenjiArai | 0:5b88d5760320 | 37 | * Event type used by GapConnectionCompleteEvent |
kenjiArai | 0:5b88d5760320 | 38 | */ |
kenjiArai | 0:5b88d5760320 | 39 | CONNECTION_COMPLETE, |
kenjiArai | 0:5b88d5760320 | 40 | |
kenjiArai | 0:5b88d5760320 | 41 | /** |
kenjiArai | 0:5b88d5760320 | 42 | * Event type used by GapAdvertisingReportEvent |
kenjiArai | 0:5b88d5760320 | 43 | */ |
kenjiArai | 0:5b88d5760320 | 44 | ADVERTISING_REPORT, |
kenjiArai | 0:5b88d5760320 | 45 | |
kenjiArai | 0:5b88d5760320 | 46 | /** |
kenjiArai | 0:5b88d5760320 | 47 | * Event type used by GapConnectionUpdateEvent |
kenjiArai | 0:5b88d5760320 | 48 | * */ |
kenjiArai | 0:5b88d5760320 | 49 | CONNECTION_UPDATE, |
kenjiArai | 0:5b88d5760320 | 50 | |
kenjiArai | 0:5b88d5760320 | 51 | /** |
kenjiArai | 0:5b88d5760320 | 52 | * Event type used by GapRemoteConnectionParameterRequestEvent |
kenjiArai | 0:5b88d5760320 | 53 | */ |
kenjiArai | 0:5b88d5760320 | 54 | REMOTE_CONNECTION_PARAMETER_REQUEST, |
kenjiArai | 0:5b88d5760320 | 55 | |
kenjiArai | 0:5b88d5760320 | 56 | /** |
kenjiArai | 0:5b88d5760320 | 57 | * Event type used by GapDisconnectionCompleteEvent |
kenjiArai | 0:5b88d5760320 | 58 | */ |
kenjiArai | 0:5b88d5760320 | 59 | DISCONNECTION_COMPLETE |
kenjiArai | 0:5b88d5760320 | 60 | }; |
kenjiArai | 0:5b88d5760320 | 61 | |
kenjiArai | 0:5b88d5760320 | 62 | GapEventType(type event_type) : SafeEnum<GapEventType, uint8_t>(event_type) { } |
kenjiArai | 0:5b88d5760320 | 63 | }; |
kenjiArai | 0:5b88d5760320 | 64 | |
kenjiArai | 0:5b88d5760320 | 65 | |
kenjiArai | 0:5b88d5760320 | 66 | /** |
kenjiArai | 0:5b88d5760320 | 67 | * Base class of a Gap Event. |
kenjiArai | 0:5b88d5760320 | 68 | * |
kenjiArai | 0:5b88d5760320 | 69 | * Client should use the field type to deduce the actual type of the event. |
kenjiArai | 0:5b88d5760320 | 70 | */ |
kenjiArai | 0:5b88d5760320 | 71 | struct GapEvent { |
kenjiArai | 0:5b88d5760320 | 72 | |
kenjiArai | 0:5b88d5760320 | 73 | const GapEventType type; |
kenjiArai | 0:5b88d5760320 | 74 | |
kenjiArai | 0:5b88d5760320 | 75 | protected: |
kenjiArai | 0:5b88d5760320 | 76 | GapEvent(GapEventType type) : type(type) { } |
kenjiArai | 0:5b88d5760320 | 77 | |
kenjiArai | 0:5b88d5760320 | 78 | // Disable copy construction and copy assignement operations. |
kenjiArai | 0:5b88d5760320 | 79 | GapEvent(const GapEvent&); |
kenjiArai | 0:5b88d5760320 | 80 | GapEvent& operator=(const GapEvent&); |
kenjiArai | 0:5b88d5760320 | 81 | }; |
kenjiArai | 0:5b88d5760320 | 82 | |
kenjiArai | 0:5b88d5760320 | 83 | |
kenjiArai | 0:5b88d5760320 | 84 | /** |
kenjiArai | 0:5b88d5760320 | 85 | * Model an unexpected error that happen during a gap procedure. |
kenjiArai | 0:5b88d5760320 | 86 | * |
kenjiArai | 0:5b88d5760320 | 87 | * This class is mainly used to notify user code of an unexpected error returned |
kenjiArai | 0:5b88d5760320 | 88 | * in an HCI command complete event. |
kenjiArai | 0:5b88d5760320 | 89 | */ |
kenjiArai | 0:5b88d5760320 | 90 | struct GapUnexpectedErrorEvent : public GapEvent { |
kenjiArai | 0:5b88d5760320 | 91 | GapUnexpectedErrorEvent(uint16_t opcode, uint8_t error_code) : |
kenjiArai | 0:5b88d5760320 | 92 | GapEvent(GapEventType::UNEXPECTED_ERROR), |
kenjiArai | 0:5b88d5760320 | 93 | opcode(opcode), error_code(error_code) { } |
kenjiArai | 0:5b88d5760320 | 94 | |
kenjiArai | 0:5b88d5760320 | 95 | /** |
kenjiArai | 0:5b88d5760320 | 96 | * Opcode composed of the OCF and OGF of the command which has returned an |
kenjiArai | 0:5b88d5760320 | 97 | * error. |
kenjiArai | 0:5b88d5760320 | 98 | */ |
kenjiArai | 0:5b88d5760320 | 99 | const uint16_t opcode; |
kenjiArai | 0:5b88d5760320 | 100 | |
kenjiArai | 0:5b88d5760320 | 101 | /** |
kenjiArai | 0:5b88d5760320 | 102 | * Error code |
kenjiArai | 0:5b88d5760320 | 103 | */ |
kenjiArai | 0:5b88d5760320 | 104 | const uint8_t error_code; |
kenjiArai | 0:5b88d5760320 | 105 | }; |
kenjiArai | 0:5b88d5760320 | 106 | |
kenjiArai | 0:5b88d5760320 | 107 | |
kenjiArai | 0:5b88d5760320 | 108 | /** |
kenjiArai | 0:5b88d5760320 | 109 | * Indicate to both ends (slave or master) the end of the connection process. |
kenjiArai | 0:5b88d5760320 | 110 | * |
kenjiArai | 0:5b88d5760320 | 111 | * This structure should be used for Connection Complete Events and Enhanced |
kenjiArai | 0:5b88d5760320 | 112 | * Connection Complete Event. |
kenjiArai | 0:5b88d5760320 | 113 | * |
kenjiArai | 0:5b88d5760320 | 114 | * @note: See Bluetooth 5 Vol 2 PartE: 7.7.65.1 LE Connection Complete Event |
kenjiArai | 0:5b88d5760320 | 115 | * @note: See Bluetooth 5 Vol 2 PartE: 7.7.65.10 LE Enhanced Connection |
kenjiArai | 0:5b88d5760320 | 116 | */ |
kenjiArai | 0:5b88d5760320 | 117 | struct GapConnectionCompleteEvent : public GapEvent { |
kenjiArai | 0:5b88d5760320 | 118 | /** |
kenjiArai | 0:5b88d5760320 | 119 | * Construct a new GapConnectionCompleteEvent. |
kenjiArai | 0:5b88d5760320 | 120 | * |
kenjiArai | 0:5b88d5760320 | 121 | * @param status Status of the operation: 0x00 in case of success otherwise |
kenjiArai | 0:5b88d5760320 | 122 | * the error code associated with the failure. |
kenjiArai | 0:5b88d5760320 | 123 | * |
kenjiArai | 0:5b88d5760320 | 124 | * @param connection_handle handle of the connection created. This handle |
kenjiArai | 0:5b88d5760320 | 125 | * will be used to address the connection in any connection oriented |
kenjiArai | 0:5b88d5760320 | 126 | * operation. |
kenjiArai | 0:5b88d5760320 | 127 | * |
kenjiArai | 0:5b88d5760320 | 128 | * @param role Role of the LE subsystem in the connection. |
kenjiArai | 0:5b88d5760320 | 129 | * |
kenjiArai | 0:5b88d5760320 | 130 | * @param address_type Type of address used by the peer for this connection. |
kenjiArai | 0:5b88d5760320 | 131 | * |
kenjiArai | 0:5b88d5760320 | 132 | * @param address Address of the peer used to establish the connection. |
kenjiArai | 0:5b88d5760320 | 133 | * |
kenjiArai | 0:5b88d5760320 | 134 | * @param connection_interval Connection interval used on this connection. |
kenjiArai | 0:5b88d5760320 | 135 | * It shall be in a range [0x0006 : 0x0C80]. A unit is equal to 1.25ms. |
kenjiArai | 0:5b88d5760320 | 136 | * |
kenjiArai | 0:5b88d5760320 | 137 | * @param connection_latency Number of connection events the slave can |
kenjiArai | 0:5b88d5760320 | 138 | * drop. |
kenjiArai | 0:5b88d5760320 | 139 | * |
kenjiArai | 0:5b88d5760320 | 140 | * @param supervision_timeout Supervision timeout of the connection. It |
kenjiArai | 0:5b88d5760320 | 141 | * shall be in the range [0x000A : 0x0C80] where a unit represent 10ms. |
kenjiArai | 0:5b88d5760320 | 142 | * |
kenjiArai | 0:5b88d5760320 | 143 | * @note: See Bluetooth 5 Vol 2 PartE: 7.7.65.10 LE Enhanced Connection |
kenjiArai | 0:5b88d5760320 | 144 | * Complete Event |
kenjiArai | 0:5b88d5760320 | 145 | */ |
kenjiArai | 0:5b88d5760320 | 146 | GapConnectionCompleteEvent( |
kenjiArai | 0:5b88d5760320 | 147 | uint8_t status, |
kenjiArai | 0:5b88d5760320 | 148 | connection_handle_t connection_handle, |
kenjiArai | 0:5b88d5760320 | 149 | connection_role_t role, |
kenjiArai | 0:5b88d5760320 | 150 | advertising_peer_address_type_t peer_address_type, |
kenjiArai | 0:5b88d5760320 | 151 | const address_t& peer_address, |
kenjiArai | 0:5b88d5760320 | 152 | uint16_t connection_interval, |
kenjiArai | 0:5b88d5760320 | 153 | uint16_t connection_latency, |
kenjiArai | 0:5b88d5760320 | 154 | uint16_t supervision_timeout |
kenjiArai | 0:5b88d5760320 | 155 | ) : |
kenjiArai | 0:5b88d5760320 | 156 | GapEvent(GapEventType::CONNECTION_COMPLETE), |
kenjiArai | 0:5b88d5760320 | 157 | status(status), |
kenjiArai | 0:5b88d5760320 | 158 | connection_handle(connection_handle), |
kenjiArai | 0:5b88d5760320 | 159 | role(role), |
kenjiArai | 0:5b88d5760320 | 160 | peer_address_type( |
kenjiArai | 0:5b88d5760320 | 161 | peer_address_type == advertising_peer_address_type_t::PUBLIC ? |
kenjiArai | 0:5b88d5760320 | 162 | peer_address_type_t::PUBLIC : |
kenjiArai | 0:5b88d5760320 | 163 | peer_address_type_t::RANDOM |
kenjiArai | 0:5b88d5760320 | 164 | ), |
kenjiArai | 0:5b88d5760320 | 165 | peer_address(peer_address), |
kenjiArai | 0:5b88d5760320 | 166 | connection_interval(connection_interval), |
kenjiArai | 0:5b88d5760320 | 167 | connection_latency(connection_latency), |
kenjiArai | 0:5b88d5760320 | 168 | supervision_timeout(supervision_timeout), |
kenjiArai | 0:5b88d5760320 | 169 | local_resolvable_private_address(), |
kenjiArai | 0:5b88d5760320 | 170 | peer_resolvable_private_address() { |
kenjiArai | 0:5b88d5760320 | 171 | } |
kenjiArai | 0:5b88d5760320 | 172 | |
kenjiArai | 0:5b88d5760320 | 173 | /** |
kenjiArai | 0:5b88d5760320 | 174 | * Construct a new GapConnectionCompleteEvent. |
kenjiArai | 0:5b88d5760320 | 175 | * |
kenjiArai | 0:5b88d5760320 | 176 | * @param status Status of the operation: 0x00 in case of success otherwise |
kenjiArai | 0:5b88d5760320 | 177 | * the error code associated with the failure. |
kenjiArai | 0:5b88d5760320 | 178 | * |
kenjiArai | 0:5b88d5760320 | 179 | * @param connection_handle handle of the connection created. This handle |
kenjiArai | 0:5b88d5760320 | 180 | * will be used to address the connection in any connection oriented |
kenjiArai | 0:5b88d5760320 | 181 | * operation. |
kenjiArai | 0:5b88d5760320 | 182 | * |
kenjiArai | 0:5b88d5760320 | 183 | * @param role Role of the LE subsystem in the connection. |
kenjiArai | 0:5b88d5760320 | 184 | * |
kenjiArai | 0:5b88d5760320 | 185 | * @param address_type Type of address used by the peer for this connection. |
kenjiArai | 0:5b88d5760320 | 186 | * |
kenjiArai | 0:5b88d5760320 | 187 | * @param address Address of the peer used to establish the connection. |
kenjiArai | 0:5b88d5760320 | 188 | * |
kenjiArai | 0:5b88d5760320 | 189 | * @param connection_interval Connection interval used on this connection. |
kenjiArai | 0:5b88d5760320 | 190 | * It shall be in a range [0x0006 : 0x0C80]. A unit is equal to 1.25ms. |
kenjiArai | 0:5b88d5760320 | 191 | * |
kenjiArai | 0:5b88d5760320 | 192 | * @param connection_latency Number of connection events the slave can |
kenjiArai | 0:5b88d5760320 | 193 | * drop. |
kenjiArai | 0:5b88d5760320 | 194 | * |
kenjiArai | 0:5b88d5760320 | 195 | * @param supervision_timeout Supervision timeout of the connection. It |
kenjiArai | 0:5b88d5760320 | 196 | * shall be in the range [0x000A : 0x0C80] where a unit represent 10ms. |
kenjiArai | 0:5b88d5760320 | 197 | * |
kenjiArai | 0:5b88d5760320 | 198 | * @param local_resolvable_private_address Resolvable private address used |
kenjiArai | 0:5b88d5760320 | 199 | * by the local device to establish the connection. |
kenjiArai | 0:5b88d5760320 | 200 | * |
kenjiArai | 0:5b88d5760320 | 201 | * @param peer_resolvable_private_address Resolvable private address used |
kenjiArai | 0:5b88d5760320 | 202 | * by the peer to establish the connection. |
kenjiArai | 0:5b88d5760320 | 203 | * |
kenjiArai | 0:5b88d5760320 | 204 | * @note: See Bluetooth 5 Vol 2 PartE: 7.7.65.10 LE Enhanced Connection |
kenjiArai | 0:5b88d5760320 | 205 | * Complete Event |
kenjiArai | 0:5b88d5760320 | 206 | */ |
kenjiArai | 0:5b88d5760320 | 207 | GapConnectionCompleteEvent( |
kenjiArai | 0:5b88d5760320 | 208 | uint8_t status, |
kenjiArai | 0:5b88d5760320 | 209 | connection_handle_t connection_handle, |
kenjiArai | 0:5b88d5760320 | 210 | connection_role_t role, |
kenjiArai | 0:5b88d5760320 | 211 | peer_address_type_t peer_address_type, |
kenjiArai | 0:5b88d5760320 | 212 | const address_t& peer_address, |
kenjiArai | 0:5b88d5760320 | 213 | uint16_t connection_interval, |
kenjiArai | 0:5b88d5760320 | 214 | uint16_t connection_latency, |
kenjiArai | 0:5b88d5760320 | 215 | uint16_t supervision_timeout, |
kenjiArai | 0:5b88d5760320 | 216 | const address_t& local_resolvable_private_address, |
kenjiArai | 0:5b88d5760320 | 217 | const address_t& peer_resolvable_private_address |
kenjiArai | 0:5b88d5760320 | 218 | ) : |
kenjiArai | 0:5b88d5760320 | 219 | GapEvent(GapEventType::CONNECTION_COMPLETE), |
kenjiArai | 0:5b88d5760320 | 220 | status(status), |
kenjiArai | 0:5b88d5760320 | 221 | connection_handle(connection_handle), |
kenjiArai | 0:5b88d5760320 | 222 | role(role), |
kenjiArai | 0:5b88d5760320 | 223 | peer_address_type(peer_address_type), |
kenjiArai | 0:5b88d5760320 | 224 | peer_address(peer_address), |
kenjiArai | 0:5b88d5760320 | 225 | connection_interval(connection_interval), |
kenjiArai | 0:5b88d5760320 | 226 | connection_latency(connection_latency), |
kenjiArai | 0:5b88d5760320 | 227 | supervision_timeout(supervision_timeout), |
kenjiArai | 0:5b88d5760320 | 228 | local_resolvable_private_address(local_resolvable_private_address), |
kenjiArai | 0:5b88d5760320 | 229 | peer_resolvable_private_address(peer_resolvable_private_address) { |
kenjiArai | 0:5b88d5760320 | 230 | } |
kenjiArai | 0:5b88d5760320 | 231 | |
kenjiArai | 0:5b88d5760320 | 232 | |
kenjiArai | 0:5b88d5760320 | 233 | /* |
kenjiArai | 0:5b88d5760320 | 234 | * @param status Indicate if the connection succesfully completed or not: |
kenjiArai | 0:5b88d5760320 | 235 | * - 0: Connection successfuly completed |
kenjiArai | 0:5b88d5760320 | 236 | * - [0x01 : 0xFF] Connection failed to complete, the value represent |
kenjiArai | 0:5b88d5760320 | 237 | * the code for the error. |
kenjiArai | 0:5b88d5760320 | 238 | */ |
kenjiArai | 0:5b88d5760320 | 239 | const uint8_t status; |
kenjiArai | 0:5b88d5760320 | 240 | |
kenjiArai | 0:5b88d5760320 | 241 | /** |
kenjiArai | 0:5b88d5760320 | 242 | * Handle of the connection created, valid if status is equal to 0. |
kenjiArai | 0:5b88d5760320 | 243 | * @attention Valid if status is equal to 0. |
kenjiArai | 0:5b88d5760320 | 244 | */ |
kenjiArai | 0:5b88d5760320 | 245 | const connection_handle_t connection_handle; |
kenjiArai | 0:5b88d5760320 | 246 | |
kenjiArai | 0:5b88d5760320 | 247 | /** |
kenjiArai | 0:5b88d5760320 | 248 | * Role of the device in the connection |
kenjiArai | 0:5b88d5760320 | 249 | * @attention Valid if status is equal to 0. |
kenjiArai | 0:5b88d5760320 | 250 | */ |
kenjiArai | 0:5b88d5760320 | 251 | const connection_role_t role; |
kenjiArai | 0:5b88d5760320 | 252 | |
kenjiArai | 0:5b88d5760320 | 253 | /** |
kenjiArai | 0:5b88d5760320 | 254 | * Peer address type. |
kenjiArai | 0:5b88d5760320 | 255 | */ |
kenjiArai | 0:5b88d5760320 | 256 | const peer_address_type_t peer_address_type; |
kenjiArai | 0:5b88d5760320 | 257 | |
kenjiArai | 0:5b88d5760320 | 258 | /** |
kenjiArai | 0:5b88d5760320 | 259 | * Peer address. |
kenjiArai | 0:5b88d5760320 | 260 | */ |
kenjiArai | 0:5b88d5760320 | 261 | const address_t peer_address; |
kenjiArai | 0:5b88d5760320 | 262 | |
kenjiArai | 0:5b88d5760320 | 263 | /** |
kenjiArai | 0:5b88d5760320 | 264 | * Connection interval used in this connection. |
kenjiArai | 0:5b88d5760320 | 265 | * It shall be in a range [0x0006 : 0x0C80]. A unit is equal to 1.25ms. |
kenjiArai | 0:5b88d5760320 | 266 | */ |
kenjiArai | 0:5b88d5760320 | 267 | const uint16_t connection_interval; |
kenjiArai | 0:5b88d5760320 | 268 | |
kenjiArai | 0:5b88d5760320 | 269 | /** |
kenjiArai | 0:5b88d5760320 | 270 | * Number of connection events the slave can drop. |
kenjiArai | 0:5b88d5760320 | 271 | */ |
kenjiArai | 0:5b88d5760320 | 272 | const uint16_t connection_latency; |
kenjiArai | 0:5b88d5760320 | 273 | |
kenjiArai | 0:5b88d5760320 | 274 | /** |
kenjiArai | 0:5b88d5760320 | 275 | * Supervision timeout of the connection |
kenjiArai | 0:5b88d5760320 | 276 | * It shall be in the range [0x000A : 0x0C80] where a unit represent 10ms. |
kenjiArai | 0:5b88d5760320 | 277 | */ |
kenjiArai | 0:5b88d5760320 | 278 | const uint16_t supervision_timeout; |
kenjiArai | 0:5b88d5760320 | 279 | |
kenjiArai | 0:5b88d5760320 | 280 | /** |
kenjiArai | 0:5b88d5760320 | 281 | * Resolvable private address of the local device. |
kenjiArai | 0:5b88d5760320 | 282 | * Set to all 0 if not available. |
kenjiArai | 0:5b88d5760320 | 283 | */ |
kenjiArai | 0:5b88d5760320 | 284 | const address_t local_resolvable_private_address; |
kenjiArai | 0:5b88d5760320 | 285 | |
kenjiArai | 0:5b88d5760320 | 286 | /** |
kenjiArai | 0:5b88d5760320 | 287 | * Resolvable private address of the peer. |
kenjiArai | 0:5b88d5760320 | 288 | * Set to all 0 if not available. * |
kenjiArai | 0:5b88d5760320 | 289 | */ |
kenjiArai | 0:5b88d5760320 | 290 | const address_t peer_resolvable_private_address; |
kenjiArai | 0:5b88d5760320 | 291 | }; |
kenjiArai | 0:5b88d5760320 | 292 | |
kenjiArai | 0:5b88d5760320 | 293 | |
kenjiArai | 0:5b88d5760320 | 294 | /** |
kenjiArai | 0:5b88d5760320 | 295 | * Report advertising from one or more LE device. |
kenjiArai | 0:5b88d5760320 | 296 | * |
kenjiArai | 0:5b88d5760320 | 297 | * @attention This class has to be implemented by the BLE port. |
kenjiArai | 0:5b88d5760320 | 298 | * |
kenjiArai | 0:5b88d5760320 | 299 | * @note: See Bluetooth 5 Vol 2 PartE: 7.7.65.2 LE Advertising Report Event |
kenjiArai | 0:5b88d5760320 | 300 | */ |
kenjiArai | 0:5b88d5760320 | 301 | struct GapAdvertisingReportEvent : public GapEvent { |
kenjiArai | 0:5b88d5760320 | 302 | |
kenjiArai | 0:5b88d5760320 | 303 | /** |
kenjiArai | 0:5b88d5760320 | 304 | * POD representing an advertising captured by the LE subsystem. |
kenjiArai | 0:5b88d5760320 | 305 | */ |
kenjiArai | 0:5b88d5760320 | 306 | struct advertising_t { |
kenjiArai | 0:5b88d5760320 | 307 | received_advertising_type_t type; |
kenjiArai | 0:5b88d5760320 | 308 | connection_peer_address_type_t address_type; |
kenjiArai | 0:5b88d5760320 | 309 | address_t address; |
kenjiArai | 0:5b88d5760320 | 310 | Span<const uint8_t> data; |
kenjiArai | 0:5b88d5760320 | 311 | int8_t rssi; |
kenjiArai | 0:5b88d5760320 | 312 | }; |
kenjiArai | 0:5b88d5760320 | 313 | |
kenjiArai | 0:5b88d5760320 | 314 | GapAdvertisingReportEvent() : GapEvent(GapEventType::ADVERTISING_REPORT) { } |
kenjiArai | 0:5b88d5760320 | 315 | |
kenjiArai | 0:5b88d5760320 | 316 | virtual ~GapAdvertisingReportEvent() { } |
kenjiArai | 0:5b88d5760320 | 317 | |
kenjiArai | 0:5b88d5760320 | 318 | /** |
kenjiArai | 0:5b88d5760320 | 319 | * Count of advertising in this event. |
kenjiArai | 0:5b88d5760320 | 320 | */ |
kenjiArai | 0:5b88d5760320 | 321 | virtual uint8_t size() const = 0; |
kenjiArai | 0:5b88d5760320 | 322 | |
kenjiArai | 0:5b88d5760320 | 323 | /** |
kenjiArai | 0:5b88d5760320 | 324 | * Access the advertising at index i. |
kenjiArai | 0:5b88d5760320 | 325 | */ |
kenjiArai | 0:5b88d5760320 | 326 | virtual advertising_t operator[](uint8_t i) const = 0; |
kenjiArai | 0:5b88d5760320 | 327 | }; |
kenjiArai | 0:5b88d5760320 | 328 | |
kenjiArai | 0:5b88d5760320 | 329 | |
kenjiArai | 0:5b88d5760320 | 330 | /** |
kenjiArai | 0:5b88d5760320 | 331 | * Indicates the connection update process completion. |
kenjiArai | 0:5b88d5760320 | 332 | * |
kenjiArai | 0:5b88d5760320 | 333 | * If no parameters are updated after a connection update request from the peer |
kenjiArai | 0:5b88d5760320 | 334 | * then this event shall not be emmited. |
kenjiArai | 0:5b88d5760320 | 335 | * |
kenjiArai | 0:5b88d5760320 | 336 | * @note: See Bluetooth 5 Vol 2 PartE: 7.7.65.3 LE Connection Update Complete |
kenjiArai | 0:5b88d5760320 | 337 | * Event. |
kenjiArai | 0:5b88d5760320 | 338 | */ |
kenjiArai | 0:5b88d5760320 | 339 | struct GapConnectionUpdateEvent : public GapEvent { |
kenjiArai | 0:5b88d5760320 | 340 | |
kenjiArai | 0:5b88d5760320 | 341 | /** |
kenjiArai | 0:5b88d5760320 | 342 | * Construct a connection update event for a successful process. |
kenjiArai | 0:5b88d5760320 | 343 | * |
kenjiArai | 0:5b88d5760320 | 344 | * @param status Status of the connection update event operation. If equal |
kenjiArai | 0:5b88d5760320 | 345 | * to 0x00 then the process was successful, otherwise the status indicates |
kenjiArai | 0:5b88d5760320 | 346 | * the reason of the faillure. |
kenjiArai | 0:5b88d5760320 | 347 | * |
kenjiArai | 0:5b88d5760320 | 348 | * @param connection_handle Handle of the connection updated. |
kenjiArai | 0:5b88d5760320 | 349 | * |
kenjiArai | 0:5b88d5760320 | 350 | * @param connection_interval New connection interval used by the connection. |
kenjiArai | 0:5b88d5760320 | 351 | * |
kenjiArai | 0:5b88d5760320 | 352 | * @param Connection_latency New connection latency used by the connection. |
kenjiArai | 0:5b88d5760320 | 353 | * |
kenjiArai | 0:5b88d5760320 | 354 | * @param supervision_timeout New connection supervision timeout. |
kenjiArai | 0:5b88d5760320 | 355 | */ |
kenjiArai | 0:5b88d5760320 | 356 | GapConnectionUpdateEvent( |
kenjiArai | 0:5b88d5760320 | 357 | uint8_t status, |
kenjiArai | 0:5b88d5760320 | 358 | connection_handle_t connection_handle, |
kenjiArai | 0:5b88d5760320 | 359 | uint16_t connection_interval, |
kenjiArai | 0:5b88d5760320 | 360 | uint16_t connection_latency, |
kenjiArai | 0:5b88d5760320 | 361 | uint16_t supervision_timeout |
kenjiArai | 0:5b88d5760320 | 362 | ) : |
kenjiArai | 0:5b88d5760320 | 363 | GapEvent(GapEventType::CONNECTION_UPDATE), |
kenjiArai | 0:5b88d5760320 | 364 | status(status), |
kenjiArai | 0:5b88d5760320 | 365 | connection_handle(connection_handle), |
kenjiArai | 0:5b88d5760320 | 366 | connection_interval(connection_interval), |
kenjiArai | 0:5b88d5760320 | 367 | connection_latency(connection_latency), |
kenjiArai | 0:5b88d5760320 | 368 | supervision_timeout(supervision_timeout) { |
kenjiArai | 0:5b88d5760320 | 369 | } |
kenjiArai | 0:5b88d5760320 | 370 | |
kenjiArai | 0:5b88d5760320 | 371 | /** |
kenjiArai | 0:5b88d5760320 | 372 | * If equal to 0, the connection update has succesfully completed otherwise |
kenjiArai | 0:5b88d5760320 | 373 | * the process has failled and this field represent the error associated to |
kenjiArai | 0:5b88d5760320 | 374 | * the faillure. |
kenjiArai | 0:5b88d5760320 | 375 | */ |
kenjiArai | 0:5b88d5760320 | 376 | const uint8_t status; |
kenjiArai | 0:5b88d5760320 | 377 | |
kenjiArai | 0:5b88d5760320 | 378 | /** |
kenjiArai | 0:5b88d5760320 | 379 | * Handle of the connection which has completed the connection update |
kenjiArai | 0:5b88d5760320 | 380 | * process. |
kenjiArai | 0:5b88d5760320 | 381 | */ |
kenjiArai | 0:5b88d5760320 | 382 | const connection_handle_t connection_handle; |
kenjiArai | 0:5b88d5760320 | 383 | |
kenjiArai | 0:5b88d5760320 | 384 | /** |
kenjiArai | 0:5b88d5760320 | 385 | * New connection interval used by the connection. |
kenjiArai | 0:5b88d5760320 | 386 | * It shall be in a range [0x0006 : 0x0C80]. A unit is equal to 1.25ms. |
kenjiArai | 0:5b88d5760320 | 387 | */ |
kenjiArai | 0:5b88d5760320 | 388 | const uint16_t connection_interval; |
kenjiArai | 0:5b88d5760320 | 389 | |
kenjiArai | 0:5b88d5760320 | 390 | /* |
kenjiArai | 0:5b88d5760320 | 391 | * New number of connection events the slave can drop. |
kenjiArai | 0:5b88d5760320 | 392 | */ |
kenjiArai | 0:5b88d5760320 | 393 | const uint16_t connection_latency; |
kenjiArai | 0:5b88d5760320 | 394 | |
kenjiArai | 0:5b88d5760320 | 395 | /* |
kenjiArai | 0:5b88d5760320 | 396 | * New supervision timeout of the connection. |
kenjiArai | 0:5b88d5760320 | 397 | * It shall be in the range [0x000A : 0x0C80] where a unit represent 10ms. |
kenjiArai | 0:5b88d5760320 | 398 | */ |
kenjiArai | 0:5b88d5760320 | 399 | const uint16_t supervision_timeout; |
kenjiArai | 0:5b88d5760320 | 400 | }; |
kenjiArai | 0:5b88d5760320 | 401 | |
kenjiArai | 0:5b88d5760320 | 402 | |
kenjiArai | 0:5b88d5760320 | 403 | /** |
kenjiArai | 0:5b88d5760320 | 404 | * indicate a request from the peer to change the connection parameters. |
kenjiArai | 0:5b88d5760320 | 405 | * |
kenjiArai | 0:5b88d5760320 | 406 | * @note: See Bluetooth 5 Vol 2 PartE: 7.7.65.6 LE Remote Connection Parameter |
kenjiArai | 0:5b88d5760320 | 407 | * Request Event. |
kenjiArai | 0:5b88d5760320 | 408 | */ |
kenjiArai | 0:5b88d5760320 | 409 | struct GapRemoteConnectionParameterRequestEvent : public GapEvent { |
kenjiArai | 0:5b88d5760320 | 410 | /** |
kenjiArai | 0:5b88d5760320 | 411 | * Construct a new remote connection parameter request event. |
kenjiArai | 0:5b88d5760320 | 412 | * |
kenjiArai | 0:5b88d5760320 | 413 | * @param connection_handle Handle of the connection with the peer |
kenjiArai | 0:5b88d5760320 | 414 | * requesting the parameter update |
kenjiArai | 0:5b88d5760320 | 415 | * |
kenjiArai | 0:5b88d5760320 | 416 | * @param min_connection_interval Minimum value of the connection interval |
kenjiArai | 0:5b88d5760320 | 417 | * requested by the peer. |
kenjiArai | 0:5b88d5760320 | 418 | * |
kenjiArai | 0:5b88d5760320 | 419 | * @param max_connection_interval Maximum value of the connection interval |
kenjiArai | 0:5b88d5760320 | 420 | * requested by the peer. |
kenjiArai | 0:5b88d5760320 | 421 | * |
kenjiArai | 0:5b88d5760320 | 422 | * @param connection_latency Slave latency requested by the peer. |
kenjiArai | 0:5b88d5760320 | 423 | * |
kenjiArai | 0:5b88d5760320 | 424 | * @param supervision_timeout Supervision timeout requested by the peer. |
kenjiArai | 0:5b88d5760320 | 425 | */ |
kenjiArai | 0:5b88d5760320 | 426 | GapRemoteConnectionParameterRequestEvent( |
kenjiArai | 0:5b88d5760320 | 427 | connection_handle_t connection_handle, |
kenjiArai | 0:5b88d5760320 | 428 | uint16_t min_connection_interval, |
kenjiArai | 0:5b88d5760320 | 429 | uint16_t max_connection_interval, |
kenjiArai | 0:5b88d5760320 | 430 | uint16_t connection_latency, |
kenjiArai | 0:5b88d5760320 | 431 | uint16_t supervision_timeout |
kenjiArai | 0:5b88d5760320 | 432 | ) : GapEvent(GapEventType::REMOTE_CONNECTION_PARAMETER_REQUEST), |
kenjiArai | 0:5b88d5760320 | 433 | connection_handle(connection_handle), |
kenjiArai | 0:5b88d5760320 | 434 | min_connection_interval(min_connection_interval), |
kenjiArai | 0:5b88d5760320 | 435 | max_connection_interval(max_connection_interval), |
kenjiArai | 0:5b88d5760320 | 436 | connection_latency(connection_latency), |
kenjiArai | 0:5b88d5760320 | 437 | supervision_timeout(supervision_timeout) { |
kenjiArai | 0:5b88d5760320 | 438 | } |
kenjiArai | 0:5b88d5760320 | 439 | |
kenjiArai | 0:5b88d5760320 | 440 | /** |
kenjiArai | 0:5b88d5760320 | 441 | * Handle of the connection with the peer requesting the parameter update. |
kenjiArai | 0:5b88d5760320 | 442 | */ |
kenjiArai | 0:5b88d5760320 | 443 | const connection_handle_t connection_handle; |
kenjiArai | 0:5b88d5760320 | 444 | |
kenjiArai | 0:5b88d5760320 | 445 | /** |
kenjiArai | 0:5b88d5760320 | 446 | * Minimum value of the connection interval requested by the peer. |
kenjiArai | 0:5b88d5760320 | 447 | * It shall be in a range [0x0006 : 0x0C80]. A unit is equal to 1.25ms. |
kenjiArai | 0:5b88d5760320 | 448 | */ |
kenjiArai | 0:5b88d5760320 | 449 | const uint16_t min_connection_interval; |
kenjiArai | 0:5b88d5760320 | 450 | |
kenjiArai | 0:5b88d5760320 | 451 | /** |
kenjiArai | 0:5b88d5760320 | 452 | * Maximum value of the connection interval requested by the peer. |
kenjiArai | 0:5b88d5760320 | 453 | * It shall be in a range [0x0006 : 0x0C80]. A unit is equal to 1.25ms. |
kenjiArai | 0:5b88d5760320 | 454 | */ |
kenjiArai | 0:5b88d5760320 | 455 | const uint16_t max_connection_interval; |
kenjiArai | 0:5b88d5760320 | 456 | |
kenjiArai | 0:5b88d5760320 | 457 | /* |
kenjiArai | 0:5b88d5760320 | 458 | * Slave latency requested by the peer. |
kenjiArai | 0:5b88d5760320 | 459 | */ |
kenjiArai | 0:5b88d5760320 | 460 | const uint16_t connection_latency; |
kenjiArai | 0:5b88d5760320 | 461 | |
kenjiArai | 0:5b88d5760320 | 462 | /* |
kenjiArai | 0:5b88d5760320 | 463 | * Supervision timeout requested by the peer. |
kenjiArai | 0:5b88d5760320 | 464 | * It shall be in the range [0x000A : 0x0C80] where a unit represent 10ms. |
kenjiArai | 0:5b88d5760320 | 465 | */ |
kenjiArai | 0:5b88d5760320 | 466 | const uint16_t supervision_timeout; |
kenjiArai | 0:5b88d5760320 | 467 | }; |
kenjiArai | 0:5b88d5760320 | 468 | |
kenjiArai | 0:5b88d5760320 | 469 | |
kenjiArai | 0:5b88d5760320 | 470 | /** |
kenjiArai | 0:5b88d5760320 | 471 | * Indicate the end of a disconnection process. |
kenjiArai | 0:5b88d5760320 | 472 | * |
kenjiArai | 0:5b88d5760320 | 473 | * @note: See Bluetooth 5 Vol 2 PartE: 7.7.5 Disconnection Complete Event. |
kenjiArai | 0:5b88d5760320 | 474 | */ |
kenjiArai | 0:5b88d5760320 | 475 | struct GapDisconnectionCompleteEvent : public GapEvent { |
kenjiArai | 0:5b88d5760320 | 476 | /** |
kenjiArai | 0:5b88d5760320 | 477 | * Construct a disconnection complete event. |
kenjiArai | 0:5b88d5760320 | 478 | * |
kenjiArai | 0:5b88d5760320 | 479 | * @param status Status of the procedure. If equal to 0 then the |
kenjiArai | 0:5b88d5760320 | 480 | * disconnection process complete successfully. Otherwise it represents the |
kenjiArai | 0:5b88d5760320 | 481 | * error code associated with the faillure. |
kenjiArai | 0:5b88d5760320 | 482 | * |
kenjiArai | 0:5b88d5760320 | 483 | * @param connection_handle Handle of the connection disconnected. |
kenjiArai | 0:5b88d5760320 | 484 | * |
kenjiArai | 0:5b88d5760320 | 485 | * @param reason Reason of the disconnection |
kenjiArai | 0:5b88d5760320 | 486 | */ |
kenjiArai | 0:5b88d5760320 | 487 | GapDisconnectionCompleteEvent( |
kenjiArai | 0:5b88d5760320 | 488 | uint8_t status, |
kenjiArai | 0:5b88d5760320 | 489 | connection_handle_t connection_handle, |
kenjiArai | 0:5b88d5760320 | 490 | uint8_t reason |
kenjiArai | 0:5b88d5760320 | 491 | ) : GapEvent(GapEventType::DISCONNECTION_COMPLETE), |
kenjiArai | 0:5b88d5760320 | 492 | status(status), |
kenjiArai | 0:5b88d5760320 | 493 | connection_handle(connection_handle), |
kenjiArai | 0:5b88d5760320 | 494 | reason(reason) { |
kenjiArai | 0:5b88d5760320 | 495 | } |
kenjiArai | 0:5b88d5760320 | 496 | |
kenjiArai | 0:5b88d5760320 | 497 | /** |
kenjiArai | 0:5b88d5760320 | 498 | * Status of the procedure. If equal to 0 then the procedure was a success |
kenjiArai | 0:5b88d5760320 | 499 | * otherwise this variable contains the error code associated with the |
kenjiArai | 0:5b88d5760320 | 500 | * faillure. |
kenjiArai | 0:5b88d5760320 | 501 | */ |
kenjiArai | 0:5b88d5760320 | 502 | const uint8_t status; |
kenjiArai | 0:5b88d5760320 | 503 | |
kenjiArai | 0:5b88d5760320 | 504 | /** |
kenjiArai | 0:5b88d5760320 | 505 | * Handle of the connection used for the procedure. |
kenjiArai | 0:5b88d5760320 | 506 | */ |
kenjiArai | 0:5b88d5760320 | 507 | const connection_handle_t connection_handle; |
kenjiArai | 0:5b88d5760320 | 508 | |
kenjiArai | 0:5b88d5760320 | 509 | /** |
kenjiArai | 0:5b88d5760320 | 510 | * Reason for disconnection. |
kenjiArai | 0:5b88d5760320 | 511 | * |
kenjiArai | 0:5b88d5760320 | 512 | * @attention ignored in case of faillure. |
kenjiArai | 0:5b88d5760320 | 513 | */ |
kenjiArai | 0:5b88d5760320 | 514 | const uint8_t reason; |
kenjiArai | 0:5b88d5760320 | 515 | }; |
kenjiArai | 0:5b88d5760320 | 516 | |
kenjiArai | 0:5b88d5760320 | 517 | } // namespace pal |
kenjiArai | 0:5b88d5760320 | 518 | } // namespace ble |
kenjiArai | 0:5b88d5760320 | 519 | |
kenjiArai | 0:5b88d5760320 | 520 | #endif /* BLE_PAL_GAP_MESSAGE_H_ */ |