Refactor UI state management and improve error handling in the application. Added success and error messages to enhance user feedback during package creation and device connection status updates.

This commit is contained in:
2026-01-29 10:45:12 -06:00
parent a44f433bba
commit f5a688e741
7 changed files with 120 additions and 77 deletions
+10 -5
View File
@@ -68,13 +68,18 @@ func (d *Device) Connect() error {
// ExitDevMode sends the command to exit dev mode.
func (d *Device) ExitDevMode() error {
if !d.Connected || d.Port == nil {
return fmt.Errorf("device not connected")
if d.Port == nil {
return fmt.Errorf("port not open")
}
// Send exit dev mode command
// TODO: Replace with the actual command sequence to exit dev mode
// This is currently not implemented on the Cardputer side.
// disable dev mode
_, err := d.Port.Write([]byte{0xAA, 0x05, 0x00, 0x00, 0x00})
if err != nil {
return fmt.Errorf("failed to send exit dev mode command: %w", err)
}
// Allow some time for the device to respond or settle if needed
time.Sleep(100 * time.Millisecond)
return nil
}