From 0b261ba45282f78a907d179b10128806d38d6f0c Mon Sep 17 00:00:00 2001 From: Rodrigo Bertoldo de Sousa Martins Date: Tue, 10 Feb 2026 20:54:56 -0300 Subject: [PATCH] fiberhome: add remove onu option Signed-off-by: Rodrigo Bertoldo de Sousa Martins --- FIBERHOME-RX-POWER-INFO.md | 69 +++++++++++++++++++++++++++++ src/bot/handler.js | 5 ++- src/fiberhome/manager.js | 91 +++++++++++++++++++++++--------------- 3 files changed, 128 insertions(+), 37 deletions(-) create mode 100644 FIBERHOME-RX-POWER-INFO.md diff --git a/FIBERHOME-RX-POWER-INFO.md b/FIBERHOME-RX-POWER-INFO.md new file mode 100644 index 0000000..2350725 --- /dev/null +++ b/FIBERHOME-RX-POWER-INFO.md @@ -0,0 +1,69 @@ +# Informações sobre RX Power em ONUs FiberHome + +## Problema Identificado + +O comando TL1 `LST-OMDDM` retorna valores de potência **medidos pela OLT**, não pela ONU: + +``` +ONUID RxPower RxPowerR TxPower TxPowerR PTxPower PRxPower +-- -23,01 Normal 4,71 Normal -- -- +``` + +### Campos Retornados: + +- **RxPower**: -23,01 dBm - Sinal que a **OLT recebe** da ONU (uplink) +- **TxPower**: 4,71 dBm - Potência de **transmissão da OLT** (não é sinal recebido!) +- **PTxPower**: -- (vazio) - Deveria ser potência transmitida pela ONU +- **PRxPower**: -- (vazio) - Deveria ser potência recebida pela ONU + +## Diferença com o UNM2000 + +O UNM2000 mostra **-20.22 dBm**, mas o TL1 retorna **-23,01 dBm**. + +### Possíveis Causas: + +1. **UNM2000 usa OMCI diretamente**: O sistema de gestão pode acessar a ONU via protocolo OMCI (ONT Management and Control Interface), obtendo valores medidos pela própria ONU + +2. **Comando TL1 diferente**: O UNM2000 pode usar um comando proprietário ou extensão do TL1 não documentada no manual + +3. **Cálculo/compensação**: Pode haver algum cálculo de compensação de atenuação + +## Solução Implementada + +O bot agora mostra o **RxPower** (-23,01 dBm) que é o único valor confiável disponível via TL1, com a indicação de que é medido pela OLT: + +``` +📡 RX Power: -23.01 dBm (uplink) +💡 Valores medidos pela OLT via protocolo TL1 +``` + +## Comandos TL1 Testados + +- ✅ **LST-OMDDM**: Retorna potências medidas pela OLT +- ✅ **LST-ONUSTATE**: Apenas status (UP/DOWN) +- ✅ **LST-ONUCFG**: Apenas configuração e distância +- ✅ **LST-PONPERF**: Apenas estatísticas de pacotes + +## Notas Técnicas + +### Significado dos Campos LST-OMDDM: + +| Campo | Significado | Medido em | +|-------|-------------|-----------| +| RxPower | Sinal recebido ONU→OLT | OLT | +| TxPower | Potência transmitida OLT→ONU | OLT | +| PTxPower | Potência transmitida ONU→OLT | ONU (vazio via TL1) | +| PRxPower | Sinal recebido OLT→ONU | ONU (vazio via TL1) | + +### Interpretação: + +- **RxPower da OLT** = **TX Power da ONU** (mesmo sinal, medido na chegada) +- Para obter o sinal que a ONU recebe, seria necessário acesso OMCI ou comando específico + +## Recomendação + +Para obter valores idênticos ao UNM2000, seria necessário: + +1. Acesso direto à ONU via OMCI +2. Documentação adicional de comandos TL1 proprietários +3. Ou usar diretamente a API do UNM2000 se disponível diff --git a/src/bot/handler.js b/src/bot/handler.js index 73ac122..ea47351 100644 --- a/src/bot/handler.js +++ b/src/bot/handler.js @@ -1752,9 +1752,12 @@ Digite /help para ver todos os comandos disponíveis! message += `🔌 *Status:* ${resultado.online ? '🟢 Online' : '🔴 Offline'}\n\n`; message += `📊 *Informações do Sinal:*\n`; - message += `📡 *RX Power:* ${resultado.rxPower}\n`; + message += `📡 *RX Power:* ${resultado.rxPower} _(uplink)_\n`; message += `📤 *TX Power:* ${resultado.txPower}\n`; message += `📏 *Distância:* ${resultado.distance}\n\n`; + + // Nota sobre leitura de potência + message += `_💡 Valores medidos pela OLT via protocolo TL1_\n\n`; // Status das portas Ethernet (resumido) if (resultado.portasEthernet.length > 0) { diff --git a/src/fiberhome/manager.js b/src/fiberhome/manager.js index bbb6b3c..04c6326 100644 --- a/src/fiberhome/manager.js +++ b/src/fiberhome/manager.js @@ -390,27 +390,63 @@ class FiberhomeManager { // Para informações DDM/potência ótica (comando válido do manual) `LST-OMDDM::OLTID=${oltId},PONID=${ponEncontrada},ONUNO=${numeroONU}:CTAG::;`, // Para informações das portas LAN (comando válido do manual) - `LST-ONULANINFO::OLTID=${oltId},PONID=${ponEncontrada},ONUNO=${numeroONU}:CTAG::;` + `LST-ONULANINFO::OLTID=${oltId},PONID=${ponEncontrada},ONUNO=${numeroONU}:CTAG::;`, + // NOVO: Tentar LST-ONUCFG para ver se tem mais informações + `LST-ONUCFG::OLTID=${oltId},PONID=${ponEncontrada},ONUIDTYPE=MAC,ONUID=${serialNumber.toUpperCase()}:CTAG::;` ]; this.logger.debug('Executando comandos TL1 detalhados:', comandosDetalhados); - const [resultadoEstado, resultadoDDM, resultadoLAN] = await Promise.all([ + const [resultadoEstado, resultadoDDM, resultadoLAN, resultadoCFG] = await Promise.all([ this.executarComandoTL1(comandosDetalhados[0]), this.executarComandoTL1(comandosDetalhados[1]), - this.executarComandoTL1(comandosDetalhados[2]) + this.executarComandoTL1(comandosDetalhados[2]), + this.executarComandoTL1(comandosDetalhados[3]) ]); + // LOG COMPLETO DO LST-OMDDM PARA DEBUG - FORÇAR CONSOLE OUTPUT + if (resultadoDDM.success && resultadoDDM.data) { + const separador = '='.repeat(80); + console.log('\n' + separador); + console.log('LST-OMDDM RESPOSTA COMPLETA'); + console.log(separador); + console.log('Comando: ' + comandosDetalhados[1]); + console.log('Resposta RAW:'); + console.log(resultadoDDM.data); + console.log(separador + '\n'); + + // Também no logger para arquivo + this.logger.info('==================== LST-OMDDM RESPOSTA COMPLETA ===================='); + this.logger.info('Comando: ' + comandosDetalhados[1]); + this.logger.info('Resposta RAW:'); + this.logger.info(resultadoDDM.data); + this.logger.info('===================================================================='); + } + + // LOG COMPLETO DO LST-ONUCFG PARA DEBUG + if (resultadoCFG.success && resultadoCFG.data) { + const separador = '='.repeat(80); + console.log('\n' + separador); + console.log('LST-ONUCFG RESPOSTA COMPLETA'); + console.log(separador); + console.log('Comando: ' + comandosDetalhados[3]); + console.log('Resposta RAW:'); + console.log(resultadoCFG.data); + console.log(separador + '\n'); + } + // Adicionar dados coletados onuEncontrada.estadoGeral = resultadoEstado.success ? resultadoEstado.data : null; onuEncontrada.detalhes = resultadoDDM.success ? resultadoDDM.data : null; onuEncontrada.lan = resultadoLAN.success ? resultadoLAN.data : null; + onuEncontrada.config = resultadoCFG.success ? resultadoCFG.data : null; // Adicionar respostas detalhadas para processamento onuEncontrada.detalhados = [ { comando: comandosDetalhados[0], response: resultadoEstado.data, success: resultadoEstado.success }, { comando: comandosDetalhados[1], response: resultadoDDM.data, success: resultadoDDM.success }, - { comando: comandosDetalhados[2], response: resultadoLAN.data, success: resultadoLAN.success } + { comando: comandosDetalhados[2], response: resultadoLAN.data, success: resultadoLAN.success }, + { comando: comandosDetalhados[3], response: resultadoCFG.data, success: resultadoCFG.success } ]; // Log dos resultados dos comandos detalhados @@ -665,15 +701,12 @@ class FiberhomeManager { if (resposta.comando && resposta.comando.includes('LST-OMDDM')) { this.logger.debug('🔍 Processando LST-OMDDM - Resposta completa:', dados); - // Buscar pela tabela de potência ótica no formato do manual TL1 - // Formato: ONUID RxPower RxPowerR TxPower TxPowerR CurrTxBias CurrTxBiasR - // Temperature TemperatureR Voltage VoltageR PTxPower PRxPower const linhasTabela = dados.split('\n').filter(linha => linha.includes('\t') && - !linha.includes('ONUID\tRxPower') && // header - !linha.includes('ONUID RxPower') && // header sem tabs - !linha.includes('---') && // separador - linha.match(/[+-]?\d+[,.]?\d*/) // linha com dados + !linha.includes('ONUID\tRxPower') && + !linha.includes('ONUID RxPower') && + !linha.includes('---') && + linha.match(/[+-]?\d+[,.]?\d*/) ); this.logger.debug(`📋 Linhas de dados encontradas: ${linhasTabela.length}`); @@ -683,12 +716,6 @@ class FiberhomeManager { const campos = linhasTabela[0].split('\t'); this.logger.debug(`📊 Total de campos: ${campos.length}`); - // Log de TODOS os campos para debug - campos.forEach((campo, idx) => { - this.logger.debug(` Campo [${idx}]: "${campo}"`); - }); - - // Extrair todos os valores possíveis const valores = { onuId: campos[0]?.trim(), rxPower: campos[1]?.replace(',', '.').trim(), // OLT recebe da ONU @@ -706,33 +733,25 @@ class FiberhomeManager { }; this.logger.debug('📡 Valores de potência extraídos:', { - 'RxPower (OLT recebe)': valores.rxPower, + 'RxPower (OLT recebe da ONU)': valores.rxPower, 'TxPower (OLT transmite)': valores.txPower, 'PTxPower (ONU transmite)': valores.ptxPower, - 'PRxPower (ONU recebe)': valores.prxPower + 'PRxPower (ONU recebe da OLT)': valores.prxPower }); - // TESTE: Usar TxPower da OLT como RX da ONU (pode ser o correto!) - // TxPower da OLT = sinal que sai da OLT = sinal que chega na ONU - if (valores.txPower && valores.txPower !== '--' && !isNaN(parseFloat(valores.txPower))) { - resultado.rxPower = `${valores.txPower} dBm`; - this.logger.info(`✅ RX Power da ONU (TxPower da OLT): ${valores.txPower} dBm`); - } else if (valores.prxPower && valores.prxPower !== '--' && !isNaN(parseFloat(valores.prxPower))) { - resultado.rxPower = `${valores.prxPower} dBm`; - this.logger.info(`✅ RX Power da ONU (PRxPower): ${valores.prxPower} dBm`); - } else if (valores.rxPower && valores.rxPower !== '--' && !isNaN(parseFloat(valores.rxPower))) { + // NOTA: LST-OMDDM retorna potências medidas pela OLT, não pela ONU + // RxPower = sinal que a OLT recebe (uplink) + // Este é o valor mais confiável disponível via TL1 + // O UNM2000 pode estar usando OMCI diretamente ou outro método + if (valores.rxPower && valores.rxPower !== '--' && !isNaN(parseFloat(valores.rxPower))) { resultado.rxPower = `${valores.rxPower} dBm`; - this.logger.info(`⚠️ RX Power (RxPower da OLT - fallback): ${valores.rxPower} dBm`); + this.logger.info(`✅ RX Power (uplink ONU→OLT): ${valores.rxPower} dBm`); } - // TX Power: usar PTxPower (ONU transmite para OLT) - if (valores.ptxPower && valores.ptxPower !== '--' && !isNaN(parseFloat(valores.ptxPower))) { - resultado.txPower = `${valores.ptxPower} dBm`; - this.logger.info(`✅ TX Power da ONU (PTxPower): ${valores.ptxPower} dBm`); - } else if (valores.rxPower && valores.rxPower !== '--' && !isNaN(parseFloat(valores.rxPower))) { - // RxPower na OLT = TxPower na ONU (é o mesmo sinal) + // TX Power: RxPower é o mesmo (sinal da ONU para OLT) + if (valores.rxPower && valores.rxPower !== '--' && !isNaN(parseFloat(valores.rxPower))) { resultado.txPower = `${valores.rxPower} dBm`; - this.logger.info(`✅ TX Power da ONU (RxPower da OLT): ${valores.rxPower} dBm`); + this.logger.info(`✅ TX Power da ONU (= RxPower na OLT): ${valores.rxPower} dBm`); } } }