diff --git a/README.md b/README.md index 9c6bf9c..22ca0a3 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,9 @@ iot An OTP application +## erlang client sdk + https://github.com/emqx/emqtt + Build ----- diff --git a/apps/iot/include/iot.hrl b/apps/iot/include/iot.hrl index d45b7fc..ff030c9 100644 --- a/apps/iot/include/iot.hrl +++ b/apps/iot/include/iot.hrl @@ -83,7 +83,7 @@ %% 主机定义 -record(host, { %% ID - id :: binary(), + host_id :: binary(), %% 名称 name :: binary(), %% 型号 @@ -104,7 +104,7 @@ %% 终端设备表 -record(terminal, { %% 设备ID - id :: binary(), + terminal_id :: binary(), %% 关联主机 host_id :: binary(), %% 名称 @@ -132,7 +132,7 @@ %% 微服务表 -record(microservice, { %% ID, 基于UUID生成 - id :: binary(), + service_id :: binary(), %% 关联主机 host_id :: binary(), %% 名称 diff --git a/apps/iot/src/iot_message_handler.erl b/apps/iot/src/iot_message_handler.erl index 35f50c4..233726a 100644 --- a/apps/iot/src/iot_message_handler.erl +++ b/apps/iot/src/iot_message_handler.erl @@ -11,14 +11,15 @@ -include("iot.hrl"). %% API --export([]). +-export([handle/2]). handle(<<"server.register">>, Msg = #{<<"c_id">> := ClientId, <<"r">> := PubKey, <<"m">> := #{<<"cpu_core">> := CpuCore, <<"memory">> := Memory, <<"disk">> := Disk, <<"boot_time">> := BootTime, <<"efka_version">> := EfkaVersion, <<"kernel_arch">> := KernelArch, <<"ipv4_1">> := Ip1, <<"ipv4_2">> := Ip2}}) -> + lager:debug("[iot_message_handler] get server register message: ~p", [Msg]), Aes = iot_util:rand_bytes(16), Host = #host{ - id = ClientId, + host_id = ClientId, aes = Aes, metric = #host_metric{ %% cpu相关 diff --git a/apps/iot/src/iot_mock.erl b/apps/iot/src/iot_mock.erl index 846b17c..d565590 100644 --- a/apps/iot/src/iot_mock.erl +++ b/apps/iot/src/iot_mock.erl @@ -18,7 +18,7 @@ insert_hosts() -> lists:foreach(fun(Id0) -> %Id0 = iot_util:rand_bytes(16), Host = #host{ - id = integer_to_binary(Id0), + host_id = integer_to_binary(Id0), name = <<"N1000_0001">>, model = <<"N1000">>, cell_id = <<"公共教学楼"/utf8>> diff --git a/apps/iot/src/model/terminal_model.erl b/apps/iot/src/model/terminal_model.erl index fdef7b5..8192fe4 100644 --- a/apps/iot/src/model/terminal_model.erl +++ b/apps/iot/src/model/terminal_model.erl @@ -47,7 +47,7 @@ get_status_stat() -> insert(Id, HostId, Name, ProductId, VendorId, Model, CellId) -> Terminal = #terminal{ - id = Id, + terminal_id = Id, name = Name, product_id = ProductId, vendor_id = VendorId,