Main Content

bluetoothPacketDuration

Compute Bluetooth BR/EDR or LE packet duration

    Description

    example

    packetDuration = bluetoothPacketDuration(mode,packetType,payloadLength) returns the duration, packetDuration, of the Bluetooth® basic rate/enhanced data rate (BR/EDR) or low energy (LE) packet, based on the Bluetooth packet type packetType and length of the payload, payloadLength. The input, packetType, specifies the type of Bluetooth packet corresponding to the specified physical layer (PHY) transmission mode, mode.

    example

    packetDuration = bluetoothPacketDuration(___,cteLength) specifies the length of the constant tone extension (CTE) for the "ConnectionCTE" and "ConnectionlessCTE" packet types in "LE1M" or "LE2M" PHY transmission mode.

    example

    [___,numBits] = bluetoothPacketDuration(___) additionally returns the number of bits in the Bluetooth BR/EDR or LE packet.

    Examples

    collapse all

    Set the PHY transmission mode to BR.

    mode = "BR";

    Specify the packet type and payload length of the Bluetooth BR packet.

    packetType = "DH1";
    payloadLen = 18;             % In bytes

    Compute the Bluetooth BR packet duration.

    packetDuration = bluetoothPacketDuration(mode,packetType,payloadLen) % In microseconds
    packetDuration = 294
    

    Set the PHY transmission mode to LE.

    mode = "LE1M";

    Specify the packet type and payload length of the Bluetooth LE packet.

    packetType = "ConnectionCTE";
    payloadLen = 120;             % In bytes

    Set the length of the CTE. The function multiplies the specified value by 8 to get the duration in microseconds. For this example, specify 4 to set the length to 32 microseconds.

    cteLength = 4;

    Compute the Bluetooth LE packet duration.

    packetDuration = bluetoothPacketDuration(mode,packetType,payloadLen,cteLength) % In microseconds
    packetDuration = 1080
    

    Set the PHY transmission mode to EDR2M or EDR3M.

    mode = "EDR2M";

    Specify the packet type and payload length of the Bluetooth EDR packet.

    packetType = "2-DH3";
    payloadLen = 100;             % In bytes

    Compute the packet duration and total number of bits in the Bluetooth EDR packet.

    [packetDuration,numBits] = bluetoothPacketDuration(mode,packetType,payloadLen)
    packetDuration = 560
    
    numBits = 989
    

    Input Arguments

    collapse all

    PHY transmission mode, specified as "BR", "EDR2M", "EDR3M", "LE1M", "LE2M", "LE125K", or "LE500K". Specify Bluetooth PHY transmission mode based on the packet type you require.

    Data Types: char | string

    Bluetooth BR/EDR or LE packet type, specified as one of these values. When you set packetType input, you must set mode input to the corresponding value.

    packetType Valuemode Value
    • "ID"

    • "NULL"

    • "POLL"

    • "FHS"

    • "DM1"

    • "AUX1"

    "BR", "EDR2M", or "EDR3M"
    • "DH1"

    • "DM3"

    • "DH3"

    • "DM5"

    • "DH5"

    • "HV1"

    • "HV2"

    • "HV3"

    • "EV3"

    • "EV4"

    • "EV5"

    • "DV"

    "BR"
    • "2-DH1"

    • "2-DH3"

    • "2-DH5"

    • "2-EV3"

    • "2-EV5"

    "EDR2M"
    • "3-DH1"

    • "3-DH3"

    • "3-DH5"

    • "3-EV3"

    • "3-EV5"

    "EDR3M"
    • "ConnectionCTE"

    • "ConnectionlessCTE"

    "LE1M" or "LE2M"
    • "Disabled"

    "LE1M", "LE2M", "LE125K", or "LE500K"

    Data Types: char | string

    Length of the payload, specified as a nonnegative integer. If you set the mode argument to "LE1M", "LE2M", "LE125K", or "LE500K", specify this input in the range [0, 256]. If you set mode argument to "BR", "EDR2M", or "EDR3M", this function sets this input based on the specified packetType value.

    packetType Value payloadLength Value
    "ID", "NULL", or "POLL"0
    "FHS"18
    "HV1"10
    "HV2"20
    "DM1"[0,17]
    "DM3"[0,121]
    "DM5"[0,224]
    "DH1"[0,121]
    "DH3"[0,183]
    "DH5"[0,339]
    "EV3"[1,30]
    "EV4"[1,120]
    "EV5"[1,180]
    "DV"[10,19]
    "2-DH1"[0,54]
    "2-DH3"[0,367]
    "2-DH5"[0,679]
    "3-DH1"[0,83]
    "3-DH3"[0,552]
    "3-DH5"[0,1021]
    "2-EV3"[1,60]
    "2-EV5"[1,360]
    "3-EV3"[1,90]
    "3-EV5"[1,540]
    "AUX1"[0,29]

    Data Types: double

    Length of the CTE, specified as an integer in the range [2, 20]. The function multiplies the specified value by 8 to get the duration in microseconds. You can specify this argument only when:

    • mode is "LE1M" or "LE2M". packetType is "ConnectionCTE" or "ConnectionlessCTE".

    Data Types: double

    Output Arguments

    collapse all

    Duration of Bluetooth BR/EDR or LE packet, in microseconds, returned as an integer.

    Data Types: double

    Number of bits in the Bluetooth BR/EDR or LE packet, returned as an integer. This output returns the total length of the Bluetooth BR/EDR or LE packet, in bits.

    Data Types: double

    References

    [1] Bluetooth Technology Website. “Bluetooth Technology Website | The Official Website of Bluetooth Technology.” Accessed November 22, 2021. https://www.bluetooth.com/.

    [2] Bluetooth Special Interest Group (SIG). "Bluetooth Core Specification." Version 5.3. https://www.bluetooth.com/.

    Extended Capabilities

    C/C++ Code Generation
    Generate C and C++ code using MATLAB® Coder™.

    Version History

    Introduced in R2022a