bleGAPDataBlock

Generate BLE GAP data block

Download Required: To use bleGAPDataBlock, first download Communications Toolbox™ Library for the Bluetooth® Protocol. For more information, see Get and Manage Add-Ons. Alternatively, see Communications Toolbox Library for the Bluetooth Protocol File Exchange.

Description

example

dataBlock = bleGAPDataBlock(cfgGAP) generates a Bluetooth low energy (BLE) generic access profile (GAP) data block of type advertising data (AD) or scan response data (SRD) corresponding to the BLE GAP data block configuration object cfgGAP.

Examples

collapse all

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)
dataBlock = 6x2 char array
    '02'
    '01'
    '05'
    '02'
    '0A'
    '2D'

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)
dataBlock = 15x2 char array
    '03'
    '1A'
    '30'
    '00'
    '0A'
    '08'
    '4D'
    '61'
    '74'
    '68'
    '57'
    '6F'
    '72'
    '6B'
    '73'

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)
dataBlock = 3x2 char array
    '02'
    '01'
    '11'

Input Arguments

collapse all

BLE GAP data block configuration object, specified as a bleGAPDataBlockConfig object. This value defines the type of BLE GAP data block and its applicable properties.

Output Arguments

collapse all

Generated BLE GAP data block, 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, 2019. https://www.bluetooth.com/.

[2] Bluetooth Special Interest Group (SIG). "Bluetooth Core Specification." Version 5.1. https://www.bluetooth.com/.

[3] Bluetooth Special Interest Group (SIG). "Supplement to the Bluetooth Core Specification." CSS Version 7 (2016).

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Introduced in R2019b