fix iot_build

This commit is contained in:
anlicheng 2025-01-07 21:54:44 +08:00
parent a4125f3093
commit efdf503103
2 changed files with 5 additions and 5 deletions

View File

@ -18,7 +18,7 @@
%% API %% API
-export([get_name/1, get_pid/1]). -export([get_name/1, get_pid/1]).
-export([start_link/2]). -export([start_link/2]).
-export([handle_data/3]). -export([handle_data/4]).
%% gen_server callbacks %% gen_server callbacks
-export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]). -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) -> get_name(BuildLocationCode) when is_binary(BuildLocationCode) ->
binary_to_atom(<<"iot_build:", BuildLocationCode/binary>>). binary_to_atom(<<"iot_build:", BuildLocationCode/binary>>).
-spec handle_data(Pid :: pid(), Fields :: list(), Timestamp :: integer()) -> no_return(). -spec handle_data(Pid :: pid(), DeviceUUID :: binary(), Fields :: list(), Timestamp :: integer()) -> no_return().
handle_data(Pid, Fields, Timestamp) when is_pid(Pid), is_list(Fields), is_integer(Timestamp) -> handle_data(Pid, DeviceUUID, Fields, Timestamp) when is_pid(Pid), is_list(Fields), is_integer(Timestamp) ->
gen_server:cast(Pid, {handle_data, Fields, Timestamp}). gen_server:cast(Pid, {handle_data, DeviceUUID, Fields, Timestamp}).
%% @doc Spawns the server and registers the local name (unique) %% @doc Spawns the server and registers the local name (unique)
-spec(start_link(Name :: atom(), BuildLocationCode :: binary()) -> -spec(start_link(Name :: atom(), BuildLocationCode :: binary()) ->

View File

@ -295,7 +295,7 @@ handle_cast({handle_data, Fields, Timestamp}, State = #state{device_uuid = Devic
NLocationCode = extract_build_location_code(LocationCode), NLocationCode = extract_build_location_code(LocationCode),
lager:debug("[iot_device] light device: ~p, build location_code: ~p", [DeviceUUID, NLocationCode]), lager:debug("[iot_device] light device: ~p, build location_code: ~p", [DeviceUUID, NLocationCode]),
{ok, BuildPid} = iot_build_sup:ensured_build_started(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 -> false ->
ok ok
%iot_zd_endpoint:forward(LocationCode, DynamicLocationCode, Fields, Timestamp) %iot_zd_endpoint:forward(LocationCode, DynamicLocationCode, Fields, Timestamp)