Organize files
This commit is contained in:
parent
37a7074aea
commit
26b87ed628
|
@ -8,7 +8,7 @@
|
|||
"clean": "rimraf ./dist",
|
||||
"build": "npm run clean && tsc",
|
||||
"start": "node src",
|
||||
"dev": "nodemon --ext js,ts,mts,mjs ./src/index.ts --exec ts-node-esm"
|
||||
"dev": "nodemon --ext js,ts,mts,mjs,json ./src/index.ts --exec ts-node-esm"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
|
|
|
@ -1,76 +1,14 @@
|
|||
import {
|
||||
PrinterInfo,
|
||||
PrinterModel,
|
||||
PrinterObjectIDConfig,
|
||||
PrinterObjectIDs,
|
||||
Varbind,
|
||||
VarbindString
|
||||
} from './types.mjs'
|
||||
|
||||
import snmp from 'net-snmp'
|
||||
import { printerObjectIDConfigs } from './printerObjectIDConfigs.mjs'
|
||||
|
||||
const printerObjectIDConfigs: PrinterObjectIDConfig[] = [
|
||||
{
|
||||
model: 'm3655idn',
|
||||
objectIds: {
|
||||
model: '1.3.6.1.2.1.25.3.2.1.3.1',
|
||||
serial: '1.3.6.1.2.1.43.5.1.1.17.1',
|
||||
counter: '1.3.6.1.4.1.1347.43.10.1.1.12.1.1',
|
||||
toners: {
|
||||
black: {
|
||||
current: '1.3.6.1.2.1.43.11.1.1.9.1.1',
|
||||
max: '1.3.6.1.2.1.43.11.1.1.8.1.1',
|
||||
model: '1.3.6.1.2.1.43.11.1.1.6.1.1'
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
model: 'p6235cdn',
|
||||
objectIds: {
|
||||
model: '1.3.6.1.2.1.25.3.2.1.3.1',
|
||||
serial: '1.3.6.1.2.1.43.5.1.1.17.1',
|
||||
counter: '1.3.6.1.4.1.1347.43.10.1.1.12.1.1',
|
||||
toners: {
|
||||
black: {
|
||||
current: '1.3.6.1.2.1.43.11.1.1.9.1.4',
|
||||
max: '1.3.6.1.2.1.43.11.1.1.8.1.4',
|
||||
model: '1.3.6.1.2.1.43.11.1.1.6.1.4'
|
||||
},
|
||||
cyan: {
|
||||
current: '1.3.6.1.2.1.43.11.1.1.9.1.1',
|
||||
max: '1.3.6.1.2.1.43.11.1.1.8.1.1',
|
||||
model: '1.3.6.1.2.1.43.11.1.1.6.1.1'
|
||||
},
|
||||
magenta: {
|
||||
current: '1.3.6.1.2.1.43.11.1.1.9.1.2',
|
||||
max: '1.3.6.1.2.1.43.11.1.1.8.1.2',
|
||||
model: '1.3.6.1.2.1.43.11.1.1.6.1.2'
|
||||
},
|
||||
yellow: {
|
||||
current: '1.3.6.1.2.1.43.11.1.1.9.1.3',
|
||||
max: '1.3.6.1.2.1.43.11.1.1.8.1.3',
|
||||
model: '1.3.6.1.2.1.43.11.1.1.6.1.3'
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
model: 'm2040dn',
|
||||
objectIds: {
|
||||
model: '1.3.6.1.2.1.25.3.2.1.3.1',
|
||||
serial: '1.3.6.1.2.1.43.5.1.1.17.1',
|
||||
counter: '1.3.6.1.4.1.1347.43.10.1.1.12.1.1',
|
||||
toners: {
|
||||
black: {
|
||||
current: '1.3.6.1.2.1.43.11.1.1.9.1.1',
|
||||
max: '1.3.6.1.2.1.43.11.1.1.8.1.1',
|
||||
model: '1.3.6.1.2.1.43.11.1.1.6.1.1'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
import snmp from 'net-snmp'
|
||||
|
||||
export class Printer {
|
||||
constructor(name: string, ip: string, model: PrinterModel) {
|
||||
|
@ -205,14 +143,14 @@ export class Printer {
|
|||
}
|
||||
|
||||
async getPrinterInfo(): Promise<PrinterInfo> {
|
||||
const session = snmp.createSession(this.ip, 'public')
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
const session = snmp.createSession(this.ip, 'public')
|
||||
session.get(this.oIDsArray(), (error, varbinds) => {
|
||||
const varbindsString = this.deBufferizeVarbinds(varbinds)
|
||||
const info = this.objectIDsToPrinterInfo(varbindsString)
|
||||
|
||||
resolve(info)
|
||||
session.close()
|
||||
})
|
||||
})
|
||||
}
|
||||
|
|
64
src/printerObjectIDConfigs.mts
Normal file
64
src/printerObjectIDConfigs.mts
Normal file
|
@ -0,0 +1,64 @@
|
|||
import { PrinterObjectIDConfig } from './types.mjs'
|
||||
|
||||
export const printerObjectIDConfigs: PrinterObjectIDConfig[] = [
|
||||
{
|
||||
model: 'm3655idn',
|
||||
objectIds: {
|
||||
model: '1.3.6.1.2.1.25.3.2.1.3.1',
|
||||
serial: '1.3.6.1.2.1.43.5.1.1.17.1',
|
||||
counter: '1.3.6.1.4.1.1347.43.10.1.1.12.1.1',
|
||||
toners: {
|
||||
black: {
|
||||
current: '1.3.6.1.2.1.43.11.1.1.9.1.1',
|
||||
max: '1.3.6.1.2.1.43.11.1.1.8.1.1',
|
||||
model: '1.3.6.1.2.1.43.11.1.1.6.1.1'
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
model: 'p6235cdn',
|
||||
objectIds: {
|
||||
model: '1.3.6.1.2.1.25.3.2.1.3.1',
|
||||
serial: '1.3.6.1.2.1.43.5.1.1.17.1',
|
||||
counter: '1.3.6.1.4.1.1347.43.10.1.1.12.1.1',
|
||||
toners: {
|
||||
black: {
|
||||
current: '1.3.6.1.2.1.43.11.1.1.9.1.4',
|
||||
max: '1.3.6.1.2.1.43.11.1.1.8.1.4',
|
||||
model: '1.3.6.1.2.1.43.11.1.1.6.1.4'
|
||||
},
|
||||
cyan: {
|
||||
current: '1.3.6.1.2.1.43.11.1.1.9.1.1',
|
||||
max: '1.3.6.1.2.1.43.11.1.1.8.1.1',
|
||||
model: '1.3.6.1.2.1.43.11.1.1.6.1.1'
|
||||
},
|
||||
magenta: {
|
||||
current: '1.3.6.1.2.1.43.11.1.1.9.1.2',
|
||||
max: '1.3.6.1.2.1.43.11.1.1.8.1.2',
|
||||
model: '1.3.6.1.2.1.43.11.1.1.6.1.2'
|
||||
},
|
||||
yellow: {
|
||||
current: '1.3.6.1.2.1.43.11.1.1.9.1.3',
|
||||
max: '1.3.6.1.2.1.43.11.1.1.8.1.3',
|
||||
model: '1.3.6.1.2.1.43.11.1.1.6.1.3'
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
model: 'm2040dn',
|
||||
objectIds: {
|
||||
model: '1.3.6.1.2.1.25.3.2.1.3.1',
|
||||
serial: '1.3.6.1.2.1.43.5.1.1.17.1',
|
||||
counter: '1.3.6.1.4.1.1347.43.10.1.1.12.1.1',
|
||||
toners: {
|
||||
black: {
|
||||
current: '1.3.6.1.2.1.43.11.1.1.9.1.1',
|
||||
max: '1.3.6.1.2.1.43.11.1.1.8.1.1',
|
||||
model: '1.3.6.1.2.1.43.11.1.1.6.1.1'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
Loading…
Reference in New Issue
Block a user