@airframes/acars-decoder 1.6.4 → 1.6.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +57 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +57 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1537,6 +1537,59 @@ function addChecksum(decodeResult, value) {
|
|
|
1537
1537
|
});
|
|
1538
1538
|
}
|
|
1539
1539
|
|
|
1540
|
+
// lib/plugins/Label_H1_OHMA.ts
|
|
1541
|
+
import * as zlib from "minizlib";
|
|
1542
|
+
var Label_H1_OHMA = class extends DecoderPlugin {
|
|
1543
|
+
name = "label-h1-ohma";
|
|
1544
|
+
qualifiers() {
|
|
1545
|
+
return {
|
|
1546
|
+
labels: ["H1"],
|
|
1547
|
+
preambles: ["OHMA", "/RTNBOCR.OHMA", "#T1B/RTNBOCR.OHMA"]
|
|
1548
|
+
};
|
|
1549
|
+
}
|
|
1550
|
+
decode(message, options = {}) {
|
|
1551
|
+
let decodeResult = this.defaultResult;
|
|
1552
|
+
decodeResult.decoder.name = this.name;
|
|
1553
|
+
decodeResult.formatted.description = "OHMA Message";
|
|
1554
|
+
decodeResult.message = message;
|
|
1555
|
+
decodeResult.remaining.text = "";
|
|
1556
|
+
const data = message.text.split("OHMA")[1];
|
|
1557
|
+
try {
|
|
1558
|
+
const compressedBuffer = Buffer.from(data, "base64");
|
|
1559
|
+
const decompress = new zlib.Inflate({ windowBits: 15 });
|
|
1560
|
+
decompress.write(compressedBuffer);
|
|
1561
|
+
decompress.flush(zlib.constants.Z_SYNC_FLUSH);
|
|
1562
|
+
const result = decompress.read();
|
|
1563
|
+
const jsonText = result.toString();
|
|
1564
|
+
const json = JSON.parse(jsonText);
|
|
1565
|
+
let formattedMsg;
|
|
1566
|
+
if (json.message.startsWith("{")) {
|
|
1567
|
+
const ohmaMsg = JSON.parse(json.message);
|
|
1568
|
+
formattedMsg = JSON.stringify(ohmaMsg, null, 2);
|
|
1569
|
+
} else {
|
|
1570
|
+
formattedMsg = json.message;
|
|
1571
|
+
}
|
|
1572
|
+
decodeResult.decoded = true;
|
|
1573
|
+
decodeResult.decoder.decodeLevel = "full";
|
|
1574
|
+
decodeResult.raw.ohma = jsonText;
|
|
1575
|
+
decodeResult.formatted.items.push({
|
|
1576
|
+
type: "ohma",
|
|
1577
|
+
code: "OHMA",
|
|
1578
|
+
label: "OHMA Downlink",
|
|
1579
|
+
value: formattedMsg
|
|
1580
|
+
});
|
|
1581
|
+
} catch (e) {
|
|
1582
|
+
if (options.debug) {
|
|
1583
|
+
console.log(`Decoder: Unknown H1 OHMA message: ${message.text}`, e);
|
|
1584
|
+
}
|
|
1585
|
+
decodeResult.remaining.text += message.text;
|
|
1586
|
+
decodeResult.decoded = false;
|
|
1587
|
+
decodeResult.decoder.decodeLevel = "none";
|
|
1588
|
+
}
|
|
1589
|
+
return decodeResult;
|
|
1590
|
+
}
|
|
1591
|
+
};
|
|
1592
|
+
|
|
1540
1593
|
// lib/plugins/Label_H1_POS.ts
|
|
1541
1594
|
var Label_H1_POS = class extends DecoderPlugin {
|
|
1542
1595
|
name = "label-h1-pos";
|
|
@@ -2110,7 +2163,7 @@ var Label_QQ = class extends DecoderPlugin {
|
|
|
2110
2163
|
|
|
2111
2164
|
// lib/utils/miam.ts
|
|
2112
2165
|
import * as Base85 from "base85";
|
|
2113
|
-
import * as
|
|
2166
|
+
import * as zlib2 from "minizlib";
|
|
2114
2167
|
var MIAMCoreV1CRCLength = 4;
|
|
2115
2168
|
var MIAMCoreV2CRCLength = 2;
|
|
2116
2169
|
var MIAMCoreUtils = class {
|
|
@@ -2820,9 +2873,9 @@ var MIAMCoreUtils = class {
|
|
|
2820
2873
|
if (body !== void 0 && body.length > 0) {
|
|
2821
2874
|
if ([1 /* Deflate */, 1 /* Deflate */].indexOf(pduCompression) >= 0) {
|
|
2822
2875
|
try {
|
|
2823
|
-
const decompress = new
|
|
2876
|
+
const decompress = new zlib2.InflateRaw({ windowBits: 15 });
|
|
2824
2877
|
decompress.write(body);
|
|
2825
|
-
decompress.flush(
|
|
2878
|
+
decompress.flush(zlib2.constants.Z_SYNC_FLUSH);
|
|
2826
2879
|
pduData = decompress.read();
|
|
2827
2880
|
} catch (e) {
|
|
2828
2881
|
pduErrors.push("Inflation failed for body: " + e);
|
|
@@ -2934,6 +2987,7 @@ var MessageDecoder = class {
|
|
|
2934
2987
|
this.registerPlugin(new Label_44_POS(this));
|
|
2935
2988
|
this.registerPlugin(new Label_B6_Forwardslash(this));
|
|
2936
2989
|
this.registerPlugin(new Label_H1_FPN(this));
|
|
2990
|
+
this.registerPlugin(new Label_H1_OHMA(this));
|
|
2937
2991
|
this.registerPlugin(new Label_H1_POS(this));
|
|
2938
2992
|
this.registerPlugin(new Label_H1_WRN(this));
|
|
2939
2993
|
this.registerPlugin(new Label_80(this));
|