diff --git a/src/cfclient/ui/connectivity_manager.py b/src/cfclient/ui/connectivity_manager.py
index 85165fd8b3..4bd305e94c 100644
--- a/src/cfclient/ui/connectivity_manager.py
+++ b/src/cfclient/ui/connectivity_manager.py
@@ -70,21 +70,23 @@ def register_ui_elements(self, ui_elements):
self._interface_combo_current_index_changed_handler)
def set_state(self, state):
- self._state = state
- self._update_ui()
-
- if self._state == self.UIState.DISCONNECTED:
- self.connection_state_changed.emit(self.UIState.DISCONNECTED)
- elif self._state == self.UIState.CONNECTED:
- self.connection_state_changed.emit(self.UIState.CONNECTED)
- elif self._state == self.UIState.CONNECTING:
- self.connection_state_changed.emit(self.UIState.CONNECTING)
- elif self._state == self.UIState.SCANNING:
- self.connection_state_changed.emit(self.UIState.SCANNING)
+ if self._state != state:
+ self._state = state
+ self._update_ui()
+
+ if self._state == self.UIState.DISCONNECTED:
+ self.connection_state_changed.emit(self.UIState.DISCONNECTED)
+ elif self._state == self.UIState.CONNECTED:
+ self.connection_state_changed.emit(self.UIState.CONNECTED)
+ elif self._state == self.UIState.CONNECTING:
+ self.connection_state_changed.emit(self.UIState.CONNECTING)
+ elif self._state == self.UIState.SCANNING:
+ self.connection_state_changed.emit(self.UIState.SCANNING)
def set_enable(self, enable):
- self._is_enabled = enable
- self._update_ui()
+ if self._is_enabled != enable:
+ self._is_enabled = enable
+ self._update_ui()
def set_address(self, address):
for ui_elements in self._ui_elements:
diff --git a/src/cfclient/ui/dialogs/bootloader.py b/src/cfclient/ui/dialogs/bootloader.py
index 2a38ea5dc7..9dca6e690a 100644
--- a/src/cfclient/ui/dialogs/bootloader.py
+++ b/src/cfclient/ui/dialogs/bootloader.py
@@ -117,6 +117,8 @@ def __init__(self, helper, *args):
self.clt.disconnectedSignal.connect(
lambda: self.setUiState(UIState.DISCONNECTED))
+ self._cold_boot_error_message = ''
+
self._releases = {}
self._release_firmwares_found.connect(self._populate_firmware_dropdown)
self._release_downloaded.connect(self.release_zip_downloaded)
@@ -129,8 +131,8 @@ def __init__(self, helper, *args):
self.clt.start()
def _ui_connection_fail(self, message):
- self.setStatusLabel(message)
- self.coldBootButton.setEnabled(True)
+ self._cold_boot_error_message = message
+ self.setUiState(UIState.CONNECT_FAILED)
def setUiState(self, state):
if (state == UIState.DISCONNECTED):
@@ -141,25 +143,30 @@ def setUiState(self, state):
self.progressBar.setTextVisible(False)
self.progressBar.setValue(0)
self.statusLabel.setText('Status: IDLE')
+ self.helper.connectivity_manager.set_enable(True)
elif (state == UIState.CONNECTING):
self.resetButton.setEnabled(False)
self.programButton.setEnabled(False)
self.setStatusLabel("Trying to connect cold bootloader, restart "
"the Crazyflie to connect")
self.coldBootButton.setEnabled(False)
+ self.helper.connectivity_manager.set_enable(False)
elif (state == UIState.CONNECT_FAILED):
- self.setStatusLabel("Connecting to bootloader failed")
+ self.setStatusLabel(self._cold_boot_error_message)
self.coldBootButton.setEnabled(True)
+ self.helper.connectivity_manager.set_enable(True)
elif (state == UIState.COLD_CONNECT):
self.resetButton.setEnabled(True)
self.programButton.setEnabled(True)
self.setStatusLabel("Connected to bootloader")
self.coldBootButton.setEnabled(False)
+ self.helper.connectivity_manager.set_enable(False)
elif (state == UIState.RESET):
self.setStatusLabel("Resetting to firmware, disconnected")
self.resetButton.setEnabled(False)
self.programButton.setEnabled(False)
self.coldBootButton.setEnabled(False)
+ self.helper.connectivity_manager.set_enable(False)
def setStatusLabel(self, text):
self.connectionStatus.setText("Status: %s" % text)