function [sps, bleSNR, initImpairments] = helperBLEInitPHYParameters(EbNo, phyMode)
%helperBLEInitPHYParameters BLE PHY parameters initialization
%   [SPS, BLESNR, INITIMPAIRMENTS] = helperBLEInitPHYParameters(EBNO,
%   PHYMODE) initializes the PHY parameters (SPS, SNR and impairments)
%   based on the EbNo (energy per bit to noise power ratio), and PHY mode
%   ('LE2M' | 'LE1M' | 'LE500K' | 'LE125K').

%   Copyright 2019 The MathWorks, Inc.

% Only 20MHz bandwidth is used for configuring WLAN traffic
wlanChannelBandwidth = 20; % in MHz

% Initialize sps (samples per symbol)
sps = wlanChannelBandwidth;

if strcmpi(phyMode, 'LE2M')
    sps = wlanChannelBandwidth/2;
end

% Set SNR points based on PHY transmission mode
% For Coded PHYs(LE500K and LE125K), the code rate factor is included
% in SNR calculation as 1/2 rate FEC encoder is used.
if any(strcmp(phyMode, {'LE1M', 'LE2M'}))
    bleSNR = EbNo - 10*log10(sps);
else
    codeRate = 1/2;
    bleSNR = EbNo + 10*log10(codeRate) - 10*log10(sps);
end

% Create and configure the System objects for BLE PHY impairments
initImpairments = helperBLEImpairmentsInit(phyMode, sps);
end