add debug

This commit is contained in:
anlicheng 2023-08-31 17:44:31 +08:00
parent d8d5bf698d
commit c92bfb70dd

View File

@ -419,6 +419,7 @@ handle_event(cast, heartbeat, _, State = #state{uuid = UUID, heartbeat_counter =
handle_event(info, {timeout, _, heartbeat_ticker}, StateName, State = #state{uuid = UUID, host_id = HostId, heartbeat_counter = HeartbeatCounter}) ->
case StateName =:= ?STATE_DENIED andalso HeartbeatCounter =:= 0 of
true ->
lager:warning("[iot_host] uuid: ~p, heartbeat lost, devices will unknown", [UUID]),
{ok, _} = host_bo:change_status(UUID, ?HOST_OFFLINE),
change_devices_status(HostId, ?DEVICE_UNKNOWN);
false ->
@ -461,6 +462,7 @@ code_change(_OldVsn, StateName, State = #state{}, _Extra) ->
%%
change_devices_status(HostId, NewStatus) when is_integer(HostId), is_integer(NewStatus) ->
{ok, Devices} = device_bo:get_host_devices(HostId),
lager:debug("[iot_host] host_id: ~p, devices new status: ~p, devices: ~p", [HostId, NewStatus, Devices]),
lists:foreach(fun(DeviceUUID) ->
Pid = iot_device:get_pid(DeviceUUID),
iot_device:change_status(Pid, NewStatus)