From b7b25aa41fa7ec359f49542e3e62b0bdd94903da Mon Sep 17 00:00:00 2001 From: anlicheng Date: Thu, 17 Aug 2023 15:35:11 +0800 Subject: [PATCH] fix device --- apps/iot/src/http_handler/device_handler.erl | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/iot/src/http_handler/device_handler.erl b/apps/iot/src/http_handler/device_handler.erl index 227cfee..3c4308c 100644 --- a/apps/iot/src/http_handler/device_handler.erl +++ b/apps/iot/src/http_handler/device_handler.erl @@ -18,7 +18,7 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% 重新加载对应的主机信息 -handle_request("POST", "/device/reload", _, #{<<"host_id">> := HostId, <<"device_uuid">> := DeviceUUID}) when is_binary(DeviceUUID) -> +handle_request("POST", "/device/reload", _, #{<<"host_id">> := HostId, <<"device_uuid">> := DeviceUUID}) when is_integer(HostId), is_binary(DeviceUUID) -> lager:debug("[device_handler] host_id: ~p, will reload device uuid: ~p", [HostId, DeviceUUID]), AliasName = iot_host:get_alias_name(HostId), case global:whereis_name(AliasName) of @@ -35,7 +35,7 @@ handle_request("POST", "/device/reload", _, #{<<"host_id">> := HostId, <<"device end; %% 删除对应的主机信息 -handle_request("POST", "/device/delete", _, #{<<"host_id">> := HostId, <<"device_uuid">> := DeviceUUID}) when is_binary(DeviceUUID) -> +handle_request("POST", "/device/delete", _, #{<<"host_id">> := HostId, <<"device_uuid">> := DeviceUUID}) when is_integer(HostId), is_binary(DeviceUUID) -> AliasName = iot_host:get_alias_name(HostId), case global:whereis_name(AliasName) of undefined -> @@ -46,7 +46,9 @@ handle_request("POST", "/device/delete", _, #{<<"host_id">> := HostId, <<"device end; %% 处理主机的授权的激活 -handle_request("POST", "/device/activate", _, #{<<"host_id">> := HostId, <<"device_uuid">> := DeviceUUID, <<"auth">> := Auth}) when is_binary(DeviceUUID) -> +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 ->