Skip to content

Commit

Permalink
Add vendor TLV tag (#103)
Browse files Browse the repository at this point in the history
* Add vendor TLV tag

Users received "unkown type 74" when trying to import Thread dataset
from an Apple iOS device. It seems that an additional tag with type 74
is present in those datasets.

Accept this unkown tag type as well.

* Fix falke8/black

* Split long line properly

* Update python_otbr_api/tlv_parser.py

Co-authored-by: Stefan Agner <[email protected]>

* Update test_tlv_parser.py

---------

Co-authored-by: Erik Montnemery <[email protected]>
  • Loading branch information
agners and emontnemery authored Feb 6, 2024
1 parent 016c0ca commit 752e38e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
2 changes: 2 additions & 0 deletions python_otbr_api/tlv_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ class MeshcopTLVType(IntEnum):
PERIOD = 55
SCAN_DURATION = 56
ENERGY_LIST = 57
# Seen in a dataset imported through iOS companion app
APPLE_TAG_UNKNOWN = 74
DISCOVERYREQUEST = 128
DISCOVERYRESPONSE = 129
JOINERADVERTISEMENT = 241
Expand Down
26 changes: 26 additions & 0 deletions tests/test_tlv_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,32 @@ def test_parse_tlv() -> None:
}


def test_parse_tlv_apple() -> None:
"""Test the TLV parser from a (truncated) dataset from an Apple BR."""
dataset_tlv = (
"0e08000065901a07000000030000194a0300000f35060004001fffc003104d79486f6d65313233"
"31323331323334"
)
dataset = parse_tlv(dataset_tlv)
assert dataset == {
MeshcopTLVType.ACTIVETIMESTAMP: Timestamp(
MeshcopTLVType.ACTIVETIMESTAMP, bytes.fromhex("000065901a070000")
),
MeshcopTLVType.CHANNEL: Channel(
MeshcopTLVType.CHANNEL, bytes.fromhex("000019")
),
MeshcopTLVType.APPLE_TAG_UNKNOWN: MeshcopTLVItem(
MeshcopTLVType.APPLE_TAG_UNKNOWN, bytes.fromhex("00000f")
),
MeshcopTLVType.CHANNELMASK: MeshcopTLVItem(
MeshcopTLVType.CHANNELMASK, bytes.fromhex("0004001fffc0")
),
MeshcopTLVType.NETWORKNAME: NetworkName(
MeshcopTLVType.NETWORKNAME, "MyHome1231231234".encode()
),
}


@pytest.mark.parametrize(
"tlv, error, msg",
(
Expand Down

0 comments on commit 752e38e

Please sign in to comment.