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 24, 2023
1 parent deba1f1 commit 1cab151
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 @@ -61,9 +61,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, maybe_start_network, []).
spawn(?MODULE, maybe_start_network, []),
started.

%%
%% Boot handling
Expand All @@ -78,10 +91,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 1cab151

Please sign in to comment.