%% Write BLE Link Layer Packet to PCAPNG File
% Create a PCAPNG file writer object, specifying the name of the PCAPNG file. Specify the BLE link type.

pcapngObj = pcapngWriter('FileName','BLELLCapture');

% Write an interface description block for BLE.

interfaceName = 'BLE interface';
bleLinkType = 251;
interfaceId = writeInterfaceDescriptionBlock(pcapngObj,bleLinkType, ...
    interfaceName);

% Specify a BLE LL packet.

llpacket = '42BC13E206120E00050014010A001F0040001700170000007D47C0';

% Write the BLE LL packet to the PCAPNG format file.

timestamp = 0; % Number of microseconds
packetComment = 'This is a BLE packet';
write(pcapngObj,llpacket,timestamp,interfaceId,'PacketComment', ...
    packetComment);

% Copyright 2020 The MathWorks, Inc.