increase delay & send LanSearchExt
This commit is contained in:
+11
-4
@@ -1,5 +1,5 @@
|
|||||||
import EventEmitter from "node:events";
|
import EventEmitter from "node:events";
|
||||||
import { create_LanSearch, parse_PunchPkt } from "./impl.js";
|
import { create_LanSearchExt, create_LanSearch, parse_PunchPkt } from "./impl.js";
|
||||||
import { createSocket, RemoteInfo } from "node:dgram";
|
import { createSocket, RemoteInfo } from "node:dgram";
|
||||||
import { Commands } from "./datatypes.js";
|
import { Commands } from "./datatypes.js";
|
||||||
import { logger } from "./logger.js";
|
import { logger } from "./logger.js";
|
||||||
@@ -31,11 +31,18 @@ export const discoverDevices = (discovery_ip: string): EventEmitter => {
|
|||||||
sock.setBroadcast(true);
|
sock.setBroadcast(true);
|
||||||
logger.info(`Searching for devices on ${discovery_ip}`);
|
logger.info(`Searching for devices on ${discovery_ip}`);
|
||||||
|
|
||||||
let buf = create_LanSearch();
|
let ls_buf = create_LanSearch();
|
||||||
|
let lse_buf = create_LanSearchExt();
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
sock.send(new Uint8Array(buf.buffer), SEND_PORT, discovery_ip);
|
logger.log("trace", `>> LanSearch`);
|
||||||
|
sock.send(new Uint8Array(ls_buf.buffer), SEND_PORT, discovery_ip);
|
||||||
|
logger.log("trace", `>> LanSearchExt`);
|
||||||
|
sock.send(new Uint8Array(lse_buf.buffer), SEND_PORT, discovery_ip);
|
||||||
}, 2000);
|
}, 2000);
|
||||||
sock.send(new Uint8Array(buf.buffer), SEND_PORT, discovery_ip);
|
logger.log("trace", `>> LanSearch`);
|
||||||
|
sock.send(new Uint8Array(ls_buf.buffer), SEND_PORT, discovery_ip);
|
||||||
|
logger.log("trace", `>> LanSearchExt`);
|
||||||
|
sock.send(new Uint8Array(lse_buf.buffer), SEND_PORT, discovery_ip);
|
||||||
});
|
});
|
||||||
|
|
||||||
sock.bind();
|
sock.bind();
|
||||||
|
|||||||
@@ -155,6 +155,13 @@ export const SendUsrChk = (session: Session, username: string, password: string)
|
|||||||
return makeDataReadWrite(session, ControlCommands.ConnectUser, cmd_payload);
|
return makeDataReadWrite(session, ControlCommands.ConnectUser, cmd_payload);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const create_LanSearchExt = (): DataView => {
|
||||||
|
const outbuf = new DataView(new Uint8Array(4).buffer);
|
||||||
|
outbuf.writeU16(Commands.LanSearchExt);
|
||||||
|
outbuf.add(2).writeU16(0x0);
|
||||||
|
return outbuf;
|
||||||
|
};
|
||||||
|
|
||||||
export const create_LanSearch = (): DataView => {
|
export const create_LanSearch = (): DataView => {
|
||||||
const outbuf = new DataView(new Uint8Array(4).buffer);
|
const outbuf = new DataView(new Uint8Array(4).buffer);
|
||||||
outbuf.writeU16(Commands.LanSearch);
|
outbuf.writeU16(Commands.LanSearch);
|
||||||
|
|||||||
+2
-1
@@ -69,7 +69,8 @@ export const makeSession = (
|
|||||||
session.started = true;
|
session.started = true;
|
||||||
};
|
};
|
||||||
if (options.slow_startup) {
|
if (options.slow_startup) {
|
||||||
setTimeout(startup, 3000);
|
logger.info("Delaying session startup");
|
||||||
|
setTimeout(startup, 6500);
|
||||||
} else {
|
} else {
|
||||||
startup();
|
startup();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user