refactor a bit more

This commit is contained in:
DavidVentura
2024-01-26 17:36:06 +01:00
parent 36ab8d3285
commit 130c0c7f7e
4 changed files with 7 additions and 38 deletions
+2 -29
View File
@@ -1,33 +1,5 @@
import { swap_endianness_u32, swap_endianness_u16, u16_swap } from "./utils.js";
export const Commands = {
Close: 0xf1f0,
LanSearchExt: 0xf132,
LanSearch: 0xf130,
P2PAlive: 0xf1e0,
P2PAliveAck: 0xf1e1,
Hello: 0xf100,
P2pRdy: 0xf142,
P2pReq: 0xf120,
LstReq: 0xf167,
DrwAck: 0xf1d1,
Drw: 0xf1d0,
// From CSession_CtrlPkt_Proc, incomplete
PunchTo: 0xf140,
PunchPkt: 0xf141,
HelloAck: 0xf101,
RlyTo: 0xf102,
DevLgnAck: 0xf111,
P2PReqAck: 0xf121,
ListenReqAck: 0xf169,
RlyHelloAck: 0xf170, // always
RlyHelloAck2: 0xf171, // if len >1??
};
export const CommandsByValue = Object.keys(Commands).reduce((acc, cur) => {
acc[Commands[cur]] = cur;
return acc;
}, {});
import { Commands, CommandsByValue } from "./datatypes.js";
const writeCommand2 = (command, buf) => {
buf.writeByteArray([(command & 0xff00) >> 8, command & 0xff]);
@@ -37,6 +9,7 @@ const writeCommand4 = (command, buf) => {
};
export const XqBytesDec = (inoutbuf, buflen, rotate) => {
// only rotation is different
let new_buf = new Uint8Array(buflen);
new_buf.fill(0x1);
for (let i = 0; i < buflen; i++) {