Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Configure env variables:
```
WS_URL - websocket endpoint
CP_ID - ID of this VCP
CP_USERNAME - if used for OCPP Authentication, defaults to CP_ID if only PASSWORD defined
PASSWORD - if used for OCPP Authentication, otherwise can be left blank
```

Expand Down
1 change: 1 addition & 0 deletions index_16.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const vcp = new VCP({
endpoint: process.env["WS_URL"] ?? "ws://localhost:3000",
chargePointId: process.env["CP_ID"] ?? "123456",
ocppVersion: OcppVersion.OCPP_1_6,
basicAuthUsername: process.env["CP_USERNAME"] ?? undefined,
basicAuthPassword: process.env["PASSWORD"] ?? undefined,
adminWsPort: parseInt(
process.env["ADMIN_PORT"] ?? "9999"
Expand Down
1 change: 1 addition & 0 deletions index_201.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const vcp = new VCP({
endpoint: process.env["WS_URL"] ?? "ws://localhost:3000",
chargePointId: process.env["CP_ID"] ?? "123456",
ocppVersion: OcppVersion.OCPP_2_0_1,
basicAuthUsername: process.env["CP_USERNAME"] ?? undefined,
basicAuthPassword: process.env["PASSWORD"] ?? undefined,
adminWsPort: parseInt(process.env["ADMIN_WS_PORT"] ?? "9999"),
});
Expand Down
3 changes: 2 additions & 1 deletion src/vcp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ interface VCPOptions {
ocppVersion: OcppVersion;
endpoint: string;
chargePointId: string;
basicAuthUsername?: string;
basicAuthPassword?: string;
adminWsPort?: number;
}
Expand Down Expand Up @@ -54,7 +55,7 @@ export class VCP {
this.ws = new WebSocket(websocketUrl, [protocol], {
rejectUnauthorized: false,
auth: this.vcpOptions.basicAuthPassword
? `${this.vcpOptions.chargePointId}:${this.vcpOptions.basicAuthPassword}`
? `${this.vcpOptions.basicAuthUsername || this.vcpOptions.chargePointId}:${this.vcpOptions.basicAuthPassword}`
: undefined,
followRedirects: true,
});
Expand Down