Skip to content
This repository has been archived by the owner on Nov 25, 2024. It is now read-only.

Commit

Permalink
[codec] add decoding for allowlists that are passed back from the NCP (
Browse files Browse the repository at this point in the history
…#125)

Add unpacking for the various types of responses that come back from
the MAC_ALLOWLIST property. Note that there are three different
formats, so we try them from the most complex/involved to the least
complex/involved.

1. Try to decode an array of structures composed of an EUI64 and an
   unsigned 8-bit integer (from querying the value)
2. If that fails, try to decode a single entry composed of an EUI64
   and an unsigned 8-bit integer (from inserting a value)
3. If that fails, try to decode a single entry composed of only an
   EUI64 (from deleting an entry)
4. If all of these fail, return None
  • Loading branch information
mmb-davidsmith authored Sep 30, 2022
1 parent b378b1f commit 2c461dd
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion spinel/codec.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import binascii
import time
import logging
import struct
import threading
import traceback
import queue
Expand Down Expand Up @@ -502,7 +503,13 @@ def MAC_RAW_STREAM_ENABLED(self, _, payload):
return self.parse_b(payload)

def MAC_ALLOWLIST(self, _, payload):
pass
formats = ["A(t(EC))", "EC", "E"]
for format in formats:
try:
return self.parse_fields(payload, format)
except struct.error:
pass
return None

def MAC_ALLOWLIST_ENABLED(self, _, payload):
return self.parse_b(payload)
Expand Down

0 comments on commit 2c461dd

Please sign in to comment.