Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: TYBLE16_simple_data_logger TYBLE16_MP3_Air
AttServerMessage.h
00001 /* mbed Microcontroller Library 00002 * Copyright (c) 2017-2017 ARM Limited 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 #ifndef BLE_PAL_ATT_SERVER_MESSAGE_H_ 00018 #define BLE_PAL_ATT_SERVER_MESSAGE_H_ 00019 00020 #include "ble/BLETypes.h" 00021 00022 namespace ble { 00023 namespace pal { 00024 00025 /** 00026 * Operation code defined for attribute operations 00027 * @note see: BLUETOOTH SPECIFICATION Version 5.0 | Vol 3, Part F Section 3.4.8 00028 */ 00029 struct AttributeOpcode { 00030 enum Code { 00031 ERROR_RESPONSE = 0x01, /// Opcode of an AttErrorResponse 00032 EXCHANGE_MTU_REQUEST = 0x02, 00033 EXCHANGE_MTU_RESPONSE = 0x03, /// OpCode of an AttExchangeMTUResponse 00034 FIND_INFORMATION_REQUEST = 0x04, 00035 FIND_INFORMATION_RESPONSE = 0x05, /// OpCode of an AttFindInformationResponse 00036 FIND_BY_TYPE_VALUE_REQUEST = 0x06, 00037 FIND_BY_VALUE_TYPE_RESPONSE = 0x07, /// OpCode of an AttFindByTypeValueResponse 00038 READ_BY_TYPE_REQUEST = 0x08, 00039 READ_BY_TYPE_RESPONSE = 0x09, /// Opcode of an AttReadByTypeResponse 00040 READ_REQUEST = 0x0A, 00041 READ_RESPONSE = 0x0B, /// Opcode of an AttReadResponse 00042 READ_BLOB_REQUEST = 0x0C, 00043 READ_BLOB_RESPONSE = 0x0D, /// Opcode of an AttReadBlobResponse 00044 READ_MULTIPLE_REQUEST = 0x0E, 00045 READ_MULTIPLE_RESPONSE = 0x0F, /// Opcode of an AttReadMultipleResponse 00046 READ_BY_GROUP_TYPE_REQUEST = 0x10, 00047 READ_BY_GROUP_TYPE_RESPONSE = 0x11, /// Opcode of an AttReadByGroupTypeResponse 00048 WRITE_REQUEST = 0x12, 00049 WRITE_RESPONSE = 0x13, /// Opcode of an AttWriteResponse 00050 WRITE_COMMAND = 0x52, 00051 SIGNED_WRITE_COMMAND = 0xD2, 00052 PREPARE_WRITE_REQUEST = 0x16, 00053 PREPARE_WRITE_RESPONSE = 0x17, /// Opcode of an AttPrepareWriteResponse 00054 EXECUTE_WRITE_REQUEST = 0x18, 00055 EXECUTE_WRITE_RESPONSE = 0x19, /// Opcode of an AttExecuteWriteResponse 00056 HANDLE_VALUE_NOTIFICATION = 0x1B, 00057 HANDLE_VALUE_INDICATION = 0x1D 00058 }; 00059 00060 /** 00061 * Construct an AttributeOpcode from a Code. 00062 */ 00063 AttributeOpcode(Code value) : _value(value) { } 00064 00065 /** 00066 * Equality comparison operator between two AttributeOpcode 00067 */ 00068 friend bool operator==(AttributeOpcode lhs, AttributeOpcode rhs) { 00069 return lhs._value == rhs._value; 00070 } 00071 00072 /** 00073 * Non equality comparison operator between two AttributeOpcode 00074 */ 00075 friend bool operator!=(AttributeOpcode lhs, AttributeOpcode rhs) { 00076 return lhs._value != rhs._value; 00077 } 00078 00079 /** 00080 * implicit cast to uint8_t. 00081 * Allows AttributeOpcode to be used in switch statements. 00082 */ 00083 operator uint8_t() const { 00084 return _value; 00085 } 00086 00087 private: 00088 uint8_t _value; 00089 }; 00090 00091 00092 /** 00093 * Base class for Attribute Server Message. 00094 * The correct type of the instance can be determined with the attribute opcode. 00095 * @note see BLUETOOTH SPECIFICATION Version 5.0 | Vol 3, Part F Section 3.3.1 00096 */ 00097 struct AttServerMessage { 00098 /** 00099 * Op code used to identify the type of the attribute response. 00100 */ 00101 const AttributeOpcode opcode; 00102 00103 protected: 00104 /** 00105 * Construction of an AttResponse is reserved for descendent of the class 00106 */ 00107 AttServerMessage(AttributeOpcode opcode_) : opcode(opcode_) { } 00108 }; 00109 00110 00111 /** 00112 * Response to a request which can't be performed 00113 * @note see BLUETOOTH SPECIFICATION Version 5.0 | Vol 3, Part F Section 3.4.1.1 00114 * for details about error response. 00115 * @note see BLUETOOTH SPECIFICATION Version 5.0 | Vol 3, Part F Section 3.4.9 00116 * which details possible error response by requests. 00117 */ 00118 struct AttErrorResponse : public AttServerMessage { 00119 /** 00120 * Construct an attribute error response. 00121 * 00122 * @param request_opcode_ The Attribute opcode of the request that generated 00123 * the error. 00124 * @param handle_in_error_ The attribute handle that generated this error 00125 * response. 00126 * @param error_code The reason why the request has generated an error. 00127 */ 00128 AttErrorResponse( 00129 AttributeOpcode request_opcode_, 00130 attribute_handle_t handle_in_error_, 00131 uint8_t error_code_ 00132 ) : AttServerMessage(AttributeOpcode::ERROR_RESPONSE), 00133 request_opcode(request_opcode_), 00134 handle_in_error(handle_in_error_), error_code(error_code_) { 00135 } 00136 00137 /** 00138 * Construct an attribute error response in the case where there was no 00139 * attribute handle in the original response or if the request is not 00140 * supported. 00141 * 00142 * @param request_opcode_ The Attribute opcode of the request that generated 00143 * the error. 00144 * @param error_code The reason why the request has generated an error. 00145 */ 00146 AttErrorResponse( 00147 AttributeOpcode request_opcode_, 00148 uint8_t error_code_ 00149 ) : AttServerMessage(AttributeOpcode::ERROR_RESPONSE), 00150 request_opcode(request_opcode_), 00151 handle_in_error(0x0000), error_code(error_code_) { 00152 } 00153 00154 /** 00155 * The opcode of the request that generated this error response. 00156 */ 00157 const AttributeOpcode request_opcode; 00158 00159 /** 00160 * The attribute handle that generated this error response. 00161 * If there was no attribute handle in the original request or if the 00162 * request is not supported, then this field is equal to 0x0000. 00163 */ 00164 const attribute_handle_t handle_in_error; 00165 00166 /** 00167 * The reason why the request has generated an error response 00168 */ 00169 const uint8_t error_code; 00170 00171 /** 00172 * List of Error codes for the ATT protocol 00173 */ 00174 enum AttributeErrorCode { 00175 /** The attribute handle given was not valid on this server. */ 00176 INVALID_HANDLE = 0x01, 00177 00178 /** The attribute cannot be read. */ 00179 READ_NOT_PERMITTED = 0x02, 00180 00181 /** The attribute cannot be written. */ 00182 WRITE_NOT_PERMITTED = 0x03, 00183 00184 /** The attribute PDU was invalid. */ 00185 INVALID_PDU = 0x04, 00186 00187 /** The attribute requires authentication before it can be read or 00188 * written. 00189 */ 00190 INSUFFICIENT_AUTHENTICATION = 0x05, 00191 00192 /** Attribute server does not support the request received from the 00193 * client. 00194 */ 00195 REQUEST_NOT_SUPPORTED = 0x06, 00196 00197 /** Offset specified was past the end of the attribute. */ 00198 INVALID_OFFSET = 0x07, 00199 00200 /** The attribute requires authorization before it can be read or written. */ 00201 INSUFFICIENT_AUTHORIZATION = 0x08, 00202 00203 /** Too many prepare writes have been queued. */ 00204 PREPARE_QUEUE_FULL = 0x09, 00205 00206 /** No attribute found within the given attribute handle range. */ 00207 ATTRIBUTE_NOT_FOUND = 0x0A, 00208 00209 /** The attribute cannot be read using the Read Blob Request. */ 00210 ATTRIBUTE_NOT_LONG = 0x0B, 00211 00212 /** The Encryption Key Size used for encrypting this link is 00213 * insufficient. 00214 */ 00215 INSUFFICIENT_ENCRYPTION_KEY_SIZE = 0x0C, 00216 00217 /** The attribute value length is invalid for the operation. */ 00218 INVALID_ATTRIBUTE_VALUE_LENGTH = 0x0D, 00219 00220 /** The attribute request that was requested has encountered an error 00221 * that was unlikely, and therefore could not be completed as requested. 00222 */ 00223 UNLIKELY_ERROR = 0x0E, 00224 00225 /** The attribute requires encryption before it can be read or written. */ 00226 INSUFFICIENT_ENCRYPTION = 0x0F, 00227 00228 /** The attribute type is not a supported grouping attribute as defined 00229 * by a higher layer specification. 00230 */ 00231 UNSUPPORTED_GROUP_TYPE = 0x10, 00232 00233 /** Insufficient Resources to complete the request. */ 00234 INSUFFICIENT_RESOURCES = 0x11, 00235 00236 /* 0x12 - 0x7F => reserved for future use */ 00237 00238 /* 0x80 - 0x9F => Application Error */ 00239 00240 /* 0xA0 0xDF => Reserved for future use */ 00241 00242 /* 0xE0 - 0xFF Common Profile and service Error Codes */ 00243 00244 /** The Write Request Rejected error code is used when a requested write 00245 * operation cannot be fulfilled for reasons other than permissions. 00246 */ 00247 WRITE_REQUEST_REJECTED = 0xFC, 00248 00249 /** The Client Characteristic Configuration Descriptor Improperly 00250 * Configured error code is used when a Client Characteristic 00251 * Configuration descriptor is not configured according to the 00252 * requirements of the profile or service. 00253 */ 00254 CLIENT_CHARACTERISTIC_CONFIGURATION_DESCRIPTOR_IMPROPERLY_CONFIGURED = 0xFD, 00255 00256 /** The Procedure Already in Progress error code is used when a profile 00257 * or service request cannot be serviced because an operation that has 00258 * been previously triggered is still in progress 00259 */ 00260 PROCEDURE_ALREADY_IN_PROGRESS = 0xFE, 00261 00262 /** The Out of Range error code is used when an attribute value is out 00263 * of range as defined by a profile or service specification. 00264 */ 00265 OUT_OF_RANGE = 0xFF 00266 }; 00267 }; 00268 00269 00270 /** 00271 * The Exchange MTU Request is used by the client to inform the server of the 00272 * client’s maximum receive MTU size and request the server to respond with its 00273 * maximum rx MTU size. 00274 * @note see BLUETOOTH SPECIFICATION Version 5.0 | Vol 3, Part F Section 3.4.2.2 00275 */ 00276 struct AttExchangeMTUResponse : public AttServerMessage { 00277 /** 00278 * Construct an exchange mtu response containing the max rx mtu of the 00279 * server. 00280 * 00281 * @param server_rx_mtu_ The max rx mtu the server can handle. 00282 */ 00283 AttExchangeMTUResponse(uint16_t server_rx_mtu_) : 00284 AttServerMessage(AttributeOpcode::EXCHANGE_MTU_RESPONSE), 00285 server_rx_mtu(server_rx_mtu_) { 00286 } 00287 00288 /** 00289 * The max rx mtu the server can handle. 00290 */ 00291 const uint16_t server_rx_mtu; 00292 }; 00293 00294 00295 /** 00296 * The Find Information Response is sent in reply to a received Find Information 00297 * Request and contains information about this server. 00298 * 00299 * The Find Information Response contains a sequence of handle-uuid pairs in 00300 * ascending order if attribute handles. 00301 * 00302 * This class has to be subclassed by an implementation specific class defining 00303 * the member function size and the subscript operator. 00304 * @note see BLUETOOTH SPECIFICATION Version 5.0 | Vol 3, Part F Section 3.4.3.2 00305 */ 00306 struct AttFindInformationResponse : public AttServerMessage { 00307 00308 /** handle-uuid pair */ 00309 struct information_data_t { 00310 attribute_handle_t handle; 00311 UUID uuid; 00312 }; 00313 00314 /** 00315 * Base constructor, setup the OpCode of the response. 00316 */ 00317 AttFindInformationResponse() : 00318 AttServerMessage(AttributeOpcode::FIND_INFORMATION_RESPONSE) { 00319 } 00320 00321 /** 00322 * virtual destructor to overide if the sub class needs it. 00323 */ 00324 virtual ~AttFindInformationResponse() { } 00325 00326 /** 00327 * Returns the number of information_data_t present in the response. 00328 */ 00329 virtual size_t size() const = 0; 00330 00331 /** 00332 * Access to information_data_t elements present in the response. 00333 * @note Out of range access is undefined. 00334 */ 00335 virtual information_data_t operator[](size_t index) const = 0; 00336 }; 00337 00338 00339 /** 00340 * Find by type value responses are sent in response to find by type value 00341 * request. 00342 * 00343 * The response contains a sequence of Found Attribute Handle, Group End Handle 00344 * pair where: 00345 * - Found Attribute Handle is the handle of an attribute matching the type 00346 * and the value requested. 00347 * - Group End Handle is the end of the attribute group if the attribute found 00348 * is a grouping attribute or the same value as Found Attribute Handle if 00349 * the attribute is not a grouping attribute. 00350 * 00351 * This class should be subclassed by an implementation specific class defining 00352 * the member function size and the subscript operator. 00353 * 00354 * @note see BLUETOOTH SPECIFICATION Version 5.0 | Vol 3, Part F Section 3.4.3.4 00355 */ 00356 struct AttFindByTypeValueResponse : public AttServerMessage { 00357 /** 00358 * Base constructor, setup the OpCode of the response. 00359 */ 00360 AttFindByTypeValueResponse() : 00361 AttServerMessage(AttributeOpcode::FIND_BY_VALUE_TYPE_RESPONSE) { 00362 } 00363 00364 /** 00365 * virtual destructor to overide if the sub class needs it. 00366 */ 00367 virtual ~AttFindByTypeValueResponse() { } 00368 00369 /** 00370 * Returns the number of attribute_handle_range_t present in the response. 00371 */ 00372 virtual std::size_t size() const = 0; 00373 00374 /** 00375 * Access to the attribute range present in the response. 00376 * @note Out of range access is undefined. 00377 */ 00378 virtual attribute_handle_range_t operator[](size_t index) const = 0; 00379 }; 00380 00381 00382 /** 00383 * Response to a Read By Type request. 00384 * 00385 * It contains a list of handle-value pairs where: 00386 * - handle is the handle of the attribute matching the rype requested. 00387 * - value is the value of the attribute found. If the value is longer than 00388 * (mtu - 4) then it can be truncated and read blob request should be used 00389 * to read the remaining octet of the attribute. 00390 * 00391 * This class has to be subclassed by an implementation specific class defining 00392 * the member function size and the subscript operator. 00393 * 00394 * @note see BLUETOOTH SPECIFICATION Version 5.0 | Vol 3, Part F Section 3.4.4.2 00395 */ 00396 struct AttReadByTypeResponse : public AttServerMessage { 00397 /** 00398 * handle-value pair 00399 */ 00400 struct attribute_data_t { 00401 attribute_handle_t handle; 00402 Span<const uint8_t> value; 00403 }; 00404 00405 /** 00406 * Base constructor, setup the OpCode of the response. 00407 */ 00408 AttReadByTypeResponse() : 00409 AttServerMessage(AttributeOpcode::READ_BY_TYPE_RESPONSE) { 00410 } 00411 00412 /** 00413 * virtual destructor to overide if the sub class needs it. 00414 */ 00415 virtual ~AttReadByTypeResponse() { } 00416 00417 /** 00418 * Return the number of attribute_data_t presents in the response. 00419 */ 00420 virtual size_t size() const = 0; 00421 00422 /** 00423 * Return the attribute data at index. 00424 * @note Out of range access is undefined. 00425 */ 00426 virtual attribute_data_t operator[](size_t index) const = 0; 00427 }; 00428 00429 00430 /** 00431 * The read response is sent in reply to a received Read Request and contains 00432 * the value of the attribute that has been read. 00433 * 00434 * The attribute value shall be set to the value of the attribute identified by 00435 * the attribute handle in the request. If the attribute value is longer than 00436 * (ATT_MTU-1) then the first (ATT_MTU-1) octets shall be included in this 00437 * response. 00438 * 00439 * @note The Read Blob Request would be used to read the remaining octets of a 00440 * long attribute value. 00441 * 00442 * @note see BLUETOOTH SPECIFICATION Version 5.0 | Vol 3, Part F Section 3.4.4.4 00443 */ 00444 struct AttReadResponse : public AttServerMessage { 00445 /** 00446 * Construct a Read Response from an array of bytes. 00447 */ 00448 AttReadResponse(Span<const uint8_t> data_) : 00449 AttServerMessage(AttributeOpcode::READ_RESPONSE), _data(data_) { 00450 } 00451 00452 /** 00453 * Return the number of octets presents in the response. 00454 */ 00455 size_t size() const { 00456 return _data.size(); 00457 } 00458 00459 /** 00460 * Return the octet at the specified index. 00461 * @note Out of range access is undefined. 00462 */ 00463 uint8_t operator[](size_t index) const { 00464 return _data[index]; 00465 } 00466 00467 /** 00468 * Return the pointer to the actual data 00469 */ 00470 const uint8_t* data() const { 00471 return _data.data(); 00472 } 00473 00474 private: 00475 const Span<const uint8_t> _data; 00476 }; 00477 00478 00479 /** 00480 * The Read Blob Response is sent in reply to a received Read Blob Request and 00481 * contains part of the value of the attribute that has been read. 00482 * 00483 * If the offset requested is equal to the length of the attribute then the 00484 * response contains no data and the size of the data returned is equal to 0. 00485 * 00486 * If the value of the attribute starting at the offset requested is longer than 00487 * (mtu - 1) octets then the first (mtu - 1) will be present in the response. 00488 * The remaining octets will be acquired by another Read Blob Request with an 00489 * updated index. 00490 * 00491 * @note see BLUETOOTH SPECIFICATION Version 5.0 | Vol 3, Part F Section 3.4.4.6 00492 */ 00493 struct AttReadBlobResponse : public AttServerMessage { 00494 /** 00495 * Construct a read blob response from the value responded. 00496 */ 00497 AttReadBlobResponse(Span<const uint8_t> data_) : 00498 AttServerMessage(AttributeOpcode::READ_BLOB_RESPONSE), _data(data_) { 00499 } 00500 00501 /** 00502 * Return the number of octets presents in the response value. 00503 */ 00504 size_t size() const { 00505 return _data.size(); 00506 } 00507 00508 /** 00509 * Return the octet of the value read at the specified index. 00510 * @note Out of range access is undefined. 00511 */ 00512 uint8_t operator[](size_t index) const { 00513 return _data[index]; 00514 } 00515 00516 /** 00517 * Return the pointer to the actual data 00518 */ 00519 const uint8_t* data() const { 00520 return _data.data(); 00521 } 00522 00523 private: 00524 const Span<const uint8_t> _data; 00525 }; 00526 00527 00528 /** 00529 * Response to a Read Multiple Request. It contains the values of the attributes 00530 * that have been read. 00531 * 00532 * If the set of values that has been read is longer than (mtu - 1) then only 00533 * the first (mtu - 1) octets are included in the response. 00534 * 00535 * @note see BLUETOOTH SPECIFICATION Version 5.0 | Vol 3, Part F Section 3.4.4.8 00536 */ 00537 struct AttReadMultipleResponse : public AttServerMessage { 00538 /** 00539 * Construct a Resd Multiple Response from the set of value received. 00540 */ 00541 AttReadMultipleResponse(Span<const uint8_t> data_) : 00542 AttServerMessage(AttributeOpcode::READ_MULTIPLE_RESPONSE), _data(data_) { 00543 } 00544 00545 /** 00546 * Return the number of octets presents in the response set of value. 00547 */ 00548 size_t size() const { 00549 return _data.size(); 00550 } 00551 00552 /** 00553 * Return the octet of the set of value read at the specified index. 00554 * @note Out of range access is undefined. 00555 */ 00556 uint8_t operator[](size_t index) const { 00557 return _data[index]; 00558 } 00559 00560 private: 00561 const Span<const uint8_t> _data; 00562 }; 00563 00564 00565 /** 00566 * The Read By Group Type Response is sent in reply to a received Read By 00567 * Group Type Request and contains the handles and values of the attributes that 00568 * have been read. 00569 * 00570 * The response is a list of group range-value pair where: 00571 * - group range: The range of the group found where begin is the grouping 00572 * attribute handle and end is the handle of the end of the group. 00573 * - value: The value of the grouping attribute. 00574 * 00575 * This class has to be subclassed by an implementation specific class defining 00576 * the member function size and the subscript operator. 00577 * 00578 * @note The value responded can be trucated if it doesn't fit in the response, 00579 * in that case a Read Blob Request could be used to read the remaining octets. 00580 * 00581 * @note see BLUETOOTH SPECIFICATION Version 5.0 | Vol 3, Part F Section 3.4.4.10 00582 */ 00583 struct AttReadByGroupTypeResponse : public AttServerMessage { 00584 /** 00585 * Data read from the grouping attribute. 00586 * It includes the range of the group and the value of the attribute. 00587 */ 00588 struct attribute_data_t { 00589 attribute_handle_range_t group_range; 00590 Span<const uint8_t> value; 00591 }; 00592 00593 /** 00594 * Base constructor, setup the OpCode of the response. 00595 */ 00596 AttReadByGroupTypeResponse() : 00597 AttServerMessage(AttributeOpcode::READ_BY_GROUP_TYPE_RESPONSE) { 00598 } 00599 00600 /** 00601 * virtual destructor to overide if the sub class needs it. 00602 */ 00603 virtual ~AttReadByGroupTypeResponse() { } 00604 00605 /** 00606 * Return the number of attribute_data_t present in the response. 00607 */ 00608 virtual size_t size() const = 0; 00609 00610 /** 00611 * Return the attribute data read at the index specified. 00612 * @note Out of range access is undefined. 00613 */ 00614 virtual attribute_data_t operator[](size_t index) const = 0; 00615 }; 00616 00617 00618 /** 00619 * The Write Response is sent in reply to a valid Write Request and 00620 * acknowledges that the attribute has been successfully written. 00621 * It is just a placeholder which indicates the client that the write request 00622 * was successful. 00623 * 00624 * @note see BLUETOOTH SPECIFICATION Version 5.0 | Vol 3, Part F Section 3.4.5.2 00625 */ 00626 struct AttWriteResponse : public AttServerMessage { 00627 /** 00628 * Construct a write response. 00629 */ 00630 AttWriteResponse() : AttServerMessage(AttributeOpcode::WRITE_RESPONSE) { } 00631 }; 00632 00633 00634 /** 00635 * Response to a Prepare Write Request. It acknowledges the client that the 00636 * value has been successfully received and placed in the write queue. 00637 * 00638 * The response contains the same values as the one present in the request. 00639 * 00640 * @note see BLUETOOTH SPECIFICATION Version 5.0 | Vol 3, Part F Section 3.4.6.2 00641 */ 00642 struct AttPrepareWriteResponse : public AttServerMessage { 00643 /** 00644 * Construct a prepare write response. 00645 * @param handle_ The handle of the attribute to be written. 00646 * @param offset_: The offset of the first octet to be writen. 00647 * @param value_: The value of the attribute to be written at the offset 00648 * indicated. 00649 */ 00650 AttPrepareWriteResponse( 00651 attribute_handle_t handle_, 00652 uint16_t offset_, 00653 Span<const uint8_t> value_ 00654 ) : AttServerMessage(AttributeOpcode::PREPARE_WRITE_RESPONSE), 00655 attribute_handle(handle_), 00656 offset(offset_), 00657 partial_value(value_) { 00658 } 00659 00660 /** 00661 * The handle of the attribute to be written. 00662 */ 00663 const attribute_handle_t attribute_handle; 00664 00665 /** 00666 * The offset of the first octet to be writen. 00667 */ 00668 const uint16_t offset; 00669 00670 /** 00671 * The value of the attribute to be written at the offset indicated. 00672 */ 00673 const Span<const uint8_t> partial_value; 00674 }; 00675 00676 00677 /** 00678 * The Execute Write Response is sent in response to a received Execute Write 00679 * Request. 00680 * 00681 * It is just a placeholder which indicates the client that the execution of the 00682 * write request has been successfull. 00683 * 00684 * @note see BLUETOOTH SPECIFICATION Version 5.0 | Vol 3, Part F Section 3.4.6.4 00685 */ 00686 struct AttExecuteWriteResponse : public AttServerMessage { 00687 /** 00688 * Construct an execute write response object. 00689 */ 00690 AttExecuteWriteResponse() : 00691 AttServerMessage(AttributeOpcode::EXECUTE_WRITE_RESPONSE) { 00692 } 00693 }; 00694 00695 00696 /** 00697 * Notification of an attribute's value sent by the server. 00698 * 00699 * It contains the handle of the attribute and its value. 00700 * 00701 * If the attribute value is longer than (mtu - 3) then the value is truncated 00702 * to (mtu - 3) octets to fit in the response and the client will have to use 00703 * a read blob request to read the remaining octets of the attribute. 00704 * 00705 * @note see BLUETOOTH SPECIFICATION Version 5.0 | Vol 3, Part F Section 3.4.7.1 00706 */ 00707 struct AttHandleValueNotification : public AttServerMessage { 00708 /** 00709 * Construct an Handle Value Notification from the attribute handle and its 00710 * value notified. 00711 */ 00712 AttHandleValueNotification( 00713 attribute_handle_t attribute_handle, 00714 Span<const uint8_t> attribute_value 00715 ) : AttServerMessage(AttributeOpcode::HANDLE_VALUE_NOTIFICATION), 00716 attribute_handle(attribute_handle), 00717 attribute_value(attribute_value) { 00718 } 00719 00720 /** 00721 * Handle of the attribute 00722 */ 00723 const attribute_handle_t attribute_handle; 00724 00725 /** 00726 * The current value of the attribute. 00727 */ 00728 const Span<const uint8_t> attribute_value; 00729 }; 00730 00731 00732 /** 00733 * Indication of an attribute's value sent by the server. 00734 * 00735 * It contains the handle of the attribute and its value. The client should 00736 * respond with and handle value confirmation. 00737 * 00738 * If the attribute value is longer than (mtu - 3) then the value is truncated 00739 * to (mtu - 3) octets to fit in the response and the client will have to use 00740 * a read blob request to read the remaining octets of the attribute. 00741 * 00742 * @note see BLUETOOTH SPECIFICATION Version 5.0 | Vol 3, Part F Section 3.4.7.2 00743 */ 00744 struct AttHandleValueIndication : public AttServerMessage { 00745 /** 00746 * Construct an Handle Value Indication from the attribute handle and its 00747 * value indicated. 00748 */ 00749 AttHandleValueIndication( 00750 attribute_handle_t handle, Span<const uint8_t> value 00751 ) : AttServerMessage(AttributeOpcode::HANDLE_VALUE_INDICATION), 00752 attribute_handle(handle), attribute_value(value) { 00753 } 00754 00755 /** 00756 * Handle of the attribute 00757 */ 00758 const attribute_handle_t attribute_handle; 00759 00760 /** 00761 * The current value of the attribute. 00762 */ 00763 const Span<const uint8_t> attribute_value; 00764 }; 00765 00766 00767 } // namespace pal 00768 } // namespace ble 00769 00770 #endif /* BLE_PAL_ATT_SERVER_MESSAGE_H_ */
Generated on Tue Jul 12 2022 13:54:02 by
