bleATTPDUConfig
Bluetooth LE ATT PDU configuration parameters
Description
The bleATTPDUConfig
object parameterizes the bleATTPDU
function to generate a Bluetooth® low energy (LE) attribute protocol data unit (ATT PDU).
Creation
Description
creates a default
Bluetooth LE ATT PDU configuration object.cfgATT
= bleATTPDUConfig
sets properties
using one or more name-value pairs. Enclose each property name in quotes. For example,
cfgATT
= bleATTPDUConfig(Name,Value
)('Opcode','Error response')
sets the operation code to
'Error response'
.
Properties
Note
For more information about Bluetooth LE ATT PDU properties and their respective values, see Volume 3, Part F, Sections 3.3 and 3.4 of the Bluetooth Core Specification [2].
Opcode
— Bluetooth LE ATT PDU operation code
'Read request'
(default) | 'MTU request'
| 'Information request'
| ...
Bluetooth LE ATT PDU operation code, specified as one of these values.
'MTU request'
'MTU response'
'Error response'
'Information request'
'Find by type value request'
'Read by type request'
'Read request'
'Read response'
'Read blob request'
'Read blob response'
'Read by group type request'
'Write request'
'Write response'
'Write command'
'Prepare write request'
'Prepare write response'
'Execute write request'
'Execute write response'
'Handle value notification'
'Handle value indication'
'Handle value confirmation'
'Information response'
'Find by type value response'
'Read by type response'
'Read by group type response'
Data Types: char
| string
RequestedOpcode
— Opcode of request Bluetooth LE ATT PDU
'Read request'
(default) | 'MTU request'
| 'Information request'
| 'Find by type value request'
| ...
Opcode of request Bluetooth LE ATT PDU, specified as one of the values in this list. Each valid value describes a request Bluetooth LE ATT PDU (from a peer device) that caused an error.
'MTU request'
'Information request'
'Find by type value request'
'Read by type request'
'Read request'
'Read blob request'
'Read by group type request'
'Write request'
'Prepare to write request'
'Execute write request'
Data Types: char
| string
Format
— Format of information data field
'16 bit'
(default) | '128 bit'
Format of information data field, specified as '16 bit'
or
'128 bit'
. This value specifies the format of the information data
element in the PDU with Opcode
'Information Response'
.
Data Types: char
| string
AttributeHandle
— Handle value of attribute
'0001'
(default) | character vector or string scalar of 2-octet hexadecimal value
Handle value of attribute, specified as the character vector or string scalar of a 2-octet hexadecimal value in the range [0x0001, 0xFFFF]. This value is a unique identifier. The server dynamically assigns this value.
Data Types: char
| string
ErrorMessage
— Error message corresponding to request Bluetooth LE ATT PDU
'Invalid handle'
(default) | 'Invalid handle'
| 'Read not permitted'
| ...
Error message corresponding to request Bluetooth LE ATT PDU, specified as one of the values in this list. Each value indicates the cause of an error corresponding to the request Bluetooth LE ATT PDU from a peer device.
'Invalid handle'
'Read not permitted'
'Write not permitted'
'Invalid PDU'
'Insufficient authentication'
'Request not supported'
'Invalid offset'
'Insufficient authorization'
'Prepare queue full'
'Attribute not found'
'Attribute not long'
'Insufficient encryption key size'
'Invalid attribute value length'
'Unlikely error'
'Insufficient encryption'
'Unsupported group type'
'Insufficient resources'
Data Types: char
| string
MaxTransmissionUnit
— Maximum size of Bluetooth LE ATT PDU
23
(default) | integer in the range [23, 65,535]
Maximum size of Bluetooth LE ATT PDU, specified as an integer in the range [23, 65,535]. This value sets the maximum size of the Bluetooth LE ATT PDU in bytes that a client or a server can receive.
Data Types: double
StartHandle
— Starting handle of handle range
'0001'
(default) | character vector or string scalar of 2-octet hexadecimal value in range
[0x0001,0xFFFF]
Starting handle of handle range, specified as a character vector or string scalar of 2-octet hexadecimal value in the range [0x0001,0xFFFF]. This value indicates the handle value of a service, characteristic declaration, or the starting handle of a handle range. This value must be less than the EndHandle property value.
Data Types: char
| string
EndHandle
— Ending handle of handle range
'FFFF'
(default) | character vector or string scalar of 2-octet hexadecimal value in range
[0x0001,0xFFFF]
Ending handle of handle range, specified as a character vector or string scalar of 2-octet hexadecimal value in range [0x0001,0xFFFF]. This value sets the end handle value of a service declaration, characteristic declaration, or the ending handle of a handle range. This value must be greater than the StartHandle value.
Data Types: char
| string
AttributeType
— Type of attribute
'2800' (Primary service)
(default) | 4-element or 32-element character vector | 2-octet or 16-octet string scalar
Type of attribute, specified as a 4-element or 32-element character vector or a string scalar denoting a 2-octet or 16-octet hexadecimal value.
Data Types: char
| string
AttributeValue
— Value of attribute
' '
(default) | character vector | string scalar | numeric vector of elements in the range [0, 255] | n-by-2 character array of maximum length
131068
Value of attribute, specified as one of these values:
Character vector — This vector represent octets in hexadecimal format.
String scalar — This scalar represent octets in hexadecimal format.
Numeric vector of elements in the range [0, 255] — This vector represent octets in decimal format. The maximum length of the numeric vector is
65534
.n
-by-2 character array — Each row represent an octet in hexadecimal format. The maximum length of the character array is131068
.
This property specifies the value of an attribute to be stored in or read from the attribute database. Specify this value in least significant bit (LSB) first format.
Data Types: char
| string
| double
Offset
— Offset of next octet to be read
0
(default) | integer in the range [0, 65,565]
Offset of next octet to be read, specified as an integer in the range [0, 65,535].
To identify an attribute value offset in the attribute database, use this value in the
Bluetooth LE ATT PDUs with opcodes 'Read blob request'
,
'Prepare write request'
, and 'Prepare write
response'
.
Data Types: double
ExecuteWrite
— Execute write flag
'Cancel all prepared writes'
(default) | 'Write all pending requests'
Execute write flag, specified as 'Cancel all prepared writes'
or
'Write all pending requests'
. The object performs the discard or
write action by setting this value.
Data Types: char
| string
Examples
Create Bluetooth LE ATT PDU Configuration Objects
Create two unique Bluetooth LE ATT PDU configuration objects: one of type 'Read by type request'
and the other of type 'Error response'
.
Create a default Bluetooth LE ATT PDU configuration object.
cfgATT = bleATTPDUConfig
cfgATT = bleATTPDUConfig with properties: Opcode: 'Read request' AttributeHandle: '0001'
Set the Bluetooth LE ATT PDU opcode as 'Read by type request'
.
cfgATT.Opcode = 'Read by type request'
cfgATT = bleATTPDUConfig with properties: Opcode: 'Read by type request' StartHandle: '0001' EndHandle: 'FFFF' AttributeType: '2800'
Create another Bluetooth LE ATT PDU configuration object, specifying the opcode as 'Error response'
.
cfgATT = bleATTPDUConfig('Opcode','Error response')
cfgATT = bleATTPDUConfig with properties: Opcode: 'Error response' RequestedOpcode: 'Read request' AttributeHandle: '0001' ErrorMessage: 'Invalid handle'
End-to-End Workflow of Bluetooth LE ATT PDU
Create a Bluetooth LE ATT PDU configuration object. Set the opcode to 'Read by type request'
.
cfgATTPDUTx = bleATTPDUConfig;
cfgATTPDUTx.Opcode = 'Read by type request'
cfgATTPDUTx = bleATTPDUConfig with properties: Opcode: 'Read by type request' StartHandle: '0001' EndHandle: 'FFFF' AttributeType: '2800'
Generate a Bluetooth LE ATT PDU from the corresponding configuration object.
attPDU = bleATTPDU(cfgATTPDUTx);
Decode the generated Bluetooth LE ATT PDU. The returned status indicates decoding is successful.
[status,cfgATTPDURx] = bleATTPDUDecode(attPDU)
status = blePacketDecodeStatus enumeration Success
cfgATTPDURx = bleATTPDUConfig with properties: Opcode: 'Read by type request' StartHandle: '0001' EndHandle: 'FFFF' AttributeType: '2800'
References
[1] Bluetooth Technology Website. “Bluetooth Technology Website | The Official Website of Bluetooth Technology.” Accessed November 22, 2021. https://www.bluetooth.com/.
[2] Bluetooth Special Interest Group (SIG). "Bluetooth Core Specification." Version 5.3. https://www.bluetooth.com/.
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Version History
Introduced in R2019b
See Also
Functions
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)