%% Use BLE PCAP Writer to Write BLE LL Packet to PCAPNG File
% Create a BLE PCAPNG file writer object, specifying the name and extension of the PCAPNG file.

pcapObj = blePCAPWriter('FileName','sampleBLELL', ...
    'FileExtension','pcapng');

% Generate a BLE LL packet.

cfgLLData = bleLLDataChannelPDUConfig('LLID', ...
    'Data (start fragment/complete)');
payload = '0E00050014010A001F004000170017000000';
llDataPDU = bleLLDataChannelPDU(cfgLLData,payload);
connAccessAddress = de2bi(hex2dec('E213BC42'),32)';
llpacket = [connAccessAddress; llDataPDU];

% Write the BLE LL packet to the PCAPNG file.

timestamp = 12800000; % Number of microseconds
write(pcapObj,llpacket,timestamp,'PacketFormat','bits');

% Copyright 2020 The MathWorks, Inc.