Main Content

bleGAPDataBlock

Generate Bluetooth LE GAP data block

    Description

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

    example

    Examples

    collapse all

    Generate three unique Bluetooth LE 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'. All the three GAP AD blocks have simultaneous support for Bluetooth LE and basic rate/enhanced data rate (BR/EDR) at the host.

    Create a configuration object for a Bluetooth LE GAP AD block and specify the AD types as 'Flags' and 'Tx power level'. Set the values of LED discoverability to 'Limited' and Tx power level to 45.

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

    Generate the Bluetooth LE GAP AD block from the corresponding configuration object.

    dataBlock1 = bleGAPDataBlock(cfgGAP)
    dataBlock1 = 6x2 char array
        '02'
        '01'
        '05'
        '02'
        '0A'
        '2D'
    
    

    Create a configuration object for a Bluetooth LE GAP AD block, this time with the 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 Bluetooth LE GAP AD block from the corresponding configuration object.

    dataBlock2 = bleGAPDataBlock(cfgGAP)
    dataBlock2 = 15x2 char array
        '03'
        '1A'
        '30'
        '00'
        '0A'
        '08'
        '4D'
        '61'
        '74'
        '68'
        '57'
        '6F'
        '72'
        '6B'
        '73'
    
    

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

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

    Generate the Bluetooth LE GAP AD block from the corresponding configuration object.

    dataBlock3 = bleGAPDataBlock(cfgGAP)
    dataBlock3 = 3x2 char array
        '02'
        '01'
        '11'
    
    

    Input Arguments

    collapse all

    Bluetooth LE GAP data block configuration object, specified as a bleGAPDataBlockConfig object.

    Output Arguments

    collapse all

    Generated Bluetooth LE 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, 2021. https://www.bluetooth.com/.

    [2] Bluetooth Special Interest Group (SIG). "Bluetooth Core Specification." Version 5.3. 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™.

    Version History

    Introduced in R2019b