mirror of
https://gitee.com/dgiiot/dgiot.git
synced 2024-12-04 21:27:39 +08:00
api
This commit is contained in:
parent
58ebff879f
commit
351a6abf4c
115
apps/dgiot_dlink/priv/Dashboard.json
Normal file
115
apps/dgiot_dlink/priv/Dashboard.json
Normal file
@ -0,0 +1,115 @@
|
||||
{
|
||||
"dashboard": [
|
||||
{
|
||||
"dataType": "map",
|
||||
"vuekey": "baiduMap",
|
||||
"table": "baidu",
|
||||
"query": {
|
||||
"keys": [
|
||||
"count(*)"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"dataType": "card",
|
||||
"vuekey": "app_count",
|
||||
"table": "App",
|
||||
"query": {
|
||||
"limit": 1,
|
||||
"keys": [
|
||||
"count(*)"
|
||||
],
|
||||
"where": {}
|
||||
}
|
||||
},
|
||||
{
|
||||
"dataType": "card",
|
||||
"vuekey": "product_count",
|
||||
"table": "Product",
|
||||
"query": {
|
||||
"keys": [
|
||||
"count(*)"
|
||||
],
|
||||
"where": {}
|
||||
}
|
||||
},
|
||||
{
|
||||
"dataType": "card",
|
||||
"vuekey": "dev_online_count",
|
||||
"table": "Device",
|
||||
"query": {
|
||||
"order": "-updatedAt",
|
||||
"limit": 15,
|
||||
"keys": [
|
||||
"count(*)"
|
||||
],
|
||||
"where": {
|
||||
"status": "ONLINE"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"dataType": "card",
|
||||
"vuekey": "dev_off_count",
|
||||
"table": "Device",
|
||||
"query": {
|
||||
"limit": 15,
|
||||
"order": "-updatedAt",
|
||||
"keys": [
|
||||
"count(*)"
|
||||
],
|
||||
"where": {
|
||||
"status": "OFFLINE"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"dataType": "card",
|
||||
"vuekey": "project_count",
|
||||
"table": "Project",
|
||||
"query": {
|
||||
"limit": 1,
|
||||
"keys": [
|
||||
"count(*)"
|
||||
],
|
||||
"where": {}
|
||||
}
|
||||
},
|
||||
{
|
||||
"dataType": "card",
|
||||
"vuekey": "ChartStatus",
|
||||
"table": "ChartStatus",
|
||||
"query": {
|
||||
"limit": 1,
|
||||
"keys": [
|
||||
"count(*)"
|
||||
],
|
||||
"where": {}
|
||||
}
|
||||
},
|
||||
{
|
||||
"dataType": "card",
|
||||
"vuekey": "device_count",
|
||||
"table": "Device",
|
||||
"query": {
|
||||
"limit": 1,
|
||||
"keys": [
|
||||
"count(*)"
|
||||
],
|
||||
"where": {}
|
||||
}
|
||||
},
|
||||
{
|
||||
"dataType": "card",
|
||||
"vuekey": "warn_count",
|
||||
"table": "Notification",
|
||||
"query": {
|
||||
"limit": 1,
|
||||
"keys": [
|
||||
"count(*)"
|
||||
],
|
||||
"where": {}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
34
apps/dgiot_dlink/priv/Topic.json
Normal file
34
apps/dgiot_dlink/priv/Topic.json
Normal file
@ -0,0 +1,34 @@
|
||||
{
|
||||
"basic": [
|
||||
{
|
||||
"category": "OTA 升级",
|
||||
"desc": "设备属性上报",
|
||||
"isdef": true,
|
||||
"topic": "$dg/user/${deviceid}/post",
|
||||
"type": "sub"
|
||||
},
|
||||
{
|
||||
"category": "OTA 升级",
|
||||
"desc": "消息下发",
|
||||
"isdef": true,
|
||||
"topic": "$dg/thing/${deviceid}/",
|
||||
"type": "pub"
|
||||
}
|
||||
],
|
||||
"thing": [
|
||||
{
|
||||
"category": "属性上报",
|
||||
"desc": "设备属性上报",
|
||||
"isdef": true,
|
||||
"topic": "$dg/user/${deviceid}/post",
|
||||
"type": "sub'"
|
||||
},
|
||||
{
|
||||
"category": "属性上报",
|
||||
"desc": "消息下发",
|
||||
"isdef": true,
|
||||
"topic": "$dg/thing/${deviceid}/",
|
||||
"type": "pub"
|
||||
}
|
||||
]
|
||||
}
|
460
apps/dgiot_dlink/priv/Unit.json
Normal file
460
apps/dgiot_dlink/priv/Unit.json
Normal file
@ -0,0 +1,460 @@
|
||||
{
|
||||
"UnifyUnitSpecsDTO": [
|
||||
{
|
||||
"Symbol": "ml/min",
|
||||
"Name": "滴速"
|
||||
},
|
||||
{
|
||||
"Symbol": "mmHg",
|
||||
"Name": "血压"
|
||||
},
|
||||
{
|
||||
"Symbol": "mmol/L",
|
||||
"Name": "血糖"
|
||||
},
|
||||
{
|
||||
"Symbol": "mm/s",
|
||||
"Name": "毫米每秒"
|
||||
},
|
||||
{
|
||||
"Symbol": "turn/m",
|
||||
"Name": "转每分钟"
|
||||
},
|
||||
{
|
||||
"Symbol": "count",
|
||||
"Name": "次"
|
||||
},
|
||||
{
|
||||
"Symbol": "gear",
|
||||
"Name": "档"
|
||||
},
|
||||
{
|
||||
"Symbol": "stepCount",
|
||||
"Name": "步"
|
||||
},
|
||||
{
|
||||
"Symbol": "Nm3/h",
|
||||
"Name": "标准立方米每小时"
|
||||
},
|
||||
{
|
||||
"Symbol": "kV",
|
||||
"Name": "千伏"
|
||||
},
|
||||
{
|
||||
"Symbol": "kVA",
|
||||
"Name": "千伏安"
|
||||
},
|
||||
{
|
||||
"Symbol": "kVar",
|
||||
"Name": "千乏"
|
||||
},
|
||||
{
|
||||
"Symbol": "uw/cm2",
|
||||
"Name": "微瓦每平方厘米"
|
||||
},
|
||||
{
|
||||
"Symbol": "只",
|
||||
"Name": "只"
|
||||
},
|
||||
{
|
||||
"Symbol": "%RH",
|
||||
"Name": "相对湿度"
|
||||
},
|
||||
{
|
||||
"Symbol": "m³/s",
|
||||
"Name": "立方米每秒"
|
||||
},
|
||||
{
|
||||
"Symbol": "kg/s",
|
||||
"Name": "公斤每秒"
|
||||
},
|
||||
{
|
||||
"Symbol": "r/min",
|
||||
"Name": "转每分钟"
|
||||
},
|
||||
{
|
||||
"Symbol": "t/h",
|
||||
"Name": "吨每小时"
|
||||
},
|
||||
{
|
||||
"Symbol": "KCL/h",
|
||||
"Name": "千卡每小时"
|
||||
},
|
||||
{
|
||||
"Symbol": "L/s",
|
||||
"Name": "升每秒"
|
||||
},
|
||||
{
|
||||
"Symbol": "Mpa",
|
||||
"Name": "兆帕"
|
||||
},
|
||||
{
|
||||
"Symbol": "m³/h",
|
||||
"Name": "立方米每小时"
|
||||
},
|
||||
{
|
||||
"Symbol": "kvarh",
|
||||
"Name": "千乏时"
|
||||
},
|
||||
{
|
||||
"Symbol": "μg/L",
|
||||
"Name": "微克每升"
|
||||
},
|
||||
{
|
||||
"Symbol": "kcal",
|
||||
"Name": "千卡路里"
|
||||
},
|
||||
{
|
||||
"Symbol": "GB",
|
||||
"Name": "吉字节"
|
||||
},
|
||||
{
|
||||
"Symbol": "MB",
|
||||
"Name": "兆字节"
|
||||
},
|
||||
{
|
||||
"Symbol": "KB",
|
||||
"Name": "千字节"
|
||||
},
|
||||
{
|
||||
"Symbol": "B",
|
||||
"Name": "字节"
|
||||
},
|
||||
{
|
||||
"Symbol": "μg/(d㎡·d)",
|
||||
"Name": "微克每平方分米每天"
|
||||
},
|
||||
{
|
||||
"Symbol": "",
|
||||
"Name": "无"
|
||||
},
|
||||
{
|
||||
"Symbol": "ppm",
|
||||
"Name": "百万分率"
|
||||
},
|
||||
{
|
||||
"Symbol": "pixel",
|
||||
"Name": "像素"
|
||||
},
|
||||
{
|
||||
"Symbol": "Lux",
|
||||
"Name": "照度"
|
||||
},
|
||||
{
|
||||
"Symbol": "grav",
|
||||
"Name": "重力加速度"
|
||||
},
|
||||
{
|
||||
"Symbol": "dB",
|
||||
"Name": "分贝"
|
||||
},
|
||||
{
|
||||
"Symbol": "%",
|
||||
"Name": "百分比"
|
||||
},
|
||||
{
|
||||
"Symbol": "lm",
|
||||
"Name": "流明"
|
||||
},
|
||||
{
|
||||
"Symbol": "bit",
|
||||
"Name": "比特"
|
||||
},
|
||||
{
|
||||
"Symbol": "g/mL",
|
||||
"Name": "克每毫升"
|
||||
},
|
||||
{
|
||||
"Symbol": "g/L",
|
||||
"Name": "克每升"
|
||||
},
|
||||
{
|
||||
"Symbol": "mg/L",
|
||||
"Name": "毫克每升"
|
||||
},
|
||||
{
|
||||
"Symbol": "μg/m³",
|
||||
"Name": "微克每立方米"
|
||||
},
|
||||
{
|
||||
"Symbol": "mg/m³",
|
||||
"Name": "毫克每立方米"
|
||||
},
|
||||
{
|
||||
"Symbol": "g/m³",
|
||||
"Name": "克每立方米"
|
||||
},
|
||||
{
|
||||
"Symbol": "kg/m³",
|
||||
"Name": "千克每立方米"
|
||||
},
|
||||
{
|
||||
"Symbol": "nF",
|
||||
"Name": "纳法"
|
||||
},
|
||||
{
|
||||
"Symbol": "pF",
|
||||
"Name": "皮法"
|
||||
},
|
||||
{
|
||||
"Symbol": "μF",
|
||||
"Name": "微法"
|
||||
},
|
||||
{
|
||||
"Symbol": "F",
|
||||
"Name": "法拉"
|
||||
},
|
||||
{
|
||||
"Symbol": "Ω",
|
||||
"Name": "欧姆"
|
||||
},
|
||||
{
|
||||
"Symbol": "μA",
|
||||
"Name": "微安"
|
||||
},
|
||||
{
|
||||
"Symbol": "mA",
|
||||
"Name": "毫安"
|
||||
},
|
||||
{
|
||||
"Symbol": "kA",
|
||||
"Name": "千安"
|
||||
},
|
||||
{
|
||||
"Symbol": "A",
|
||||
"Name": "安培"
|
||||
},
|
||||
{
|
||||
"Symbol": "mV",
|
||||
"Name": "毫伏"
|
||||
},
|
||||
{
|
||||
"Symbol": "V",
|
||||
"Name": "伏特"
|
||||
},
|
||||
{
|
||||
"Symbol": "ms",
|
||||
"Name": "毫秒"
|
||||
},
|
||||
{
|
||||
"Symbol": "s",
|
||||
"Name": "秒"
|
||||
},
|
||||
{
|
||||
"Symbol": "min",
|
||||
"Name": "分钟"
|
||||
},
|
||||
{
|
||||
"Symbol": "h",
|
||||
"Name": "小时"
|
||||
},
|
||||
{
|
||||
"Symbol": "day",
|
||||
"Name": "日"
|
||||
},
|
||||
{
|
||||
"Symbol": "week",
|
||||
"Name": "周"
|
||||
},
|
||||
{
|
||||
"Symbol": "month",
|
||||
"Name": "月"
|
||||
},
|
||||
{
|
||||
"Symbol": "year",
|
||||
"Name": "年"
|
||||
},
|
||||
{
|
||||
"Symbol": "kn",
|
||||
"Name": "节"
|
||||
},
|
||||
{
|
||||
"Symbol": "km/h",
|
||||
"Name": "千米每小时"
|
||||
},
|
||||
{
|
||||
"Symbol": "m/s",
|
||||
"Name": "米每秒"
|
||||
},
|
||||
{
|
||||
"Symbol": "″",
|
||||
"Name": "秒"
|
||||
},
|
||||
{
|
||||
"Symbol": "′",
|
||||
"Name": "分"
|
||||
},
|
||||
{
|
||||
"Symbol": "°",
|
||||
"Name": "度"
|
||||
},
|
||||
{
|
||||
"Symbol": "rad",
|
||||
"Name": "弧度"
|
||||
},
|
||||
{
|
||||
"Symbol": "Hz",
|
||||
"Name": "赫兹"
|
||||
},
|
||||
{
|
||||
"Symbol": "μW",
|
||||
"Name": "微瓦"
|
||||
},
|
||||
{
|
||||
"Symbol": "mW",
|
||||
"Name": "毫瓦"
|
||||
},
|
||||
{
|
||||
"Symbol": "kW",
|
||||
"Name": "千瓦特"
|
||||
},
|
||||
{
|
||||
"Symbol": "W",
|
||||
"Name": "瓦特"
|
||||
},
|
||||
{
|
||||
"Symbol": "cal",
|
||||
"Name": "卡路里"
|
||||
},
|
||||
{
|
||||
"Symbol": "kW·h",
|
||||
"Name": "千瓦时"
|
||||
},
|
||||
{
|
||||
"Symbol": "Wh",
|
||||
"Name": "瓦时"
|
||||
},
|
||||
{
|
||||
"Symbol": "eV",
|
||||
"Name": "电子伏"
|
||||
},
|
||||
{
|
||||
"Symbol": "kJ",
|
||||
"Name": "千焦"
|
||||
},
|
||||
{
|
||||
"Symbol": "J",
|
||||
"Name": "焦耳"
|
||||
},
|
||||
{
|
||||
"Symbol": "℉",
|
||||
"Name": "华氏度"
|
||||
},
|
||||
{
|
||||
"Symbol": "K",
|
||||
"Name": "开尔文"
|
||||
},
|
||||
{
|
||||
"Symbol": "t",
|
||||
"Name": "吨"
|
||||
},
|
||||
{
|
||||
"Symbol": "°C",
|
||||
"Name": "摄氏度"
|
||||
},
|
||||
{
|
||||
"Symbol": "mPa",
|
||||
"Name": "毫帕"
|
||||
},
|
||||
{
|
||||
"Symbol": "hPa",
|
||||
"Name": "百帕"
|
||||
},
|
||||
{
|
||||
"Symbol": "kPa",
|
||||
"Name": "千帕"
|
||||
},
|
||||
{
|
||||
"Symbol": "Pa",
|
||||
"Name": "帕斯卡"
|
||||
},
|
||||
{
|
||||
"Symbol": "mg",
|
||||
"Name": "毫克"
|
||||
},
|
||||
{
|
||||
"Symbol": "g",
|
||||
"Name": "克"
|
||||
},
|
||||
{
|
||||
"Symbol": "kg",
|
||||
"Name": "千克"
|
||||
},
|
||||
{
|
||||
"Symbol": "N",
|
||||
"Name": "牛"
|
||||
},
|
||||
{
|
||||
"Symbol": "mL",
|
||||
"Name": "毫升"
|
||||
},
|
||||
{
|
||||
"Symbol": "L",
|
||||
"Name": "升"
|
||||
},
|
||||
{
|
||||
"Symbol": "mm³",
|
||||
"Name": "立方毫米"
|
||||
},
|
||||
{
|
||||
"Symbol": "cm³",
|
||||
"Name": "立方厘米"
|
||||
},
|
||||
{
|
||||
"Symbol": "km³",
|
||||
"Name": "立方千米"
|
||||
},
|
||||
{
|
||||
"Symbol": "m³",
|
||||
"Name": "立方米"
|
||||
},
|
||||
{
|
||||
"Symbol": "h㎡",
|
||||
"Name": "公顷"
|
||||
},
|
||||
{
|
||||
"Symbol": "c㎡",
|
||||
"Name": "平方厘米"
|
||||
},
|
||||
{
|
||||
"Symbol": "m㎡",
|
||||
"Name": "平方毫米"
|
||||
},
|
||||
{
|
||||
"Symbol": "k㎡",
|
||||
"Name": "平方千米"
|
||||
},
|
||||
{
|
||||
"Symbol": "㎡",
|
||||
"Name": "平方米"
|
||||
},
|
||||
{
|
||||
"Symbol": "nm",
|
||||
"Name": "纳米"
|
||||
},
|
||||
{
|
||||
"Symbol": "μm",
|
||||
"Name": "微米"
|
||||
},
|
||||
{
|
||||
"Symbol": "mm",
|
||||
"Name": "毫米"
|
||||
},
|
||||
{
|
||||
"Symbol": "cm",
|
||||
"Name": "厘米"
|
||||
},
|
||||
{
|
||||
"Symbol": "dm",
|
||||
"Name": "分米"
|
||||
},
|
||||
{
|
||||
"Symbol": "km",
|
||||
"Name": "千米"
|
||||
},
|
||||
{
|
||||
"Symbol": "m",
|
||||
"Name": "米"
|
||||
}
|
||||
]
|
||||
}
|
@ -10,7 +10,6 @@
|
||||
}
|
||||
],
|
||||
"definitions": {
|
||||
|
||||
},
|
||||
"paths": {
|
||||
"/protocol": {
|
||||
@ -41,12 +40,24 @@
|
||||
]
|
||||
}
|
||||
},
|
||||
"/topic": {
|
||||
"/dlinkjson": {
|
||||
"get": {
|
||||
"security": [],
|
||||
"summary": "获取topic列表",
|
||||
"description": "获取topic列表",
|
||||
"summary": "获取json信息",
|
||||
"description": "获取json信息",
|
||||
"parameters": [
|
||||
{
|
||||
"in": "query",
|
||||
"name": "type",
|
||||
"type": "string",
|
||||
"description": "Topic/Dashboard/Unit",
|
||||
"required": true,
|
||||
"enum": [
|
||||
"Topic",
|
||||
"Dashboard",
|
||||
"Unit"
|
||||
]
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
|
@ -64,7 +64,7 @@ stop(Server) ->
|
||||
_ = grpc:stop_server(Server).
|
||||
|
||||
login(ClinetId) ->
|
||||
SvrAddr = "http://127.0.0.1:30051",
|
||||
SvrAddr = "http://127.0.0.1:30051",
|
||||
{ok, _} = grpc_client_sup:create_channel_pool(ClinetId, SvrAddr, #{}).
|
||||
|
||||
logout(ClinetId) ->
|
||||
@ -74,24 +74,24 @@ send(ClinetId) ->
|
||||
dgiot_dlink_client:say_hello(#{name => <<"Xiao Ming">>}, #{channel => ClinetId}).
|
||||
|
||||
|
||||
test()->
|
||||
test() ->
|
||||
FileName = <<"dlink">>,
|
||||
Proto = <<"Ly8gY29weSBmcm9tOiBodHRwczovL2dycGMuaW8vZG9jcy93aGF0LWlzLWdycGMvaW50cm9kdWN0aW9uLwoKCnN5bnRheCA9ICJwcm90bzMiOwoKb3B0aW9uIGphdmFfbXVsdGlwbGVfZmlsZXMgPSB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TsKfQoKCm1lc3NhZ2UgSGVhbHRoQ2hlY2tSZXF1ZXN0IHsKICBzdHJpbmcgc2VydmljZSA9IDE7Cn0KCm1lc3NhZ2UgSGVhbHRoQ2hlY2tSZXNwb25zZSB7CiAgZW51bSBTZXJ2aW5nU3RhdHVzIHsKICAgIFVOS05PV04gPSAwOwogICAgU0VSVklORyA9IDE7CiAgICBOT1RfU0VSVklORyA9IDI7CiAgICBTRVJWSUNFX1VOS05PV04gPSAzOyAgLy8gVXNlZCBvbmx5IGJ5IHRoZSBXYXRjaCBtZXRob2QuCiAgfQogIFNlcnZpbmdTdGF0dXMgc3RhdHVzID0gMTsKfQ==">>,
|
||||
{file, Here} = code:is_loaded(?MODULE),
|
||||
ErlangDir = dgiot_httpc:url_join([filename:dirname(filename:dirname(Here)), "/priv/example/Erlang/"]),
|
||||
Dir = dgiot_httpc:url_join([filename:dirname(filename:dirname(Here)), "/priv/example/Erlang/priv/"]),
|
||||
Name = dgiot_utils:to_list(FileName),
|
||||
?LOG(info, "~p" , [Dir ++ Name ++ ".proto"]),
|
||||
?LOG(info, "~p" , [base64:decode(Proto)]),
|
||||
case file:open(Name, [raw, write, delayed_write, binary]) of
|
||||
{ok, Fd} ->
|
||||
Result = file:write_file(Dir ++ Name ++ ".proto",base64:decode(Proto)),
|
||||
?LOG(info, "~p", [Dir ++ Name ++ ".proto"]),
|
||||
?LOG(info, "~p", [base64:decode(Proto)]),
|
||||
case file:open(Name, [raw, write, delayed_write, binary]) of
|
||||
{ok, Fd} ->
|
||||
Result = file:write_file(Dir ++ Name ++ ".proto", base64:decode(Proto)),
|
||||
file:close(Fd),
|
||||
?LOG(info, "~p" , [Result]);
|
||||
?LOG(info, "~p", [Result]);
|
||||
_ -> pass
|
||||
end,
|
||||
Cmd = "cd " ++ ErlangDir ++ " && ./rebar3 compile",
|
||||
?LOG(info, "~p" , [Cmd]),
|
||||
?LOG(info, "~p", [Cmd]),
|
||||
os:cmd(Cmd),
|
||||
ok.
|
||||
|
||||
@ -142,38 +142,29 @@ list() ->
|
||||
end,
|
||||
lists:sort(dgiot_plugin:check_module(Fun, [])).
|
||||
|
||||
getTopic()->
|
||||
#{
|
||||
<<"basic">> => [
|
||||
#{
|
||||
<<"topic">> => <<"$dg/user/${deviceid}/post">>,
|
||||
<<"type">> => <<"sub">>,
|
||||
<<"desc">> => <<"设备属性上报"/utf8>>,
|
||||
<<"isdef">> => true,
|
||||
<<"category">> => <<"OTA 升级"/utf8>>
|
||||
},
|
||||
#{
|
||||
<<"topic">> => <<"$dg/thing/${deviceid}/">>,
|
||||
<<"type">> => <<"pub">>,
|
||||
<<"desc">> => <<"消息下发"/utf8>>,
|
||||
<<"isdef">> => true,
|
||||
<<"category">> => <<"OTA 升级"/utf8>>
|
||||
}
|
||||
],
|
||||
<<"thing">> => [
|
||||
#{
|
||||
<<"topic">> => <<"$dg/user/${deviceid}/post">>,
|
||||
<<"type">> => <<"sub'">>,
|
||||
<<"desc">> => <<"设备属性上报"/utf8>>,
|
||||
<<"isdef">> => true,
|
||||
<<"category">> => <<"属性上报"/utf8>>
|
||||
},
|
||||
#{
|
||||
<<"topic">> => <<"$dg/thing/${deviceid}/">>,
|
||||
<<"type">> => <<"pub">>,
|
||||
<<"desc">> => <<"消息下发"/utf8>>,
|
||||
<<"isdef">> => true,
|
||||
<<"category">> => <<"属性上报"/utf8>>
|
||||
}
|
||||
]
|
||||
}.
|
||||
read_include_file(Filename, IncludeSearchPath) ->
|
||||
case file:path_open(IncludeSearchPath, Filename, [read, raw, binary]) of
|
||||
{ok, IoDevice, FullName} ->
|
||||
{ok, Data} = file:read(IoDevice, filelib:file_size(FullName)),
|
||||
file:close(IoDevice),
|
||||
binary_to_list(Data);
|
||||
{error, Reason} ->
|
||||
throw({failed_to_read_include_file, Reason, Filename, IncludeSearchPath})
|
||||
end.
|
||||
|
||||
|
||||
%%
|
||||
%% @description: 读取json文件并返回
|
||||
%%
|
||||
getJson(FileName) ->
|
||||
{file, Here} = code:is_loaded(?MODULE),
|
||||
Dir = filename:dirname(filename:dirname(Here)),
|
||||
Path = dgiot_httpc:url_join([Dir, "/priv/", dgiot_utils:to_list(FileName)]),
|
||||
case catch file:read_file(Path) of
|
||||
{Err, Reason} when Err == 'EXIT'; Err == error ->
|
||||
?LOG(error, "read Path,~p error,~p ~n", [Path, Reason]),
|
||||
{error, Reason};
|
||||
{ok, Bin} ->
|
||||
Bin
|
||||
end.
|
||||
|
||||
|
@ -77,16 +77,12 @@ do_request(get_protocol, _Body, #{<<"sessionToken">> := _SessionToken} = _Contex
|
||||
Protocols = dgiot_dlink:get_all_protocol(),
|
||||
{200, Protocols};
|
||||
|
||||
%%%===================================================================
|
||||
%%% 内部函数 Version:API版本
|
||||
%%%===================================================================
|
||||
%% Proctol 概要: 获取Dlink topic列表
|
||||
%% OperationId:topic
|
||||
%% 请求:GET /iotapi/topic
|
||||
do_request(get_topic, _Body, _Context, _Req) ->
|
||||
Topics = dgiot_dlink:getTopic(),
|
||||
{200, Topics};
|
||||
|
||||
%% Proctol 概要: 获取Dlink json信息
|
||||
%% OperationId:dlinkjson
|
||||
%% 请求:GET /iotapi/dlinkjson
|
||||
do_request(get_dlinkjson, #{<<"type">> := Type}, _Context, _Req) ->
|
||||
DlinkJson = dgiot_dlink:getJson(<<Type/binary, ".json">>),
|
||||
{200, DlinkJson};
|
||||
|
||||
do_request(_OperationId, _Args, _Context, _Req) ->
|
||||
{error, <<"Not Allowed.">>}.
|
||||
|
Loading…
Reference in New Issue
Block a user