%% Recover Information Bits in L-SIG Field
% Recover the information bits in the L-SIG field of a WLAN HE single-user (HE-SU) waveform.
% Create a WLAN HE-SU-format configuration object with default settings and use it to generate an HE-SU waveform.

cfgHE = wlanHESUConfig;
cbw = cfgHE.ChannelBandwidth;
waveform = wlanWaveformGenerator(1,cfgHE);

% Obtain the WLAN field indices, which contain the modulated L-SIG and RL-SIG fields.

ind = wlanFieldIndices(cfgHE);
rxLSIG = waveform(ind.LSIG(1):ind.RLSIG(2),:);

% Perform orthogonal frequency-division multiplexing (OFDM) demodulation to extract the L-SIG field.

lsigDemod = wlanHEDemodulate(rxLSIG,'L-SIG',cbw);

% Average the L-SIG and RL-SIG symbols, return the pre-HE OFDM information, and extract the demodulated L-SIG symbols.

lsigDemodAverage = mean(lsigDemod,2);
preHEInfo = wlanHEOFDMInfo('L-SIG',cbw);
lsig = lsigDemodAverage(preHEInfo.DataIndices,:);

% Recover the L-SIG information bits and other information, assuming no channel noise. Display the parity check result.

noiseVarEst = 0;
[bits,failCheck,info] = wlanLSIGBitRecover(lsig,noiseVarEst);
disp(failCheck);

% Copyright 2018 The MathWorks, Inc.