Skip to content

Commit

Permalink
ESP32: add option option for starting always dev mode
Browse files Browse the repository at this point in the history
Add (opt-in) NVS setting for enabling always ALISP console and web server.

Signed-off-by: Davide Bettio <[email protected]>
  • Loading branch information
bettio committed Jul 27, 2023
1 parent 17234c5 commit 9720ac7
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions libs/esp32boot/esp32init.erl
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,22 @@ loop() ->
loop()
end.

maybe_start_dev_mode(SystemStatus) ->
case {SystemStatus, esp:nvs_get_binary(atomvm, dev_mode)} of
{_, <<"always">>} ->
start_dev_mode();
{_, <<"never">>} ->
not_started;
{ok, undefined} ->
not_started;
{failed_app_start, undefined} ->
start_dev_mode()
end.

start_dev_mode() ->
avm_pubsub:start(default_pubsub),
spawn(?MODULE, fun maybe_start_network/0, []).
spawn(?MODULE, fun maybe_start_network/0, []),
started.

%%
%% Boot handling
Expand All @@ -77,10 +90,11 @@ boot() ->
case atomvm:add_avm_pack_file(BootPath, [{name, app}]) of
ok ->
StartModule = get_start_module(),
maybe_start_dev_mode(ok),
StartModule:start();
{error, Reason} ->
io:format("Failed app start: ~p.~n", [Reason]),
start_dev_mode()
maybe_start_dev_mode(failed_app_start)
end.

get_boot_path() ->
Expand Down

0 comments on commit 9720ac7

Please sign in to comment.