bleATTPDUConfig

Configuration object for BLE ATT PDU

Download Required: To use bleATTPDUConfig, first download Communications Toolbox™ Library for the Bluetooth® Protocol. For more information, see Get and Manage Add-Ons. Alternatively, see Communications Toolbox Library for the Bluetooth Protocol File Exchange.

Description

The bleATTPDUConfig creates a configuration object for a Bluetooth low energy (BLE) attribute protocol data unit (ATT PDU). You can configure a BLE ATT PDU using the applicable properties of bleATTPDUConfig.

Creation

Description

example

cfgATT = bleATTPDUConfig creates a bleATTPDUConfig configuration object, cfgATT, for a BLE ATT PDU with default values.

example

cfgATT = bleATTPDUConfig(Name,Value) sets properties using one or more name-value pairs. Enclose each property name in quotes. For example, bleATTPDUConfig('Opcode','Error response') sets the Opcode property of cfgATT to 'Error response'.

Properties

expand all

Note

For more information about BLE ATT PDU properties and their respective values, see volume 3, part F, sections 3.3 and 3.4 of the Bluetooth Core Specification [2].

BLE ATT PDU operation code, specified as one of the values in this list. Each valid value describes a BLE ATT PDU operation code.

  • 'MTU request'

  • '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

Opcode of request BLE ATT PDU, specified as one of the values in this list. Each valid value describes a request BLE 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 of information data field, specified as '16 bit' or '128 bit'. This value specifies the format of information data element in the PDU with opcode 'Information Response'.

Data Types: char | string

Handle value of attribute, specified as the character vector of a two-octet hexadecimal value in the range [0x0001, 0xFFFF]. This value is a unique identifier. The server dynamically assigns this value.

Data Types: char | string

Error message corresponding to request BLE ATT PDU, specified as one of the values in this list. Each value indicates the cause of an error corresponding to the request 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

Maximum size of BLE ATT PDU, specified as a positive integer in the range [23,65535]. This value sets the maximum size of the BLE ATT PDU in bytes that a client or server can receive.

Data Types: double

Starting handle of handle range, specified as a two-octet hexadecimal value in the range [0x0001,0xFFFF]. This value indicates the handle value of a service or characteristic declaration or the starting handle of a handle range. This value must be less than the EndHandle.

Data Types: char | string

Ending handle of handle range, specified as a two-octet hexadecimal value in the range [0x0001,0xFFFF]. This value sets the end handle value of a service declaration or a characteristic declaration or the ending handle of a handle range. This value must be greater than the StartHandle.

Data Types: char | string

Type of attribute, specified as a four-element or 32-element character vector or a string scalar denoting a two-octet or16-octet hexadecimal value.

Data Types: char | string

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 is 131068.

AttributeValue indicates the value of an attribute to be stored in or read from the attribute database. Specify this value in LSB first format.

Data Types: char | string | double

Offset of next octet to be read, specified as an integer in the range [0, 65535]. You can use this value in the BLE ATT PDUs with opcodes 'Read blob request', 'Prepare write request', and 'Prepare write response' to identify an attribute value offset in the attribute database.

Data Types: double

Execute write flag, specified as 'Cancel all prepared writes' or 'Write all pending requests'. You can determine the action (discard or write) to be performed when this property is used.

Data Types: char | string

Object Functions

expand all

bleATTPDUGenerate BLE ATT PDU
bleATTPDUDecodeDecode BLE ATT PDU

Examples

collapse all

Create two unique BLE ATT PDU configuration objects: one of type 'Read by type request' and the other of type 'Error response' using default settings and name-value pairs respectively.

Create a BLE ATT PDU configuration object with default settings.

cfgATT = bleATTPDUConfig;

Set the BLE ATT PDU opcode as 'Read by type request'. View the applicable properties of the opcode '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 BLE ATT PDU configuration object, this time using the name-value pairs. Change the BLE ATT PDU opcode to 'Error response'. View the applicable properties of the opcode 'Error response'.

cfgATT = bleATTPDUConfig('Opcode','Error response')
cfgATT = 
  bleATTPDUConfig with properties:

             Opcode: 'Error response'
    RequestedOpcode: 'Read request'
    AttributeHandle: '0001'
       ErrorMessage: 'Invalid handle'

Create a BLE ATT PDU configuration object. Change the value of opcode to 'Read by type request'. View the applicable properties of the specified value of opcode.

cfgTx = bleATTPDUConfig;
cfgTx.Opcode = 'Read by type request'
cfgTx = 
  bleATTPDUConfig with properties:

           Opcode: 'Read by type request'
      StartHandle: '0001'
        EndHandle: 'FFFF'
    AttributeType: '2800'

Generate a BLE ATT PDU from the corresponding configuration object.

attPDU = bleATTPDU(cfgTx);

Decode the generated BLE ATT PDU. The returned status indicates decoding is successful. View the applicable properties of the opcode 'Error response'.

[status, cfgRx] = bleATTPDUDecode(attPDU)
status = 
Success
cfgRx = 
  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, 2019. https://www.bluetooth.com/.

[2] Bluetooth Special Interest Group (SIG). "Bluetooth Core Specification." Version 5.1. https://www.bluetooth.com/.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Introduced in R2019b