mesh-tools 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -11
- package/package.json +9 -6
- package/src/index.js +15 -2
package/README.md
CHANGED
|
@@ -1,35 +1,39 @@
|
|
|
1
1
|
# Mesh-Tools
|
|
2
2
|
|
|
3
|
-
This is a
|
|
3
|
+
This is a package made for use with the Meshtastic Project. I am not affiliated with or sponsored by Meshtastic. This project is just for fun. [Meshtastic](https://meshtastic.org)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
This package is currently deployed to npm!
|
|
6
|
+
|
|
7
|
+
### Download: [Mesh Tools NPM](https://www.npmjs.com/package/mesh-tools)
|
|
6
8
|
|
|
7
|
-
|
|
9
|
+
Use `npm i mesh-tools` to use in your project!
|
|
10
|
+
|
|
11
|
+
## Documentation
|
|
8
12
|
|
|
9
|
-
[
|
|
13
|
+
[Documentation](https://github.com/JStudios6118/Mesh-Tools/blob/main/docs/table-of-contents.md)
|
|
10
14
|
|
|
11
15
|
## What this package does #
|
|
12
16
|
This package is meant to abstract the functions of the meshtastic node.js cli package. It is meant to make the developement of programs that interact with the mesh network easier and more efficient.
|
|
13
17
|
|
|
14
|
-
This is a side project so don't expect this to always be up to date but I'll
|
|
18
|
+
This is a side project so don't expect this to always be up to date but I'll try my best.
|
|
15
19
|
|
|
16
|
-
It can easily handle connecting to nodes,
|
|
20
|
+
It can easily handle connecting to nodes, detect when someone has dmed you, sending dms, sending on channels, receiving on channels and more. All of the stuff you would ever want. It can even manage an optional Database of Nodes and store custom data for each node.
|
|
17
21
|
|
|
18
22
|
## How it works
|
|
19
23
|
|
|
20
|
-
I tried my best to abstract
|
|
24
|
+
I tried my best to abstract many of the Meshtastic CLI's functions.
|
|
21
25
|
|
|
22
26
|
Here is all of the code needed to connect to your node. It is much shorter than what would be needed if you were not using my package.
|
|
23
27
|
```js
|
|
24
|
-
// Import the package
|
|
25
|
-
const MeshTools = require('mesh-tools')
|
|
28
|
+
// Import the package. Install with npm i mesh-tools
|
|
29
|
+
const MeshTools = require('mesh-tools');
|
|
26
30
|
// Define the port your node is on over serial
|
|
27
31
|
const node = new MeshTools.SerialNode('/dev/ttyACM1');
|
|
28
32
|
// Connect the node to your computer
|
|
29
33
|
node.connect()
|
|
30
34
|
```
|
|
31
35
|
|
|
32
|
-
If
|
|
36
|
+
If you wanted to listen for a direct messages to your node, it is as easy as this chunk of code.
|
|
33
37
|
|
|
34
38
|
```js
|
|
35
39
|
// Connect to the receiveDm event
|
|
@@ -47,4 +51,4 @@ I made this because I was annoyed at how difficult it was to work with the nodej
|
|
|
47
51
|
|
|
48
52
|
Thanks for checking this out! Please give it a star :)
|
|
49
53
|
|
|
50
|
-
-JStudios6118
|
|
54
|
+
-JStudios6118
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mesh-tools",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "A helpful package for automating the Meshtastic node api",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "Josh Carlson",
|
|
@@ -9,7 +9,9 @@
|
|
|
9
9
|
"scripts": {
|
|
10
10
|
"test": "node test.js"
|
|
11
11
|
},
|
|
12
|
-
"engines": {
|
|
12
|
+
"engines": {
|
|
13
|
+
"node": ">=18.0.0"
|
|
14
|
+
},
|
|
13
15
|
"dependencies": {
|
|
14
16
|
"@meshtastic/core": "^2.6.7",
|
|
15
17
|
"@meshtastic/transport-http": "^0.2.5",
|
|
@@ -27,10 +29,11 @@
|
|
|
27
29
|
],
|
|
28
30
|
"repository": {
|
|
29
31
|
"type": "git",
|
|
30
|
-
"url": "https://github.com/JStudios6118/Mesh-Tools"
|
|
32
|
+
"url": "git+https://github.com/JStudios6118/Mesh-Tools.git"
|
|
31
33
|
},
|
|
32
34
|
"homepage": "https://github.com/JStudios6118/Mesh-Tools#readme",
|
|
33
35
|
"bugs": "https://github.com/JStudios6118/Mesh-Tools/issues",
|
|
34
|
-
"files": [
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
"files": [
|
|
37
|
+
"src"
|
|
38
|
+
]
|
|
39
|
+
}
|
package/src/index.js
CHANGED
|
@@ -16,15 +16,16 @@ const path = require('path');
|
|
|
16
16
|
|
|
17
17
|
TODO:
|
|
18
18
|
-ADD MESSAGE ACKNOWLEDGEMENT HANDLING
|
|
19
|
-
-ADD TCP AND HTTP CONNECTION TYPES
|
|
20
19
|
-MAKE EVERYTHING ASYNCHRONOUS
|
|
21
20
|
-ADD LOG LEVELS
|
|
22
|
-
-ADD SUPPORT FOR
|
|
21
|
+
-ADD SUPPORT FOR MORE PACKET TYPES LIKE TELEMETRY AND ETC
|
|
23
22
|
-ADD PROPER JSDOC DOCUMENTATION FOR AUTOFILL AND SUCH
|
|
23
|
+
-ADD PROPER ERROR HANDLING FOR ALL FUNCTIONS
|
|
24
24
|
|
|
25
25
|
DONE:
|
|
26
26
|
-ADD BROADCAST MESSAGING
|
|
27
27
|
-ADD A NODE DATABASE BUILDER
|
|
28
|
+
-ADD TCP AND HTTP CONNECTION TYPES
|
|
28
29
|
|
|
29
30
|
*/
|
|
30
31
|
|
|
@@ -177,6 +178,18 @@ class NodeDB {
|
|
|
177
178
|
return true;
|
|
178
179
|
}
|
|
179
180
|
|
|
181
|
+
async updateLastHeard(identifier){
|
|
182
|
+
if (this.#db === null) { this.#logger.log("Database has not been initialized yet!"); return false }
|
|
183
|
+
|
|
184
|
+
const index = this.#checkId(identifier);
|
|
185
|
+
if (index === -1) { this.#logger.log("Node not found!"); return false }
|
|
186
|
+
|
|
187
|
+
this.#dbData.nodes[index].lastHeard = Math.floor(Date.now() / 1000);
|
|
188
|
+
|
|
189
|
+
await this.#db.write;
|
|
190
|
+
return true;
|
|
191
|
+
}
|
|
192
|
+
|
|
180
193
|
}
|
|
181
194
|
|
|
182
195
|
// Node class for NodeDB
|