%% Generate BLE LL Advertising Channel PDUs
% Generate two unique BLE LL advertising channel PDUs: first one of the type 'Advertising indication' using advertising data '020106' and the other of type 'Connection indication' using a set of data channels to be used.
% Create a BLE LL advertising channel PDU configuration object, 'cfgLLAdv', with the opcode as 'Advertising indication' by using advertising data '020106'. View the configured properties corresponding to the opcode.

cfgLLAdv = bleLLAdvertisingChannelPDUConfig;
cfgLLAdv.AdvertisingData = '020106'

% Generate the BLE LL advertising channel PDU by using the corresponding configuration object. Display the PDU length in octets.

pdu = bleLLAdvertisingChannelPDU(cfgLLAdv);
numel(pdu)/8

% Display the first octet of the generated BLE LL advertising channel PDU.

pdu(1:8)

% Create another BLE LL advertising channel PDU configuration object, this time using the name-value pairs. Change the BLE LL advertising channel PDU opcode to 'Connection indication'. View the active configured properties of the specified opcode.

cfgLLAdv = bleLLAdvertisingChannelPDUConfig('PDUType', ...
    'Connection indication')

% Specify the value of connection interval as 8 and the set of data channels as [0 4 12 16 18 24 25]. View the configured properties.

cfgLLAdv.ConnectionInterval = 8; % in milliseconds
cfgLLAdv.UsedChannels       = [0 4 12 16 18 24 25]

% Generate the BLE LL advertising channel PDU from the corresponding configuration object. Display the PDU length in octets.

pdu = bleLLAdvertisingChannelPDU(cfgLLAdv);
numel(pdu)/8

% Display the first octet of the generated BLE LL advertising channel PDU.

pdu(1:8)

% Copyright 2019 The MathWorks, Inc.