This commit is contained in:
安礼成 2023-02-22 16:37:29 +08:00
parent 1ad849c058
commit e7ef3350f0
5 changed files with 11 additions and 7 deletions

View File

@ -3,6 +3,9 @@ iot
An OTP application An OTP application
## erlang client sdk
https://github.com/emqx/emqtt
Build Build
----- -----

View File

@ -83,7 +83,7 @@
%% %%
-record(host, { -record(host, {
%% ID %% ID
id :: binary(), host_id :: binary(),
%% %%
name :: binary(), name :: binary(),
%% %%
@ -104,7 +104,7 @@
%% %%
-record(terminal, { -record(terminal, {
%% ID %% ID
id :: binary(), terminal_id :: binary(),
%% %%
host_id :: binary(), host_id :: binary(),
%% %%
@ -132,7 +132,7 @@
%% %%
-record(microservice, { -record(microservice, {
%% ID, UUID生成 %% ID, UUID生成
id :: binary(), service_id :: binary(),
%% %%
host_id :: binary(), host_id :: binary(),
%% %%

View File

@ -11,14 +11,15 @@
-include("iot.hrl"). -include("iot.hrl").
%% API %% API
-export([]). -export([handle/2]).
handle(<<"server.register">>, Msg = #{<<"c_id">> := ClientId, <<"r">> := PubKey, 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}}) -> <<"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), Aes = iot_util:rand_bytes(16),
Host = #host{ Host = #host{
id = ClientId, host_id = ClientId,
aes = Aes, aes = Aes,
metric = #host_metric{ metric = #host_metric{
%% cpu相关 %% cpu相关

View File

@ -18,7 +18,7 @@ insert_hosts() ->
lists:foreach(fun(Id0) -> lists:foreach(fun(Id0) ->
%Id0 = iot_util:rand_bytes(16), %Id0 = iot_util:rand_bytes(16),
Host = #host{ Host = #host{
id = integer_to_binary(Id0), host_id = integer_to_binary(Id0),
name = <<"N1000_0001">>, name = <<"N1000_0001">>,
model = <<"N1000">>, model = <<"N1000">>,
cell_id = <<"公共教学楼"/utf8>> cell_id = <<"公共教学楼"/utf8>>

View File

@ -47,7 +47,7 @@ get_status_stat() ->
insert(Id, HostId, Name, ProductId, VendorId, Model, CellId) -> insert(Id, HostId, Name, ProductId, VendorId, Model, CellId) ->
Terminal = #terminal{ Terminal = #terminal{
id = Id, terminal_id = Id,
name = Name, name = Name,
product_id = ProductId, product_id = ProductId,
vendor_id = VendorId, vendor_id = VendorId,