%% Decode BLE ATT PDUs
% Decode two unique BLE ATT PDUs of type 'Read by type request' and 'Error response'.
% Create a BLE ATT PDU configuration object with default settings.

cfgATT = bleATTPDUConfig;

% Change 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'

% Generate a BLE ATT PDU using the corresponding configuration object.

attPDU = bleATTPDU(cfgATT)

% Decode the generated BLE ATT PDU. The returned status indicates decoding is successful. View the applicable properties of the opcode 'Read by type request'.

[status, cfg] = bleATTPDUDecode(attPDU)

% Create another BLE ATT PDU configuration object, this time using the name-value pairs. Change the BLE ATT PDU opcode as 'Error response'. View the applicable properties of the opcode 'Error response'.

cfgATT = bleATTPDUConfig('Opcode','Error response')

% Generate a BLE ATT PDU using the corresponding configuration object.

attPDU = bleATTPDU(cfgATT)

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

[status, cfg] = bleATTPDUDecode(attPDU)

% Copyright 2018 The MathWorks, Inc.