@evpower/ocpp-ts
Version:
OCPP 1.6: Open Charge Point Protocol
22 lines (19 loc) • 778 B
text/typescript
import {
OcppServer, OcppClientConnection, BootNotificationRequest, BootNotificationResponse,
} from '../src';
const centralSystemSimple = new OcppServer(30000);
centralSystemSimple.listen(9220);
centralSystemSimple.on('connection', (client: OcppClientConnection) => {
console.log(`Client ${client.getCpId()} connected`);
client.on('close', (code: number, reason: Buffer) => {
console.log(`Client ${client.getCpId()} closed connection`, code, reason.toString());
});
client.on('BootNotification', (request: BootNotificationRequest, cb: (response: BootNotificationResponse) => void) => {
const response: BootNotificationResponse = {
status: 'Accepted',
currentTime: new Date().toISOString(),
interval: 60,
};
cb(response);
});
});