Skip to content

Commit

Permalink
feat: apps/dgiot_gb26875:Urban fire remote monitoring system gb26875 …
Browse files Browse the repository at this point in the history
…protocol analysis channel
  • Loading branch information
AvantLiu committed Sep 18, 2021
1 parent d285393 commit c38b9b9
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 25 deletions.
23 changes: 5 additions & 18 deletions apps/dgiot_gb26875/priv/swagger/baowen.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,10 @@
[

16#40, 16#40,
<<16#00, 16#00,
16#01, 16#01,
16#18, 16#0d, 16#11, 16#16, 16#0a, 16#14,
16#00, 16#00, 16#00, 16#00, 16#00, 16#00,
16#06, 16#05, 16#04, 16#03, 16#02, 16#01,
16#30, 16#00,
16#02,
16#02, 16#01, 16#01, 16#03, 16#00, 16#d9, 16#00, 16#06, 16#00, 16#02,
16#00, 16#a3, 16#c1, 16#c7, 16#f8, 16#a3, 16#b1, 16#b2, 16#e3, 16#df,
16#c8, 16#b2, 16#b8, 16#d7, 16#df, 16#c0, 16#c8, 16#00, 16#00, 16#00,
16#00, 16#00, 16#00, 16#00, 16#00, 16#00, 16#00, 16#00, 16#00, 16#00,
16#00, 16#00, 16#30, 16#12, 16#13, 16#01, 16#08, 16#14>>
16#68, 16#23, 16#23
[404000000101180d11160a140000000000000605040302013000020201010300d90006000200a3c1c7f8a3b1b2e3dfc8b2b8d7dfc0c8000000000000000000000000000000301213010814682323


]

<<64,64,0,0,1,1,24,13,17,22,10,20,0,0,0,0,0,0,6,5,4,3,2,1,48,0,2,2,1,1,3,0,217,0,6,0,2,0,163,193,199,248,163,177,178,227,223,200,178,184,215,223,192,200,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,48,18,19,1,8,20,212,36,35,35>>

<<64,64,0,0,1,1,24,13,17,22,10,20,0,0,0,0,0,0,6,5,4,3,2,1,48,0,2,2,1,1,3,0,217,0,6,0,2,0,163,193,199,248,163,177,178,227,223,200,178,184,215,223,192,200,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,48,18,19,1,8,20,104,35,35>>
C = <<646400112413172210200000006543214802211302170602016319319924816317717822722320017818421522319220000000000000000048181918201043535>>


<<"404000000101180d11160a140000000000000605040302013000020201010300d90006000200a3c1c7f8a3b1b2e3dfc8b2b8d7dfc0c8000000000000000000000000000000301213010814682323">>
65 changes: 63 additions & 2 deletions apps/dgiot_gb26875/priv/swagger/swagger_gb26875.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,72 @@
{
"definitions": {},
"paths": {
"/decoder": {
"get": {
"security": [],
"summary": "解码",
"description": "解码",
"parameters": [
{
"name": "buff",
"in": "query",
"required": true,
"description": "状态报文",
"type": "string",
"default": "404000000101180d11160a140000000000000605040302013000020201010300d90006000200a3c1c7f8a3b1b2e3dfc8b2b8d7dfc0c8000000000000000000000000000000301213010814682323"
}
],
"responses": {
"200": {
"description": ""
},
"404": {
"description": ""
}
},
"summary": "解码",
"tags": [
"gb26875"
]
}
},
"/encoder": {
"post": {
"basePath": "/",
"security": [],
"summary": "编码",
"description": "编码",
"parameters": [
{
"in": "body",
"name": "data",
"required": true,
"schema": {
"type": "object",
"properties": {}
}
}
],
"responses": {
"200": {
"description": ""
},
"404": {
"description": ""
}
},
"summary": "解码",
"tags": [
"gb26875"
]
}
}

},
"tags": [
{
"description": "dgiot_gb26875",
"name": "dgiot_gb26875"
"description": "gb26875",
"name": "gb26875"
}
]
}
16 changes: 16 additions & 0 deletions apps/dgiot_gb26875/src/handler/dgiot_gb26875_handler.erl
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,22 @@ handle(OperationID, Args, Context, Req) ->
%%%===================================================================


%% System 概要: 获取设备信息 描述:解码建筑消防设施部件状态
%% OperationId:get_decoder
%% 请求:POST /iotapi/get_decoder
do_request(get_decoder, #{<<"buff">> := Buff}, _Context, _Req) ->
dgiot_gb26875_decoder:parse_frame(dgiot_utils:hex_to_binary(Buff), #{});


%% System 概要: 获取设备信息 描述:编码建筑消防设施部件状态
%% OperationId:get_encoder
%% 请求:POST /iotapi/get_encoder
do_request(post_encoder, Body, _Context, _Req) ->
io:format("Body ~p~n", [Body]),
R = dgiot_gb26875_decoder:to_frame(Body),
{ok, R};


%% PumpTemplet 概要: 新增报告模板 描述:新增报告模板
%% OperationId:post_pump_templet
%% 请求:get /iotapi/pump/templet
Expand Down
7 changes: 4 additions & 3 deletions apps/dgiot_gb26875/src/protocol/dgiot_gb26875_decoder.erl
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ parse_frame(<<"@@", Header:22/binary, Length:16/little-integer, Tail/binary>> =
<<"target">> => dgiot_utils:binary_to_hex(reverse(Destination))
},
<<"action">> => Action,
<<"appdata">> => Appdata
<<"appdata">> => dgiot_utils:binary_to_hex(Appdata)
}, decoder_appdata(dgiot_utils:to_int(dgiot_utils:binary_to_hex(Type)), dgiot_utils:to_int(dgiot_utils:binary_to_hex(Len)), Bodys)), Rest};
false ->
{Acc, <<>>}
Expand Down Expand Up @@ -128,7 +128,7 @@ decoder_appdata(?TYPE_UP_RUNNING_STATUS, {<<Type:8, Addr:8, Type2:8, Addr2:4/bin
<<"addr">> => dgiot_utils:binary_to_hex(reverse(Addr2))
},
<<"flag">> => dgiot_utils:binary_to_hex(reverse(Flag)),
<<"description">> => Description
<<"description">> => dgiot_utils:binary_to_hex(Description)
}, Timestamp);

%%decoder_appdata(?TYPE_UP_ANALOG_QUANTITY, Len, Body) ->
Expand Down Expand Up @@ -288,7 +288,8 @@ encoder_infodata(#{<<"runningstatus">> := Bodys}) ->
Time = set_time(Body),
ReverseAddr2 = reverse(dgiot_utils:hex_to_binary(Addr2)),
ReverseFlag = reverse(dgiot_utils:hex_to_binary(Flag)),
{<<Acc/binary, Type:8, Addr:8, Type2:8, ReverseAddr2/binary, ReverseFlag/binary, Description/binary, Time/binary>>, Time}
HexDescription = dgiot_utils:hex_to_binary(Description),
{<<Acc/binary, Type:8, Addr:8, Type2:8, ReverseAddr2/binary, ReverseFlag/binary, HexDescription/binary, Time/binary>>, Time}
end, {<<>>, <<>>}, Bodys),
{<<"runningstatus">>, Infodata, Time1};

Expand Down
3 changes: 2 additions & 1 deletion apps/dgiot_http/src/wechat/dgiot_wechat.erl
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ get_sns(Jscode) ->
#{<<"openid">> := OPENID, <<"session_key">> := _SESSIONKEY} ->
?LOG(info, "~p ~p", [OPENID, _SESSIONKEY]),
case dgiot_parse:query_object(<<"_User">>, #{<<"where">> => #{<<"tag.wechat.openid">> => OPENID}}) of
{ok, #{<<"results">> := [#{<<"objectId">> := UserId, <<"username">> := Name} | _]}} ->
{ok, #{<<"results">> := Results}} when length(Results) > 0 ->
[#{<<"objectId">> := UserId, <<"username">> := Name} | _] = Results,
{ok, UserInfo} = dgiot_parse_handler:create_session(UserId, dgiot_auth:ttl(), Name),
{ok, UserInfo#{<<"openid">> => OPENID, <<"status">> => <<"bind">>}};
_ ->
Expand Down
2 changes: 1 addition & 1 deletion apps/dgiot_tdengine/src/dgiot_tdengine_channel.erl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
%% 注册通道类型
-channel_type(#{
cType => ?TYPE,
type => ?BACKEND_CHL,
type => ?BRIDGE_CHL,
title => #{
zh => <<"TD资源通道"/utf8>>
},
Expand Down
1 change: 1 addition & 0 deletions data/loaded_plugins.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@
{dgiot_group, {{enable_plugin_dgiot_group}}}.
{dgiot_shouyincheng, {{enable_plugin_dgiot_shouyincheng}}}.
{dgiot_gb26875, {{enable_plugin_dgiot_gb26875}}}.
{dgiot_xinchuangwei, {{enable_plugin_dgiot_xinchuangwei}}}.
2 changes: 2 additions & 0 deletions rebar.config.erl
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ overlay_vars_rel(RelType) ->
, {enable_plugin_dgiot_ffmpeg, true}
, {enable_plugin_dgiot_shouyincheng, true}
, {enable_plugin_dgiot_gb26875, true}
, {enable_plugin_dgiot_xinchuangwei, true}
, {vm_args_file, VmArgs}
].

Expand Down Expand Up @@ -351,6 +352,7 @@ relx_plugin_apps_per_rel(cloud) ->
, dgiot_ffmpeg
, dgiot_shouyincheng
, dgiot_gb26875
, dgiot_xinchuangwei
];
relx_plugin_apps_per_rel(edge) ->
[].
Expand Down

0 comments on commit c38b9b9

Please sign in to comment.