Main Content

bleATTPDU

Generate Bluetooth LE ATT PDU

    Description

    attPDU = bleATTPDU(cfgATT) generates a Bluetooth® low energy (LE) attribute protocol data unit (ATT PDU) corresponding to the Bluetooth LE ATT PDU configuration object cfgATT.

    example

    Examples

    collapse all

    Generate two unique Bluetooth LE ATT PDUs of the type 'Read by type request' and 'Error response'.

    Create a default Bluetooth LE ATT PDU configuration object.

    cfgATT = bleATTPDUConfig;

    Set the Bluetooth LE ATT PDU opcode to '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'
    
    

    Generate a Bluetooth LE ATT PDU using the corresponding configuration object.

    attPDU = bleATTPDU(cfgATT)
    attPDU = 7x2 char array
        '08'
        '01'
        '00'
        'FF'
        'FF'
        '00'
        '28'
    
    

    Create another Bluetooth LE ATT PDU configuration object, this time using the name-value pairs. Set the Bluetooth LE ATT PDU opcode to 'Error response'.

    cfgATT = bleATTPDUConfig('Opcode','Error response')
    cfgATT = 
      bleATTPDUConfig with properties:
    
                 Opcode: 'Error response'
        RequestedOpcode: 'Read request'
        AttributeHandle: '0001'
           ErrorMessage: 'Invalid handle'
    
    

    Generate a Bluetooth LE ATT PDU corresponding to this configuration object.

    attPDU = bleATTPDU(cfgATT)
    attPDU = 5x2 char array
        '01'
        '0A'
        '01'
        '00'
        '01'
    
    

    Input Arguments

    collapse all

    Bluetooth LE ATT PDU configuration object, specified as a bleATTPDUConfig object.

    Output Arguments

    collapse all

    Generated Bluetooth LE ATT PDU, returned as a character array. Each row in this array is the hexadecimal representation of an octet.

    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