Update ping trước khi load ios, license

This commit is contained in:
nguyentrungthat 2026-03-17 08:35:35 +07:00
parent c18b8aeff2
commit 0bb2ce2e63
3 changed files with 39 additions and 0 deletions

View File

@ -142,6 +142,8 @@ export default class LineConnection {
private testingPortPoE: boolean
private outputTestingPortPoE: string
private debounceSendSummaryReport: NodeJS.Timeout | null = null
private isPingToServer: boolean
private outputPingToServer: string
constructor(config: LineConfig, socketIO: any, handleClearLine: () => void) {
this.config = config
@ -175,6 +177,8 @@ export default class LineConnection {
this.debounceSendSummaryReport = null
this.testingPortPoE = false
this.outputTestingPortPoE = ''
this.isPingToServer = false
this.outputPingToServer = ''
}
/**
* Connect to line with socket
@ -237,6 +241,8 @@ export default class LineConnection {
this.flushLogBuffer()
}, 1000) // 1s debounce
}
if (this.isPingToServer) this.outputPingToServer += cleanData(data.toString())
if (data.toString().includes('More') || data.toString().includes('MORE'))
this.writeCommand(' ')
@ -1946,4 +1952,26 @@ ${log}
this.sendFeatureTested()
console.log('Reset DPELP data and features', this.config.id, this.config.listFeatureTested)
}
async pingToServer(serverIP: string) {
this.isPingToServer = true
this.writeCommand('\r\n')
this.writeCommand('enable\r\n')
await sleep(500)
this.writeCommand(`ping ${serverIP}\r\n`)
await sleep(500)
const start = Date.now()
// console.log('[EXPECT]', expect, timeout)
while (Date.now() - start < 60000) {
if (this.outputPingToServer.includes('Success rate')) {
this.outputPingToServer = ''
this.isPingToServer = false
return true
}
await sleep(500)
}
this.isPingToServer = false
this.outputPingToServer = ''
return false
}
}

View File

@ -961,6 +961,9 @@ export function buildBody(
note: '',
},
{ expect: '', send: ``, delay: '4', repeat: '1', note: '' },
{ expect: '', send: `ping ${tftpIp}`, delay: '3', repeat: '1', note: '' },
{ expect: 'Success rate', send: ``, delay: '2', repeat: '1', note: '' },
{ expect: '', send: ``, delay: '2', repeat: '1', note: '' },
{
expect: '#',
send: listDeviceIos?.includes(fileName) ? '' : `copy tftp: flash:`,
@ -1145,6 +1148,9 @@ export function buildBody(
repeat: '1',
note: '',
},
{ expect: '', send: `ping ${tftpIp}`, delay: '3', repeat: '1', note: '' },
{ expect: 'Success rate', send: ``, delay: '2', repeat: '1', note: '' },
{ expect: '', send: ``, delay: '2', repeat: '1', note: '' },
{
expect: '#',
send: `license install tftp://${tftpIp}/License/${fileName}`,
@ -1306,6 +1312,9 @@ export function buildBody(
repeat: '1',
note: '',
},
{ expect: '', send: `ping ${tftpIp}`, delay: '3', repeat: '1', note: '' },
{ expect: 'Success rate', send: ``, delay: '2', repeat: '1', note: '' },
{ expect: '', send: ``, delay: '2', repeat: '1', note: '' },
{
expect: '#',
send: `license install tftp://${tftpIp}/License/${fileName}`,

View File

@ -763,6 +763,8 @@ export class WebSocketIo {
[lineId],
async (lineCon) => {
if (isReboot) {
const pingSuccess = await lineCon.pingToServer(station?.tftp_ip || '172.16.7.69')
if (!pingSuccess) return
await lineCon.backupIos(iosName)
if (!outletNumber || outletNumber < 0) return
if (!station) return