update example in README

This commit is contained in:
2024-10-23 16:46:12 -05:00
parent 4eaedcdfaa
commit 8710e75a93
+12 -4
View File
@@ -13,8 +13,16 @@ typesecript implementation of the [PosiStageNet protocol](https://github.com/vyv
const { Decoder } = require('@jwetzell/posistagenet')
const decoder = new Decoder()
const infoPacketBuffer = Buffer.from('5667348000000c0001000000000000000203010101000b00536572766572204e616d650200118001000d8000000900547261636b65722031','hex')
const dataPacketBuffer = Buffer.from('5567288000000c00010000000000000002030101010014800100108000000c000000803f0000803f0000803f','hex')
const infoPacketBuffer = new Uint8Array([
0x56, 0x67, 0x34, 0x80, 0x00, 0x00, 0x0c, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x03, 0x01,
0x01, 0x01, 0x00, 0x0b, 0x00, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x20, 0x4e, 0x61, 0x6d, 0x65, 0x02, 0x00, 0x11,
0x80, 0x01, 0x00, 0x0d, 0x80, 0x00, 0x00, 0x09, 0x00, 0x54, 0x72, 0x61, 0x63, 0x6b, 0x65, 0x72, 0x20, 0x31,
]);
const dataPacketBuffer = new Uint8Array([
0x55, 0x67, 0x28, 0x80, 0x00, 0x00, 0x0c, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x03, 0x01,
0x01, 0x01, 0x00, 0x14, 0x80, 0x01, 0x00, 0x10, 0x80, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00,
0x80, 0x3f, 0x00, 0x00, 0x80, 0x3f,
]);
decoder.decode(infoPacketBuffer)
decoder.decode(dataPacketBuffer)
@@ -49,12 +57,12 @@ const infoPackets = encoder.getInfoPackets(timestamp, trackers)
dataPackets.forEach((dataPacket)=>{
console.log('send packet somehow')
console.log(dataPacket.toString('hex'))
console.log(dataPacket)
})
infoPackets.forEach((infoPacket)=>{
console.log('send packet somehow')
console.log(infoPacket.toString('hex'))
console.log(infoPacket)
})
```