Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

example ts app #95

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
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
11 changes: 11 additions & 0 deletions example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Example App
Be sure to read the README in the root folder first.

# How-to
`pnpm i`

`pnpm start`

# Requirements
1. Node.js 19.0.0+
2. pnpm 9.0+ (different than root)
26 changes: 26 additions & 0 deletions example/example.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { HttpConnection } from "./dist";

const Connect = async () => {
console.log("Running...");
const connection = new HttpConnection();
await connection.connect({
address: "meshtastic.local",
fetchInterval: 2000,
tls: false,
});

connection.events.onMessagePacket.subscribe((packet) => {
onMessage(packet.from, packet.data);
});

connection.events.onPrivatePacket.subscribe((packet) => {
onMessage(packet.from, packet.data);
});
};

const onMessage = (sender, message) => {
console.log("Message from: " + sender);
console.log("Message was: " + String(message));
};

Connect();
22 changes: 22 additions & 0 deletions example/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "example",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "tsc && tsx example.ts"
},
"keywords": [],
"author": "",
"license": "GPL-3.0-only",
"type": "module",
"dependencies": {
"typescript": "^5.5.2"
},
"devDependencies": {
"tsx": "^4.16.0"
},
"engines": {
"node": ">=19.0.0"
}
}
30 changes: 30 additions & 0 deletions example/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"compilerOptions": {
"module": "NodeNext",
"moduleResolution": "NodeNext",
"target": "ESNext",
"inlineSourceMap": true,
"declaration": true,
"outDir": "./dist",
"strict": true,
"noImplicitAny": true,
"noImplicitThis": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedIndexedAccess": true,
"noPropertyAccessFromIndexSignature": true,
"strictBindCallApply": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"strictPropertyInitialization": true,
"forceConsistentCasingInFileNames": true,
"importHelpers": true,
"removeComments": false
},
"include": ["../src/**/*"],
"typedocOptions": {
"out": "docs"
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@meshtastic/js",
"version": "2.3.7-0",
"version": "2.3.8-0",
"description": "Browser library for interfacing with meshtastic devices",
"license": "GPL-3.0-only",
"scripts": {
Expand Down
Loading