%% Return HE-SIG-B Field Length Information
% Create a WLAN HE-MU-format configuration object, specifying the allocation index.

cfgHEMU = wlanHEMUConfig(0);

% Generate a WLAN waveform for the specified configuration and return the PPDU field indices.

waveform = wlanWaveformGenerator(1,cfgHEMU);
ind = wlanFieldIndices(cfgHEMU);

% Decode the L-SIG field and obtain the OFDM information. This information is required to obtain the L-SIG length, which is used in the recovery configuration object.

lsig = waveform(ind.LSIG(1):ind.LSIG(2),:);
lsigDemod = wlanHEDemodulate(lsig,'L-SIG',cfgHEMU.ChannelBandwidth);
preHEInfo = wlanHEOFDMInfo('L-SIG',cfgHEMU.ChannelBandwidth);

% Recover the L-SIG information bits and related information, making sure that the bits pass the parity check. For this example, we assume a noiseless channel. For more realistic results you can pass the waveform through an 802.11ax™ channel model by using the wlanTGaxChannel System object™ and work with the received waveform.

csi = ones(52,1);
[lsigBits,failCheck,lsigInfo] = wlanLSIGBitRecover(lsigDemod(preHEInfo.DataIndices,:,:),0,csi);

% Decode the HE-SIG-A field and recover the HE-SIG-A information bits, ensuring that the bits pass the cyclic redundancy check (CRC).

siga = waveform(ind.HESIGA(1):ind.HESIGA(2),:);
sigaDemod = wlanHEDemodulate(siga,'HE-SIG-A',cfgHEMU.ChannelBandwidth);
preHEInfo = wlanHEOFDMInfo('HE-SIG-A',cfgHEMU.ChannelBandwidth);
[bits,failCRC] = wlanHESIGABitRecover(sigaDemod(preHEInfo.DataIndices,:,:),0,csi);

% Create a WLAN recovery configuration object, specifying an HE-MU-format packet and the length of the L-SIG field.

cfg = wlanHERecoveryConfig('PacketFormat','HE-MU','LSIGLength',lsigInfo.Length);

% Update the recovery configuration object with the recovered HE-SIG-A bits.

cfgUpdated = interpretHESIGABits(cfg,bits);

% Return and display the HE-SIG-B information.

info = getSIGBLength(cfgUpdated);
disp(info);

% Copyright 2018 The MathWorks, Inc.