%% Generate BLE Waveform Using Specified Name-Value Pairs
% Create an input message column vector of length 640 containing random binary values.

message = randi([0 1],640,1);

% Specify the values of generating mode, channel index, samples per symbol and access address. Set symbol rate to default value.

phyMode = 'LE125K';
chanIdx = 2;
sps = 4;
accAdd = [1 1 1 1 0 1 0 0 1 1 0 1 0 0 1 0 0 1 1 0 1 1 1 0 1 ...
    0 1 0 1 1 0 0].';
symbolRate = 1e6;

% Create a dsp.SpectrumAnalyzer System object to display the frequency spectrum of the generated BLE waveform. Set the sample rate of the frequency spectrum.

scope = dsp.SpectrumAnalyzer;
scope.SampleRate = sps*symbolRate;

% Generate the BLE waveform using specified name-value pair arguments. Plot the BLE waveform.

waveform = bleWaveformGenerator(message,'Mode',phyMode, ...
    'SamplesPerSymbol',sps,'ChannelIndex',chanIdx,'AccessAddress',accAdd);
scope(waveform);

% Copyright 2018 The MathWorks, Inc.