Browse Source

Methods for setting/removing fixed position (#802)

* Method for setting fixed position

* Implement removeFixedPosition

* Fix formatting
pull/815/head
Henri Bergius 9 months ago
committed by GitHub
parent
commit
85aa7a37b9
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 47
      packages/core/src/meshDevice.ts

47
packages/core/src/meshDevice.ts

@ -378,6 +378,53 @@ export class MeshDevice {
);
}
/**
* Sets the fixed position of a device. Can be used to
* position GPS-less devices.
*/
public async setFixedPosition(
latitude: number,
longitude: number,
): Promise<number> {
const setPositionMessage = create(Protobuf.Admin.AdminMessageSchema, {
payloadVariant: {
case: "setFixedPosition",
value: create(Protobuf.Mesh.PositionSchema, {
latitudeI: Math.floor(latitude / 1e-7),
longitudeI: Math.floor(longitude / 1e-7),
}),
},
});
return await this.sendPacket(
toBinary(Protobuf.Admin.AdminMessageSchema, setPositionMessage),
Protobuf.Portnums.PortNum.ADMIN_APP,
"self",
0,
true,
false,
);
}
/**
* Remove the fixed position of a device
*/
public async removeFixedPosition(): Promise<number> {
const removePositionMessage = create(Protobuf.Admin.AdminMessageSchema, {
payloadVariant: {
case: "removeFixedPosition",
value: true,
},
});
return await this.sendPacket(
toBinary(Protobuf.Admin.AdminMessageSchema, removePositionMessage),
Protobuf.Portnums.PortNum.ADMIN_APP,
"self",
0,
true,
false,
);
}
/**
* Gets specified channel information from the radio
*/

Loading…
Cancel
Save