Implement DFU mode

This commit is contained in:
atse 2023-08-01 10:33:53 +08:00
parent 9291160798
commit bfec9efbec
2 changed files with 22 additions and 0 deletions

View File

@ -240,3 +240,16 @@ class Client:
await self._writer.drain()
await self.disconnect()
async def dfu(self):
"""Put the Thermostat in DFU update mode
The client is disconnected as the Thermostat stops responding to
TCP commands in DFU update mode. The only way to exit it is by
power-cycling.
"""
async with self._command_lock:
self._writer.write("dfu\n".encode('utf-8'))
await self._writer.drain()
await self.disconnect()

View File

@ -320,7 +320,16 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
self.actionReset.triggered.connect(reset_thermostat)
self.thermostat_menu.addAction(self.actionReset)
@asyncSlot(bool)
async def dfu_mode(_):
await self._on_connection_changed(False)
await self.client.dfu()
# TODO: add a firmware flashing GUI?
self.actionEnter_DFU_Mode.triggered.connect(dfu_mode)
self.thermostat_menu.addAction(self.actionEnter_DFU_Mode)
self.thermostat_menu.addAction(self.actionNetwork_Settings)
self.thermostat_menu.addAction(self.actionLoad_all_configs)
self.thermostat_menu.addAction(self.actionSave_all_configs)