%% Generate Multipacket Bluetooth BR/EDR Waveform with HV1 Packets
% Specify the number of HV1 packets.

numPackets = 10;

% Create a Bluetooth BR/EDR waveform configuration object. Specify the packet type as HV1.

cfg = bluetoothWaveformConfig;
cfg.PacketType = 'HV1';

% Create a random input bit vector containing concatenated payloads.

numBits = getPayloadLength(cfg)*8*numPackets; % Byte to bit conversion
dataBits = randi([0 1],numBits,1);

% Set the symbol rate.

symbolRate = 1e6; % In MHz

% Generate the Bluetooth waveform.

waveform = bluetoothWaveformGenerator(dataBits,cfg);

% Create a dsp.SpectrumAnalyzer System object to display the frequency spectrum of the generated Bluetooth BR/EDR waveform. Set the sample rate of the frequency spectrum.

scope = dsp.SpectrumAnalyzer;
scope.SampleRate = cfg.SamplesPerSymbol*symbolRate;

% Plot the Bluetooth BR/EDR waveform.

scope(waveform);

% Copyright 2019 The MathWorks, Inc.