Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
vesta
rigado-devkit
Commits
3ea93e43
Commit
3ea93e43
authored
Oct 09, 2017
by
Donald Chen
Browse files
fix disconnectAll command
parent
d5d3a4b3
Changes
1
Hide whitespace changes
Inline
Side-by-side
noble-connect/node-red-noble-connect.js
View file @
3ea93e43
...
...
@@ -17,6 +17,7 @@ module.exports = function(RED) {
function
NobleConnectNode
(
config
)
{
RED
.
nodes
.
createNode
(
this
,
config
);
var
node
=
this
;
node
.
log
(
"
Created node
"
+
node
.
id
);
// Store local copies of the node configuration
...
...
@@ -75,26 +76,38 @@ module.exports = function(RED) {
node
.
log
(
"
create peripheral
"
+
p
.
uuid
);
node
.
peripherals
[
p
.
uuid
]
=
{};
}
node
.
peripherals
[
p
.
uuid
].
lastUpdated
=
new
Date
().
getTime
();
if
(
p
.
hasOwnProperty
(
"
once
"
))
node
.
peripherals
[
p
.
uuid
].
once
=
p
.
once
;
if
(
p
.
hasOwnProperty
(
"
rssi
"
))
node
.
peripherals
[
p
.
uuid
].
rssi
=
p
.
rssi
;
node
.
peripherals
[
p
.
uuid
].
peripheralObj
=
p
;
if
(
p
.
hasOwnProperty
(
"
rssi
"
))
{
node
.
peripherals
[
p
.
uuid
].
rssi
=
p
.
rssi
;
}
if
(
p
.
hasOwnProperty
(
"
advertisement
"
)
&&
p
.
advertisement
.
hasOwnProperty
(
"
localName
"
))
{
node
.
peripherals
[
p
.
uuid
].
name
=
p
.
advertisement
.
localName
;
}
if
(
p
.
hasOwnProperty
(
"
connected
"
))
node
.
peripherals
[
p
.
uuid
].
connected
=
p
.
connected
;
if
(
p
.
hasOwnProperty
(
"
connected
"
))
{
node
.
peripherals
[
p
.
uuid
].
connected
=
p
.
connected
;
}
}
function
disconnectAll
()
{
node
.
log
(
"
disconnect all
"
);
var
uuids
=
[];
for
(
var
i
=
0
;
i
<
Object
.
keys
(
node
.
peripherals
).
length
;
i
++
)
{
uuids
.
push
(
Object
.
keys
(
node
.
peripherals
)[
i
]);
}
for
(
var
j
=
0
;
j
<
uuids
.
length
;
j
++
)
{
// try to be safe about this...
if
(
node
.
peripherals
.
hasOwnProperty
(
uuids
[
j
])
&&
node
.
peripherals
[
uuids
[
j
]].
hasOwnProperty
(
"
once
"
))
{
node
.
peripherals
[
uuids
[
j
]].
once
(
'
disconnect
'
,
()
=>
{
peripheralDisconnected
(
node
.
peripherals
[
uuids
[
j
]]);
});
}
var
p
=
node
.
peripherals
[
uuids
[
j
]].
peripheralObj
;
if
(
p
&&
p
.
connected
)
{
p
.
disconnect
();
}
}
}
...
...
Write
Preview
Markdown
is supported
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