Skip to content

Commit 3a9aaa4

Browse files
committed
Increase timeout for radio stats retrieval and enhance device model fetching on connect
1 parent 0a2470c commit 3a9aaa4

1 file changed

Lines changed: 17 additions & 6 deletions

File tree

content/wardrive.js

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3966,7 +3966,7 @@ async function sendPing(manual = false) {
39663966
if (state.connection) {
39673967
debugLog("[PING] Refreshing radio stats before ping");
39683968
try {
3969-
const stats = await state.connection.getRadioStats(3000);
3969+
const stats = await state.connection.getRadioStats(10000);
39703970
if (stats && typeof stats.noiseFloor !== 'undefined') {
39713971
state.lastNoiseFloor = stats.noiseFloor;
39723972
} else {
@@ -4411,17 +4411,28 @@ async function connect() {
44114411
state.devicePublicKey = BufferUtils.bytesToHex(selfInfo.publicKey);
44124412
debugLog(`[BLE] Device public key stored: ${state.devicePublicKey.substring(0, 16)}...`);
44134413

4414-
// Store device model for Settings and show device name
4415-
state.deviceModel = selfInfo?.manufacturerModel || "-";
4416-
debugLog(`[BLE] Device model stored: ${state.deviceModel}`);
4417-
if (deviceModelEl) deviceModelEl.textContent = state.deviceModel;
4414+
// Store device name from selfInfo
44184415
state.deviceName = selfInfo?.name || "[No device]";
44194416
debugLog(`[BLE] Device name stored: ${state.deviceName}`);
44204417
if (deviceNameEl) deviceNameEl.textContent = state.deviceName;
4418+
4419+
// Get device model from deviceQuery (contains manufacturerModel)
4420+
debugLog("[BLE] Requesting device info via deviceQuery");
4421+
try {
4422+
const deviceInfo = await conn.deviceQuery(1);
4423+
debugLog(`[BLE] deviceQuery response received: firmwareVer=${deviceInfo?.firmwareVer}, model=${deviceInfo?.manufacturerModel}`);
4424+
state.deviceModel = deviceInfo?.manufacturerModel || "-";
4425+
debugLog(`[BLE] Device model stored: ${state.deviceModel}`);
4426+
if (deviceModelEl) deviceModelEl.textContent = state.deviceModel;
4427+
} catch (e) {
4428+
debugError(`[BLE] deviceQuery failed: ${e && e.message ? e.message : e}`);
4429+
state.deviceModel = "-";
4430+
if (deviceModelEl) deviceModelEl.textContent = "-";
4431+
}
44214432
// Immediately attempt to read radio stats (noise floor) on connect
44224433
debugLog("[BLE] Requesting radio stats on connect");
44234434
try {
4424-
const stats = await conn.getRadioStats(5000).catch(e => { throw e; });
4435+
const stats = await conn.getRadioStats(10000).catch(e => { throw e; });
44254436
if (stats && typeof stats.noiseFloor !== 'undefined') {
44264437
state.lastNoiseFloor = stats.noiseFloor;
44274438
} else {

0 commit comments

Comments
 (0)