ENCODING!! and lots of organization

This commit is contained in:
2023-09-13 14:50:27 -05:00
parent 2ab90d0146
commit fa0160fc54
37 changed files with 651 additions and 222 deletions
+4
View File
@@ -0,0 +1,4 @@
const chunk = require('../chunk');
module.exports = (packetHeaderChunk, trackerListChunk) =>
chunk(0x6755, Buffer.concat([packetHeaderChunk, trackerListChunk]), true);
@@ -0,0 +1,9 @@
const chunk = require('../chunk');
module.exports = (x, y, z) => {
const buf = Buffer.alloc(12);
buf.writeFloatLE(x);
buf.writeFloatLE(y, 4);
buf.writeFloatLE(z, 8);
return chunk(0x0004, buf, false);
};
+3
View File
@@ -0,0 +1,3 @@
const chunk = require('../chunk');
module.exports = (trackerId, fieldChunks) => chunk(trackerId, Buffer.concat(fieldChunks), true);
+3
View File
@@ -0,0 +1,3 @@
const chunk = require('../chunk');
module.exports = (trackerChunks) => chunk(0x0001, Buffer.concat(trackerChunks), true);
+9
View File
@@ -0,0 +1,9 @@
const chunk = require('../chunk');
module.exports = (x, y, z) => {
const buf = Buffer.alloc(12);
buf.writeFloatLE(x);
buf.writeFloatLE(y, 4);
buf.writeFloatLE(z, 8);
return chunk(0x0002, buf, false);
};
+9
View File
@@ -0,0 +1,9 @@
const chunk = require('../chunk');
module.exports = (x, y, z) => {
const buf = Buffer.alloc(12);
buf.writeFloatLE(x);
buf.writeFloatLE(y, 4);
buf.writeFloatLE(z, 8);
return chunk(0x0000, buf, false);
};
@@ -0,0 +1,9 @@
const chunk = require('../chunk');
module.exports = (x, y, z) => {
const buf = Buffer.alloc(12);
buf.writeFloatLE(x);
buf.writeFloatLE(y, 4);
buf.writeFloatLE(z, 8);
return chunk(0x0001, buf, false);
};
@@ -0,0 +1,7 @@
const chunk = require('../chunk');
module.exports = (validity) => {
const buf = Buffer.alloc(4);
buf.writeFloatLE(validity);
return chunk(0x0003, buf, false);
};
@@ -0,0 +1,10 @@
const chunk = require('../chunk');
module.exports = (timestamp) => {
const buf = Buffer.alloc(8);
const timestampHigh = timestamp.toString(2).padStart(64, '0').substring(0, 32);
const timestampLow = timestamp.toString(2).padStart(64, '0').substring(32);
buf.writeUInt32LE(parseInt(timestampLow, 2));
buf.writeUInt32LE(parseInt(timestampHigh, 2), 4);
return chunk(0x0006, buf, false);
};
@@ -0,0 +1,9 @@
const chunk = require('../chunk');
module.exports = (x, y, z) => {
const buf = Buffer.alloc(12);
buf.writeFloatLE(x);
buf.writeFloatLE(y, 4);
buf.writeFloatLE(z, 8);
return chunk(0x0005, buf, false);
};