Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Dgiot
Commits
9fcc72cc
Commit
9fcc72cc
authored
3 years ago
by
AvantLiu
Browse files
Options
Download
Email Patches
Plain Diff
fix: channel log,install.sh
parent
fbaf6288
master
4.3.7
dawnwinterLiu
dependabot/maven/apps/dgiot_dlink/priv/example/java/com.google.protobuf-protobuf-java-3.19.6
guo
h7ml
lsxredrain
restyled/master
wanguliux
yanliubao
yuhang
v4.7.0
v4.6.3
v4.6.2
v4.6.1
v4.6.0
v4.5.9
v4.5.8
v4.5.7
v4.5.6
v4.5.5
v4.5.4
v4.5.3
v4.5.1
v4.4.9
v4.4.8
v4.4.7
v4.4.6
v4.4.5
v4.4.4
v4.4.3
v4.4.2
v4.4.1
v4.4.0
v4.3.9
v4.3.8
v4.3.7
v4.3.6
v4.3.5
v4.3.4
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
apps/dgiot_bridge/src/dgiot_bridge.erl
+3
-3
apps/dgiot_bridge/src/dgiot_bridge.erl
apps/dgiot_modbus/src/dgiot_modbus_tcp.erl
+7
-6
apps/dgiot_modbus/src/dgiot_modbus_tcp.erl
dgiot_install.sh
+3
-3
dgiot_install.sh
with
13 additions
and
12 deletions
+13
-12
apps/dgiot_bridge/src/dgiot_bridge.erl
+
3
-
3
View file @
9fcc72cc
...
...
@@ -154,7 +154,7 @@ send_log(ChannelId, ProductId, Fmt, Args) ->
send_log
(
ChannelId
,
Fmt
,
Args
)
->
is_send_log
(
ChannelId
,
undefined
,
undefined
,
fun
()
->
Topic
=
<<
"log/channel/"
,
ChannelId
/
binary
>>
,
Topic
=
<<
"log/channel/"
,
ChannelId
/
binary
,
"/channelid"
>>
,
Payload
=
io_lib
:
format
(
"[
~s
]
~p
"
++
Fmt
,
[
node
(),
self
()
|
Args
]),
dgiot_mqtt
:
publish
(
ChannelId
,
Topic
,
unicode
:
characters_to_binary
(
Payload
))
end
).
...
...
@@ -230,7 +230,7 @@ register_all_channel() ->
Mod
=
maps
:
get
(
mod
,
Channel_type
),
CType
=
maps
:
get
(
cType
,
Channel_type
),
register_channel
(
CType
,
Mod
)
end
,
list
()).
end
,
list
()).
get_all_channel
()
->
lists
:
foldl
(
fun
({_,
Channel_type
},
Acc
)
->
...
...
@@ -302,7 +302,7 @@ list() ->
case
[
Channel
||
{
channel_type
,
[
Channel
]}
<-
Mod
:
module_info
(
attributes
)]
of
[]
->
Acc
;
[
Channel
|
_]
->
[
Channel
|
_]
->
[{
maps
:
get
(
priority
,
Channel
,
255
),
Channel
#
{
app
=>
App
,
mod
=>
Mod
,
vsn
=>
Vsn
}}]
++
Acc
end
end
...
...
This diff is collapsed.
Click to expand it.
apps/dgiot_modbus/src/dgiot_modbus_tcp.erl
+
7
-
6
View file @
9fcc72cc
...
...
@@ -50,7 +50,7 @@ init(#tcp{state = #state{id = ChannelId}} = TCPState) ->
%% 9C A5 25 CD 00 DB
%% 11 04 02 06 92 FA FE
handle_info
({
tcp
,
Buff
},
#tcp
{
socket
=
Socket
,
state
=
#state
{
id
=
ChannelId
,
devaddr
=
<<>>
,
head
=
Head
,
len
=
Len
,
product
=
ProductId
,
dtutype
=
Dtutype
}
=
State
}
=
TCPState
)
->
dgiot_bridge
:
send_log
(
ChannelId
,
"DTU revice from
~p
"
,
[
dgiot_utils
:
binary_to_hex
(
Buff
)]),
dgiot_bridge
:
send_log
(
ChannelId
,
ProductId
,
"DTU revice from
~p
"
,
[
dgiot_utils
:
binary_to_hex
(
Buff
)]),
DTUIP
=
dgiot_utils
:
get_ip
(
Socket
),
DtuAddr
=
dgiot_utils
:
binary_to_hex
(
Buff
),
List
=
dgiot_utils
:
to_list
(
DtuAddr
),
...
...
@@ -83,7 +83,7 @@ handle_info({tcp, Buff}, #tcp{socket = Socket, state = #state{id = ChannelId, de
end
;
handle_info
({
tcp
,
Buff
},
#tcp
{
state
=
#state
{
id
=
ChannelId
,
devaddr
=
DtuAddr
,
env
=
#
{
product
:
=
ProductId
,
pn
:
=
Pn
,
di
:
=
Di
},
product
=
DtuProductId
}
=
State
}
=
TCPState
)
->
dgiot_bridge
:
send_log
(
ChannelId
,
"revice from
~p
"
,
[
dgiot_utils
:
binary_to_hex
(
Buff
)]),
dgiot_bridge
:
send_log
(
ChannelId
,
ProductId
,
DtuAddr
,
"revice from
~p
"
,
[
dgiot_utils
:
binary_to_hex
(
Buff
)]),
<<
H
:
8
,
L
:
8
>>
=
dgiot_utils
:
hex_to_binary
(
modbus_rtu
:
is16
(
Di
)),
<<
Sh
:
8
,
Sl
:
8
>>
=
dgiot_utils
:
hex_to_binary
(
modbus_rtu
:
is16
(
Pn
)),
case
modbus_rtu
:
parse_frame
(
Buff
,
[],
#
{
...
...
@@ -95,7 +95,7 @@ handle_info({tcp, Buff}, #tcp{state = #state{id = ChannelId, devaddr = DtuAddr,
{_,
Things
}
->
?
LOG
(
info
,
"Things
~p
"
,
[
Things
]),
NewTopic
=
<<
"thing/"
,
DtuProductId
/
binary
,
"/"
,
DtuAddr
/
binary
,
"/post"
>>
,
dgiot_bridge
:
send_log
(
ChannelId
,
"end to_task:
~p
:
~p
~n
"
,
[
NewTopic
,
jsx
:
encode
(
Things
)]),
dgiot_bridge
:
send_log
(
ChannelId
,
ProductId
,
DtuAddr
,
"end to_task:
~p
:
~p
~n
"
,
[
NewTopic
,
jsx
:
encode
(
Things
)]),
DeviceId
=
dgiot_parse
:
get_deviceid
(
ProductId
,
DtuAddr
),
dgiot_mqtt
:
publish
(
DeviceId
,
NewTopic
,
jsx
:
encode
(
Things
));
Other
->
...
...
@@ -122,7 +122,7 @@ handle_info({deliver, _, Msg}, #tcp{state = #state{id = ChannelId} = State} = TC
pass
end
,
{
noreply
,
TCPState
};
[
<<
"thing"
>>
,
_
ProductId
,
_
DevAddr
]
->
[
<<
"thing"
>>
,
_
ProductId
,
DevAddr
]
->
[
#
{
<<
"thingdata"
>>
:
=
ThingData
}
|
_]
=
jsx
:
decode
(
Payload
,
[{
labels
,
binary
},
return_maps
]),
?
LOG
(
error
,
"ThingData
~p
"
,
[
ThingData
]),
case
ThingData
of
...
...
@@ -140,7 +140,7 @@ handle_info({deliver, _, Msg}, #tcp{state = #state{id = ChannelId} = State} = TC
<<
"di"
>>
=>
Di
}),
?
LOG
(
error
,
"Datas
~p
"
,
[
Datas
]),
lists
:
map
(
fun
(
X
)
->
dgiot_bridge
:
send_log
(
ChannelId
,
"to_device:
~p
"
,
[
dgiot_utils
:
binary_to_hex
(
X
)]),
dgiot_bridge
:
send_log
(
ChannelId
,
ProductId
,
DevAddr
,
"to_device:
~p
"
,
[
dgiot_utils
:
binary_to_hex
(
X
)]),
dgiot_tcp_server
:
send
(
TCPState
,
X
),
timer
:
sleep
(
1000
)
end
,
Datas
),
...
...
@@ -159,7 +159,7 @@ handle_info({deliver, _, Msg}, #tcp{state = #state{id = ChannelId} = State} = TC
<<
"di"
>>
=>
Di
}),
%% ?LOG(error, "Datas ~p", [Datas]),
lists
:
map
(
fun
(
X
)
->
dgiot_bridge
:
send_log
(
ChannelId
,
"to_device:
~p
"
,
[
dgiot_utils
:
binary_to_hex
(
X
)]),
dgiot_bridge
:
send_log
(
ChannelId
,
ProductId
,
DevAddr
,
"to_device:
~p
"
,
[
dgiot_utils
:
binary_to_hex
(
X
)]),
dgiot_tcp_server
:
send
(
TCPState
,
X
),
timer
:
sleep
(
1000
)
end
,
Datas
),
...
...
@@ -180,6 +180,7 @@ handle_info({deliver, _, Msg}, #tcp{state = #state{id = ChannelId} = State} = TC
#
{
<<
"_dgiotprotocol"
>>
:
=
<<
"modbus"
>>
}
->
Payloads
=
modbus_rtu
:
set_params
(
maps
:
without
([
<<
"_dgiotprotocol"
>>
],
Payload
),
ProductId
,
DevAddr
),
lists
:
map
(
fun
(
X
)
->
dgiot_bridge
:
send_log
(
ChannelId
,
ProductId
,
DevAddr
,
"to_device:
~p
"
,
[
dgiot_utils
:
binary_to_hex
(
X
)]),
dgiot_tcp_server
:
send
(
TCPState
,
X
)
end
,
Payloads
);
_
->
...
...
This diff is collapsed.
Click to expand it.
dgiot_install.sh
+
3
-
3
View file @
9fcc72cc
...
...
@@ -104,12 +104,12 @@ else
fi
# ============================= get input parameters =================================================
# dgiot_install.sh -v [single | cluster] -d [prod.iotn2n.com | your_domain_name] -s [dgiot_
36
| dgiot_n]
# dgiot_install.sh -v [single | cluster] -d [prod.iotn2n.com | your_domain_name] -s [dgiot_
44
| dgiot_n]
# set parameters by default value
verType
=
single
# [single | cluster]
domain_name
=
"prod.iotn2n.com"
#[prod.iotn2n.com | your_domain_name]
dgiot
=
"dgiot_
36
"
#[dgiot_
36
| dgiot_n]
dgiot
=
"dgiot_
44
"
#[dgiot_
44
| dgiot_n]
while
getopts
"h:v:d:s:"
arg
do
case
$arg
in
...
...
@@ -131,7 +131,7 @@ do
domain_name
=
$(
echo
$OPTARG
)
;;
h
)
echo
"Usage:
`
basename
$0
`
-v [single | cluster] -s [dgiot_
36
| dgiot_n] -d [prod.iotn2n.com | your_domain_name]"
echo
"Usage:
`
basename
$0
`
-v [single | cluster] -s [dgiot_
44
| dgiot_n] -d [prod.iotn2n.com | your_domain_name]"
exit
0
;;
?
)
#unknow option
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help