From 7df30eaf7583f12b2f5bc0b29bef54c0e62cfc7b Mon Sep 17 00:00:00 2001 From: anlicheng Date: Wed, 16 Aug 2023 17:09:54 +0800 Subject: [PATCH] fix --- apps/iot/src/iot_device.erl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/iot/src/iot_device.erl b/apps/iot/src/iot_device.erl index 59f9089..1f83735 100644 --- a/apps/iot/src/iot_device.erl +++ b/apps/iot/src/iot_device.erl @@ -36,7 +36,7 @@ -record(state, { device_id :: integer(), device_uuid :: binary(), - status = ?DEVICE_STATUS_OFFLINE + status = ?DEVICE_STATUS_ONLINE }). %%%=================================================================== @@ -106,10 +106,10 @@ init0(#{<<"device_uuid">> := DeviceUUID, <<"authorize_status">> := AuthorizeStat true -> ?STATE_ACTIVATED end, %% 重启时,离线状态 - {ok, _} = device_bo:change_status(DeviceId, ?DEVICE_STATUS_OFFLINE), + {ok, _} = device_bo:change_status(DeviceId, ?DEVICE_STATUS_ONLINE), lager:debug("[iot_device] started device: ~p, state_name: ~p", [DeviceUUID, StateName]), - {ok, StateName, #state{device_id = DeviceId, device_uuid = DeviceUUID, status = ?DEVICE_STATUS_OFFLINE}}. + {ok, StateName, #state{device_id = DeviceId, device_uuid = DeviceUUID, status = ?DEVICE_STATUS_ONLINE}}. %% @private %% @doc This function is called by a gen_statem when it needs to find out %% the callback mode of the callback module. @@ -173,10 +173,10 @@ handle_event(cast, {auth, Auth}, ?STATE_ACTIVATED, State = #state{device_id = De {keep_state, State}; false -> %% 需要矫正status字段的值 - {ok, _} = device_bo:change_status(DeviceId, ?DEVICE_STATUS_OFFLINE), + {ok, _} = device_bo:change_status(DeviceId, ?DEVICE_STATUS_ONLINE), lager:debug("[iot_device] device_uuid: ~p, auth: false, state_name from: ~p, to: ~p", [DeviceUUID, ?STATE_ACTIVATED, ?STATE_DENIED]), - {next_state, ?STATE_DENIED, State#state{status = ?DEVICE_STATUS_OFFLINE}} + {next_state, ?STATE_DENIED, State#state{status = ?DEVICE_STATUS_ONLINE}} end; handle_event(info, {timeout, _, reload_ticker}, _, State) ->