diff --git a/apps/iot/src/endpoint/endpoint_sup.erl b/apps/iot/src/endpoint/endpoint_sup.erl index 59bcec0..ad59018 100644 --- a/apps/iot/src/endpoint/endpoint_sup.erl +++ b/apps/iot/src/endpoint/endpoint_sup.erl @@ -30,19 +30,19 @@ start_link() -> init([]) -> SupFlags = #{strategy => one_for_one, intensity => 1000, period => 3600}, Endpoints = iot_api:get_all_endpoints(), - ChildSpecs = lists:flatmap(fun(EndpointInfo) -> + ChildSpecs = lists:filtermap(fun(EndpointInfo) -> case endpoint:endpoint_record(EndpointInfo) of error -> - []; + false; {ok, Endpoint} -> case endpoint:is_support(endpoint:get_protocol(Endpoint)) of true -> - [child_spec(Endpoint)]; + {true, child_spec(Endpoint)}; false -> - [] + false end end - end, Endpoints), + end, Endpoints), {ok, {SupFlags, ChildSpecs}}. -spec ensured_endpoint_started(Endpoint :: #endpoint{}) -> {ok, Pid :: pid()} | {error, Reason :: any()}.