Bluetooth Direct Test Mode

class dtm.CommandType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)

The four command types described by the Bluetooth® Core Specification: Version 5.2, Vol. 6, Part F.

TEST_SETUP = 0

Configure the device under test

RX = 1

Start Receive test

TX = 2

Start a transmit test

END = 3

End Rx/Tx Test

class dtm.ResponseType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)

There are two main response types from the DUT (device under test).

STATUS = 0

Status of the last command (e.g., setup, start tx, start rx, or vendor specific)

PACKET_REPORT = 1

The status of the the last end test command contains a 15-bit packet count

dtm.NRF5340_SOC_PWR_TABLE = [0, -1, -2, -3, -4, -5, -6, -7, -8, -12, -16, -20, -40]

Power levels supported by nRF5340 System on a Chip (SoC)

class dtm.DTM(com_port: str)

A class to represent Direct Test Mode (DTM) for a Device Under Test (DUT).

Currently, only a UART (serial port) transport is supported. All commands are 16 bits in length.

Unlike the nRF PC DTM application, the reset command and radio configuration are not sent each time a test is started.

__init__(com_port: str)

Open serial port to device under test.

Send the reset command.

Set the packet length to the maximum (and send vendor specific command). This is done so that RF power measurements are more accurate with inexpensive spectrum analyzers. In addition, most conformance testers use the maximum packet length.

Parameters:

com_port (str) – Communication port

Raises:

Exception – if port cannot be opened or reset and packet length commands cannot be sent

reset_cmd()

Send a reset (test setup) command and expect success.

Reset the upper bits of the length and set the PHY to 1M.

end_test()

Send an end test command and expect a packet response.

start_tx_test(freq=None, duration=0.0)

Start transmit test.

Parameters:
  • freq – If present, frequency in MHz (2402-2480) to use for test

  • duration – If greater than 0, the duration of the test in seconds

start_tx_sweep(duration=1.0, repeat_count: int = 0)

Transmit on all channels for duration in seconds.

Parameters:
  • duration – time to remain on each channel

  • repeat_count (int) – Number of times to repeat sweep

start_rx_test(freq=None, duration=0.0)

Start receive test.

Parameters:
  • freq – If present, frequency in MHz (2402-2480) to use for test

  • duration – If greater than 0, the duration of the test in seconds

set_frequency(freq: int)

Set frequency in MHz (2402 to 2408).

set_channel_physical(channel: int)

Set physical channel (2*channel + 2402) MHz.

2402 = 0

2440 = 19

2480 = 39

set_channel_logical(channel: int)

Set logical channel.

2402 = 37

2404 = 0

2424 = 10

2426 = 38

2428 = 11

2480 = 39

get_channel_logical()

Get logical channel from physical channel.

2402 = 37

2404 = 0

2424 = 10

2426 = 38

2428 = 11

2480 = 39

tx_constant_carrier(freq=None, duration=0.0)

Start a constant carrier test.

Parameters:
  • freq – If present, frequency in MHz (2402-2480) to use for test

  • duration – If greater than 0, the duration of the test in seconds

set_tx_power(power: int)

Set the transmit power using a vendor specific command.

Power cannot be set while a test is running.

Parameters:

power (int) – Only set powers supported by the nRF5340 (NRF5340_SOC_PWR_TABLE) can be set by the vendor specific command

set_fem_gain(gain: int)

Set the gain register of the FEM.

24-26 is nominally 20 dB (20 dBm at the output with SoC output of 0 dBm).

Parameters:

gain (int) – Value of gain register in nRF21540 (0-31)

region_unset()

FEM gain is not kept track of by this module. Therefore, it is not possible to change the region without resetting board and creating a new object.

configure_for_ce()

Configure the BL5340PA (nRF5340 output power and FEM gain) for operation in Europe (CE).

configure_for_north_america(internal_antenna: bool = False)

Use FCC/IC power tables.

Antenna input of FEM cannot be changed during runtime, but its value must be known to select the correct power table.

configure_for_australia_nz(internal_antenna: bool = False)

Use RCM power tables.

Antenna input of FEM cannot be changed during runtime, but its value must be known to select the correct power table.

set_phy_1M()

Set physical layer to 1 Megabit/second (1 symbol per bit).

set_phy_2M()

Set physical layer to 2 Megabits/second.

set_phy_coded_s8()

Set physical layer to coded(8 symbols per bit)

set_phy_coded_s2()

Set physical layer to coded(2 symbols per bit)

set_packet_length(length: int)

Set the packet length.

Splits length into two parts.

Sends the test setup command to set the upper 2 bits of the length. The lower part (6 bits) is sent as part of the start test command.

Parameters:

length (int) – The length of the packet (0-255)

set_packet_type_PRBS9()

Set packet type to pseudorandom binary sequence.

set_packet_type_11110000()

Set packet type to 11110000.

set_packet_type_10101010()

Set packet type to 10101010.