Surface handset registrations and RSSI, tighten reboot health to 7 days, and consolidate Base / Handsets & RF / Network & RTP sections. Co-authored-by: Cursor <cursoragent@cursor.com>
50 lines
1.5 KiB
JavaScript
50 lines
1.5 KiB
JavaScript
// services/dectStatus/matchHandsetByMac.js
|
|
//
|
|
// Correlate base-local RSSI / statistics rows with Webex handset records.
|
|
|
|
import { normalizeMac } from '../dectDiscovery.js';
|
|
|
|
/**
|
|
* @param {object|null} handset Webex handset record
|
|
* @param {object} rssiRow parsed RSSI entry from status.xml
|
|
* @returns {boolean}
|
|
*/
|
|
export function handsetMatchesRssiRow(handset, rssiRow) {
|
|
const hMac = normalizeMac(handset?.mac);
|
|
const rMac = normalizeMac(rssiRow?.mac);
|
|
return !!(hMac && rMac && hMac === rMac);
|
|
}
|
|
|
|
/**
|
|
* Find the Webex handset matching an RSSI row (by MAC).
|
|
*
|
|
* @param {object} rssiRow
|
|
* @param {object[]} handsets
|
|
* @returns {object|null}
|
|
*/
|
|
export function findHandsetForRssiRow(rssiRow, handsets) {
|
|
const list = Array.isArray(handsets) ? handsets : [];
|
|
return list.find((h) => handsetMatchesRssiRow(h, rssiRow)) || null;
|
|
}
|
|
|
|
/**
|
|
* Build display rows merging RSSI with optional Webex handset metadata.
|
|
*
|
|
* @param {object[]} rssiRows parsed status.rssi
|
|
* @param {object[]} handsets Webex handsets for this base
|
|
* @returns {object[]}
|
|
*/
|
|
export function mergeRssiWithHandsets(rssiRows, handsets) {
|
|
const rows = Array.isArray(rssiRows) ? rssiRows : [];
|
|
const list = Array.isArray(handsets) ? handsets : [];
|
|
return rows.map((row) => {
|
|
const handset = findHandsetForRssiRow(row, list);
|
|
return {
|
|
rpn: row.rpn,
|
|
mac: row.mac,
|
|
rssiDbm: row.rssiDbm,
|
|
handsetName: handset?.name || null,
|
|
extension: handset?.extension || null,
|
|
};
|
|
});
|
|
}
|