@@ -630,12 +630,42 @@ def test_manufacturer_data_short_by_two():
630630
631631
632632def test_manufacturer_data_short_by_three ():
633- """Test short manufacturer data."""
633+ """Test manufacturer data with minimum size (company ID only, no payload).
634+
635+ This is now valid after fixing issue #179 - manufacturer data with just
636+ a company ID and empty payload is accepted, consistent with service data.
637+ """
634638
635639 data = (b"\x03 \xff \x01 \x01 " ,)
636640
637641 adv = parse_advertisement_data (data )
638642
643+ assert adv .local_name is None
644+ assert adv .service_uuids == []
645+ assert adv .service_data == {}
646+ assert adv .manufacturer_data == {257 : b"" }
647+ assert adv .tx_power is None
648+
649+ assert parse_advertisement_data_tuple (tuple (data )) == (
650+ None ,
651+ [],
652+ {},
653+ {257 : b"" },
654+ None ,
655+ )
656+
657+
658+ def test_manufacturer_data_short_by_four ():
659+ """Test short manufacturer data.
660+
661+ Manufacturer data claims length of 4 but only has 3 bytes available
662+ (type + company ID, no payload bytes when 1 payload byte is claimed).
663+ """
664+
665+ data = (b"\x04 \xff \x01 \x01 " ,)
666+
667+ adv = parse_advertisement_data (data )
668+
639669 assert adv .local_name is None
640670 assert adv .service_uuids == []
641671 assert adv .service_data == {}
@@ -917,3 +947,29 @@ def test_negative_splice_pos_does_not_crash(data: tuple[bytes, bytes, bytes]) ->
917947 {},
918948 None ,
919949 )
950+
951+
952+ def test_parse_advertisement_with_empty_service_data ():
953+ """Test parsing advertisement with empty service data payload (issue #179).
954+
955+ This tests the case where service data contains only a UUID with no payload bytes.
956+ The parser should accept this as valid empty service data and continue parsing
957+ subsequent advertisement structures.
958+ """
959+ # Data from issue #179:
960+ # 02 01 06 - Flags (type 0x01, data 0x06)
961+ # 03 16 0a 18 - Service Data (type 0x16, UUID 0x180a, empty payload)
962+ # 03 03 fa ff - Complete 16-bit Service UUIDs (type 0x03, UUID 0xfffa)
963+ # 07 ff 00 01 50 90 40 a2 - Manufacturer Data (type 0xff, company 0x0100, data)
964+ # 10 09 4b 54... - Complete Local Name (type 0x09, "KT12200-B-00100")
965+ data = bytes .fromhex (
966+ "02010603160a180303faff07ff0001509040a210094b5431323230302d422d3030313030"
967+ )
968+
969+ adv = parse_advertisement_data ((data ,))
970+
971+ assert adv .local_name == "KT12200-B-00100"
972+ assert adv .service_uuids == ["0000fffa-0000-1000-8000-00805f9b34fb" ]
973+ assert adv .service_data == {"0000180a-0000-1000-8000-00805f9b34fb" : b"" }
974+ assert adv .manufacturer_data == {256 : b"\x50 \x90 \x40 \xa2 " }
975+ assert adv .tx_power is None
0 commit comments