Main Content

bleATTPDUConfig

Bluetooth LE ATT PDU configuration parameters

Since R2019b

    Description

    The bleATTPDUConfig object parameterizes the bleATTPDU function to generate a Bluetooth® low energy (LE) attribute protocol data unit (ATT PDU).

    Creation

    Description

    example

    cfgATT = bleATTPDUConfig creates a default Bluetooth LE ATT PDU configuration object.

    example

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

    Properties

    expand all

    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].

    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

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

    Handle value of attribute, specified as the character vector 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

    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

    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

    Starting handle of handle range, specified as a 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

    Ending handle of handle range, specified as a 2-octet hexadecimal value in the 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

    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

    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.

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

    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

    collapse all

    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'
    
    

    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