Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions src/infuse_iot/rpc_wrappers/file_write_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,13 @@ def __init__(self, args):

with open(self.file, "rb") as f:
self.payload = f.read()
self._expected_crc = binascii.crc32(self.payload)

def auth_level(self):
return Auth.NETWORK

def request_struct(self):
return self.request(self.action, binascii.crc32(self.payload))
return self.request(self.action, self._expected_crc)

def data_payload(self):
print("Preparing for file upload...")
Expand All @@ -112,6 +113,11 @@ def handle_response(self, return_code, response):
if return_code != 0:
print(f"Failed to write file ({errno.strerror(-return_code)})")
return
print("File written")
print(f"\tLength: {response.recv_len}")
print(f"\t CRC: 0x{response.recv_crc:08x}")
if (response.recv_len != len(self.payload)) or (response.recv_crc != self._expected_crc):
print("Unexpected write contents")
print(f"\tLength: {response.recv_len} (Expected {len(self.payload)})")
print(f"\t CRC: 0x{response.recv_crc:08x} (Expected 0x{self._expected_crc:08x})")
else:
print("File written")
print(f"\tLength: {response.recv_len}")
print(f"\t CRC: 0x{response.recv_crc:08x}")
3 changes: 3 additions & 0 deletions src/infuse_iot/tools/native_bt.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from bleak.backends.characteristic import BleakGATTCharacteristic
from bleak.backends.device import BLEDevice
from bleak.backends.scanner import AdvertisementData
from cryptography.exceptions import InvalidTag

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

hop = HopReceived(
Expand Down