digi.xbee.sender module

class digi.xbee.sender.PacketSender(xbee)[source]

Bases: object

Class to send XBee packets.

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

Parameters

xbee (XBeeDevice) – The XBee.

send_packet(packet)[source]

Sends a packet to the XBee. The packet to send is escaped depending on the current operating mode.

Parameters

packet (XBeePacket) – The packet to send.

Raises
  • InvalidOperatingModeException – If the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.

  • XBeeException – if the XBee device’s communication interface is closed.

See also

is_op_mode_valid(value)[source]

Returns True if the provided value is a valid operating mode for the library.

Parameters

value (Bytearray) – The value to check.

Returns

True for a valid value, False otherwise.

Return type

Boolean

at_response_received_cb(response)[source]

Callback to deal with AT command responses and update the corresponding node. Only for internal use.

Parameters

( (response) – class: .XBeeAPIPacket): The received API packet.

class digi.xbee.sender.SyncRequestSender(xbee, packet_to_send, timeout)[source]

Bases: object

Class to synchronously send XBee packets. This means after sending the packet it waits for its response, if the package includes a frame ID, otherwise it does not wait.

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

Parameters
  • xbee (XBeeDevice) – The local XBee to send the packet.

  • packet_to_send (XBeePacket) – The packet to transmit.

  • timeout (Integer) – Number of seconds to wait. -1 to wait indefinitely.

send()[source]

Sends the packet and waits for its corresponding response.

Returns

Received response packet.

Return type

XBeePacket

Raises
  • InvalidOperatingModeException – If the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.

  • TimeoutException – If the response is not received in the configured timeout.

  • XBeeException – If the XBee device’s communication interface is closed.

See also

property xbee

Returns the local XBee to send the packet.

Returns

Local XBee device.

Return type

XBeeDevice

property packet

Returns the packet to send.

Returns

Packet to send.

Return type

XBeePacket

property timeout

Returns the maximum number of seconds to wait for a response.

Returns

Timeout to wait for a response.

Return type

Integer