0.6.1-beta • Published 8 months ago

@node-ocpp/core v0.6.1-beta

Weekly downloads
-
License
ISC
Repository
github
Last release
8 months ago

A Node.js-based library for implementing an OCPP Central System (CS) providing an intuitive syntax for sending & handling messages. Currently supports OCPP-J (JSON over WebSocket) and includes message type definitions for 1.6 Feature Profile 'Core'.

Usage example

import { WsEndpoint, ocpp16 } from '@node-ocpp/core';

const cs = new WsEndpoint({ authRequired: false });

cs.handle<ocpp16.BootNotificationRequest>('BootNotification', async data => ({
  currentTime: new Date(),
  status: 'Accepted',
  interval: 120,
}));

cs.on('client_connected', async session => {
  const response = await cs.send<ocpp16.RemoteStartTransactionRequest>(
    session.client.id,
    'RemoteStartTransaction',
    { idTag: '1234567890' }
  );
  console.dir(response);
});

cs.listen();

Configuration

KeyTypePurposeDefault
portnumberTCP port on which the application should listen8080 (development)80 (production)
hostnamestringHost name on which the application should listenlocalhost
routestringRoute which clients should connect to, appended by their individual CP id/ocpp
protocolsstring[]WebSocket subprotocol versions for which upgrade requests should be allowedocpp1.2 - ocpp2.0.1
actionsAllowedstring[]OCPP actions which the CS should allow to be sent/receivedActions for 1.6 Feature Profile 'Core'
maxConnectionsnumberMaximum number of clients which should be allowed to connect at the same time511
sessionTimeoutnumberTime in milliseconds after which a client session will be terminated if no further messages are received30000
authRequiredbooleanWhether connection attempts should be denied unless explicitly acceptedtrue
basicAuthbooleanWhether HTTP BASIC authentication mechanism should be allowed(Only secure in combination with HTTPS)true
certificateAuthbooleanWhether clients should be able to use SSL/TLS certificates for authentication(It is recommended to use an e.g. Nginx proxy for this purpose)false
validationbooleanWhether the contents of inbound & outbound messages should be validated against official JSON schemastrue