Skip to content

Commit

Permalink
fix: issue where only part of the mobuffer was being sent
Browse files Browse the repository at this point in the history
  • Loading branch information
brendon-stephens committed Jul 14, 2022
1 parent 1b0b6e4 commit 9f538ca
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,7 @@ export class IridiumEmulator extends TypedEmitter<IridiumEmulatorInterface> {

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
Expand All @@ -818,10 +818,17 @@ export class IridiumEmulator extends TypedEmitter<IridiumEmulatorInterface> {
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,
Expand Down

0 comments on commit 9f538ca

Please sign in to comment.