function [waasstatus] = parseNSTBwaasstatus(fid);
%---------------------------------------------------------
% parse NSTB message type 100 (GEO/WAAS message)
% Ju-Yong Do,  Jan 14, 2009
%---------------------------------------------------------
% input  : NSTB file indicator
% output : WAAS subsystem status message in "waasstatus"
%=========================================================
%=========================================================
global rx option

%read header
waasstatus.weiid    = fread(fid, 1, '*uint16');     %WEI id
gpsweek             = fread(fid, 1, '*uint16');     %time of validity
waasstatus.tow      = fread(fid, 1, 'uint32')*1e-3; %time of validity in time of week (ms->sec)
waasstatus.nummsg   = fread(fid, 1, '*uint8');      %number of messages

%=========================================================
%read WAAS message
for i=1:waasstatus.nummsg
    waasstatus.subid(i)     = fread(fid, 1, '*uint16');     %waas subsystem id
    waasstatus.net(i)       = fread(fid, 1, '*uint8');      %network status
    waasstatus.master(i)    = fread(fid, 1, '*uint8');      %master status
    waasstatus.composite(i) = fread(fid, 1, '*uint8');      %composite fault code status    
    waasstatus.p43(i)       = fread(fid, 1, '*uint8');      %43p status    
    waasstatus.rx(i)        = fread(fid, 1, '*uint8');      %receiver status    
    waasstatus.cs(i)        = fread(fid, 1, '*uint8');      %cesium status    
    waasstatus.pcu(i)       = fread(fid, 1, '*uint8');      %power control unit status    
end

%stack up what's collected
rx.aiding.waasstatus     = [rx.aiding.waasstatus waasstatus];

%=========================================================
% CRC test for sanity check
crcTestNSTB(fid, 10, 9*double(waasstatus.nummsg), 2); %(fid,headLen,bodyLen,tailLen)

%=========================================================
if option.plot,     
    disp('=======MESSAGE 100 WAAS SUBSYSTEM STATUS=====================');
    disp(['tow= ',num2str(waasstatus.tow),' sec']); 
end

return
%=========================================================
%=========================================================
