digi.xbee.packets.zigbee module

class digi.xbee.packets.zigbee.RegisterJoiningDevicePacket(frame_id, registrant_address, options, key, op_mode=OperatingMode.API_MODE)[source]

Bases: XBeeAPIPacket

This class represents a Register Joining Device packet. Packet is built using the parameters of the constructor or providing a valid API payload.

Use this frame to securely register a joining device to a trust center. Registration is the process by which a node is authorized to join the network using a preconfigured link key or installation code that is conveyed to the trust center out-of-band (using a physical interface and not over-the-air).

If registering a device with a centralized trust center (EO = 2), then the key entry will only persist for KT seconds before expiring.

Registering devices in a distributed trust center (EO = 0) is persistent and the key entry will never expire unless explicitly removed.

To remove a key entry on a distributed trust center, this frame should be issued with a null (None) key. In a centralized trust center you cannot use this method to explicitly remove the key entries.

See also

Class constructor. Instantiates a new RegisterJoiningDevicePacket object with the provided parameters.

Parameters:
  • frame_id (integer) – the frame ID of the packet.

  • registrant_address (XBee64BitAddress) – the 64-bit address of the destination device.

  • options (RegisterKeyOptions) – the register options indicating the key source.

  • key (Bytearray) – key of the device to register. Up to 16 bytes if entering a Link Key or up to 18 bytes (16-byte code + 2 byte CRC) if entering an Install Code.

  • op_mode (OperatingMode, optional, default=`OperatingMode.API_MODE`) – The mode in which the frame was captured.

Raises:

ValueError – if frame_id is less than 0 or greater than 255.

static create_packet(raw, operating_mode)[source]

Override method.

Returns:

RegisterJoiningDevicePacket.

Raises:

See also

XBeeAPIPacket._check_api_packet()
needs_id()[source]

Override method.

property registrant_address

Returns the 64-bit registrant address.

Returns:

the 64-bit registrant address.

Return type:

XBee64BitAddress

See also

property options

Returns the register options value.

Returns:

the register options indicating the key source.

Return type:

RegisterKeyOptions

property key

Returns the register key.

Returns:

the register key.

Return type:

Bytearray

property effective_len

Returns the effective length of the packet.

Returns:

Effective length of the packet.

Return type:

Integer

property frame_id

Returns the frame ID of the packet.

Returns:

the frame ID of the packet.

Return type:

Integer

get_checksum()

Returns the checksum value of this XBeePacket. The checksum is the last 8 bits of the sum of the bytes between the length field and the checksum field.

Returns:

checksum value of this XBeePacket.

Return type:

Integer

See also

get_frame_spec_data()

Override method.

get_frame_type()

Returns the frame type of this packet.

Returns:

the frame type of this packet.

Return type:

ApiFrameType

See also

get_frame_type_value()

Returns the frame type integer value of this packet.

Returns:

the frame type integer value of this packet.

Return type:

Integer

See also

is_broadcast()

Returns whether this packet is broadcast or not.

Returns:

True if this packet is broadcast, False otherwise.

Return type:

Boolean

property op_mode

Retrieves the operating mode in which this packet was read.

Returns:

The operating mode.

Return type:

OperatingMode

output(escaped=False)

Returns the raw bytearray of this XBeePacket, ready to be send by the serial port.

Parameters:

escaped (Boolean) – indicates if the raw bytearray must be escaped.

Returns:

raw bytearray of the XBeePacket.

Return type:

Bytearray

to_dict()

Returns a dictionary with all information of the XBeePacket fields.

Returns:

dictionary with all info of the XBeePacket fields.

Return type:

Dictionary

static unescape_data(data)

Un-escapes the provided bytearray data.

Parameters:

data (Bytearray) – the bytearray to unescape.

Returns:

data unescaped.

Return type:

Bytearray

class digi.xbee.packets.zigbee.RegisterDeviceStatusPacket(frame_id, status, op_mode=OperatingMode.API_MODE)[source]

Bases: XBeeAPIPacket

This class represents a Register Device Status packet. Packet is built using the parameters of the constructor or providing a valid API payload.

This frame is sent out of the UART of the trust center as a response to a 0x24 Register Device frame, indicating whether the registration was successful or not.

Class constructor. Instantiates a new RegisterDeviceStatusPacket object with the provided parameters.

Parameters:
  • frame_id (integer) – the frame ID of the packet.

  • status (ZigbeeRegisterStatus) – status of the register device operation.

  • op_mode (OperatingMode, optional, default=`OperatingMode.API_MODE`) – The mode in which the frame was captured.

Raises:

ValueError – if frame_id is less than 0 or greater than 255.

static create_packet(raw, operating_mode)[source]

Override method.

Returns:

RegisterDeviceStatusPacket.

Raises:

See also

XBeeAPIPacket._check_api_packet()
needs_id()[source]

Override method.

property status

Returns the register device status.

Returns:

the register device status.

Return type:

ZigbeeRegisterStatus

property effective_len

Returns the effective length of the packet.

Returns:

Effective length of the packet.

Return type:

Integer

property frame_id

Returns the frame ID of the packet.

Returns:

the frame ID of the packet.

Return type:

Integer

get_checksum()

Returns the checksum value of this XBeePacket. The checksum is the last 8 bits of the sum of the bytes between the length field and the checksum field.

Returns:

checksum value of this XBeePacket.

Return type:

Integer

See also

get_frame_spec_data()

Override method.

get_frame_type()

Returns the frame type of this packet.

Returns:

the frame type of this packet.

Return type:

ApiFrameType

See also

get_frame_type_value()

Returns the frame type integer value of this packet.

Returns:

the frame type integer value of this packet.

Return type:

Integer

See also

is_broadcast()

Returns whether this packet is broadcast or not.

Returns:

True if this packet is broadcast, False otherwise.

Return type:

Boolean

property op_mode

Retrieves the operating mode in which this packet was read.

Returns:

The operating mode.

Return type:

OperatingMode

output(escaped=False)

Returns the raw bytearray of this XBeePacket, ready to be send by the serial port.

Parameters:

escaped (Boolean) – indicates if the raw bytearray must be escaped.

Returns:

raw bytearray of the XBeePacket.

Return type:

Bytearray

to_dict()

Returns a dictionary with all information of the XBeePacket fields.

Returns:

dictionary with all info of the XBeePacket fields.

Return type:

Dictionary

static unescape_data(data)

Un-escapes the provided bytearray data.

Parameters:

data (Bytearray) – the bytearray to unescape.

Returns:

data unescaped.

Return type:

Bytearray

class digi.xbee.packets.zigbee.RouteRecordIndicatorPacket(x64bit_addr, x16bit_addr, rx_opts, hops=None, op_mode=OperatingMode.API_MODE)[source]

Bases: XBeeAPIPacket

This class represents a Zigbee Route Record Indicator packet. Packet is built using the parameters of the constructor or providing a valid API payload.

The route record indicator is received whenever a device sends a Zigbee route record command. This is used with many-to-one routing to create source routes for devices in a network.

Among received data, some options can also be received indicating transmission parameters.

Class constructor. Instantiates a new RouteRecordIndicatorPacket object with the provided parameters.

Parameters:
  • x64bit_addr (XBee64BitAddress) – The 64-bit source address.

  • x16bit_addr (XBee16BitAddress) – The 16-bit source address.

  • rx_opts (Integer) – Bitfield indicating the receive options.

  • hops (List, optional, default=`None`) – List of 16-bit address of intermediate hops in the source route (excluding source and destination).

  • op_mode (OperatingMode, optional, default=`OperatingMode.API_MODE`) – The mode in which the frame was captured.

static create_packet(raw, operating_mode)[source]

Override method.

Returns:

RouteRecordIndicatorPacket.

Raises:

See also

XBeeAPIPacket._check_api_packet()
needs_id()[source]

Override method.

is_broadcast()[source]

Override method.

See also

XBeeAPIPacket.is_broadcast()
property x64bit_source_addr

Returns the 64-bit source address.

Returns:

The 64-bit source address.

Return type:

XBee64BitAddress

See also

property x16bit_source_addr

Returns the 16-bit source address.

Returns:

The 16-bit source address.

Return type:

XBee16BitAddress

See also

property receive_options

Returns the receive options bitfield.

Returns:

The receive options bitfield.

Return type:

Integer

See also

property number_of_hops

Returns the number of intermediate hops in the source route (excluding source and destination).

Returns:

The number of addresses.

Return type:

Integer

property hops

Returns the list of intermediate hops starting from the closest to destination hop and finishing with the closest to the source (excluding source and destination).

Returns:

The list of 16-bit addresses of intermediate hops.

Return type:

List

See also

property effective_len

Returns the effective length of the packet.

Returns:

Effective length of the packet.

Return type:

Integer

property frame_id

Returns the frame ID of the packet.

Returns:

the frame ID of the packet.

Return type:

Integer

get_checksum()

Returns the checksum value of this XBeePacket. The checksum is the last 8 bits of the sum of the bytes between the length field and the checksum field.

Returns:

checksum value of this XBeePacket.

Return type:

Integer

See also

get_frame_spec_data()

Override method.

get_frame_type()

Returns the frame type of this packet.

Returns:

the frame type of this packet.

Return type:

ApiFrameType

See also

get_frame_type_value()

Returns the frame type integer value of this packet.

Returns:

the frame type integer value of this packet.

Return type:

Integer

See also

property op_mode

Retrieves the operating mode in which this packet was read.

Returns:

The operating mode.

Return type:

OperatingMode

output(escaped=False)

Returns the raw bytearray of this XBeePacket, ready to be send by the serial port.

Parameters:

escaped (Boolean) – indicates if the raw bytearray must be escaped.

Returns:

raw bytearray of the XBeePacket.

Return type:

Bytearray

to_dict()

Returns a dictionary with all information of the XBeePacket fields.

Returns:

dictionary with all info of the XBeePacket fields.

Return type:

Dictionary

static unescape_data(data)

Un-escapes the provided bytearray data.

Parameters:

data (Bytearray) – the bytearray to unescape.

Returns:

data unescaped.

Return type:

Bytearray

class digi.xbee.packets.zigbee.CreateSourceRoutePacket(frame_id, x64bit_addr, x16bit_addr, route_options=0, hops=None, op_mode=OperatingMode.API_MODE)[source]

Bases: XBeeAPIPacket

This class represents a Zigbee Create Source Route packet. This packet is built using the parameters of the constructor or providing a valid API payload.

This frame creates a source route in the node. A source route specifies the complete route a packet should travese to get from source to destination. Source routing should be used with many-to-one routing for best results.

Note: Both, 64-bit and 16-bit destination addresses are required when creating a source route. These are obtained when a Route Record Indicator (0xA1) frame is received.

Class constructor. Instantiates a new CreateSourceRoutePacket object with the provided parameters.

Parameters:
  • frame_id (integer) – the frame ID of the packet.

  • x64bit_addr (XBee64BitAddress) – The 64-bit destination address.

  • x16bit_addr (XBee16BitAddress) – The 16-bit destination address.

  • route_options (Integer) – Route command options.

  • hops (List, optional, default=`None`) – List of 16-bit addresses of intermediate hops in the source route (excluding source and destination).

  • op_mode (OperatingMode, optional, default=`OperatingMode.API_MODE`) – The mode in which the frame was captured.

static create_packet(raw, operating_mode)[source]

Override method.

Returns:

CreateSourceRoutePacket.

Raises:

See also

XBeeAPIPacket._check_api_packet()
needs_id()[source]

Override method.

property x64bit_dest_addr

Returns the 64-bit destination address.

Returns:

The 64-bit destination address.

Return type:

XBee64BitAddress

See also

property x16bit_dest_addr

Returns the 16-bit destination address.

Returns:

The 16-bit destination address.

Return type:

XBee16BitAddress

See also

property route_cmd_options

Returns the route command options bitfield.

Returns:

The route command options bitfield.

Return type:

Integer

property number_of_hops

Returns the number of intermediate hops in the source route (excluding source and destination).

Returns:

The number of intermediate hops.

Return type:

Integer

property hops

Returns the list of intermediate hops starting from the closest to destination hop and finishing with the closest to the source (excluding source and destination).

Returns:

The list of 16-bit addresses of intermediate hops.

Return type:

List

See also

property effective_len

Returns the effective length of the packet.

Returns:

Effective length of the packet.

Return type:

Integer

property frame_id

Returns the frame ID of the packet.

Returns:

the frame ID of the packet.

Return type:

Integer

get_checksum()

Returns the checksum value of this XBeePacket. The checksum is the last 8 bits of the sum of the bytes between the length field and the checksum field.

Returns:

checksum value of this XBeePacket.

Return type:

Integer

See also

get_frame_spec_data()

Override method.

get_frame_type()

Returns the frame type of this packet.

Returns:

the frame type of this packet.

Return type:

ApiFrameType

See also

get_frame_type_value()

Returns the frame type integer value of this packet.

Returns:

the frame type integer value of this packet.

Return type:

Integer

See also

is_broadcast()

Returns whether this packet is broadcast or not.

Returns:

True if this packet is broadcast, False otherwise.

Return type:

Boolean

property op_mode

Retrieves the operating mode in which this packet was read.

Returns:

The operating mode.

Return type:

OperatingMode

output(escaped=False)

Returns the raw bytearray of this XBeePacket, ready to be send by the serial port.

Parameters:

escaped (Boolean) – indicates if the raw bytearray must be escaped.

Returns:

raw bytearray of the XBeePacket.

Return type:

Bytearray

to_dict()

Returns a dictionary with all information of the XBeePacket fields.

Returns:

dictionary with all info of the XBeePacket fields.

Return type:

Dictionary

static unescape_data(data)

Un-escapes the provided bytearray data.

Parameters:

data (Bytearray) – the bytearray to unescape.

Returns:

data unescaped.

Return type:

Bytearray

class digi.xbee.packets.zigbee.OTAFirmwareUpdateStatusPacket(src_address_64, updater_address_16, rx_options, msg_type, block_number, target_address_64, op_mode=OperatingMode.API_MODE)[source]

Bases: XBeeAPIPacket

This class represents a an Over The Air Firmware Update Status packet. Packet is built using the parameters of the constructor or providing a valid API payload.

This frame provides a status indication of a firmware update transmission.

If a query request returns a 0x15 (NACK) status, the target is likely waiting for a firmware update image. If no messages are sent to it for about 75 seconds, the target will timeout and accept new query messages.

If a query status returns a 0x51 (QUERY) status, then the target’s bootloader is not active and will not respond to query messages.

Class constructor. Instantiates a new OTAFirmwareUpdateStatusPacket object with the provided parameters.

Parameters:
  • src_address_64 (XBee64BitAddress) – the 64-bit address of the device returning this answer.

  • updater_address_16 (XBee16BitAddress) – the 16-bit address of the updater device.

  • rx_options (Integer) – bitfield indicating the receive options.

  • msg_type (EmberBootloaderMessageType) – Ember bootloader message type

  • block_number (Integer) – block number used in the update request.

  • target_address_64 (XBee64BitAddress) – the 64-bit address of the device that is being updated.

  • op_mode (OperatingMode, optional, default=`OperatingMode.API_MODE`) – The mode in which the frame was captured.

property effective_len

Returns the effective length of the packet.

Returns:

Effective length of the packet.

Return type:

Integer

property frame_id

Returns the frame ID of the packet.

Returns:

the frame ID of the packet.

Return type:

Integer

get_checksum()

Returns the checksum value of this XBeePacket. The checksum is the last 8 bits of the sum of the bytes between the length field and the checksum field.

Returns:

checksum value of this XBeePacket.

Return type:

Integer

See also

get_frame_spec_data()

Override method.

get_frame_type()

Returns the frame type of this packet.

Returns:

the frame type of this packet.

Return type:

ApiFrameType

See also

get_frame_type_value()

Returns the frame type integer value of this packet.

Returns:

the frame type integer value of this packet.

Return type:

Integer

See also

is_broadcast()

Returns whether this packet is broadcast or not.

Returns:

True if this packet is broadcast, False otherwise.

Return type:

Boolean

property op_mode

Retrieves the operating mode in which this packet was read.

Returns:

The operating mode.

Return type:

OperatingMode

output(escaped=False)

Returns the raw bytearray of this XBeePacket, ready to be send by the serial port.

Parameters:

escaped (Boolean) – indicates if the raw bytearray must be escaped.

Returns:

raw bytearray of the XBeePacket.

Return type:

Bytearray

to_dict()

Returns a dictionary with all information of the XBeePacket fields.

Returns:

dictionary with all info of the XBeePacket fields.

Return type:

Dictionary

static unescape_data(data)

Un-escapes the provided bytearray data.

Parameters:

data (Bytearray) – the bytearray to unescape.

Returns:

data unescaped.

Return type:

Bytearray

static create_packet(raw, operating_mode)[source]

Override method.

Returns:

OTAFirmwareUpdateStatusPacket.

Raises:
  • InvalidPacketException – if the bytearray length is less than 17. (start delim. + length (2 bytes) + frame type + source 64bit addr. (8 bytes) + updater 16bit addr. (2 bytes) + receive options + bootloader message type + block number + source 64bit addr. (8 bytes) + checksum = 27 bytes).

  • InvalidPacketException – if the length field of ‘raw’ is different from its real length. (length field: bytes 1 and 3)

  • InvalidPacketException – if the first byte of ‘raw’ is not the header byte. See SpecialByte.

  • InvalidPacketException – if the calculated checksum is different from the checksum field value (last byte).

  • InvalidPacketException – if the frame type is not ApiFrameType.OTA_FIRMWARE_UPDATE_STATUS.

  • InvalidOperatingModeException – if operating_mode is not supported.

See also

XBeeAPIPacket._check_api_packet()
needs_id()[source]

Override method.

property x64bit_source_addr

Returns the 64-bit source address.

Returns:

the 64-bit source address.

Return type:

XBee64BitAddress

See also

property x16bit_updater_addr

Returns the 16-bit updater address.

Returns:

the 16-bit updater address.

Return type:

XBee16BitAddress

See also

property receive_options

Returns the receive options bitfield.

Returns:

the receive options bitfield.

Return type:

Integer

See also

property bootloader_msg_type

Returns the bootloader message type.

Returns:

the bootloader message type.

Return type:

EmberBootloaderMessageType

property block_number

Returns the block number of the request.

Returns:

the block number of the request.

Return type:

Integer

property x64bit_target_addr

Returns the 64-bit target address.

Returns:

the 64-bit target address.

Return type:

XBee64BitAddress

See also