Main Content

Create Configuration Objects

Communications Toolbox™ Library for the Bluetooth® Protocol uses value objects to organize properties required for generation of higher layer Bluetooth PDUs. After you create the various configuration objects described here, you can use them to generate waveforms.

Create Link Layer Data Channel PDU Configuration Object

This example shows how to create a BLE link layer data channel PDU configuration object. It also shows how to change the default property settings by using dot notation or by overriding the default settings by using Name,Value pairs when creating the object.

Create Object and Then Modify Properties

Create a BLE link layer data channel PDU configuration object with default settings.

lldatapdu = bleLLDataChannelPDUConfig
lldatapdu = 
  bleLLDataChannelPDUConfig with properties:

                 LLID: 'Data (continuation fragment/empty)'
                 NESN: 0
       SequenceNumber: 0
             MoreData: 0
    CRCInitialization: '012345'

Modify the defaults to specify a 'Data (start fragment/complete)' PDU.

lldatapdu.LLID = 'Data (start fragment/complete)'
lldatapdu = 
  bleLLDataChannelPDUConfig with properties:

                 LLID: 'Data (start fragment/complete)'
                 NESN: 0
       SequenceNumber: 0
             MoreData: 0
    CRCInitialization: '012345'

Override Default Property Values During Object Creation

Create a BLE link layer data channel PDU configuration object, using Name,Value pairs to specify a 'Control' PDU.

lldatapdu2 = bleLLDataChannelPDUConfig('LLID','Control')
lldatapdu2 = 
  bleLLDataChannelPDUConfig with properties:

                 LLID: 'Control'
                 NESN: 0
       SequenceNumber: 0
             MoreData: 0
    CRCInitialization: '012345'
        ControlConfig: [1x1 bleLLControlPDUConfig]

Create Link Layer Advertising Channel PDU Configuration Object

This example shows how to create a BLE link layer advertising channel PDU configuration object. It also shows how to change the default property settings by using dot notation or by overriding the default settings by using Name,Value pairs when creating the object.

Create Object and Then Modify Properties

Create a BLE link layer advertising channel PDU configuration object with default settings.

lladvertpdu = bleLLAdvertisingChannelPDUConfig
lladvertpdu = 
  bleLLAdvertisingChannelPDUConfig with properties:

                  PDUType: 'Advertising indication'
         ChannelSelection: 'Algorithm1'
    AdvertiserAddressType: 'Random'
        AdvertiserAddress: '0123456789AB'
          AdvertisingData: [3x2 char]

Modify the defaults to specify a 'Advertising direct indication' PDU.

lladvertpdu.PDUType = 'Advertising direct indication'
lladvertpdu = 
  bleLLAdvertisingChannelPDUConfig with properties:

                  PDUType: 'Advertising direct indication'
         ChannelSelection: 'Algorithm1'
    AdvertiserAddressType: 'Random'
        AdvertiserAddress: '0123456789AB'
        TargetAddressType: 'Random'
            TargetAddress: '0123456789CD'

Override Default Property Values During Object Creation

Create a BLE link layer advertising channel PDU configuration object, using Name,Value pairs to specify a 'Scan response' PDU using channel section algorithm 2.

lldatapdu2 = bleLLAdvertisingChannelPDUConfig('PDUType','Scan response','ChannelSelection','Algorithm2')
lldatapdu2 = 
  bleLLAdvertisingChannelPDUConfig with properties:

                  PDUType: 'Scan response'
         ChannelSelection: 'Algorithm2'
    AdvertiserAddressType: 'Random'
        AdvertiserAddress: '0123456789AB'
         ScanResponseData: [3x2 char]

Create L2CAP Frame Configuration Object

This example shows how to create a BLE logical link control and adaptation protocol (L2CAP) frame configuration object. It also shows how to change the default property settings by using dot notation or by overriding the default settings by using Name,Value pairs when creating the object.

Create Object and Then Modify Properties

Create a BLE L2CAP frame configuration object with default settings.

l2capframe = bleL2CAPFrameConfig 
l2capframe = 
  bleL2CAPFrameConfig with properties:

          ChannelIdentifier: '0005'
                CommandType: 'Credit based connection request'
           SignalIdentifier: '01'
    SourceChannelIdentifier: '0040'
                      LEPSM: '001F'
        MaxTransmissionUnit: 23
          MaxPDUPayloadSize: 23
                    Credits: 1

Modify the defaults setting the channel identifier to '0004' to specify an ATT channel.

l2capframe.ChannelIdentifier = '0004'
l2capframe = 
  bleL2CAPFrameConfig with properties:

    ChannelIdentifier: '0004'

Override Default Property Values During Object Creation

Create a BLE L2CAP frame configuration object, using Name,Value pairs to specify a 'Command reject' signaling channel command with the reject reason 'Invalid CID in request'.

l2capframe = bleL2CAPFrameConfig ('CommandType','Command reject','CommandRejectReason','Invalid CID in request')
l2capframe = 
  bleL2CAPFrameConfig with properties:

               ChannelIdentifier: '0005'
                     CommandType: 'Command reject'
                SignalIdentifier: '01'
             CommandRejectReason: 'Invalid CID in request'
         SourceChannelIdentifier: '0040'
    DestinationChannelIdentifier: '0040'

Create GAP Data Block Configuration Object

This example shows how to create a BLE GAP data block configuration object. It also shows how to change the default property settings by using dot notation or by overriding the default settings by using Name,Value pairs when creating the object.

Create Object and Then Modify Properties

Create a BLE GAP data block configuration object with default settings.

gapDataBlk = bleGAPDataBlockConfig  
gapDataBlk = 
  bleGAPDataBlockConfig with properties:

    AdvertisingDataTypes: {'Flags'}
       LEDiscoverability: 'General'
                   BREDR: 0

Modify the defaults to specify for an advertising data block for 'Flags' and 'Tx power level' advertising data types.

gapDataBlk.AdvertisingDataTypes = {'Flags'; 'Tx power level'}
gapDataBlk = 
  bleGAPDataBlockConfig with properties:

    AdvertisingDataTypes: {2x1 cell}
       LEDiscoverability: 'General'
                   BREDR: 0
            TxPowerLevel: 0

gapDataBlk.AdvertisingDataTypes
ans = 2x1 cell
    {'Flags'         }
    {'Tx power level'}

Override Default Property Values During Object Creation

Create a BLE GAP data block configuration object, using Name,Value pairs to specify 'Advertising interval' and 'Local name' advertising data types.

gapDataBlk = bleGAPDataBlockConfig  ('AdvertisingDataTypes', {'Advertising interval', 'Local name'})
gapDataBlk = 
  bleGAPDataBlockConfig with properties:

    AdvertisingDataTypes: {2x1 cell}
               LocalName: 'Bluetooth'
     LocalNameShortening: 0
     AdvertisingInterval: 32

gapDataBlk.AdvertisingDataTypes
ans = 2x1 cell
    {'Advertising interval'}
    {'Local name'          }

Create Attribute PDU Configuration Object

This example shows how to create a BLE attribute (ATT) PDU configuration object. It also shows how to change the default property settings by using dot notation or by overriding the default settings by using Name,Value pairs when creating the object.

Create Object and Then Modify Properties

Create a BLE ATT PDU configuration object with default settings.

attpdu = bleATTPDUConfig
attpdu = 
  bleATTPDUConfig with properties:

             Opcode: 'Read request'
    AttributeHandle: '0001'

Modify the defaults to specify a 'Read blob request' operation code.

attpdu.Opcode = 'Read blob request'
attpdu = 
  bleATTPDUConfig with properties:

             Opcode: 'Read blob request'
    AttributeHandle: '0001'
             Offset: 0

Override Default Property Values During Object Creation

Create a BLE ATT PDU configuration object, using Name,Value pairs to specify 'Information request' for the operation code of a request PDU that caused an error.

lldatapdu2 = bleATTPDUConfig('RequestedOpcode','Information request')
lldatapdu2 = 
  bleATTPDUConfig with properties:

             Opcode: 'Read request'
    AttributeHandle: '0001'

Related Topics