Skip to content

Commit 829ed0c

Browse files
committed
tools: native_bt: handle InvalidTag exception
Handle decryption failures without crashing. Signed-off-by: Jordan Yates <jordan@embeint.com>
1 parent a390407 commit 829ed0c

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

src/infuse_iot/tools/native_bt.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from bleak.backends.characteristic import BleakGATTCharacteristic
1616
from bleak.backends.device import BLEDevice
1717
from bleak.backends.scanner import AdvertisementData
18+
from cryptography.exceptions import InvalidTag
1819

1920
from infuse_iot.commands import InfuseCommand
2021
from infuse_iot.common import InfuseBluetoothUUID, InfuseType
@@ -248,6 +249,8 @@ def simple_callback(self, device: BLEDevice, data: AdvertisementData):
248249
self.unknown_networks.add(network_id)
249250
Console.log_info(f"Unknown network 0x{network_id:06x}")
250251
return
252+
except InvalidTag as _e:
253+
Console.log_info(f"Failed to decrypt packet from {device}")
251254
self.bleak_mapping[hdr.device_id] = device
252255

253256
hop = HopReceived(

0 commit comments

Comments
 (0)