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 BLE_PAL_ATT_SERVER_MESSAGE_H_
kenjiArai 0:5b88d5760320 18 #define BLE_PAL_ATT_SERVER_MESSAGE_H_
kenjiArai 0:5b88d5760320 19
kenjiArai 0:5b88d5760320 20 #include "ble/BLETypes.h"
kenjiArai 0:5b88d5760320 21
kenjiArai 0:5b88d5760320 22 namespace ble {
kenjiArai 0:5b88d5760320 23 namespace pal {
kenjiArai 0:5b88d5760320 24
kenjiArai 0:5b88d5760320 25 /**
kenjiArai 0:5b88d5760320 26 * Operation code defined for attribute operations
kenjiArai 0:5b88d5760320 27 * @note see: BLUETOOTH SPECIFICATION Version 5.0 | Vol 3, Part F Section 3.4.8
kenjiArai 0:5b88d5760320 28 */
kenjiArai 0:5b88d5760320 29 struct AttributeOpcode {
kenjiArai 0:5b88d5760320 30 enum Code {
kenjiArai 0:5b88d5760320 31 ERROR_RESPONSE = 0x01, /// Opcode of an AttErrorResponse
kenjiArai 0:5b88d5760320 32 EXCHANGE_MTU_REQUEST = 0x02,
kenjiArai 0:5b88d5760320 33 EXCHANGE_MTU_RESPONSE = 0x03, /// OpCode of an AttExchangeMTUResponse
kenjiArai 0:5b88d5760320 34 FIND_INFORMATION_REQUEST = 0x04,
kenjiArai 0:5b88d5760320 35 FIND_INFORMATION_RESPONSE = 0x05, /// OpCode of an AttFindInformationResponse
kenjiArai 0:5b88d5760320 36 FIND_BY_TYPE_VALUE_REQUEST = 0x06,
kenjiArai 0:5b88d5760320 37 FIND_BY_VALUE_TYPE_RESPONSE = 0x07, /// OpCode of an AttFindByTypeValueResponse
kenjiArai 0:5b88d5760320 38 READ_BY_TYPE_REQUEST = 0x08,
kenjiArai 0:5b88d5760320 39 READ_BY_TYPE_RESPONSE = 0x09, /// Opcode of an AttReadByTypeResponse
kenjiArai 0:5b88d5760320 40 READ_REQUEST = 0x0A,
kenjiArai 0:5b88d5760320 41 READ_RESPONSE = 0x0B, /// Opcode of an AttReadResponse
kenjiArai 0:5b88d5760320 42 READ_BLOB_REQUEST = 0x0C,
kenjiArai 0:5b88d5760320 43 READ_BLOB_RESPONSE = 0x0D, /// Opcode of an AttReadBlobResponse
kenjiArai 0:5b88d5760320 44 READ_MULTIPLE_REQUEST = 0x0E,
kenjiArai 0:5b88d5760320 45 READ_MULTIPLE_RESPONSE = 0x0F, /// Opcode of an AttReadMultipleResponse
kenjiArai 0:5b88d5760320 46 READ_BY_GROUP_TYPE_REQUEST = 0x10,
kenjiArai 0:5b88d5760320 47 READ_BY_GROUP_TYPE_RESPONSE = 0x11, /// Opcode of an AttReadByGroupTypeResponse
kenjiArai 0:5b88d5760320 48 WRITE_REQUEST = 0x12,
kenjiArai 0:5b88d5760320 49 WRITE_RESPONSE = 0x13, /// Opcode of an AttWriteResponse
kenjiArai 0:5b88d5760320 50 WRITE_COMMAND = 0x52,
kenjiArai 0:5b88d5760320 51 SIGNED_WRITE_COMMAND = 0xD2,
kenjiArai 0:5b88d5760320 52 PREPARE_WRITE_REQUEST = 0x16,
kenjiArai 0:5b88d5760320 53 PREPARE_WRITE_RESPONSE = 0x17, /// Opcode of an AttPrepareWriteResponse
kenjiArai 0:5b88d5760320 54 EXECUTE_WRITE_REQUEST = 0x18,
kenjiArai 0:5b88d5760320 55 EXECUTE_WRITE_RESPONSE = 0x19, /// Opcode of an AttExecuteWriteResponse
kenjiArai 0:5b88d5760320 56 HANDLE_VALUE_NOTIFICATION = 0x1B,
kenjiArai 0:5b88d5760320 57 HANDLE_VALUE_INDICATION = 0x1D
kenjiArai 0:5b88d5760320 58 };
kenjiArai 0:5b88d5760320 59
kenjiArai 0:5b88d5760320 60 /**
kenjiArai 0:5b88d5760320 61 * Construct an AttributeOpcode from a Code.
kenjiArai 0:5b88d5760320 62 */
kenjiArai 0:5b88d5760320 63 AttributeOpcode(Code value) : _value(value) { }
kenjiArai 0:5b88d5760320 64
kenjiArai 0:5b88d5760320 65 /**
kenjiArai 0:5b88d5760320 66 * Equality comparison operator between two AttributeOpcode
kenjiArai 0:5b88d5760320 67 */
kenjiArai 0:5b88d5760320 68 friend bool operator==(AttributeOpcode lhs, AttributeOpcode rhs) {
kenjiArai 0:5b88d5760320 69 return lhs._value == rhs._value;
kenjiArai 0:5b88d5760320 70 }
kenjiArai 0:5b88d5760320 71
kenjiArai 0:5b88d5760320 72 /**
kenjiArai 0:5b88d5760320 73 * Non equality comparison operator between two AttributeOpcode
kenjiArai 0:5b88d5760320 74 */
kenjiArai 0:5b88d5760320 75 friend bool operator!=(AttributeOpcode lhs, AttributeOpcode rhs) {
kenjiArai 0:5b88d5760320 76 return lhs._value != rhs._value;
kenjiArai 0:5b88d5760320 77 }
kenjiArai 0:5b88d5760320 78
kenjiArai 0:5b88d5760320 79 /**
kenjiArai 0:5b88d5760320 80 * implicit cast to uint8_t.
kenjiArai 0:5b88d5760320 81 * Allows AttributeOpcode to be used in switch statements.
kenjiArai 0:5b88d5760320 82 */
kenjiArai 0:5b88d5760320 83 operator uint8_t() const {
kenjiArai 0:5b88d5760320 84 return _value;
kenjiArai 0:5b88d5760320 85 }
kenjiArai 0:5b88d5760320 86
kenjiArai 0:5b88d5760320 87 private:
kenjiArai 0:5b88d5760320 88 uint8_t _value;
kenjiArai 0:5b88d5760320 89 };
kenjiArai 0:5b88d5760320 90
kenjiArai 0:5b88d5760320 91
kenjiArai 0:5b88d5760320 92 /**
kenjiArai 0:5b88d5760320 93 * Base class for Attribute Server Message.
kenjiArai 0:5b88d5760320 94 * The correct type of the instance can be determined with the attribute opcode.
kenjiArai 0:5b88d5760320 95 * @note see BLUETOOTH SPECIFICATION Version 5.0 | Vol 3, Part F Section 3.3.1
kenjiArai 0:5b88d5760320 96 */
kenjiArai 0:5b88d5760320 97 struct AttServerMessage {
kenjiArai 0:5b88d5760320 98 /**
kenjiArai 0:5b88d5760320 99 * Op code used to identify the type of the attribute response.
kenjiArai 0:5b88d5760320 100 */
kenjiArai 0:5b88d5760320 101 const AttributeOpcode opcode;
kenjiArai 0:5b88d5760320 102
kenjiArai 0:5b88d5760320 103 protected:
kenjiArai 0:5b88d5760320 104 /**
kenjiArai 0:5b88d5760320 105 * Construction of an AttResponse is reserved for descendent of the class
kenjiArai 0:5b88d5760320 106 */
kenjiArai 0:5b88d5760320 107 AttServerMessage(AttributeOpcode opcode_) : opcode(opcode_) { }
kenjiArai 0:5b88d5760320 108 };
kenjiArai 0:5b88d5760320 109
kenjiArai 0:5b88d5760320 110
kenjiArai 0:5b88d5760320 111 /**
kenjiArai 0:5b88d5760320 112 * Response to a request which can't be performed
kenjiArai 0:5b88d5760320 113 * @note see BLUETOOTH SPECIFICATION Version 5.0 | Vol 3, Part F Section 3.4.1.1
kenjiArai 0:5b88d5760320 114 * for details about error response.
kenjiArai 0:5b88d5760320 115 * @note see BLUETOOTH SPECIFICATION Version 5.0 | Vol 3, Part F Section 3.4.9
kenjiArai 0:5b88d5760320 116 * which details possible error response by requests.
kenjiArai 0:5b88d5760320 117 */
kenjiArai 0:5b88d5760320 118 struct AttErrorResponse : public AttServerMessage {
kenjiArai 0:5b88d5760320 119 /**
kenjiArai 0:5b88d5760320 120 * Construct an attribute error response.
kenjiArai 0:5b88d5760320 121 *
kenjiArai 0:5b88d5760320 122 * @param request_opcode_ The Attribute opcode of the request that generated
kenjiArai 0:5b88d5760320 123 * the error.
kenjiArai 0:5b88d5760320 124 * @param handle_in_error_ The attribute handle that generated this error
kenjiArai 0:5b88d5760320 125 * response.
kenjiArai 0:5b88d5760320 126 * @param error_code The reason why the request has generated an error.
kenjiArai 0:5b88d5760320 127 */
kenjiArai 0:5b88d5760320 128 AttErrorResponse(
kenjiArai 0:5b88d5760320 129 AttributeOpcode request_opcode_,
kenjiArai 0:5b88d5760320 130 attribute_handle_t handle_in_error_,
kenjiArai 0:5b88d5760320 131 uint8_t error_code_
kenjiArai 0:5b88d5760320 132 ) : AttServerMessage(AttributeOpcode::ERROR_RESPONSE),
kenjiArai 0:5b88d5760320 133 request_opcode(request_opcode_),
kenjiArai 0:5b88d5760320 134 handle_in_error(handle_in_error_), error_code(error_code_) {
kenjiArai 0:5b88d5760320 135 }
kenjiArai 0:5b88d5760320 136
kenjiArai 0:5b88d5760320 137 /**
kenjiArai 0:5b88d5760320 138 * Construct an attribute error response in the case where there was no
kenjiArai 0:5b88d5760320 139 * attribute handle in the original response or if the request is not
kenjiArai 0:5b88d5760320 140 * supported.
kenjiArai 0:5b88d5760320 141 *
kenjiArai 0:5b88d5760320 142 * @param request_opcode_ The Attribute opcode of the request that generated
kenjiArai 0:5b88d5760320 143 * the error.
kenjiArai 0:5b88d5760320 144 * @param error_code The reason why the request has generated an error.
kenjiArai 0:5b88d5760320 145 */
kenjiArai 0:5b88d5760320 146 AttErrorResponse(
kenjiArai 0:5b88d5760320 147 AttributeOpcode request_opcode_,
kenjiArai 0:5b88d5760320 148 uint8_t error_code_
kenjiArai 0:5b88d5760320 149 ) : AttServerMessage(AttributeOpcode::ERROR_RESPONSE),
kenjiArai 0:5b88d5760320 150 request_opcode(request_opcode_),
kenjiArai 0:5b88d5760320 151 handle_in_error(0x0000), error_code(error_code_) {
kenjiArai 0:5b88d5760320 152 }
kenjiArai 0:5b88d5760320 153
kenjiArai 0:5b88d5760320 154 /**
kenjiArai 0:5b88d5760320 155 * The opcode of the request that generated this error response.
kenjiArai 0:5b88d5760320 156 */
kenjiArai 0:5b88d5760320 157 const AttributeOpcode request_opcode;
kenjiArai 0:5b88d5760320 158
kenjiArai 0:5b88d5760320 159 /**
kenjiArai 0:5b88d5760320 160 * The attribute handle that generated this error response.
kenjiArai 0:5b88d5760320 161 * If there was no attribute handle in the original request or if the
kenjiArai 0:5b88d5760320 162 * request is not supported, then this field is equal to 0x0000.
kenjiArai 0:5b88d5760320 163 */
kenjiArai 0:5b88d5760320 164 const attribute_handle_t handle_in_error;
kenjiArai 0:5b88d5760320 165
kenjiArai 0:5b88d5760320 166 /**
kenjiArai 0:5b88d5760320 167 * The reason why the request has generated an error response
kenjiArai 0:5b88d5760320 168 */
kenjiArai 0:5b88d5760320 169 const uint8_t error_code;
kenjiArai 0:5b88d5760320 170
kenjiArai 0:5b88d5760320 171 /**
kenjiArai 0:5b88d5760320 172 * List of Error codes for the ATT protocol
kenjiArai 0:5b88d5760320 173 */
kenjiArai 0:5b88d5760320 174 enum AttributeErrorCode {
kenjiArai 0:5b88d5760320 175 /** The attribute handle given was not valid on this server. */
kenjiArai 0:5b88d5760320 176 INVALID_HANDLE = 0x01,
kenjiArai 0:5b88d5760320 177
kenjiArai 0:5b88d5760320 178 /** The attribute cannot be read. */
kenjiArai 0:5b88d5760320 179 READ_NOT_PERMITTED = 0x02,
kenjiArai 0:5b88d5760320 180
kenjiArai 0:5b88d5760320 181 /** The attribute cannot be written. */
kenjiArai 0:5b88d5760320 182 WRITE_NOT_PERMITTED = 0x03,
kenjiArai 0:5b88d5760320 183
kenjiArai 0:5b88d5760320 184 /** The attribute PDU was invalid. */
kenjiArai 0:5b88d5760320 185 INVALID_PDU = 0x04,
kenjiArai 0:5b88d5760320 186
kenjiArai 0:5b88d5760320 187 /** The attribute requires authentication before it can be read or
kenjiArai 0:5b88d5760320 188 * written.
kenjiArai 0:5b88d5760320 189 */
kenjiArai 0:5b88d5760320 190 INSUFFICIENT_AUTHENTICATION = 0x05,
kenjiArai 0:5b88d5760320 191
kenjiArai 0:5b88d5760320 192 /** Attribute server does not support the request received from the
kenjiArai 0:5b88d5760320 193 * client.
kenjiArai 0:5b88d5760320 194 */
kenjiArai 0:5b88d5760320 195 REQUEST_NOT_SUPPORTED = 0x06,
kenjiArai 0:5b88d5760320 196
kenjiArai 0:5b88d5760320 197 /** Offset specified was past the end of the attribute. */
kenjiArai 0:5b88d5760320 198 INVALID_OFFSET = 0x07,
kenjiArai 0:5b88d5760320 199
kenjiArai 0:5b88d5760320 200 /** The attribute requires authorization before it can be read or written. */
kenjiArai 0:5b88d5760320 201 INSUFFICIENT_AUTHORIZATION = 0x08,
kenjiArai 0:5b88d5760320 202
kenjiArai 0:5b88d5760320 203 /** Too many prepare writes have been queued. */
kenjiArai 0:5b88d5760320 204 PREPARE_QUEUE_FULL = 0x09,
kenjiArai 0:5b88d5760320 205
kenjiArai 0:5b88d5760320 206 /** No attribute found within the given attribute handle range. */
kenjiArai 0:5b88d5760320 207 ATTRIBUTE_NOT_FOUND = 0x0A,
kenjiArai 0:5b88d5760320 208
kenjiArai 0:5b88d5760320 209 /** The attribute cannot be read using the Read Blob Request. */
kenjiArai 0:5b88d5760320 210 ATTRIBUTE_NOT_LONG = 0x0B,
kenjiArai 0:5b88d5760320 211
kenjiArai 0:5b88d5760320 212 /** The Encryption Key Size used for encrypting this link is
kenjiArai 0:5b88d5760320 213 * insufficient.
kenjiArai 0:5b88d5760320 214 */
kenjiArai 0:5b88d5760320 215 INSUFFICIENT_ENCRYPTION_KEY_SIZE = 0x0C,
kenjiArai 0:5b88d5760320 216
kenjiArai 0:5b88d5760320 217 /** The attribute value length is invalid for the operation. */
kenjiArai 0:5b88d5760320 218 INVALID_ATTRIBUTE_VALUE_LENGTH = 0x0D,
kenjiArai 0:5b88d5760320 219
kenjiArai 0:5b88d5760320 220 /** The attribute request that was requested has encountered an error
kenjiArai 0:5b88d5760320 221 * that was unlikely, and therefore could not be completed as requested.
kenjiArai 0:5b88d5760320 222 */
kenjiArai 0:5b88d5760320 223 UNLIKELY_ERROR = 0x0E,
kenjiArai 0:5b88d5760320 224
kenjiArai 0:5b88d5760320 225 /** The attribute requires encryption before it can be read or written. */
kenjiArai 0:5b88d5760320 226 INSUFFICIENT_ENCRYPTION = 0x0F,
kenjiArai 0:5b88d5760320 227
kenjiArai 0:5b88d5760320 228 /** The attribute type is not a supported grouping attribute as defined
kenjiArai 0:5b88d5760320 229 * by a higher layer specification.
kenjiArai 0:5b88d5760320 230 */
kenjiArai 0:5b88d5760320 231 UNSUPPORTED_GROUP_TYPE = 0x10,
kenjiArai 0:5b88d5760320 232
kenjiArai 0:5b88d5760320 233 /** Insufficient Resources to complete the request. */
kenjiArai 0:5b88d5760320 234 INSUFFICIENT_RESOURCES = 0x11,
kenjiArai 0:5b88d5760320 235
kenjiArai 0:5b88d5760320 236 /* 0x12 - 0x7F => reserved for future use */
kenjiArai 0:5b88d5760320 237
kenjiArai 0:5b88d5760320 238 /* 0x80 - 0x9F => Application Error */
kenjiArai 0:5b88d5760320 239
kenjiArai 0:5b88d5760320 240 /* 0xA0 0xDF => Reserved for future use */
kenjiArai 0:5b88d5760320 241
kenjiArai 0:5b88d5760320 242 /* 0xE0 - 0xFF Common Profile and service Error Codes */
kenjiArai 0:5b88d5760320 243
kenjiArai 0:5b88d5760320 244 /** The Write Request Rejected error code is used when a requested write
kenjiArai 0:5b88d5760320 245 * operation cannot be fulfilled for reasons other than permissions.
kenjiArai 0:5b88d5760320 246 */
kenjiArai 0:5b88d5760320 247 WRITE_REQUEST_REJECTED = 0xFC,
kenjiArai 0:5b88d5760320 248
kenjiArai 0:5b88d5760320 249 /** The Client Characteristic Configuration Descriptor Improperly
kenjiArai 0:5b88d5760320 250 * Configured error code is used when a Client Characteristic
kenjiArai 0:5b88d5760320 251 * Configuration descriptor is not configured according to the
kenjiArai 0:5b88d5760320 252 * requirements of the profile or service.
kenjiArai 0:5b88d5760320 253 */
kenjiArai 0:5b88d5760320 254 CLIENT_CHARACTERISTIC_CONFIGURATION_DESCRIPTOR_IMPROPERLY_CONFIGURED = 0xFD,
kenjiArai 0:5b88d5760320 255
kenjiArai 0:5b88d5760320 256 /** The Procedure Already in Progress error code is used when a profile
kenjiArai 0:5b88d5760320 257 * or service request cannot be serviced because an operation that has
kenjiArai 0:5b88d5760320 258 * been previously triggered is still in progress
kenjiArai 0:5b88d5760320 259 */
kenjiArai 0:5b88d5760320 260 PROCEDURE_ALREADY_IN_PROGRESS = 0xFE,
kenjiArai 0:5b88d5760320 261
kenjiArai 0:5b88d5760320 262 /** The Out of Range error code is used when an attribute value is out
kenjiArai 0:5b88d5760320 263 * of range as defined by a profile or service specification.
kenjiArai 0:5b88d5760320 264 */
kenjiArai 0:5b88d5760320 265 OUT_OF_RANGE = 0xFF
kenjiArai 0:5b88d5760320 266 };
kenjiArai 0:5b88d5760320 267 };
kenjiArai 0:5b88d5760320 268
kenjiArai 0:5b88d5760320 269
kenjiArai 0:5b88d5760320 270 /**
kenjiArai 0:5b88d5760320 271 * The Exchange MTU Request is used by the client to inform the server of the
kenjiArai 0:5b88d5760320 272 * client’s maximum receive MTU size and request the server to respond with its
kenjiArai 0:5b88d5760320 273 * maximum rx MTU size.
kenjiArai 0:5b88d5760320 274 * @note see BLUETOOTH SPECIFICATION Version 5.0 | Vol 3, Part F Section 3.4.2.2
kenjiArai 0:5b88d5760320 275 */
kenjiArai 0:5b88d5760320 276 struct AttExchangeMTUResponse : public AttServerMessage {
kenjiArai 0:5b88d5760320 277 /**
kenjiArai 0:5b88d5760320 278 * Construct an exchange mtu response containing the max rx mtu of the
kenjiArai 0:5b88d5760320 279 * server.
kenjiArai 0:5b88d5760320 280 *
kenjiArai 0:5b88d5760320 281 * @param server_rx_mtu_ The max rx mtu the server can handle.
kenjiArai 0:5b88d5760320 282 */
kenjiArai 0:5b88d5760320 283 AttExchangeMTUResponse(uint16_t server_rx_mtu_) :
kenjiArai 0:5b88d5760320 284 AttServerMessage(AttributeOpcode::EXCHANGE_MTU_RESPONSE),
kenjiArai 0:5b88d5760320 285 server_rx_mtu(server_rx_mtu_) {
kenjiArai 0:5b88d5760320 286 }
kenjiArai 0:5b88d5760320 287
kenjiArai 0:5b88d5760320 288 /**
kenjiArai 0:5b88d5760320 289 * The max rx mtu the server can handle.
kenjiArai 0:5b88d5760320 290 */
kenjiArai 0:5b88d5760320 291 const uint16_t server_rx_mtu;
kenjiArai 0:5b88d5760320 292 };
kenjiArai 0:5b88d5760320 293
kenjiArai 0:5b88d5760320 294
kenjiArai 0:5b88d5760320 295 /**
kenjiArai 0:5b88d5760320 296 * The Find Information Response is sent in reply to a received Find Information
kenjiArai 0:5b88d5760320 297 * Request and contains information about this server.
kenjiArai 0:5b88d5760320 298 *
kenjiArai 0:5b88d5760320 299 * The Find Information Response contains a sequence of handle-uuid pairs in
kenjiArai 0:5b88d5760320 300 * ascending order if attribute handles.
kenjiArai 0:5b88d5760320 301 *
kenjiArai 0:5b88d5760320 302 * This class has to be subclassed by an implementation specific class defining
kenjiArai 0:5b88d5760320 303 * the member function size and the subscript operator.
kenjiArai 0:5b88d5760320 304 * @note see BLUETOOTH SPECIFICATION Version 5.0 | Vol 3, Part F Section 3.4.3.2
kenjiArai 0:5b88d5760320 305 */
kenjiArai 0:5b88d5760320 306 struct AttFindInformationResponse : public AttServerMessage {
kenjiArai 0:5b88d5760320 307
kenjiArai 0:5b88d5760320 308 /** handle-uuid pair */
kenjiArai 0:5b88d5760320 309 struct information_data_t {
kenjiArai 0:5b88d5760320 310 attribute_handle_t handle;
kenjiArai 0:5b88d5760320 311 UUID uuid;
kenjiArai 0:5b88d5760320 312 };
kenjiArai 0:5b88d5760320 313
kenjiArai 0:5b88d5760320 314 /**
kenjiArai 0:5b88d5760320 315 * Base constructor, setup the OpCode of the response.
kenjiArai 0:5b88d5760320 316 */
kenjiArai 0:5b88d5760320 317 AttFindInformationResponse() :
kenjiArai 0:5b88d5760320 318 AttServerMessage(AttributeOpcode::FIND_INFORMATION_RESPONSE) {
kenjiArai 0:5b88d5760320 319 }
kenjiArai 0:5b88d5760320 320
kenjiArai 0:5b88d5760320 321 /**
kenjiArai 0:5b88d5760320 322 * virtual destructor to overide if the sub class needs it.
kenjiArai 0:5b88d5760320 323 */
kenjiArai 0:5b88d5760320 324 virtual ~AttFindInformationResponse() { }
kenjiArai 0:5b88d5760320 325
kenjiArai 0:5b88d5760320 326 /**
kenjiArai 0:5b88d5760320 327 * Returns the number of information_data_t present in the response.
kenjiArai 0:5b88d5760320 328 */
kenjiArai 0:5b88d5760320 329 virtual size_t size() const = 0;
kenjiArai 0:5b88d5760320 330
kenjiArai 0:5b88d5760320 331 /**
kenjiArai 0:5b88d5760320 332 * Access to information_data_t elements present in the response.
kenjiArai 0:5b88d5760320 333 * @note Out of range access is undefined.
kenjiArai 0:5b88d5760320 334 */
kenjiArai 0:5b88d5760320 335 virtual information_data_t operator[](size_t index) const = 0;
kenjiArai 0:5b88d5760320 336 };
kenjiArai 0:5b88d5760320 337
kenjiArai 0:5b88d5760320 338
kenjiArai 0:5b88d5760320 339 /**
kenjiArai 0:5b88d5760320 340 * Find by type value responses are sent in response to find by type value
kenjiArai 0:5b88d5760320 341 * request.
kenjiArai 0:5b88d5760320 342 *
kenjiArai 0:5b88d5760320 343 * The response contains a sequence of Found Attribute Handle, Group End Handle
kenjiArai 0:5b88d5760320 344 * pair where:
kenjiArai 0:5b88d5760320 345 * - Found Attribute Handle is the handle of an attribute matching the type
kenjiArai 0:5b88d5760320 346 * and the value requested.
kenjiArai 0:5b88d5760320 347 * - Group End Handle is the end of the attribute group if the attribute found
kenjiArai 0:5b88d5760320 348 * is a grouping attribute or the same value as Found Attribute Handle if
kenjiArai 0:5b88d5760320 349 * the attribute is not a grouping attribute.
kenjiArai 0:5b88d5760320 350 *
kenjiArai 0:5b88d5760320 351 * This class should be subclassed by an implementation specific class defining
kenjiArai 0:5b88d5760320 352 * the member function size and the subscript operator.
kenjiArai 0:5b88d5760320 353 *
kenjiArai 0:5b88d5760320 354 * @note see BLUETOOTH SPECIFICATION Version 5.0 | Vol 3, Part F Section 3.4.3.4
kenjiArai 0:5b88d5760320 355 */
kenjiArai 0:5b88d5760320 356 struct AttFindByTypeValueResponse : public AttServerMessage {
kenjiArai 0:5b88d5760320 357 /**
kenjiArai 0:5b88d5760320 358 * Base constructor, setup the OpCode of the response.
kenjiArai 0:5b88d5760320 359 */
kenjiArai 0:5b88d5760320 360 AttFindByTypeValueResponse() :
kenjiArai 0:5b88d5760320 361 AttServerMessage(AttributeOpcode::FIND_BY_VALUE_TYPE_RESPONSE) {
kenjiArai 0:5b88d5760320 362 }
kenjiArai 0:5b88d5760320 363
kenjiArai 0:5b88d5760320 364 /**
kenjiArai 0:5b88d5760320 365 * virtual destructor to overide if the sub class needs it.
kenjiArai 0:5b88d5760320 366 */
kenjiArai 0:5b88d5760320 367 virtual ~AttFindByTypeValueResponse() { }
kenjiArai 0:5b88d5760320 368
kenjiArai 0:5b88d5760320 369 /**
kenjiArai 0:5b88d5760320 370 * Returns the number of attribute_handle_range_t present in the response.
kenjiArai 0:5b88d5760320 371 */
kenjiArai 0:5b88d5760320 372 virtual std::size_t size() const = 0;
kenjiArai 0:5b88d5760320 373
kenjiArai 0:5b88d5760320 374 /**
kenjiArai 0:5b88d5760320 375 * Access to the attribute range present in the response.
kenjiArai 0:5b88d5760320 376 * @note Out of range access is undefined.
kenjiArai 0:5b88d5760320 377 */
kenjiArai 0:5b88d5760320 378 virtual attribute_handle_range_t operator[](size_t index) const = 0;
kenjiArai 0:5b88d5760320 379 };
kenjiArai 0:5b88d5760320 380
kenjiArai 0:5b88d5760320 381
kenjiArai 0:5b88d5760320 382 /**
kenjiArai 0:5b88d5760320 383 * Response to a Read By Type request.
kenjiArai 0:5b88d5760320 384 *
kenjiArai 0:5b88d5760320 385 * It contains a list of handle-value pairs where:
kenjiArai 0:5b88d5760320 386 * - handle is the handle of the attribute matching the rype requested.
kenjiArai 0:5b88d5760320 387 * - value is the value of the attribute found. If the value is longer than
kenjiArai 0:5b88d5760320 388 * (mtu - 4) then it can be truncated and read blob request should be used
kenjiArai 0:5b88d5760320 389 * to read the remaining octet of the attribute.
kenjiArai 0:5b88d5760320 390 *
kenjiArai 0:5b88d5760320 391 * This class has to be subclassed by an implementation specific class defining
kenjiArai 0:5b88d5760320 392 * the member function size and the subscript operator.
kenjiArai 0:5b88d5760320 393 *
kenjiArai 0:5b88d5760320 394 * @note see BLUETOOTH SPECIFICATION Version 5.0 | Vol 3, Part F Section 3.4.4.2
kenjiArai 0:5b88d5760320 395 */
kenjiArai 0:5b88d5760320 396 struct AttReadByTypeResponse : public AttServerMessage {
kenjiArai 0:5b88d5760320 397 /**
kenjiArai 0:5b88d5760320 398 * handle-value pair
kenjiArai 0:5b88d5760320 399 */
kenjiArai 0:5b88d5760320 400 struct attribute_data_t {
kenjiArai 0:5b88d5760320 401 attribute_handle_t handle;
kenjiArai 0:5b88d5760320 402 Span<const uint8_t> value;
kenjiArai 0:5b88d5760320 403 };
kenjiArai 0:5b88d5760320 404
kenjiArai 0:5b88d5760320 405 /**
kenjiArai 0:5b88d5760320 406 * Base constructor, setup the OpCode of the response.
kenjiArai 0:5b88d5760320 407 */
kenjiArai 0:5b88d5760320 408 AttReadByTypeResponse() :
kenjiArai 0:5b88d5760320 409 AttServerMessage(AttributeOpcode::READ_BY_TYPE_RESPONSE) {
kenjiArai 0:5b88d5760320 410 }
kenjiArai 0:5b88d5760320 411
kenjiArai 0:5b88d5760320 412 /**
kenjiArai 0:5b88d5760320 413 * virtual destructor to overide if the sub class needs it.
kenjiArai 0:5b88d5760320 414 */
kenjiArai 0:5b88d5760320 415 virtual ~AttReadByTypeResponse() { }
kenjiArai 0:5b88d5760320 416
kenjiArai 0:5b88d5760320 417 /**
kenjiArai 0:5b88d5760320 418 * Return the number of attribute_data_t presents in the response.
kenjiArai 0:5b88d5760320 419 */
kenjiArai 0:5b88d5760320 420 virtual size_t size() const = 0;
kenjiArai 0:5b88d5760320 421
kenjiArai 0:5b88d5760320 422 /**
kenjiArai 0:5b88d5760320 423 * Return the attribute data at index.
kenjiArai 0:5b88d5760320 424 * @note Out of range access is undefined.
kenjiArai 0:5b88d5760320 425 */
kenjiArai 0:5b88d5760320 426 virtual attribute_data_t operator[](size_t index) const = 0;
kenjiArai 0:5b88d5760320 427 };
kenjiArai 0:5b88d5760320 428
kenjiArai 0:5b88d5760320 429
kenjiArai 0:5b88d5760320 430 /**
kenjiArai 0:5b88d5760320 431 * The read response is sent in reply to a received Read Request and contains
kenjiArai 0:5b88d5760320 432 * the value of the attribute that has been read.
kenjiArai 0:5b88d5760320 433 *
kenjiArai 0:5b88d5760320 434 * The attribute value shall be set to the value of the attribute identified by
kenjiArai 0:5b88d5760320 435 * the attribute handle in the request. If the attribute value is longer than
kenjiArai 0:5b88d5760320 436 * (ATT_MTU-1) then the first (ATT_MTU-1) octets shall be included in this
kenjiArai 0:5b88d5760320 437 * response.
kenjiArai 0:5b88d5760320 438 *
kenjiArai 0:5b88d5760320 439 * @note The Read Blob Request would be used to read the remaining octets of a
kenjiArai 0:5b88d5760320 440 * long attribute value.
kenjiArai 0:5b88d5760320 441 *
kenjiArai 0:5b88d5760320 442 * @note see BLUETOOTH SPECIFICATION Version 5.0 | Vol 3, Part F Section 3.4.4.4
kenjiArai 0:5b88d5760320 443 */
kenjiArai 0:5b88d5760320 444 struct AttReadResponse : public AttServerMessage {
kenjiArai 0:5b88d5760320 445 /**
kenjiArai 0:5b88d5760320 446 * Construct a Read Response from an array of bytes.
kenjiArai 0:5b88d5760320 447 */
kenjiArai 0:5b88d5760320 448 AttReadResponse(Span<const uint8_t> data_) :
kenjiArai 0:5b88d5760320 449 AttServerMessage(AttributeOpcode::READ_RESPONSE), _data(data_) {
kenjiArai 0:5b88d5760320 450 }
kenjiArai 0:5b88d5760320 451
kenjiArai 0:5b88d5760320 452 /**
kenjiArai 0:5b88d5760320 453 * Return the number of octets presents in the response.
kenjiArai 0:5b88d5760320 454 */
kenjiArai 0:5b88d5760320 455 size_t size() const {
kenjiArai 0:5b88d5760320 456 return _data.size();
kenjiArai 0:5b88d5760320 457 }
kenjiArai 0:5b88d5760320 458
kenjiArai 0:5b88d5760320 459 /**
kenjiArai 0:5b88d5760320 460 * Return the octet at the specified index.
kenjiArai 0:5b88d5760320 461 * @note Out of range access is undefined.
kenjiArai 0:5b88d5760320 462 */
kenjiArai 0:5b88d5760320 463 uint8_t operator[](size_t index) const {
kenjiArai 0:5b88d5760320 464 return _data[index];
kenjiArai 0:5b88d5760320 465 }
kenjiArai 0:5b88d5760320 466
kenjiArai 0:5b88d5760320 467 /**
kenjiArai 0:5b88d5760320 468 * Return the pointer to the actual data
kenjiArai 0:5b88d5760320 469 */
kenjiArai 0:5b88d5760320 470 const uint8_t* data() const {
kenjiArai 0:5b88d5760320 471 return _data.data();
kenjiArai 0:5b88d5760320 472 }
kenjiArai 0:5b88d5760320 473
kenjiArai 0:5b88d5760320 474 private:
kenjiArai 0:5b88d5760320 475 const Span<const uint8_t> _data;
kenjiArai 0:5b88d5760320 476 };
kenjiArai 0:5b88d5760320 477
kenjiArai 0:5b88d5760320 478
kenjiArai 0:5b88d5760320 479 /**
kenjiArai 0:5b88d5760320 480 * The Read Blob Response is sent in reply to a received Read Blob Request and
kenjiArai 0:5b88d5760320 481 * contains part of the value of the attribute that has been read.
kenjiArai 0:5b88d5760320 482 *
kenjiArai 0:5b88d5760320 483 * If the offset requested is equal to the length of the attribute then the
kenjiArai 0:5b88d5760320 484 * response contains no data and the size of the data returned is equal to 0.
kenjiArai 0:5b88d5760320 485 *
kenjiArai 0:5b88d5760320 486 * If the value of the attribute starting at the offset requested is longer than
kenjiArai 0:5b88d5760320 487 * (mtu - 1) octets then the first (mtu - 1) will be present in the response.
kenjiArai 0:5b88d5760320 488 * The remaining octets will be acquired by another Read Blob Request with an
kenjiArai 0:5b88d5760320 489 * updated index.
kenjiArai 0:5b88d5760320 490 *
kenjiArai 0:5b88d5760320 491 * @note see BLUETOOTH SPECIFICATION Version 5.0 | Vol 3, Part F Section 3.4.4.6
kenjiArai 0:5b88d5760320 492 */
kenjiArai 0:5b88d5760320 493 struct AttReadBlobResponse : public AttServerMessage {
kenjiArai 0:5b88d5760320 494 /**
kenjiArai 0:5b88d5760320 495 * Construct a read blob response from the value responded.
kenjiArai 0:5b88d5760320 496 */
kenjiArai 0:5b88d5760320 497 AttReadBlobResponse(Span<const uint8_t> data_) :
kenjiArai 0:5b88d5760320 498 AttServerMessage(AttributeOpcode::READ_BLOB_RESPONSE), _data(data_) {
kenjiArai 0:5b88d5760320 499 }
kenjiArai 0:5b88d5760320 500
kenjiArai 0:5b88d5760320 501 /**
kenjiArai 0:5b88d5760320 502 * Return the number of octets presents in the response value.
kenjiArai 0:5b88d5760320 503 */
kenjiArai 0:5b88d5760320 504 size_t size() const {
kenjiArai 0:5b88d5760320 505 return _data.size();
kenjiArai 0:5b88d5760320 506 }
kenjiArai 0:5b88d5760320 507
kenjiArai 0:5b88d5760320 508 /**
kenjiArai 0:5b88d5760320 509 * Return the octet of the value read at the specified index.
kenjiArai 0:5b88d5760320 510 * @note Out of range access is undefined.
kenjiArai 0:5b88d5760320 511 */
kenjiArai 0:5b88d5760320 512 uint8_t operator[](size_t index) const {
kenjiArai 0:5b88d5760320 513 return _data[index];
kenjiArai 0:5b88d5760320 514 }
kenjiArai 0:5b88d5760320 515
kenjiArai 0:5b88d5760320 516 /**
kenjiArai 0:5b88d5760320 517 * Return the pointer to the actual data
kenjiArai 0:5b88d5760320 518 */
kenjiArai 0:5b88d5760320 519 const uint8_t* data() const {
kenjiArai 0:5b88d5760320 520 return _data.data();
kenjiArai 0:5b88d5760320 521 }
kenjiArai 0:5b88d5760320 522
kenjiArai 0:5b88d5760320 523 private:
kenjiArai 0:5b88d5760320 524 const Span<const uint8_t> _data;
kenjiArai 0:5b88d5760320 525 };
kenjiArai 0:5b88d5760320 526
kenjiArai 0:5b88d5760320 527
kenjiArai 0:5b88d5760320 528 /**
kenjiArai 0:5b88d5760320 529 * Response to a Read Multiple Request. It contains the values of the attributes
kenjiArai 0:5b88d5760320 530 * that have been read.
kenjiArai 0:5b88d5760320 531 *
kenjiArai 0:5b88d5760320 532 * If the set of values that has been read is longer than (mtu - 1) then only
kenjiArai 0:5b88d5760320 533 * the first (mtu - 1) octets are included in the response.
kenjiArai 0:5b88d5760320 534 *
kenjiArai 0:5b88d5760320 535 * @note see BLUETOOTH SPECIFICATION Version 5.0 | Vol 3, Part F Section 3.4.4.8
kenjiArai 0:5b88d5760320 536 */
kenjiArai 0:5b88d5760320 537 struct AttReadMultipleResponse : public AttServerMessage {
kenjiArai 0:5b88d5760320 538 /**
kenjiArai 0:5b88d5760320 539 * Construct a Resd Multiple Response from the set of value received.
kenjiArai 0:5b88d5760320 540 */
kenjiArai 0:5b88d5760320 541 AttReadMultipleResponse(Span<const uint8_t> data_) :
kenjiArai 0:5b88d5760320 542 AttServerMessage(AttributeOpcode::READ_MULTIPLE_RESPONSE), _data(data_) {
kenjiArai 0:5b88d5760320 543 }
kenjiArai 0:5b88d5760320 544
kenjiArai 0:5b88d5760320 545 /**
kenjiArai 0:5b88d5760320 546 * Return the number of octets presents in the response set of value.
kenjiArai 0:5b88d5760320 547 */
kenjiArai 0:5b88d5760320 548 size_t size() const {
kenjiArai 0:5b88d5760320 549 return _data.size();
kenjiArai 0:5b88d5760320 550 }
kenjiArai 0:5b88d5760320 551
kenjiArai 0:5b88d5760320 552 /**
kenjiArai 0:5b88d5760320 553 * Return the octet of the set of value read at the specified index.
kenjiArai 0:5b88d5760320 554 * @note Out of range access is undefined.
kenjiArai 0:5b88d5760320 555 */
kenjiArai 0:5b88d5760320 556 uint8_t operator[](size_t index) const {
kenjiArai 0:5b88d5760320 557 return _data[index];
kenjiArai 0:5b88d5760320 558 }
kenjiArai 0:5b88d5760320 559
kenjiArai 0:5b88d5760320 560 private:
kenjiArai 0:5b88d5760320 561 const Span<const uint8_t> _data;
kenjiArai 0:5b88d5760320 562 };
kenjiArai 0:5b88d5760320 563
kenjiArai 0:5b88d5760320 564
kenjiArai 0:5b88d5760320 565 /**
kenjiArai 0:5b88d5760320 566 * The Read By Group Type Response is sent in reply to a received Read By
kenjiArai 0:5b88d5760320 567 * Group Type Request and contains the handles and values of the attributes that
kenjiArai 0:5b88d5760320 568 * have been read.
kenjiArai 0:5b88d5760320 569 *
kenjiArai 0:5b88d5760320 570 * The response is a list of group range-value pair where:
kenjiArai 0:5b88d5760320 571 * - group range: The range of the group found where begin is the grouping
kenjiArai 0:5b88d5760320 572 * attribute handle and end is the handle of the end of the group.
kenjiArai 0:5b88d5760320 573 * - value: The value of the grouping attribute.
kenjiArai 0:5b88d5760320 574 *
kenjiArai 0:5b88d5760320 575 * This class has to be subclassed by an implementation specific class defining
kenjiArai 0:5b88d5760320 576 * the member function size and the subscript operator.
kenjiArai 0:5b88d5760320 577 *
kenjiArai 0:5b88d5760320 578 * @note The value responded can be trucated if it doesn't fit in the response,
kenjiArai 0:5b88d5760320 579 * in that case a Read Blob Request could be used to read the remaining octets.
kenjiArai 0:5b88d5760320 580 *
kenjiArai 0:5b88d5760320 581 * @note see BLUETOOTH SPECIFICATION Version 5.0 | Vol 3, Part F Section 3.4.4.10
kenjiArai 0:5b88d5760320 582 */
kenjiArai 0:5b88d5760320 583 struct AttReadByGroupTypeResponse : public AttServerMessage {
kenjiArai 0:5b88d5760320 584 /**
kenjiArai 0:5b88d5760320 585 * Data read from the grouping attribute.
kenjiArai 0:5b88d5760320 586 * It includes the range of the group and the value of the attribute.
kenjiArai 0:5b88d5760320 587 */
kenjiArai 0:5b88d5760320 588 struct attribute_data_t {
kenjiArai 0:5b88d5760320 589 attribute_handle_range_t group_range;
kenjiArai 0:5b88d5760320 590 Span<const uint8_t> value;
kenjiArai 0:5b88d5760320 591 };
kenjiArai 0:5b88d5760320 592
kenjiArai 0:5b88d5760320 593 /**
kenjiArai 0:5b88d5760320 594 * Base constructor, setup the OpCode of the response.
kenjiArai 0:5b88d5760320 595 */
kenjiArai 0:5b88d5760320 596 AttReadByGroupTypeResponse() :
kenjiArai 0:5b88d5760320 597 AttServerMessage(AttributeOpcode::READ_BY_GROUP_TYPE_RESPONSE) {
kenjiArai 0:5b88d5760320 598 }
kenjiArai 0:5b88d5760320 599
kenjiArai 0:5b88d5760320 600 /**
kenjiArai 0:5b88d5760320 601 * virtual destructor to overide if the sub class needs it.
kenjiArai 0:5b88d5760320 602 */
kenjiArai 0:5b88d5760320 603 virtual ~AttReadByGroupTypeResponse() { }
kenjiArai 0:5b88d5760320 604
kenjiArai 0:5b88d5760320 605 /**
kenjiArai 0:5b88d5760320 606 * Return the number of attribute_data_t present in the response.
kenjiArai 0:5b88d5760320 607 */
kenjiArai 0:5b88d5760320 608 virtual size_t size() const = 0;
kenjiArai 0:5b88d5760320 609
kenjiArai 0:5b88d5760320 610 /**
kenjiArai 0:5b88d5760320 611 * Return the attribute data read at the index specified.
kenjiArai 0:5b88d5760320 612 * @note Out of range access is undefined.
kenjiArai 0:5b88d5760320 613 */
kenjiArai 0:5b88d5760320 614 virtual attribute_data_t operator[](size_t index) const = 0;
kenjiArai 0:5b88d5760320 615 };
kenjiArai 0:5b88d5760320 616
kenjiArai 0:5b88d5760320 617
kenjiArai 0:5b88d5760320 618 /**
kenjiArai 0:5b88d5760320 619 * The Write Response is sent in reply to a valid Write Request and
kenjiArai 0:5b88d5760320 620 * acknowledges that the attribute has been successfully written.
kenjiArai 0:5b88d5760320 621 * It is just a placeholder which indicates the client that the write request
kenjiArai 0:5b88d5760320 622 * was successful.
kenjiArai 0:5b88d5760320 623 *
kenjiArai 0:5b88d5760320 624 * @note see BLUETOOTH SPECIFICATION Version 5.0 | Vol 3, Part F Section 3.4.5.2
kenjiArai 0:5b88d5760320 625 */
kenjiArai 0:5b88d5760320 626 struct AttWriteResponse : public AttServerMessage {
kenjiArai 0:5b88d5760320 627 /**
kenjiArai 0:5b88d5760320 628 * Construct a write response.
kenjiArai 0:5b88d5760320 629 */
kenjiArai 0:5b88d5760320 630 AttWriteResponse() : AttServerMessage(AttributeOpcode::WRITE_RESPONSE) { }
kenjiArai 0:5b88d5760320 631 };
kenjiArai 0:5b88d5760320 632
kenjiArai 0:5b88d5760320 633
kenjiArai 0:5b88d5760320 634 /**
kenjiArai 0:5b88d5760320 635 * Response to a Prepare Write Request. It acknowledges the client that the
kenjiArai 0:5b88d5760320 636 * value has been successfully received and placed in the write queue.
kenjiArai 0:5b88d5760320 637 *
kenjiArai 0:5b88d5760320 638 * The response contains the same values as the one present in the request.
kenjiArai 0:5b88d5760320 639 *
kenjiArai 0:5b88d5760320 640 * @note see BLUETOOTH SPECIFICATION Version 5.0 | Vol 3, Part F Section 3.4.6.2
kenjiArai 0:5b88d5760320 641 */
kenjiArai 0:5b88d5760320 642 struct AttPrepareWriteResponse : public AttServerMessage {
kenjiArai 0:5b88d5760320 643 /**
kenjiArai 0:5b88d5760320 644 * Construct a prepare write response.
kenjiArai 0:5b88d5760320 645 * @param handle_ The handle of the attribute to be written.
kenjiArai 0:5b88d5760320 646 * @param offset_: The offset of the first octet to be writen.
kenjiArai 0:5b88d5760320 647 * @param value_: The value of the attribute to be written at the offset
kenjiArai 0:5b88d5760320 648 * indicated.
kenjiArai 0:5b88d5760320 649 */
kenjiArai 0:5b88d5760320 650 AttPrepareWriteResponse(
kenjiArai 0:5b88d5760320 651 attribute_handle_t handle_,
kenjiArai 0:5b88d5760320 652 uint16_t offset_,
kenjiArai 0:5b88d5760320 653 Span<const uint8_t> value_
kenjiArai 0:5b88d5760320 654 ) : AttServerMessage(AttributeOpcode::PREPARE_WRITE_RESPONSE),
kenjiArai 0:5b88d5760320 655 attribute_handle(handle_),
kenjiArai 0:5b88d5760320 656 offset(offset_),
kenjiArai 0:5b88d5760320 657 partial_value(value_) {
kenjiArai 0:5b88d5760320 658 }
kenjiArai 0:5b88d5760320 659
kenjiArai 0:5b88d5760320 660 /**
kenjiArai 0:5b88d5760320 661 * The handle of the attribute to be written.
kenjiArai 0:5b88d5760320 662 */
kenjiArai 0:5b88d5760320 663 const attribute_handle_t attribute_handle;
kenjiArai 0:5b88d5760320 664
kenjiArai 0:5b88d5760320 665 /**
kenjiArai 0:5b88d5760320 666 * The offset of the first octet to be writen.
kenjiArai 0:5b88d5760320 667 */
kenjiArai 0:5b88d5760320 668 const uint16_t offset;
kenjiArai 0:5b88d5760320 669
kenjiArai 0:5b88d5760320 670 /**
kenjiArai 0:5b88d5760320 671 * The value of the attribute to be written at the offset indicated.
kenjiArai 0:5b88d5760320 672 */
kenjiArai 0:5b88d5760320 673 const Span<const uint8_t> partial_value;
kenjiArai 0:5b88d5760320 674 };
kenjiArai 0:5b88d5760320 675
kenjiArai 0:5b88d5760320 676
kenjiArai 0:5b88d5760320 677 /**
kenjiArai 0:5b88d5760320 678 * The Execute Write Response is sent in response to a received Execute Write
kenjiArai 0:5b88d5760320 679 * Request.
kenjiArai 0:5b88d5760320 680 *
kenjiArai 0:5b88d5760320 681 * It is just a placeholder which indicates the client that the execution of the
kenjiArai 0:5b88d5760320 682 * write request has been successfull.
kenjiArai 0:5b88d5760320 683 *
kenjiArai 0:5b88d5760320 684 * @note see BLUETOOTH SPECIFICATION Version 5.0 | Vol 3, Part F Section 3.4.6.4
kenjiArai 0:5b88d5760320 685 */
kenjiArai 0:5b88d5760320 686 struct AttExecuteWriteResponse : public AttServerMessage {
kenjiArai 0:5b88d5760320 687 /**
kenjiArai 0:5b88d5760320 688 * Construct an execute write response object.
kenjiArai 0:5b88d5760320 689 */
kenjiArai 0:5b88d5760320 690 AttExecuteWriteResponse() :
kenjiArai 0:5b88d5760320 691 AttServerMessage(AttributeOpcode::EXECUTE_WRITE_RESPONSE) {
kenjiArai 0:5b88d5760320 692 }
kenjiArai 0:5b88d5760320 693 };
kenjiArai 0:5b88d5760320 694
kenjiArai 0:5b88d5760320 695
kenjiArai 0:5b88d5760320 696 /**
kenjiArai 0:5b88d5760320 697 * Notification of an attribute's value sent by the server.
kenjiArai 0:5b88d5760320 698 *
kenjiArai 0:5b88d5760320 699 * It contains the handle of the attribute and its value.
kenjiArai 0:5b88d5760320 700 *
kenjiArai 0:5b88d5760320 701 * If the attribute value is longer than (mtu - 3) then the value is truncated
kenjiArai 0:5b88d5760320 702 * to (mtu - 3) octets to fit in the response and the client will have to use
kenjiArai 0:5b88d5760320 703 * a read blob request to read the remaining octets of the attribute.
kenjiArai 0:5b88d5760320 704 *
kenjiArai 0:5b88d5760320 705 * @note see BLUETOOTH SPECIFICATION Version 5.0 | Vol 3, Part F Section 3.4.7.1
kenjiArai 0:5b88d5760320 706 */
kenjiArai 0:5b88d5760320 707 struct AttHandleValueNotification : public AttServerMessage {
kenjiArai 0:5b88d5760320 708 /**
kenjiArai 0:5b88d5760320 709 * Construct an Handle Value Notification from the attribute handle and its
kenjiArai 0:5b88d5760320 710 * value notified.
kenjiArai 0:5b88d5760320 711 */
kenjiArai 0:5b88d5760320 712 AttHandleValueNotification(
kenjiArai 0:5b88d5760320 713 attribute_handle_t attribute_handle,
kenjiArai 0:5b88d5760320 714 Span<const uint8_t> attribute_value
kenjiArai 0:5b88d5760320 715 ) : AttServerMessage(AttributeOpcode::HANDLE_VALUE_NOTIFICATION),
kenjiArai 0:5b88d5760320 716 attribute_handle(attribute_handle),
kenjiArai 0:5b88d5760320 717 attribute_value(attribute_value) {
kenjiArai 0:5b88d5760320 718 }
kenjiArai 0:5b88d5760320 719
kenjiArai 0:5b88d5760320 720 /**
kenjiArai 0:5b88d5760320 721 * Handle of the attribute
kenjiArai 0:5b88d5760320 722 */
kenjiArai 0:5b88d5760320 723 const attribute_handle_t attribute_handle;
kenjiArai 0:5b88d5760320 724
kenjiArai 0:5b88d5760320 725 /**
kenjiArai 0:5b88d5760320 726 * The current value of the attribute.
kenjiArai 0:5b88d5760320 727 */
kenjiArai 0:5b88d5760320 728 const Span<const uint8_t> attribute_value;
kenjiArai 0:5b88d5760320 729 };
kenjiArai 0:5b88d5760320 730
kenjiArai 0:5b88d5760320 731
kenjiArai 0:5b88d5760320 732 /**
kenjiArai 0:5b88d5760320 733 * Indication of an attribute's value sent by the server.
kenjiArai 0:5b88d5760320 734 *
kenjiArai 0:5b88d5760320 735 * It contains the handle of the attribute and its value. The client should
kenjiArai 0:5b88d5760320 736 * respond with and handle value confirmation.
kenjiArai 0:5b88d5760320 737 *
kenjiArai 0:5b88d5760320 738 * If the attribute value is longer than (mtu - 3) then the value is truncated
kenjiArai 0:5b88d5760320 739 * to (mtu - 3) octets to fit in the response and the client will have to use
kenjiArai 0:5b88d5760320 740 * a read blob request to read the remaining octets of the attribute.
kenjiArai 0:5b88d5760320 741 *
kenjiArai 0:5b88d5760320 742 * @note see BLUETOOTH SPECIFICATION Version 5.0 | Vol 3, Part F Section 3.4.7.2
kenjiArai 0:5b88d5760320 743 */
kenjiArai 0:5b88d5760320 744 struct AttHandleValueIndication : public AttServerMessage {
kenjiArai 0:5b88d5760320 745 /**
kenjiArai 0:5b88d5760320 746 * Construct an Handle Value Indication from the attribute handle and its
kenjiArai 0:5b88d5760320 747 * value indicated.
kenjiArai 0:5b88d5760320 748 */
kenjiArai 0:5b88d5760320 749 AttHandleValueIndication(
kenjiArai 0:5b88d5760320 750 attribute_handle_t handle, Span<const uint8_t> value
kenjiArai 0:5b88d5760320 751 ) : AttServerMessage(AttributeOpcode::HANDLE_VALUE_INDICATION),
kenjiArai 0:5b88d5760320 752 attribute_handle(handle), attribute_value(value) {
kenjiArai 0:5b88d5760320 753 }
kenjiArai 0:5b88d5760320 754
kenjiArai 0:5b88d5760320 755 /**
kenjiArai 0:5b88d5760320 756 * Handle of the attribute
kenjiArai 0:5b88d5760320 757 */
kenjiArai 0:5b88d5760320 758 const attribute_handle_t attribute_handle;
kenjiArai 0:5b88d5760320 759
kenjiArai 0:5b88d5760320 760 /**
kenjiArai 0:5b88d5760320 761 * The current value of the attribute.
kenjiArai 0:5b88d5760320 762 */
kenjiArai 0:5b88d5760320 763 const Span<const uint8_t> attribute_value;
kenjiArai 0:5b88d5760320 764 };
kenjiArai 0:5b88d5760320 765
kenjiArai 0:5b88d5760320 766
kenjiArai 0:5b88d5760320 767 } // namespace pal
kenjiArai 0:5b88d5760320 768 } // namespace ble
kenjiArai 0:5b88d5760320 769
kenjiArai 0:5b88d5760320 770 #endif /* BLE_PAL_ATT_SERVER_MESSAGE_H_ */