ipoe: fluxo adicionado
Signed-off-by: Rodrigo Martins <rodrigo@martinsevieira.adv.br>
This commit is contained in:
1 parent
1427e6126a
commit
ef6f94067b
5 files changed
+8791
-8457
No files matched your search
@@ -884,6 +884,78 @@ class FiberhomeManager {
|
||||
|
||||
return diagnostico;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configura IPoE em ONU FiberHome: SET-WANSERVICE com VLAN 977
|
||||
* Busca a ONU registrada pela serial e reconfigura as portas WAN
|
||||
* @param {string} serial - MAC/Serial da ONU
|
||||
* @param {string} onuType - Tipo da ONU (para determinar número de portas)
|
||||
* @returns {Promise} - Promise com resultado
|
||||
*/
|
||||
async configurarIPoEFiberhome(serial, onuType = 'AN5506-02-B') {
|
||||
try {
|
||||
const VLAN_IPOE = 977;
|
||||
this.logger.info('Iniciando configuração IPoE FiberHome via TL1', { serial, vlan: VLAN_IPOE });
|
||||
|
||||
const conectado = await this.conectarUNM2000();
|
||||
if (!conectado) {
|
||||
throw new Error('Não foi possível conectar ao UNM2000');
|
||||
}
|
||||
|
||||
// Buscar ONU registrada pelo serial (retorna o objeto diretamente ou lança exceção)
|
||||
const onuInfo = await this.buscarOnuRegistrada(serial);
|
||||
|
||||
const nameOlt = onuInfo.nameOlt || this.config.olt.name;
|
||||
const portAlias = onuInfo.portAlias;
|
||||
|
||||
this.logger.info('ONU encontrada, reconfigurando WAN Service', { nameOlt, portAlias, serial, vlan: VLAN_IPOE });
|
||||
|
||||
// SET-WANSERVICE com VLAN 977
|
||||
const numPortas = onuType === 'AN5506-02-B' ? 2 : 1;
|
||||
|
||||
for (let porta = 1; porta <= numPortas; porta++) {
|
||||
const setWanCmd = `SET-WANSERVICE::OLTID=${nameOlt},PONID=NA-NA-${portAlias},ONUIDTYPE=MAC,ONUID=${serial}:${this.commandId++}::STATUS=1,MODE=2,CONNTYPE=1,VLAN=${VLAN_IPOE},COS=0,QOS=2,UPORT=${porta};`;
|
||||
this.logger.debug(`Configurando WAN Service IPoE porta ${porta}`, { comando: setWanCmd });
|
||||
|
||||
const resultado = await this.executarComandoTL1(setWanCmd);
|
||||
if (!resultado.success) {
|
||||
this.logger.warn(`Aviso ao configurar WAN porta ${porta}: ${resultado.error}`);
|
||||
}
|
||||
|
||||
await new Promise(resolve => setTimeout(resolve, 1000));
|
||||
}
|
||||
|
||||
// Reiniciar ONU para aplicar
|
||||
await new Promise(resolve => setTimeout(resolve, 2000));
|
||||
const resetCmd = `RESET-ONU::OLTID=${nameOlt},PONID=NA-NA-${portAlias},ONUIDTYPE=MAC,ONUID=${serial}:${this.commandId++}::;`;
|
||||
this.logger.debug('Reiniciando ONU após IPoE', { comando: resetCmd });
|
||||
const resultadoReset = await this.executarComandoTL1(resetCmd);
|
||||
if (!resultadoReset.success) {
|
||||
this.logger.warn(`Aviso ao reiniciar ONU: ${resultadoReset.error}`);
|
||||
}
|
||||
|
||||
this.logger.info('IPoE FiberHome configurado com sucesso', { serial, vlan: VLAN_IPOE });
|
||||
|
||||
return {
|
||||
success: true,
|
||||
message: `VLAN alterada para ${VLAN_IPOE} (IPoE)`,
|
||||
details: {
|
||||
olt: nameOlt,
|
||||
porta: portAlias,
|
||||
serial,
|
||||
vlan: VLAN_IPOE,
|
||||
portas: numPortas
|
||||
}
|
||||
};
|
||||
|
||||
} catch (error) {
|
||||
this.logger.error('Erro ao configurar IPoE FiberHome', { serial, error: error.message });
|
||||
return {
|
||||
success: false,
|
||||
error: error.message
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = FiberhomeManager;
|
||||
Reference in new issue
Block a user