fix
This commit is contained in:
parent
d0c38854e4
commit
a4b056faf0
@ -45,24 +45,6 @@ handle_request("POST", "/device/delete", _, #{<<"host_id">> := HostId, <<"device
|
||||
{ok, 200, iot_util:json_data(<<"success">>)}
|
||||
end;
|
||||
|
||||
%% 处理主机的授权的激活
|
||||
handle_request("POST", "/device/activate", _, #{<<"host_id">> := HostId, <<"device_uuid">> := DeviceUUID, <<"auth">> := Auth})
|
||||
when is_integer(HostId), is_binary(DeviceUUID), is_boolean(Auth) ->
|
||||
|
||||
AliasName = iot_host:get_alias_name(HostId),
|
||||
case global:whereis_name(AliasName) of
|
||||
undefined ->
|
||||
{ok, 200, iot_util:json_error(404, <<"activate device failed">>)};
|
||||
HostPid when is_pid(HostPid) ->
|
||||
case iot_host:activate_device(HostPid, DeviceUUID, Auth) of
|
||||
ok ->
|
||||
{ok, 200, iot_util:json_data(<<"success">>)};
|
||||
{error, Reason} ->
|
||||
lager:debug("[device_handler] activate device: ~p, get error: ~p", [DeviceUUID, Reason]),
|
||||
{ok, 200, iot_util:json_error(404, <<"activate device failed">>)}
|
||||
end
|
||||
end;
|
||||
|
||||
handle_request(_, Path, _, _) ->
|
||||
Path1 = list_to_binary(Path),
|
||||
{ok, 200, iot_util:json_error(-1, <<"url: ", Path1/binary, " not found">>)}.
|
||||
Loading…
x
Reference in New Issue
Block a user