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
GattAttribute Class Reference
[Server]
  Representation of a GattServer attribute. More...
#include <GattAttribute.h>
| Public Types | |
| typedef ble::attribute_handle_t | Handle_t | 
| Representation of an attribute handle. | |
| Public Member Functions | |
| GattAttribute (const UUID &uuid, uint8_t *valuePtr=NULL, uint16_t len=0, uint16_t maxLen=0, bool hasVariableLen=true) | |
| Construct an attribute. | |
| Handle_t | getHandle (void) const | 
| Get the attribute's handle in the ATT table. | |
| const UUID & | getUUID (void) const | 
| Get the UUID of the attribute. | |
| uint16_t | getLength (void) const | 
| Get the current length of the attribute value. | |
| uint16_t | getMaxLength (void) const | 
| Get the maximum length of the attribute value. | |
| uint16_t * | getLengthPtr (void) | 
| Get a pointer to the current length of the attribute value. | |
| void | setHandle (Handle_t id) | 
| Set the attribute handle. | |
| uint8_t * | getValuePtr (void) | 
| Get a pointer to the attribute value. | |
| bool | hasVariableLength (void) const | 
| Check whether the length of the attribute's value can change throughout time. | |
| void | allowRead (bool allow_read) | 
| Allow or disallow read operation from a client. | |
| bool | isReadAllowed (void) const | 
| Indicate if a client is allowed to read the attribute. | |
| void | setReadSecurityRequirement (Security_t requirement) | 
| Set the security requirements of the read operations. | |
| Security_t | getReadSecurityRequirement () const | 
| Return the security level required by read operations. | |
| void | allowWrite (bool allow_write) | 
| Allow or disallow write operation from a client. | |
| bool | isWriteAllowed (void) const | 
| Indicate if a client is allowed to write the attribute. | |
| void | setWriteSecurityRequirement (Security_t requirement) | 
| Set the security requirements of the write operations. | |
| Security_t | getWriteSecurityRequirement () const | 
| Return the security level required by write operations. | |
| Static Public Attributes | |
| static const Handle_t | INVALID_HANDLE = 0x0000 | 
| Invalid attribute handle. | |
Detailed Description
Representation of a GattServer attribute.
Attributes are the building block of GATT servers: services are attributes, characteristics are groups of attributes and characteristic descriptors are attributes, too.
- Typed values
Attributes are typed values composed of a type and its associated value. The attribute type identifies the attribute purpose. A UUID read by the client during the discovery of the GATT server models the attribute type. The value of the attribute is an array of bytes; its length may be fixed or variable.
As an example, a primary service is declared by an attribute with the type 0x2800, and the value of the attribute is the UUID of the service.
- Attribute Access
The GATT server is an array of attributes in which a unique index identifies each of the attributes within the array. That index is called the attribute handle, and clients use it to access to attributes within the server.
- Note:
- Attributes do not contain information related to their permissions, grouping or semantic. Higher level specifications define these concepts.
Definition at line 58 of file GattAttribute.h.
Member Typedef Documentation
| typedef ble::attribute_handle_t Handle_t | 
Representation of an attribute handle.
Each attribute in a GattServer has a unique handle that clients can use to identify the attribute. The underlying BLE stack usually generates and assigns handles to attributes.
Definition at line 67 of file GattAttribute.h.
Constructor & Destructor Documentation
| GattAttribute | ( | const UUID & | uuid, | 
| uint8_t * | valuePtr = NULL, | ||
| uint16_t | len = 0, | ||
| uint16_t | maxLen = 0, | ||
| bool | hasVariableLen = true | ||
| ) | 
Construct an attribute.
Application code uses attributes to model characteristic descriptors and characteristics values.
- Parameters:
- 
  [in] uuid The type of the attribute. [in] valuePtr Pointer to the memory buffer, which contains the initial value of the attribute. The constructor does not make a copy of the attribute buffer; as a consequence, the memory buffer must remain valid during the lifetime of the attribute. [in] len The length in bytes of this attribute's value. [in] maxLen The length in bytes of the memory buffer containing the attribute value. It must be greater than or equal to len.[in] hasVariableLen Flag that indicates whether the attribute's value length can change throughout time. 
- Example
// declare a value of 2 bytes within a 10 bytes buffer const uint8_t attribute_value[10] = { 10, 50 }; GattAttribute attr = GattAttribute( 0x2A19, // attribute type attribute_value, 2, // length of the current value sizeof(attribute_value), // length of the buffer containing the value true // variable length );
- Note:
- By default, read and write operations are allowed and does not require any security.
Definition at line 112 of file GattAttribute.h.
Member Function Documentation
| void allowRead | ( | bool | allow_read ) | 
Allow or disallow read operation from a client.
- Parameters:
- 
  allow_read Read is allowed if true. 
Definition at line 226 of file GattAttribute.h.
| void allowWrite | ( | bool | allow_write ) | 
Allow or disallow write operation from a client.
- Parameters:
- 
  allow_write Write is allowed if true. 
Definition at line 262 of file GattAttribute.h.
| Handle_t getHandle | ( | void | ) | const | 
Get the attribute's handle in the ATT table.
- Note:
- The GattServer sets the attribute's handle when services are inserted.
- Returns:
- The attribute's handle.
Definition at line 139 of file GattAttribute.h.
| uint16_t getLength | ( | void | ) | const | 
Get the current length of the attribute value.
- Returns:
- The current length of the attribute value.
Definition at line 161 of file GattAttribute.h.
| uint16_t* getLengthPtr | ( | void | ) | 
Get a pointer to the current length of the attribute value.
- Attention:
- note Do not use this function.
- Returns:
- A pointer to the current length of the attribute value.
Definition at line 183 of file GattAttribute.h.
| uint16_t getMaxLength | ( | void | ) | const | 
Get the maximum length of the attribute value.
The maximum length of the attribute value.
Definition at line 171 of file GattAttribute.h.
| Security_t getReadSecurityRequirement | ( | ) | const | 
Return the security level required by read operations.
- Returns:
- The security level of the read operations.
Definition at line 253 of file GattAttribute.h.
| const UUID& getUUID | ( | void | ) | const | 
Get the UUID of the attribute.
The UUID identifies the type of the attribute.
- Returns:
- The attribute.
Definition at line 151 of file GattAttribute.h.
| uint8_t* getValuePtr | ( | void | ) | 
Get a pointer to the attribute value.
- Returns:
- A pointer to the attribute value.
Definition at line 206 of file GattAttribute.h.
| Security_t getWriteSecurityRequirement | ( | ) | const | 
Return the security level required by write operations.
- Returns:
- The security level of the write operations.
Definition at line 289 of file GattAttribute.h.
| bool hasVariableLength | ( | void | ) | const | 
Check whether the length of the attribute's value can change throughout time.
- Returns:
- true if the attribute value has a variable length and false otherwise.
Definition at line 217 of file GattAttribute.h.
| bool isReadAllowed | ( | void | ) | const | 
Indicate if a client is allowed to read the attribute.
- Returns:
- true if a client is allowed to read the attribute.
Definition at line 235 of file GattAttribute.h.
| bool isWriteAllowed | ( | void | ) | const | 
Indicate if a client is allowed to write the attribute.
- Returns:
- true if a client is allowed to write the attribute.
Definition at line 271 of file GattAttribute.h.
| void setHandle | ( | Handle_t | id ) | 
Set the attribute handle.
- Attention:
- The GattServer uses this function internally. Application code must not use it.
- Parameters:
- 
  [in] id The new attribute handle. 
Definition at line 196 of file GattAttribute.h.
| void setReadSecurityRequirement | ( | Security_t | requirement ) | 
Set the security requirements of the read operations.
- Parameters:
- 
  requirement The security level required by the read operations. 
Definition at line 244 of file GattAttribute.h.
| void setWriteSecurityRequirement | ( | Security_t | requirement ) | 
Set the security requirements of the write operations.
- Parameters:
- 
  requirement The security level required by the write operations. 
Definition at line 280 of file GattAttribute.h.
Field Documentation
| const Handle_t INVALID_HANDLE = 0x0000  [static] | 
Invalid attribute handle.
Definition at line 72 of file GattAttribute.h.
Generated on Tue Jul 12 2022 13:55:31 by
 1.7.2
 1.7.2