File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -80,6 +80,8 @@ def parse_advertisement_data(
8080 if not _services :
8181 return None
8282 _service_data = _services [0 ]
83+ if not _service_data :
84+ return None
8385 _mfr_data = _mgr_datas [0 ] if _mgr_datas else None
8486 _model = chr (_service_data [0 ] & 0b01111111 )
8587
Original file line number Diff line number Diff line change @@ -29,8 +29,19 @@ def test_parse_advertisement_data_curtain():
2929 },
3030 "isEncrypted" : False ,
3131 "model" : "c" ,
32- "model_friendly_name " : "Curtain" ,
32+ "modelFriendlyName " : "Curtain" ,
3333 "modelName" : "WoCurtain" ,
3434 },
3535 device = ble_device ,
3636 )
37+
38+
39+ def test_parse_advertisement_data_empty ():
40+ """Test parse_advertisement_data with empty data does not blow up."""
41+ ble_device = BLEDevice ("aa:bb:cc:dd:ee:ff" , "any" )
42+ adv_data = AdvertisementData (
43+ manufacturer_data = {2409 : b"\xe7 \xab F\xac \x8f \x92 |\x0f \x00 \x11 \x04 " },
44+ service_data = {"0000fd3d-0000-1000-8000-00805f9b34fb" : b"" },
45+ )
46+ result = parse_advertisement_data (ble_device , adv_data )
47+ assert result is None
You can’t perform that action at this time.
0 commit comments