-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* client test * add test client * add client with auth * use station2 for the test * add hello message * Update SVG dimensions in Architecture.svg
- Loading branch information
Showing
8 changed files
with
344 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
lerna-debug.log* | ||
.pnpm-debug.log* | ||
|
||
# Diagnostic reports (https://nodejs.org/api/report.html) | ||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
*.lcov | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
bower_components | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (https://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules/ | ||
jspm_packages/ | ||
|
||
# Snowpack dependency directory (https://snowpack.dev/) | ||
web_modules/ | ||
|
||
# TypeScript cache | ||
*.tsbuildinfo | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Optional stylelint cache | ||
.stylelintcache | ||
|
||
# Microbundle cache | ||
.rpt2_cache/ | ||
.rts2_cache_cjs/ | ||
.rts2_cache_es/ | ||
.rts2_cache_umd/ | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# dotenv environment variable files | ||
.env | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
.env.local | ||
|
||
# parcel-bundler cache (https://parceljs.org/) | ||
.cache | ||
.parcel-cache | ||
|
||
# Next.js build output | ||
.next | ||
out | ||
|
||
# Nuxt.js build / generate output | ||
.nuxt | ||
dist | ||
|
||
# Gatsby files | ||
.cache/ | ||
# Comment in the public line in if your project uses Gatsby and not Next.js | ||
# https://nextjs.org/blog/next-9-1#public-directory-support | ||
# public | ||
|
||
# vuepress build output | ||
.vuepress/dist | ||
|
||
# vuepress v2.x temp and cache directory | ||
.temp | ||
.cache | ||
|
||
# Docusaurus cache and generated files | ||
.docusaurus | ||
|
||
# Serverless directories | ||
.serverless/ | ||
|
||
# FuseBox cache | ||
.fusebox/ | ||
|
||
# DynamoDB Local files | ||
.dynamodb/ | ||
|
||
# TernJS port file | ||
.tern-port | ||
|
||
# Stores VSCode versions used for testing VSCode extensions | ||
.vscode-test | ||
|
||
# yarn v2 | ||
.yarn/cache | ||
.yarn/unplugged | ||
.yarn/build-state.yml | ||
.yarn/install-state.gz | ||
.pnp.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
const WebSocket = require('ws'); | ||
|
||
// get server address from the console | ||
const serverAddress = process.argv[2]; | ||
// get station name from the console | ||
const stationName = process.argv[3]; | ||
// get station password from the console | ||
const stationPassword = process.argv[4]; | ||
|
||
const wsOptions= { | ||
rejectUnauthorized: false, | ||
headers: { | ||
'Authorization': 'Basic ' + Buffer.from(stationName + ':' + stationPassword).toString('base64') | ||
} | ||
}; | ||
// use websocket to connect to the server | ||
const ws = new WebSocket(serverAddress+`/OCPP/${stationName}`, 'ocpp1.6', wsOptions); | ||
// read user input from the console | ||
const readline = require('readline').createInterface({ | ||
input: process.stdin, | ||
output: process.stdout | ||
}); | ||
|
||
|
||
|
||
// when the connection is established | ||
ws.on('open', function open() { | ||
// send the station name and password to the server | ||
console.log("Connected to the server"); | ||
ws.send(`Hello! I'm ${stationName}.`); | ||
}); | ||
|
||
// when the server sends a message | ||
ws.on('message', function incoming(data) { | ||
//convert binary data to string | ||
const message = data.toString('utf8'); | ||
// print the message to the console | ||
console.log(message); | ||
}); | ||
|
||
// when the user types a message | ||
readline.on('line', (input) => { | ||
// send the message to the server | ||
ws.send(input); | ||
}); | ||
|
||
// when the connection is closed | ||
ws.on('close', function close() { | ||
console.log('disconnected'); | ||
// close the console | ||
readline.close(); | ||
}); | ||
|
||
// wait for the user to close the console | ||
readline.on('close', () => { | ||
// close the websocket connection | ||
ws.close(); | ||
}); | ||
|
||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"name": "ocpp-client", | ||
"version": "0.0.1-alpha", | ||
"description": "A test OCPP protocol client", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+ssh://[email protected]/jmservera/miscdemos.git" | ||
}, | ||
"keywords": [ | ||
"OCPP", | ||
"Azure", | ||
"Web", | ||
"PubSub" | ||
], | ||
"author": "jmservera", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/jmservera/miscdemos/issues" | ||
}, | ||
"homepage": "https://github.com/jmservera/miscdemos#readme", | ||
"dependencies": { | ||
"ws": "^8.18.0" | ||
} | ||
} |
Oops, something went wrong.