fix
This commit is contained in:
parent
d4d1c06086
commit
7df30eaf75
@ -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) ->
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user