browser-ocpp-client
TypeScript icon, indicating that this package has built-in type declarations

0.3.1 • Public • Published

OCPP 1.6 client for browsers

This is a modified version of ocpp-ts focused on working in the browser.

Installation

npm install --save-dev browser-ocpp-client

Usage

import {
  BootNotificationRequest,
  BootNotificationResponse,
  OcppBrowserClient, OcppError,
} from 'browser-ocpp-client';

const chargingPointSimple = new OcppClient('CP1111');
chargingPointSimple.on('error', (err: Error) => {
  console.log(err.message);
});
chargingPointSimple.on('close', () => {
  console.log('Connection closed');
});

chargingPointSimple.on('connect', async () => {
  const boot: BootNotificationRequest = {
    chargePointVendor: 'eParking',
    chargePointModel: 'NECU-T2',
  };

  try {
    const bootResp: BootNotificationResponse = await chargingPointSimple.callRequest('BootNotification', boot);
    if (bootResp.status === 'Accepted') {
      console.log('Bootnotification accepted');
    }
  } catch (e) {
    if (e instanceof Error || e instanceof OcppError) {
      console.error(e.message);
    }
  }
});
chargingPointSimple.connect('ws://localhost:9220/');

Package Sidebar

Install

npm i browser-ocpp-client

Weekly Downloads

3

Version

0.3.1

License

MIT

Unpacked Size

221 kB

Total Files

149

Last publish

Collaborators

  • suda