Skip to content

Commit 752e38e

Browse files
agnersemontnemery
andauthored
Add vendor TLV tag (#103)
* 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]>
1 parent 016c0ca commit 752e38e

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

python_otbr_api/tlv_parser.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ class MeshcopTLVType(IntEnum):
5050
PERIOD = 55
5151
SCAN_DURATION = 56
5252
ENERGY_LIST = 57
53+
# Seen in a dataset imported through iOS companion app
54+
APPLE_TAG_UNKNOWN = 74
5355
DISCOVERYREQUEST = 128
5456
DISCOVERYRESPONSE = 129
5557
JOINERADVERTISEMENT = 241

tests/test_tlv_parser.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,32 @@ def test_parse_tlv() -> None:
101101
}
102102

103103

104+
def test_parse_tlv_apple() -> None:
105+
"""Test the TLV parser from a (truncated) dataset from an Apple BR."""
106+
dataset_tlv = (
107+
"0e08000065901a07000000030000194a0300000f35060004001fffc003104d79486f6d65313233"
108+
"31323331323334"
109+
)
110+
dataset = parse_tlv(dataset_tlv)
111+
assert dataset == {
112+
MeshcopTLVType.ACTIVETIMESTAMP: Timestamp(
113+
MeshcopTLVType.ACTIVETIMESTAMP, bytes.fromhex("000065901a070000")
114+
),
115+
MeshcopTLVType.CHANNEL: Channel(
116+
MeshcopTLVType.CHANNEL, bytes.fromhex("000019")
117+
),
118+
MeshcopTLVType.APPLE_TAG_UNKNOWN: MeshcopTLVItem(
119+
MeshcopTLVType.APPLE_TAG_UNKNOWN, bytes.fromhex("00000f")
120+
),
121+
MeshcopTLVType.CHANNELMASK: MeshcopTLVItem(
122+
MeshcopTLVType.CHANNELMASK, bytes.fromhex("0004001fffc0")
123+
),
124+
MeshcopTLVType.NETWORKNAME: NetworkName(
125+
MeshcopTLVType.NETWORKNAME, "MyHome1231231234".encode()
126+
),
127+
}
128+
129+
104130
@pytest.mark.parametrize(
105131
"tlv, error, msg",
106132
(

0 commit comments

Comments
 (0)