Skip to content

Commit

Permalink
Use firmware.upgrade (toitlang#239)
Browse files Browse the repository at this point in the history
* Avoid direct use of esp32.deep_sleep

* Pull in newer SDK

* Address review feedback
  • Loading branch information
kasperl committed Sep 7, 2022
1 parent d6e1ac1 commit a12f89d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
17 changes: 11 additions & 6 deletions src/jaguar.toit
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,15 @@ registry_ / ContainerRegistry ::= ContainerRegistry
main arguments:
try:
catch --trace: registry_.start_installed
exception := catch --trace: serve arguments
logger.error "rebooting due to $(exception)"
finally:
esp32.deep_sleep (Duration --s=1)
serve arguments
finally: | is_exception exception |
// We shouldn't be able to get here without an exception having
// been thrown, but we play it defensively and force an exception
// if that should ever happen.
if not is_exception: unreachable
// Jaguar runs as a critical container, so an uncaught exception
// will cause the system to reboot.
logger.error "rebooting due to $exception.value"

serve arguments:
port := HTTP_PORT
Expand Down Expand Up @@ -463,9 +468,9 @@ serve_incoming_requests socket/tcp.ServerSocket id/uuid.Uuid name/string address
// TODO(kasper): Maybe we can share the way we try to close down
// the HTTP server nicely with the corresponding code where we
// handle /code requests?
writer.detach.close // Close connection nicely before rebooting.
writer.detach.close // Close connection nicely before upgrading.
sleep --ms=500
esp32.deep_sleep (Duration --ms=10)
firmware.upgrade

// Validate SDK version before attempting to run code.
else if sdk_version_header != vm_sdk_version:
Expand Down

0 comments on commit a12f89d

Please sign in to comment.