From 9f538ca1d09e40677703ca92d364a3824c3be039 Mon Sep 17 00:00:00 2001 From: Brendon Stephens Date: Thu, 14 Jul 2022 15:44:18 +1000 Subject: [PATCH] fix: issue where only part of the mobuffer was being sent --- src/index.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index 885ed33..0cc7994 100644 --- a/src/index.ts +++ b/src/index.ts @@ -798,7 +798,7 @@ export class IridiumEmulator extends TypedEmitter { this.#logger.debug(`Initiating simulated SBD session. Waiting ${Math.round(waitTime / SECOND)} seconds...`) - await delay(LONG_WAIT_TIME) + await delay(waitTime) // the connection was successful if we still have 2 or more // bars of signal. if we have 1 bar of signal then it should @@ -818,10 +818,17 @@ export class IridiumEmulator extends TypedEmitter { rbDateFormat = rbDateFormat .substring(0, rbDateFormat.length - 4) // drop milliseconds + let index = 0 + for (let i = this.moBuffer.length - 1; i >= 0; i--) { + if (this.moBuffer[i] === 0x00) continue + index = i + break + } + this.#logger.debug('Emitting sbd-message event with message details') const claims = { momsn: this.#moSequenceNo, - data: this.moBuffer.slice(0, this.moBuffer.indexOf(0x00)).toString('hex'), + data: this.moBuffer.slice(0, index + 1).toString('hex'), serial: 206899, iridium_latitude: 50.2563, iridium_longitude: 82.2532,