From 4d8fa3362cba7954eef4728240907ff0efbe72ff Mon Sep 17 00:00:00 2001 From: Rodrigo Bertoldo de Sousa Martins Date: Wed, 1 Apr 2026 08:02:02 -0300 Subject: [PATCH] diagnostico: fix ethernet e Rx Power_p2 Signed-off-by: Rodrigo Bertoldo de Sousa Martins --- src/fiberhome/manager.js | 79 ++++++++++++++++++---------------------- 1 file changed, 35 insertions(+), 44 deletions(-) diff --git a/src/fiberhome/manager.js b/src/fiberhome/manager.js index 04f2a11..2dc8b4e 100644 --- a/src/fiberhome/manager.js +++ b/src/fiberhome/manager.js @@ -882,33 +882,28 @@ class FiberhomeManager { } } - // Extrair informações de potência se disponível na listagem - const rxMatches = [ - dadosCompletos.match(/RX[=\s:]+([+-]?\d+\.?\d*)/gi), - dadosCompletos.match(/RXPOWER[=\s:]+([+-]?\d+\.?\d*)/gi) - ]; - - for (const matches of rxMatches) { - if (matches && matches.length > 0) { - const match = matches[0].match(/([+-]?\d+\.?\d*)/); - if (match) { - resultado.rxPower = `${match[1]} dBm`; - break; + // Extrair informações de potência se disponível na listagem (apenas como fallback) + if (resultado.rxPower === 'N/A') { + const rxMatches = [ + dadosCompletos.match(/RX[=\s:]+([+-]?\d+\.?\d*)/gi), + dadosCompletos.match(/RXPOWER[=\s:]+([+-]?\d+\.?\d*)/gi) + ]; + for (const matches of rxMatches) { + if (matches && matches.length > 0) { + const match = matches[0].match(/([+-]?\d+\.?\d*)/); + if (match) { resultado.rxPower = `${match[1]} dBm`; break; } } } } - - const txMatches = [ - dadosCompletos.match(/TX[=\s:]+([+-]?\d+\.?\d*)/gi), - dadosCompletos.match(/TXPOWER[=\s:]+([+-]?\d+\.?\d*)/gi) - ]; - - for (const matches of txMatches) { - if (matches && matches.length > 0) { - const match = matches[0].match(/([+-]?\d+\.?\d*)/); - if (match) { - resultado.txPower = `${match[1]} dBm`; - break; + if (resultado.txPower === 'N/A') { + const txMatches = [ + dadosCompletos.match(/TX[=\s:]+([+-]?\d+\.?\d*)/gi), + dadosCompletos.match(/TXPOWER[=\s:]+([+-]?\d+\.?\d*)/gi) + ]; + for (const matches of txMatches) { + if (matches && matches.length > 0) { + const match = matches[0].match(/([+-]?\d+\.?\d*)/); + if (match) { resultado.txPower = `${match[1]} dBm`; break; } } } } @@ -918,29 +913,25 @@ class FiberhomeManager { if (dadosONU.detalhes) { this.logger.debug('Processando dados detalhados da ONU:', dadosONU.detalhes); - // Extrair RX Power - const rxMatches = [ - dadosONU.detalhes.match(/RXPOWER[=\s:]+([+-]?\d+\.?\d*)/i), - dadosONU.detalhes.match(/RX[=\s:]+([+-]?\d+\.?\d*)/i) - ]; - - for (const match of rxMatches) { - if (match) { - resultado.rxPower = `${match[1]} dBm`; - break; + // Extrair RX Power (apenas como fallback) + if (resultado.rxPower === 'N/A') { + const rxMatches = [ + dadosONU.detalhes.match(/RXPOWER[=\s:]+([+-]?\d+\.?\d*)/i), + dadosONU.detalhes.match(/RX[=\s:]+([+-]?\d+\.?\d*)/i) + ]; + for (const match of rxMatches) { + if (match) { resultado.rxPower = `${match[1]} dBm`; break; } } } - // Extrair TX Power - const txMatches = [ - dadosONU.detalhes.match(/TXPOWER[=\s:]+([+-]?\d+\.?\d*)/i), - dadosONU.detalhes.match(/TX[=\s:]+([+-]?\d+\.?\d*)/i) - ]; - - for (const match of txMatches) { - if (match) { - resultado.txPower = `${match[1]} dBm`; - break; + // Extrair TX Power (apenas como fallback) + if (resultado.txPower === 'N/A') { + const txMatches = [ + dadosONU.detalhes.match(/TXPOWER[=\s:]+([+-]?\d+\.?\d*)/i), + dadosONU.detalhes.match(/TX[=\s:]+([+-]?\d+\.?\d*)/i) + ]; + for (const match of txMatches) { + if (match) { resultado.txPower = `${match[1]} dBm`; break; } } }