add ssl 心跳机制

This commit is contained in:
anlicheng 2026-05-11 00:07:57 +08:00
parent 1fdd0bf5a5
commit 627be12a6e

View File

@ -47,8 +47,10 @@ start_link() ->
{ok, State :: #state{}} | {ok, State :: #state{}, timeout() | hibernate} |
{stop, Reason :: term()} | ignore).
init([]) ->
ok = iot_log:set_metadata(),
{ok, UdpServerProps} = application:get_env(iot, udp_server),
Port = proplists:get_value(port, UdpServerProps),
logger:debug("[udp_server] start at port: ~p", [Port]),
{ok, Socket} = gen_udp:open(Port, [binary, {active, true}]),
{ok, #state{socket = Socket}}.
@ -116,6 +118,7 @@ handle_heartbeat_packet(Packet, Peer) when is_binary(Packet) ->
{ok, UUID, Timestamp, Payload, Mac} ->
case efka_client_store:verify_heartbeat(UUID, Timestamp, Payload, Mac) of
true ->
logger:warning("[udp_server] heartbeat auth from peer: ~p, uuid: ~p", [Peer, UUID]),
Pid = iot_host:get_pid(UUID),
iot_host:heartbeat(Pid);
false ->