Skip to content

Commit 73c8463

Browse files
committed
ESP32/init: start web server only on app start fail
Do not enable it by default. Signed-off-by: Davide Bettio <[email protected]>
1 parent d62451a commit 73c8463

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

libs/esp32boot/esp32init.erl

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,6 @@
3939
start() ->
4040
console:print(<<"AtomVM init.\n">>),
4141

42-
avm_pubsub:start(default_pubsub),
43-
44-
spawn(fun maybe_start_network/0),
45-
4642
io:format("Starting application...~n"),
4743

4844
Exit =
@@ -64,6 +60,10 @@ loop() ->
6460
loop()
6561
end.
6662

63+
start_dev_mode() ->
64+
avm_pubsub:start(default_pubsub),
65+
spawn(fun maybe_start_network/0).
66+
6767
%%
6868
%% Boot handling
6969
%%
@@ -74,10 +74,14 @@ loop() ->
7474

7575
boot() ->
7676
BootPath = get_boot_path(),
77-
atomvm:add_avm_pack_file(BootPath, [{name, app}]),
78-
79-
StartModule = get_start_module(),
80-
StartModule:start().
77+
case atomvm:add_avm_pack_file(BootPath, [{name, app}]) of
78+
ok ->
79+
StartModule = get_start_module(),
80+
StartModule:start();
81+
{error, Reason} ->
82+
io:format("Failed app start: ~p.~n", [Reason]),
83+
start_dev_mode()
84+
end.
8185

8286
get_boot_path() ->
8387
case esp:nvs_get_binary(atomvm, boot_path) of

0 commit comments

Comments
 (0)