From 43e88ef0369f242bdaa18f3aa4613330f964d905 Mon Sep 17 00:00:00 2001 From: Mathew Date: Thu, 8 Feb 2024 11:16:43 +1100 Subject: [PATCH] networkStatus resend handling performed by firmware --- lib/Af.js | 4 ++-- lib/AfController.js | 45 --------------------------------------------- 2 files changed, 2 insertions(+), 47 deletions(-) diff --git a/lib/Af.js b/lib/Af.js index 7699686..128bb60 100644 --- a/lib/Af.js +++ b/lib/Af.js @@ -343,7 +343,7 @@ class Af extends EventEmitter { if(ex.status == 178) { // ZApsTableFull wf.cancel() areqCancelable._cancels.delete(wf) - await Q.delay((Math.random() + 0.5) * 16000) + await Q.delay((Math.random() + 0.5) * 32000) // in case the src rtg changed const srcRtg = dstEp.getSrcRtg() @@ -372,7 +372,7 @@ class Af extends EventEmitter { if(ex.status == 178) { // ZApsTableFull wf.cancel() areqCancelable._cancels.delete(wf) - await Q.delay((Math.random() + 0.5) * 16000) + await Q.delay((Math.random() + 0.5) * 32000) continue } throw ex diff --git a/lib/AfController.js b/lib/AfController.js index 7893033..31d3412 100644 --- a/lib/AfController.js +++ b/lib/AfController.js @@ -40,35 +40,6 @@ class AfController extends EventEmitter { } /* eslint-enable no-unused-vars */ - registerResend(dstAddr, interestedCodes = DefaultCodesOfInterest){ - const afResendEvt = 'ZDO:networkStatus:' + dstAddr.toString(16) - let sendTime = Date.now() - const deferred = Q.defer() - let done = false - - const handleResend = data=>{ - if(done) return - if(interestedCodes.includes(data.code) && (Date.now() - sendTime) > 6500){ - debug(`possible indirect expiration for 0x${dstAddr.toString(16)}, resending (status: 0x${data.code.toString(16)})`) - done = true - deferred.resolve(data.code) - } else { - this.removeListener(...eventArgs) - this.once(...eventArgs) - } - } - - const eventArgs = [afResendEvt, handleResend] // declaration gets hoisted, handleResend can reference it - - this.once(...eventArgs); - - const cleanup = ()=>{ - this.removeListener(...eventArgs) - deferred.resolve(null) - } - - return {cleanup, promise: deferred.promise} - } async indirectSend(sendFn, cfg){ const shouldIndirect = this.shouldSendIndrect(cfg.dstAddr) let retries = cfg.retries || 4 @@ -97,10 +68,6 @@ class AfController extends EventEmitter { if(cfg.signalTimeout){ promises.push(cfg.signalTimeout.promise) } - if(shouldIndirect){ - resend = this.registerResend(cfg.dstAddr) - promises.push(resend.promise.then(a=>a||'resend')) - } const result = await Q.cancelledRace(promises) // Handle results for any of the promises that might have returned @@ -109,18 +76,6 @@ class AfController extends EventEmitter { await Q.cancelledRace([Q.delay(5000), workPromise]) // Wait at-least 5 seconds after a module error canSrcRtg = false } - else if(typeof result === 'number') { - // network status code - if(result != 6 && i != retries) { - const waitTime = 3500 - (Date.now() - attemptStart) - if(waitTime > 0) await Q.cancelledRace([Q.delay(waitTime), workPromise]) - - // After a MTO failure we can still srcrtg, the coordinator will send a RReq - // NO_ROUTE_AVAIL occurs when the device has no free space for new routes - if(result != 0x0c) canSrcRtg = false - } - // if is 6 (INDIRECT_TRANS_EXPIRY) we continue - } else if(result !== undefined) { // should be the same as result return await workPromise