genieacs: fix parameters
Signed-off-by: Rodrigo Bertoldo de Sousa Martins <rodrigo.sousa.577@gmail.com>
This commit is contained in:
1 parent
a701b85754
commit
a3c69e7153
1 file changed
+21
-6
+21
-6
@@ -65,9 +65,15 @@ class GenieACSApi {
|
|||||||
}
|
}
|
||||||
// O GenieACS armazena o valor em _value no nó folha
|
// O GenieACS armazena o valor em _value no nó folha
|
||||||
if (current && typeof current === 'object' && '_value' in current) {
|
if (current && typeof current === 'object' && '_value' in current) {
|
||||||
return current._value;
|
const v = current._value;
|
||||||
|
// Tratar valores vazios/nulos como ausentes (retorna null para acionar fallback)
|
||||||
|
return (v !== null && v !== undefined && v !== '') ? v : null;
|
||||||
}
|
}
|
||||||
return current ?? null;
|
// Valor direto (string, número, booleano)
|
||||||
|
if (current !== null && current !== undefined && typeof current !== 'object') {
|
||||||
|
return String(current).trim() !== '' ? current : null;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -160,6 +166,15 @@ class GenieACSApi {
|
|||||||
_parseDevice(raw) {
|
_parseDevice(raw) {
|
||||||
const get = (path) => this._getNestedValue(raw, path);
|
const get = (path) => this._getNestedValue(raw, path);
|
||||||
|
|
||||||
|
// O _id do GenieACS segue o formato "OUI-ProductClass-SerialNumber".
|
||||||
|
// Usado como fallback quando os campos DeviceID.* não chegam via projeção
|
||||||
|
// ou estão em formato diferente do esperado.
|
||||||
|
const idParts = typeof raw._id === 'string' ? raw._id.split('-') : [];
|
||||||
|
const idOUI = idParts[0] || null;
|
||||||
|
const idProductClass = idParts[1] || null;
|
||||||
|
// Serial é tudo a partir da 3ª parte (pode conter hifens)
|
||||||
|
const idSerial = idParts.length >= 3 ? idParts.slice(2).join('-') : null;
|
||||||
|
|
||||||
const autoChannel24 = get('InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.AutoChannelEnable');
|
const autoChannel24 = get('InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.AutoChannelEnable');
|
||||||
const autoChannel5 = get('InternetGatewayDevice.LANDevice.1.WLANConfiguration.2.AutoChannelEnable');
|
const autoChannel5 = get('InternetGatewayDevice.LANDevice.1.WLANConfiguration.2.AutoChannelEnable');
|
||||||
|
|
||||||
@@ -178,10 +193,10 @@ class GenieACSApi {
|
|||||||
return {
|
return {
|
||||||
deviceId : raw._id || null,
|
deviceId : raw._id || null,
|
||||||
tags : tags,
|
tags : tags,
|
||||||
serial : get('DeviceID.SerialNumber'),
|
serial : get('DeviceID.SerialNumber') ?? idSerial,
|
||||||
productClass : get('DeviceID.ProductClass'),
|
productClass : get('DeviceID.ProductClass') ?? idProductClass,
|
||||||
manufacturer : get('DeviceID.Manufacturer'),
|
manufacturer : get('DeviceID.Manufacturer') ?? idProductClass,
|
||||||
oui : get('DeviceID.OUI'),
|
oui : get('DeviceID.OUI') ?? idOUI,
|
||||||
softwareVersion : get('InternetGatewayDevice.DeviceInfo.SoftwareVersion'),
|
softwareVersion : get('InternetGatewayDevice.DeviceInfo.SoftwareVersion'),
|
||||||
hardwareVersion : get('InternetGatewayDevice.DeviceInfo.HardwareVersion'),
|
hardwareVersion : get('InternetGatewayDevice.DeviceInfo.HardwareVersion'),
|
||||||
ssid24 : get('InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.SSID'),
|
ssid24 : get('InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.SSID'),
|
||||||
|
|||||||
Reference in new issue
Block a user