%% Generate BLE GAP AD Blocks
% Generate three unique BLE GAP AD blocks: first one with AD types 'Flags' and 'Tx power level', the second one with AD types 'Advertising interval' and 'Local name' and the third one with AD type 'Flags' and having simultaneous support for low energy (LE) and basic rate/enhanced data rate (BR/EDR) at the host.
% Create a configuration object for a BLE GAP AD block and specify the AD types as 'Flags' and 'Tx power level'. Assign the values of LED discoverability as 'Limited' and Tx power level as 45.

cfgGAP = bleGAPDataBlockConfig;
cfgGAP.AdvertisingDataTypes   = {'Flags';'Tx power level'};
cfgGAP.LEDiscoverability      = 'Limited';
cfgGAP.TxPowerLevel           = 45;

% Generate the BLE GAP AD block from the corresponding configuration object.

dataBlock = bleGAPDataBlock(cfgGAP)

% Create a configuration object for a BLE GAP AD block, this time with advertising data types as 'Advertising interval' and 'Local name'. Specify the values of the advertising interval as 48, the local name as 'MathWorks' and the local name shortening as true.

cfgGAP = bleGAPDataBlockConfig('AdvertisingDataTypes', ...
    {'Advertising interval', ...
    'Local name'});
cfgGAP.AdvertisingInterval  = 48;
cfgGAP.LocalName            = 'MathWorks';
cfgGAP.LocalNameShortening  = true;

% Generate the BLE GAP AD block from the corresponding configuration object.

dataBlock = bleGAPDataBlock(cfgGAP)

% Create a configuration object for a BLE GAP AD block with type 'Flags'. Specify the values of LE discoverability as 'Limited', BR/EDR support as true, and simultaneous support for LE and BR/EDR as 'Host'.

cfgGAP = bleGAPDataBlockConfig;
cfgGAP.LEDiscoverability      = 'Limited';
cfgGAP.BREDR                  = true;
cfgGAP.LE                     = 'Host';

% Generate the BLE GAP AD block from the corresponding configuration object.

dataBlock = bleGAPDataBlock(cfgGAP)

% Copyright 2019 The MathWorks, Inc.