Skip to content

Commit 3a39b11

Browse files
committed
ESP32: add option option for starting always dev mode
Add (opt-in) NVS setting for enabling always ALISP console and web server. Signed-off-by: Davide Bettio <[email protected]>
1 parent 73c8463 commit 3a39b11

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

libs/esp32boot/esp32init.erl

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,22 @@ loop() ->
6060
loop()
6161
end.
6262

63+
maybe_start_dev_mode(SystemStatus) ->
64+
case {SystemStatus, esp:nvs_get_binary(atomvm, dev_mode)} of
65+
{_, <<"always">>} ->
66+
start_dev_mode();
67+
{_, <<"never">>} ->
68+
not_started;
69+
{ok, undefined} ->
70+
not_started;
71+
{failed_app_start, undefined} ->
72+
start_dev_mode()
73+
end.
74+
6375
start_dev_mode() ->
6476
avm_pubsub:start(default_pubsub),
65-
spawn(fun maybe_start_network/0).
77+
spawn(fun maybe_start_network/0),
78+
started.
6679

6780
%%
6881
%% Boot handling
@@ -77,10 +90,11 @@ boot() ->
7790
case atomvm:add_avm_pack_file(BootPath, [{name, app}]) of
7891
ok ->
7992
StartModule = get_start_module(),
93+
maybe_start_dev_mode(ok),
8094
StartModule:start();
8195
{error, Reason} ->
8296
io:format("Failed app start: ~p.~n", [Reason]),
83-
start_dev_mode()
97+
maybe_start_dev_mode(failed_app_start)
8498
end.
8599

86100
get_boot_path() ->

0 commit comments

Comments
 (0)