Data structures

Common configuration values

class aio_ld2410.BaudRateIndex[source]

Bases: IntEnum

Configurable baud rates.

RATE_9600 = 1

Baud rate set to 9600Hz.

RATE_19200 = 2

Baud rate set to 19200Hz.

RATE_38400 = 3

Baud rate set to 38400Hz.

RATE_57600 = 4

Baud rate set to 57600Hz.

RATE_115200 = 5

Baud rate set to 115200Hz.

RATE_230400 = 6

Baud rate set to 230400Hz.

RATE_256000 = 7

Baud rate set to 256000Hz.

RATE_460800 = 8

Baud rate set to 460800Hz.

classmethod from_integer(rate: int) Self[source]

Get the appropriate index from the provided baud rate.

Parameters:

rate (int) – the baud rate as an int.

Raises:

KeyError – when the provided rate is not configurable.

Return type:

Self

class aio_ld2410.LightControl[source]

Bases: IntEnum

Configuration of the light control.

DISABLED = 0

The OUT pin will never be affected by photo-sensor

BELOW = 1

The OUT pin is HIGH when value is under threshold.

ABOVE = 2

The OUT pin is HIGH when value is above threshold.

class aio_ld2410.ResolutionIndex[source]

Bases: IntEnum

All possible gate resolution.

The sensors divides the area in some fixed number of zones called gates (typically 9). Gates have a default resolution of 75 centimeters, but some models / firmwares allow for more precise resolutions.

RESOLUTION_75CM = 0

Each gate covers 75 centimeters.

RESOLUTION_20CM = 1

Each gate covers 20 centimeters.

class aio_ld2410.OutPinLevel[source]

Bases: IntEnum

Tell the default status of the OUT pin.

LOW = 0
HIGH = 1
class aio_ld2410.TargetStatus[source]

Bases: IntFlag

Target’s status flags.

This field is present in reports and tells whether the target (if any) is static, moving or both.

MOVING = 1

There is a moving target

STATIC = 2

There is a static target

Command parameters

class aio_ld2410.GateSensitivityConfig[source]

Bases: TypedDict

Set current sensitivity values for a specific gate.

This class is used to parse keyword arguments from LD2410.set_gate_sensitivity().

distance_gate: int

Gate to set (value form 0 to 8, can be 0xFFFF for broadcast to all gates).

moving_threshold: int

Moving energy threshold (in percent, from 0 to 100).

static_threshold: int

Static energy threshold (in percent, from 0 to 100).

class aio_ld2410.LightControlConfig[source]

Bases: TypedDict

Configuration of the light controls for the OUT pin.

This class is used to parse keyword arguments from LD2410.set_light_control().

control: LightControl

Determines when the OUT pin is high with sensitivity.

threshold: int

Photo-sensitivity threshold value (from 0 to 255).

default: OutPinLevel

Default value for OUT when not triggered.

class aio_ld2410.ParametersConfig[source]

Bases: TypedDict

Standard configuration parameters.

This class is used to parse keyword arguments from LD2410.set_parameters().

moving_max_distance_gate: int

Farthest gate to consider for moving detection (from 2 to 8).

static_max_distance_gate: int

Farthest gate to consider for static detection (from 2 to 8).

presence_timeout: int

How long to keep detecting a presence after the person moved away (0 to 65535 seconds).

Command replies

class aio_ld2410.ConfigModeStatus[source]

Values received when entering the configuration mode.

protocol_version: int

Version of the communication protocol.

buffer_size: int

Size of the device’s internal read buffer (in bytes).

class aio_ld2410.FirmwareVersion[source]

Describes a firmware version.

type: int

Firmware type (documentation says it is 0).

major: int

Major firmware version.

minor: int

Minor firmware version (should read as hex).

revision: int

Firmware revision (should be read as hex).

__str__() str[source]

Get a textual representation of the firmware version.

Return type:

str

class aio_ld2410.LightControlStatus[source]

Status of the light controls for the OUT pin.

control: LightControl

Determines when the OUT pin is high with sensitivity.

threshold: int

Photo-sensitivity threshold value (from 0 to 255).

default: OutPinLevel

Default value for OUT when not triggered.

class aio_ld2410.ParametersStatus[source]

Status of current standard parameters.

max_distance_gate: int

Farthest configurable gate number (should be 8).

moving_max_distance_gate: int

Farthest configured gate number for moving detection.

moving_threshold: Sequence[int]

Array of moving energy thresholds for each gate (9 elements, percentage).

static_max_distance_gate: int

Farthest configured gate number for static detection.

static_threshold: Sequence[int]

Array of static energy thresholds for each gate (9 elements, percentage).

presence_timeout: int

How long the sensor keeps detecting a presence after the person moved away (seconds).

Report structures

class aio_ld2410.ReportStatus[source]

Structure of a report received from the device.

basic: ReportBasicStatus

Basic part of the report (always set).

engineering: ReportEngineeringStatus | None

Engineering part of the report (only in engineering mode), None otherwise.

class aio_ld2410.ReportBasicStatus[source]

Basic part of the ReportStatus.

See also

ReportStatus

target_status: TargetStatus

Detection status flags of the target (if any).

moving_distance: int

When detected moving, at which distance (in centimeters).

moving_energy: int

Energy of the moving target (in percent, from 0 to 100).

static_distance: int

When detected static, at which distance (in centimeters).

static_energy: int

Energy of the static target (in percent, from 0 to 100).

detection_distance: int

Detection distance (in centimeters).

class aio_ld2410.ReportEngineeringStatus[source]

Engineering part of the ReportStatus.

moving_max_distance_gate: int

Farthest configured gate number for moving detection.

static_max_distance_gate: int

Farthest configured gate number for static detection.

moving_gate_energy: Sequence[int]

Array of moving energies for each gate (9 elements, percentage).

static_gate_energy: Sequence[int]

Array of static energies for each gate (9 elements, percentage).

photosensitive_value: int

Photo-sensor value (from 0 to 255).

out_pin_status: OutPinLevel

Current status of the OUT pin.

Protocol structures

class aio_ld2410.protocol.CommandCode[source]

Bases: IntEnum

List of known command OpCodes.

PARAMETERS_WRITE = 96
PARAMETERS_READ = 97
ENGINEERING_ENABLE = 98
ENGINEERING_DISABLE = 99
GATE_SENSITIVITY_SET = 100
FIRMWARE_VERSION = 160
BAUD_RATE_SET = 161
FACTORY_RESET = 162
MODULE_RESTART = 163
BLUETOOTH_SET = 164
BLUETOOTH_MAC_GET = 165
CONFIG_DISABLE = 254
CONFIG_ENABLE = 255
BLUETOOTH_AUTHENTICATE = 168
BLUETOOTH_PASSWORD_SET = 169
DISTANCE_RESOLUTION_SET = 170
DISTANCE_RESOLUTION_GET = 171
LIGHT_CONTROL_SET = 173
LIGHT_CONTROL_GET = 174
class aio_ld2410.protocol.FrameType[source]

Bases: IntEnum

All known frame types handled by the device.

COMMAND = 1

This frame is a command or reply frame.

REPORT = 2

This frame is a report frame.

class aio_ld2410.protocol.ReportType[source]

Bases: IntEnum

Type of report we received.

ENGINEERING = 1

Advanced report with per-gate values.

BASIC = 2

Basic report for an easy use.