diff --git a/apps/dgiot_gb26875/priv/swagger/baowen.json b/apps/dgiot_gb26875/priv/swagger/baowen.json index 8d195db51a..7ec86b59f2 100644 --- a/apps/dgiot_gb26875/priv/swagger/baowen.json +++ b/apps/dgiot_gb26875/priv/swagger/baowen.json @@ -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">> diff --git a/apps/dgiot_gb26875/priv/swagger/swagger_gb26875.json b/apps/dgiot_gb26875/priv/swagger/swagger_gb26875.json index dcc8839b6d..4e9a44eac1 100644 --- a/apps/dgiot_gb26875/priv/swagger/swagger_gb26875.json +++ b/apps/dgiot_gb26875/priv/swagger/swagger_gb26875.json @@ -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" } ] } diff --git a/apps/dgiot_gb26875/src/handler/dgiot_gb26875_handler.erl b/apps/dgiot_gb26875/src/handler/dgiot_gb26875_handler.erl index d52fe4adba..7b076dc953 100644 --- a/apps/dgiot_gb26875/src/handler/dgiot_gb26875_handler.erl +++ b/apps/dgiot_gb26875/src/handler/dgiot_gb26875_handler.erl @@ -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 diff --git a/apps/dgiot_gb26875/src/protocol/dgiot_gb26875_decoder.erl b/apps/dgiot_gb26875/src/protocol/dgiot_gb26875_decoder.erl index 04332b29ba..115ed4f025 100644 --- a/apps/dgiot_gb26875/src/protocol/dgiot_gb26875_decoder.erl +++ b/apps/dgiot_gb26875/src/protocol/dgiot_gb26875_decoder.erl @@ -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, <<>>} @@ -128,7 +128,7 @@ decoder_appdata(?TYPE_UP_RUNNING_STATUS, {<> => 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) -> @@ -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)), - {<>, Time} + HexDescription = dgiot_utils:hex_to_binary(Description), + {<>, Time} end, {<<>>, <<>>}, Bodys), {<<"runningstatus">>, Infodata, Time1}; diff --git a/apps/dgiot_http/src/wechat/dgiot_wechat.erl b/apps/dgiot_http/src/wechat/dgiot_wechat.erl index 3ccf3fae59..bccd95f9f7 100644 --- a/apps/dgiot_http/src/wechat/dgiot_wechat.erl +++ b/apps/dgiot_http/src/wechat/dgiot_wechat.erl @@ -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">>}}; _ -> diff --git a/apps/dgiot_tdengine/src/dgiot_tdengine_channel.erl b/apps/dgiot_tdengine/src/dgiot_tdengine_channel.erl index 0b9e1548ff..54e5252597 100644 --- a/apps/dgiot_tdengine/src/dgiot_tdengine_channel.erl +++ b/apps/dgiot_tdengine/src/dgiot_tdengine_channel.erl @@ -33,7 +33,7 @@ %% 注册通道类型 -channel_type(#{ cType => ?TYPE, - type => ?BACKEND_CHL, + type => ?BRIDGE_CHL, title => #{ zh => <<"TD资源通道"/utf8>> }, diff --git a/data/loaded_plugins.tmpl b/data/loaded_plugins.tmpl index bf58f4fb25..daa55e95cb 100644 --- a/data/loaded_plugins.tmpl +++ b/data/loaded_plugins.tmpl @@ -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}}}. diff --git a/rebar.config.erl b/rebar.config.erl index a0f091ddcd..4104e4e5a8 100644 --- a/rebar.config.erl +++ b/rebar.config.erl @@ -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} ]. @@ -351,6 +352,7 @@ relx_plugin_apps_per_rel(cloud) -> , dgiot_ffmpeg , dgiot_shouyincheng , dgiot_gb26875 + , dgiot_xinchuangwei ]; relx_plugin_apps_per_rel(edge) -> [].