Skip to content

Commit 656c353

Browse files
committed
fix(connection): Fetch allowedDeviceCount as part of requestConfig() instead of checkVersion()
1 parent e7e64cd commit 656c353

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

connection.js

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ module.exports = function (RED) {
144144
}
145145

146146
this.requestConfig = function () {
147-
this.publish(`$aws/things/${this.credentials.thingId}/shadow/get`, {})
148147
this.publish(`vsh/${this.credentials.thingId}/requestConfig`, {
149148
vshVersion: VSH_VERSION,
150149
})
@@ -435,13 +434,19 @@ module.exports = function (RED) {
435434
this.handlePing(message)
436435
break
437436
case 'overrideConfig':
437+
this.publish(`$aws/things/${this.credentials.thingId}/shadow/get`, {})
438+
438439
if (message.rateLimiter) {
439440
const iterations = message.rateLimiter
440441
this.rater.overrideConfig(iterations)
441442
}
442443
if (message.userIdToken) {
443444
this.userIdToken = message.userIdToken
444445
}
446+
if (message.allowedDeviceCount) {
447+
this.allowedDeviceCount = message.allowedDeviceCount
448+
this.unrigisterUnallowedDevices(message.allowedDeviceCount)
449+
}
445450
break
446451
case 'kill':
447452
this.handleKill(message)
@@ -503,12 +508,8 @@ module.exports = function (RED) {
503508
}
504509

505510
try {
506-
const {
507-
isAllowedVersion,
508-
isLatestVersion,
509-
updateHint,
510-
allowedDeviceCount,
511-
} = await this.checkVersion()
511+
const { isAllowedVersion, isLatestVersion, updateHint } =
512+
await this.checkVersion()
512513

513514
if (!isLatestVersion) {
514515
this.logger(
@@ -531,10 +532,6 @@ module.exports = function (RED) {
531532
})
532533
return
533534
}
534-
535-
this.allowedDeviceCount = allowedDeviceCount
536-
537-
this.unrigisterUnallowedDevices(allowedDeviceCount)
538535
} catch (e) {
539536
return this.logger(`version check failed! ${e.message}`, null, 'error')
540537
}
@@ -629,9 +626,6 @@ module.exports = function (RED) {
629626
if (match) {
630627
const deviceId = match[0]
631628

632-
// if (topic.includes('/update')) {
633-
// this.handleUpdateFromAlexa(deviceId, message)
634-
// } else
635629
if (topic.includes('/directive')) {
636630
if (message.directive.header.name == 'ReportState') {
637631
this.handleReportState(deviceId, message)

0 commit comments

Comments
 (0)