From 305084128089bf97acac84e866713255182c4f6a Mon Sep 17 00:00:00 2001 From: anlicheng <244108715@qq.com> Date: Tue, 29 Apr 2025 10:44:05 +0800 Subject: [PATCH] simple iot_device --- apps/iot/src/iot_device.erl | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-) diff --git a/apps/iot/src/iot_device.erl b/apps/iot/src/iot_device.erl index 2d5e6eb..c89f1fa 100644 --- a/apps/iot/src/iot_device.erl +++ b/apps/iot/src/iot_device.erl @@ -14,7 +14,7 @@ -behaviour(gen_server). %% API --export([get_name/1, get_pid/1, serialize/1]). +-export([get_name/1, get_pid/1]). -export([start_link/2, is_activated/1, is_alive/1, change_status/2, reload/1, auth/2]). -export([ai_event/3, handle_data/3]). @@ -50,28 +50,6 @@ %%% API %%%=================================================================== -%% 格式化efka上传的数据格式 -%"fields": [ -%{ -% "key": "test" -% "value": 124, -% "unit": "U", -% "type": "AI:遥测值,DI:遥信值,SOE:事件", -% "timestamp": int -%} -%], -%% 用来保存在内存中的格式,不需要序列话处理 !!!, 放入到influxdb的数据是基于base64的 --spec serialize(FieldsList :: [map()]) -> [{Key :: binary(), Values :: map()}]. -serialize(FieldsList) when is_list(FieldsList) -> - lists:flatmap(fun serialize0/1, FieldsList). -serialize0(Fields = #{<<"key">> := Key}) when is_binary(Key) andalso Key /= <<>> -> - Values = maps:remove(<<"key">>, Fields), - %S = base64:encode(iolist_to_binary(jiffy:encode(#{Key => Values}, [force_utf8]))), - %[<<"base64:", S/binary>>]; - [{Key, Values}]; -serialize0(_) -> - []. - -spec is_alive(DeviceUUID :: binary()) -> error | {ok, Pid :: pid()}. is_alive(DeviceUUID) when is_binary(DeviceUUID) -> case iot_device:get_pid(DeviceUUID) of