From efdf503103283922c672773fb9876fa78bca745d Mon Sep 17 00:00:00 2001 From: anlicheng <244108715@qq.com> Date: Tue, 7 Jan 2025 21:54:44 +0800 Subject: [PATCH] fix iot_build --- apps/iot/src/iot_build.erl | 8 ++++---- apps/iot/src/iot_device.erl | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/iot/src/iot_build.erl b/apps/iot/src/iot_build.erl index 5c1c157..dc75635 100644 --- a/apps/iot/src/iot_build.erl +++ b/apps/iot/src/iot_build.erl @@ -18,7 +18,7 @@ %% API -export([get_name/1, get_pid/1]). -export([start_link/2]). --export([handle_data/3]). +-export([handle_data/4]). %% gen_server callbacks -export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]). @@ -42,9 +42,9 @@ get_pid(BuildLocationCode) when is_binary(BuildLocationCode) -> get_name(BuildLocationCode) when is_binary(BuildLocationCode) -> binary_to_atom(<<"iot_build:", BuildLocationCode/binary>>). --spec handle_data(Pid :: pid(), Fields :: list(), Timestamp :: integer()) -> no_return(). -handle_data(Pid, Fields, Timestamp) when is_pid(Pid), is_list(Fields), is_integer(Timestamp) -> - gen_server:cast(Pid, {handle_data, Fields, Timestamp}). +-spec handle_data(Pid :: pid(), DeviceUUID :: binary(), Fields :: list(), Timestamp :: integer()) -> no_return(). +handle_data(Pid, DeviceUUID, Fields, Timestamp) when is_pid(Pid), is_list(Fields), is_integer(Timestamp) -> + gen_server:cast(Pid, {handle_data, DeviceUUID, Fields, Timestamp}). %% @doc Spawns the server and registers the local name (unique) -spec(start_link(Name :: atom(), BuildLocationCode :: binary()) -> diff --git a/apps/iot/src/iot_device.erl b/apps/iot/src/iot_device.erl index e736c86..3e79b7d 100644 --- a/apps/iot/src/iot_device.erl +++ b/apps/iot/src/iot_device.erl @@ -295,7 +295,7 @@ handle_cast({handle_data, Fields, Timestamp}, State = #state{device_uuid = Devic NLocationCode = extract_build_location_code(LocationCode), lager:debug("[iot_device] light device: ~p, build location_code: ~p", [DeviceUUID, NLocationCode]), {ok, BuildPid} = iot_build_sup:ensured_build_started(NLocationCode), - iot_build:handle_data(BuildPid, Fields, Timestamp); + iot_build:handle_data(BuildPid, DeviceUUID, Fields, Timestamp); false -> ok %iot_zd_endpoint:forward(LocationCode, DynamicLocationCode, Fields, Timestamp)