%% Decode BLE Waveform Using Specified Name-Value Pairs
% Specify the values of PHY generating mode, channel index and samples per symbol (sps).

phyMode = 'LE125K';
chanIndex = 2;
sps = 4;

% Generate transmission bits containing random binary values. Obtain the BLE transmit waveform from the transmission bits and the specified name-value pairs using the bleWaveformGenerator function.

txBits = randi([0 1],100,1);
txWaveform = bleWaveformGenerator(txBits,'Mode',phyMode,...
    'SamplesPerSymbol',sps,'ChannelIndex',chanIndex);

% Recover the data bits, and then compare them with the transmission bits. The recovered data bits match the transmission bits, indicating there are no errors in the decoded BLE waveform.

rxBits = bleIdealReceiver(txWaveform,'Mode',phyMode,...
    'SamplesPerSymbol',sps,'ChannelIndex',chanIndex);
isequal(txBits,rxBits)

% Copyright 2018 The MathWorks, Inc.