%% Recover VHT-SIG-A Information Bits
% Recover the information bits in the VHT-SIG-A field by performing channel estimation on the L-LTF over a 1x2 quasi-static fading channel
% Create a wlanVHTConfig object having a channel bandwidth of 80 MHz. Generate L-LTF and VHT-SIG-A field signals using this object.

cfg = wlanVHTConfig('ChannelBandwidth','CBW80');
txLLTF = wlanLLTF(cfg);
[txVHTSIGA, txBits] = wlanVHTSIGA(cfg);
chanBW = cfg.ChannelBandwidth;
noiseVarEst = 0.1;

%
% Pass the L-LTF and VHT-SIG-A signals through a 1x2 quasi-static fading channel with AWGN.

H = 1/sqrt(2)*complex(randn(1,2),randn(1,2));
rxLLTF    = awgn(txLLTF*H,10);
rxVHTSIGA = awgn(txVHTSIGA*H,10);

%
% Perform channel estimation based on the L-LTF.

demodLLTF = wlanLLTFDemodulate(rxLLTF,chanBW,1);
chanEst = wlanLLTFChannelEstimate(demodLLTF,chanBW);

%
% Recover the VHT-SIG-A. Verify that the CRC check was successful.

[rxBits,failCRC] = wlanVHTSIGARecover(rxVHTSIGA,chanEst,noiseVarEst,'CBW80');
failCRC

% The CRC failure check returns a 0, indicating that the CRC passed.
%
% Compare the transmitted bits to the received bits. Confirm that the reported CRC result is correct because the output matches the input.

isequal(txBits,rxBits)

% Copyright 2012 The MathWorks, Inc.