add debug
This commit is contained in:
parent
d8d5bf698d
commit
c92bfb70dd
@ -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}) ->
|
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
|
case StateName =:= ?STATE_DENIED andalso HeartbeatCounter =:= 0 of
|
||||||
true ->
|
true ->
|
||||||
|
lager:warning("[iot_host] uuid: ~p, heartbeat lost, devices will unknown", [UUID]),
|
||||||
{ok, _} = host_bo:change_status(UUID, ?HOST_OFFLINE),
|
{ok, _} = host_bo:change_status(UUID, ?HOST_OFFLINE),
|
||||||
change_devices_status(HostId, ?DEVICE_UNKNOWN);
|
change_devices_status(HostId, ?DEVICE_UNKNOWN);
|
||||||
false ->
|
false ->
|
||||||
@ -461,6 +462,7 @@ code_change(_OldVsn, StateName, State = #state{}, _Extra) ->
|
|||||||
%% 修改设备的状态
|
%% 修改设备的状态
|
||||||
change_devices_status(HostId, NewStatus) when is_integer(HostId), is_integer(NewStatus) ->
|
change_devices_status(HostId, NewStatus) when is_integer(HostId), is_integer(NewStatus) ->
|
||||||
{ok, Devices} = device_bo:get_host_devices(HostId),
|
{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) ->
|
lists:foreach(fun(DeviceUUID) ->
|
||||||
Pid = iot_device:get_pid(DeviceUUID),
|
Pid = iot_device:get_pid(DeviceUUID),
|
||||||
iot_device:change_status(Pid, NewStatus)
|
iot_device:change_status(Pid, NewStatus)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user