Skip to content

Commit eae0bd2

Browse files
committed
Implemented suggestions
1 parent 884c91d commit eae0bd2

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

‎meshtastic/ota.py‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,10 @@ def _read_device_name(self, address: str) -> Optional[str]:
181181
except Exception:
182182
pass
183183
finally:
184-
client.disconnect()
184+
try:
185+
client.disconnect()
186+
except Exception:
187+
pass
185188
client.close()
186189
return device_name
187190

@@ -248,9 +251,9 @@ def update(self, progress_callback: Optional[Callable[[int, int], None]] = None)
248251
else:
249252
raise OTAError("Timeout waiting for response")
250253

251-
# Streaming firmware data in chunks of 512 bytes
254+
# Streaming firmware data in chunks of 512 bytes (or MTU size)
252255
sent_bytes = 0
253-
chunk_size = 512
256+
chunk_size = min(512, client.bleak_client.mtu_size)
254257
while sent_bytes < size:
255258
chunk = data[sent_bytes : sent_bytes + chunk_size]
256259
client.write_gatt_char(self.WRITE_UUID, chunk, response=True)

0 commit comments

Comments
 (0)