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
+154 -14

No files matched your search

+63 -14
View File
@@ -663,27 +663,76 @@ class FiberhomeManager {
// Processar LST-OMDDM (potência ótica)
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 =>
linha.includes('\t') &&
!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) {
// Formato: ONUID RxPower RxPowerR TxPower TxPowerR ...
// Exemplo: -- -19,94 Normal 5,16 High 11,70 Normal ...
this.logger.debug('📄 Primeira linha de dados:', linhasTabela[0]);
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))) {
resultado.rxPower = `${rxPower} dBm`;
}
if (txPower && txPower !== '--' && !isNaN(parseFloat(txPower))) {
resultado.txPower = `${txPower} dBm`;
}
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
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`);
}
}
}