%% End-to-End Workflow of BLE LL Control PDU
% Create a BLE LL data channel PDU configuration object for a control PDU by using default configuration. View the corresponding default properties.

cfgControl = bleLLControlPDUConfig

% Generate a BLE LL data channel PDU using 'cfgTx' by specifying the value of link layer identifier, 'LLID', as 'Control' and 'ControlConfig' as 'cfgControl'. Specify the cyclic redundancy check (CRC) value for the configuration object 'cfgTx'. View the properties of  'cfgTx'.

cfgTx = bleLLDataChannelPDUConfig('LLID', 'Control', ...
    'ControlConfig',cfgControl);
cfgTx.CRCInitialization = 'E23456'

% Generate a BLE LL control PDU from 'cfgTx'.

pdu = bleLLDataChannelPDU(cfgTx);

% Decode the generated BLE LL control PDU by initializing the CRC value. The returned status indicates decoding is successful. View the values of 'status', 'cfgRx' and 'llPayload'.

crcInit = 'E23456'; % Received during associaton
[status, cfgRx, llPayload] = bleLLDataChannelPDUDecode(pdu, crcInit)

% Copyright 2019 The MathWorks, Inc.