mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-07-26 01:48:10 -07:00
FBT: Close current app when flashing firmware
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
import logging
|
||||
import os
|
||||
import pathlib
|
||||
import time
|
||||
|
||||
from flipper.app import App
|
||||
from flipper.storage import FlipperStorage, FlipperStorageOperations
|
||||
@@ -10,6 +11,8 @@ from flipper.utils.cdc import resolve_port
|
||||
|
||||
|
||||
class Main(App):
|
||||
APP_POST_CLOSE_DELAY_SEC = 0.2
|
||||
|
||||
def init(self):
|
||||
self.parser.add_argument("-p", "--port", help="CDC Port", default="auto")
|
||||
|
||||
@@ -48,6 +51,23 @@ class Main(App):
|
||||
flipper_update_path, manifest_path.parents[0]
|
||||
)
|
||||
|
||||
self.logger.info("Closing current app, if any")
|
||||
for _ in range(10):
|
||||
storage.send_and_wait_eol("loader close\r")
|
||||
result = storage.read.until(storage.CLI_EOL)
|
||||
if b"was closed" in result:
|
||||
self.logger.info("App closed")
|
||||
storage.read.until(storage.CLI_EOL)
|
||||
time.sleep(self.APP_POST_CLOSE_DELAY_SEC)
|
||||
elif result.startswith(b"No application"):
|
||||
storage.read.until(storage.CLI_EOL)
|
||||
break
|
||||
else:
|
||||
self.logger.error(
|
||||
f"Unexpected response: {result.decode('ascii')}"
|
||||
)
|
||||
return 4
|
||||
|
||||
storage.send_and_wait_eol(
|
||||
f"update install {flipper_update_path}/{manifest_name}\r"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user