Skip to content

Commit 09bfe55

Browse files
committed
fix #11: fix a few bugs when working with IPv4 frames and with API escaped mode
1 parent 8f0eee4 commit 09bfe55

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

digi/xbee/packets/network.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,16 +89,16 @@ def create_packet(raw, operating_mode):
8989
if operating_mode != OperatingMode.ESCAPED_API_MODE and operating_mode != OperatingMode.API_MODE:
9090
raise InvalidOperatingModeException(operating_mode.name + " is not supported.")
9191

92-
_raw = XBeeAPIPacket._unescape_data(raw) if operating_mode == OperatingMode.ESCAPED_API_MODE else raw
92+
raw = XBeeAPIPacket._unescape_data(raw) if operating_mode == OperatingMode.ESCAPED_API_MODE else raw
9393

94-
XBeeAPIPacket._check_api_packet(_raw, min_length=RXIPv4Packet.__MIN_PACKET_LENGTH)
94+
XBeeAPIPacket._check_api_packet(raw, min_length=RXIPv4Packet.__MIN_PACKET_LENGTH)
9595

96-
if _raw[3] != ApiFrameType.RX_IPV4.code:
96+
if raw[3] != ApiFrameType.RX_IPV4.code:
9797
raise InvalidPacketException("This packet is not an RXIPv4Packet.")
9898

9999
return RXIPv4Packet(IPv4Address(bytes(raw[4:8])), utils.bytes_to_int(raw[8:10]),
100100
utils.bytes_to_int(raw[10:12]), IPProtocol.get(raw[12]),
101-
_raw[14:-1])
101+
raw[14:-1])
102102

103103
def needs_id(self):
104104
"""
@@ -243,7 +243,7 @@ def _get_api_packet_spec_data_dict(self):
243243
DictKeys.SRC_PORT: self.__source_port,
244244
DictKeys.IP_PROTOCOL: "%s (%s)" % (self.__ip_protocol.code, self.__ip_protocol.description),
245245
DictKeys.STATUS: self.__status,
246-
DictKeys.DATA: bytearray(self.__data)}
246+
DictKeys.RF_DATA: bytearray(self.__data)}
247247

248248
source_address = property(__get_source_address, __set_source_address)
249249
""":class:`ipaddress.IPv4Address`. IPv4 address of the source device."""
@@ -511,7 +511,7 @@ def _get_api_packet_spec_data_dict(self):
511511
DictKeys.SRC_PORT: self.source_port,
512512
DictKeys.IP_PROTOCOL: "%s (%s)" % (self.__ip_protocol.code, self.__ip_protocol.description),
513513
DictKeys.OPTIONS: self.__transmit_options,
514-
DictKeys.DATA: bytearray(self.__data)}
514+
DictKeys.RF_DATA: bytearray(self.__data)}
515515

516516
dest_address = property(__get_dest_address, __set_dest_address)
517517
""":class:`ipaddress.IPv4Address`. IPv4 address of the destination device."""

0 commit comments

Comments
 (0)