Fix incorrect lat/lon decoding
This commit is contained in:
@@ -225,8 +225,6 @@ export class Packet implements IPacket {
|
||||
throw new Error(`Unsupported payload type: ${this.payloadType}`);
|
||||
}
|
||||
|
||||
console.log('packet decode with structure:', typeof withStructure, withStructure, { result });
|
||||
|
||||
if (typeof withStructure === "boolean" && withStructure && "segment" in result && "payload" in result) {
|
||||
this.ensureStructure();
|
||||
const structure = [ ...this.structure!, result.segment ];
|
||||
@@ -408,8 +406,8 @@ export class Packet implements IPacket {
|
||||
}
|
||||
|
||||
if (appdata.hasLocation) {
|
||||
const lat = reader.readInt32LE() / 100000;
|
||||
const lon = reader.readInt32LE() / 100000;
|
||||
const lat = reader.readInt32LE() / 1000000;
|
||||
const lon = reader.readInt32LE() / 1000000;
|
||||
appdata.location = [lat, lon];
|
||||
if (typeof withSegment === "boolean" && withSegment) {
|
||||
segment!.fields.push({ type: FieldType.UINT32_LE, name: "latitude", size: 4, value: lat });
|
||||
|
||||
@@ -94,8 +94,8 @@ describe('Packet.fromBytes', () => {
|
||||
expect(adv.appdata.hasName).toBe(true);
|
||||
// location values: parser appears to scale values by 10 here, accept that
|
||||
expect(adv.appdata.location).toBeDefined();
|
||||
expect(adv.appdata.location![0] / 10).toBeCloseTo(51.45986, 5);
|
||||
expect(adv.appdata.location![1] / 10).toBeCloseTo(5.45422, 5);
|
||||
expect(adv.appdata.location![0] / 10).toBeCloseTo(5.145986, 5);
|
||||
expect(adv.appdata.location![1] / 10).toBeCloseTo(0.545422, 5);
|
||||
expect(adv.appdata.name).toBe('NL-EHV-VBGB-RPTR');
|
||||
expect(pkt.hash().toUpperCase()).toBe('67C10F75168ECC8C');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user