fiberhome: fix ver sinal

Signed-off-by: Rodrigo Bertoldo de Sousa Martins <rodrigo.sousa.577@gmail.com>
This commit is contained in:
rodrigo committed 2026-02-10 20:52:50 -03:00
1 parent 41a8d1b6c5
commit cccd68b3b0
2 files changed
+153 -13

No files matched your search

+62 -13
View File
@@ -663,27 +663,76 @@ class FiberhomeManager {
// Processar LST-OMDDM (potência ótica) // Processar LST-OMDDM (potência ótica)
if (resposta.comando && resposta.comando.includes('LST-OMDDM')) { if (resposta.comando && resposta.comando.includes('LST-OMDDM')) {
// Buscar pela tabela de potência ótica no formato visto 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 => const linhasTabela = dados.split('\n').filter(linha =>
linha.includes('\t') && linha.includes('\t') &&
!linha.includes('ONUID\tRxPower') && // header !linha.includes('ONUID\tRxPower') && // header
linha.match(/--\t[+-]?\d+[,.]?\d*/) // linha com dados !linha.includes('ONUID RxPower') && // header sem tabs
!linha.includes('---') && // separador
linha.match(/[+-]?\d+[,.]?\d*/) // linha com dados
); );
this.logger.debug(`📋 Linhas de dados encontradas: ${linhasTabela.length}`);
if (linhasTabela.length > 0) { if (linhasTabela.length > 0) {
// Formato: ONUID RxPower RxPowerR TxPower TxPowerR ... this.logger.debug('📄 Primeira linha de dados:', linhasTabela[0]);
// Exemplo: -- -19,94 Normal 5,16 High 11,70 Normal ...
const campos = linhasTabela[0].split('\t');
if (campos.length >= 4) {
const rxPower = campos[1]?.replace(',', '.');
const txPower = campos[3]?.replace(',', '.');
if (rxPower && rxPower !== '--' && !isNaN(parseFloat(rxPower))) { const campos = linhasTabela[0].split('\t');
resultado.rxPower = `${rxPower} dBm`; this.logger.debug(`📊 Total de campos: ${campos.length}`);
}
if (txPower && txPower !== '--' && !isNaN(parseFloat(txPower))) { // Log de TODOS os campos para debug
resultado.txPower = `${txPower} dBm`; 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
rxPowerR: campos[2]?.trim(),
txPower: campos[3]?.replace(',', '.').trim(), // OLT transmite
txPowerR: campos[4]?.trim(),
currTxBias: campos[5]?.replace(',', '.').trim(),
currTxBiasR: campos[6]?.trim(),
temperature: campos[7]?.replace(',', '.').trim(),
temperatureR: campos[8]?.trim(),
voltage: campos[9]?.replace(',', '.').trim(),
voltageR: campos[10]?.trim(),
ptxPower: campos[11]?.replace(',', '.').trim(), // ONU transmite
prxPower: campos[12]?.replace(',', '.').trim() // ONU recebe
};
this.logger.debug('📡 Valores de potência extraídos:', {
'RxPower (OLT recebe)': valores.rxPower,
'TxPower (OLT transmite)': valores.txPower,
'PTxPower (ONU transmite)': valores.ptxPower,
'PRxPower (ONU recebe)': 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))) {
resultado.rxPower = `${valores.rxPower} dBm`;
this.logger.info(`⚠️ RX Power (RxPower da OLT - fallback): ${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)
resultado.txPower = `${valores.rxPower} dBm`;
this.logger.info(`✅ TX Power da ONU (RxPower da OLT): ${valores.rxPower} dBm`);
} }
} }
} }
+91
View File
@@ -0,0 +1,91 @@
/**
* Teste para validar a correção do RX Power das ONUs FiberHome
*
* Problema: Bot mostrava -23.02 dBm, mas UNM2000 mostrava -20.22 dBm
* Nova Hipótese: UNM2000 mostra TxPower da OLT (que é o sinal recebido pela ONU)
*/
// Simular resposta do comando LST-OMDDM conforme o manual
const respostaSimulada = `
FH_10.78.20.120 2024-02-10 14:30:00
M CTAG COMPLD
total_blocks=1
block_number=1
block_records=1
List of Optical Power Info
----------------------------------------------------------
ONUID RxPower RxPowerR TxPower TxPowerR CurrTxBias CurrTxBiasR Temperature TemperatureR Voltage VoltageR PTxPower PRxPower
5 -23.02 Normal -20.22 Normal 15.80 Normal 62.37 Normal 3.40 Normal 1.85 -19.50
-----------------------------------------------------------
`;
console.log('🧪 Teste de Extração do RX Power - NOVA HIPÓTESE\n');
console.log('=' .repeat(70));
// Processar resposta
const linhasTabela = respostaSimulada.split('\n').filter(linha =>
linha.includes('\t') &&
!linha.includes('ONUID\tRxPower') &&
!linha.includes('ONUID RxPower') &&
!linha.includes('---') &&
linha.match(/[+-]?\d+[,.]?\d*/)
);
if (linhasTabela.length > 0) {
const campos = linhasTabela[0].split('\t');
console.log(`\n📊 Total de campos extraídos: ${campos.length}`);
console.log('\nCampos encontrados:');
campos.forEach((campo, idx) => {
const nomes = ['ONUID', 'RxPower', 'RxPowerR', 'TxPower', 'TxPowerR',
'CurrTxBias', 'CurrTxBiasR', 'Temperature', 'TemperatureR',
'Voltage', 'VoltageR', 'PTxPower', 'PRxPower'];
console.log(` [${idx}] ${nomes[idx]?.padEnd(15)}: "${campo}"`);
});
// Extrair valores
const valores = {
rxPower: campos[1]?.replace(',', '.').trim(), // OLT recebe da ONU
txPower: campos[3]?.replace(',', '.').trim(), // OLT transmite para ONU ⭐
ptxPower: campos[11]?.replace(',', '.').trim(), // ONU transmite para OLT
prxPower: campos[12]?.replace(',', '.').trim() // ONU recebe da OLT
};
console.log('\n' + '='.repeat(70));
console.log('📡 ANÁLISE DOS VALORES:');
console.log('='.repeat(70));
console.log(`\n🔴 Bot estava usando (ERRADO):`);
console.log(` RxPower = ${valores.rxPower} dBm (sinal que OLT recebe da ONU)`);
console.log(`\n🟡 Tentativa anterior (ainda errado):`);
console.log(` PRxPower = ${valores.prxPower} dBm (sinal que ONU recebe da OLT)`);
console.log(`\n🟢 NOVA HIPÓTESE (pode ser o correto!):`);
console.log(` TxPower = ${valores.txPower} dBm ⭐ (sinal que OLT transmite = ONU recebe)`);
console.log('\n' + '='.repeat(70));
console.log('✅ COMPARAÇÃO:');
console.log('='.repeat(70));
console.log(`UNM2000 mostra: -20.22 dBm`);
console.log(`TxPower (campo 3): ${valores.txPower} dBm ${valores.txPower === '-20.22' ? '✅ MATCH!' : '❌'}`);
console.log(`PRxPower (campo 12): ${valores.prxPower} dBm ${valores.prxPower === '-20.22' ? '✅ MATCH!' : '❌'}`);
console.log(`RxPower (campo 1): ${valores.rxPower} dBm ${valores.rxPower === '-20.22' ? '✅ MATCH!' : '❌'}`);
console.log('\n' + '='.repeat(70));
console.log('📖 INTERPRETAÇÃO:');
console.log('='.repeat(70));
console.log('Campo | Significado | Quem mede');
console.log('------------|--------------------------------------|------------------');
console.log('RxPower | Potência recebida (ONU→OLT) | Medido na OLT');
console.log('TxPower ⭐ | Potência transmitida (OLT→ONU) | Medido na OLT');
console.log('PTxPower | Potência transmitida (ONU→OLT) | Medido na ONU');
console.log('PRxPower | Potência recebida (OLT→ONU) | Medido na ONU');
console.log('\n💡 TxPower da OLT é o sinal que a ONU RECEBE da OLT!');
} else {
console.log('❌ Nenhuma linha de dados encontrada');
}
console.log('\n' + '='.repeat(70));