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 Example
nodejs-sensor-cloud
Commits
6a361c40
Commit
6a361c40
authored
Mar 09, 2018
by
Donald Chen
Browse files
cleanup
parent
8a5622f1
Changes
2
Hide whitespace changes
Inline
Side-by-side
device.js
View file @
6a361c40
...
...
@@ -15,6 +15,7 @@ class Device {
this
.
fwVersion
=
null
;
this
.
timer
=
null
;
}
/**
* Returns a Promise that will resolve with the ble device's firmware revision,
* or reject with an error
...
...
@@ -44,7 +45,6 @@ class Device {
return
new
Promise
((
resolve
,
reject
)
=>
{
this
.
timer
=
setTimeout
(()
=>
{
console
.
log
(
`connection timeout:
${
this
.
id
}
`
)
this
.
bleDevice
.
disconnect
();
reject
(
"
connection timeout
"
)
},
10000
)
...
...
@@ -55,9 +55,8 @@ class Device {
}
if
(
this
.
timer
==
null
)
{
console
.
log
(
`duplicate connection timeout:
${
this
.
id
}
`
)
this
.
bleDevice
.
disconnect
();
reject
(
"
connection
already
time
d
out
"
)
reject
(
"
connection timeout
"
)
}
else
{
clearTimeout
(
this
.
timer
)
this
.
timer
=
null
...
...
index.js
View file @
6a361c40
...
...
@@ -74,7 +74,7 @@ function onDiscover(beaconInst) {
devices
[
device
.
id
]
=
device
;
// Set disconnect handler
device
.
bleDevice
.
on
ce
(
'
disconnect
'
,
function
disconnectHandler
()
{
device
.
bleDevice
.
on
(
'
disconnect
'
,
function
disconnectHandler
()
{
console
.
log
(
`
${
device
.
id
}
: disconnected`
);
device
.
bleDevice
.
removeListener
(
'
disconnect
'
,
disconnectHandler
);
device
.
resetState
();
...
...
@@ -98,4 +98,4 @@ noble.on('scanStart', () => {
console
.
log
(
'
Scanning started
'
);
});
rigadoSensorBeacon
.
discoverAll
(
onDiscover
);
\ No newline at end of file
rigadoSensorBeacon
.
discoverAll
(
onDiscover
);
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