[tests] fix key_id_mode handling and add exception handle (#4927)

This commit fixes key_id_mode handling and added exception handling
when key_id_mode is 0.

According to IEEE Std 802.15.4-2015, when Key Id Mode is 0x00:

    Key is determined implicitly from the originator and recipient(s)
    of the frame, as indicated in the frame header.

Our test scripts cannot handle such packets. If we leave key_id_mode =
0 case unhandled, we would get some exceptions that may cause
developers to think that something is wrong. However dropping packets
in this case is a normal behavior.
This commit is contained in:
Li Cao
2020-05-07 21:33:30 -07:00
committed by GitHub
parent 60aa241594
commit 417093e247
3 changed files with 49 additions and 22 deletions
+6 -2
View File
@@ -175,14 +175,18 @@ class VirtualTime(BaseSimulator):
self.sock.close()
self.sock = None
def _add_message(self, nodeid, message):
def _add_message(self, nodeid, message_obj):
addr = ('127.0.0.1', self.port + nodeid)
# Ignore any exceptions
try:
messages = self._message_factory.create(io.BytesIO(message))
messages = self._message_factory.create(io.BytesIO(message_obj))
self.devices[addr]['msgs'] += messages
except message.DropPacketException:
print(
'Drop current packet because it cannot be handled in test scripts'
)
except Exception as e:
# Just print the exception to the console
print("EXCEPTION: %s" % e)