mirror of
https://github.com/meshcore-dev/meshcore.js.git
synced 2026-04-20 22:13:49 +00:00
add example to readme
This commit is contained in:
parent
600e667eed
commit
540baec4b9
1 changed files with 40 additions and 0 deletions
40
README.md
40
README.md
|
|
@ -6,6 +6,46 @@ This library can be used in a Web Browser to connect to MeshCore Companion devic
|
|||
|
||||
It can also be used in NodeJS to connect to MeshCore Companion devices over TCP/WiFi.
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
npm install @liamcottle/meshcore.js
|
||||
```
|
||||
|
||||
## Simple Example
|
||||
|
||||
```
|
||||
import { TCPConnection } from "@liamcottle/meshcore.js";
|
||||
|
||||
// create tcp connection
|
||||
// tcp connections are supported by "Heltec_v3_companion_radio_wifi"
|
||||
const connection = new TCPConnection("10.1.0.226", 5000);
|
||||
|
||||
// wait until connected
|
||||
connection.on("connected", async () => {
|
||||
|
||||
// we are now connected
|
||||
console.log("connected!");
|
||||
|
||||
// log contacts
|
||||
const contacts = await connection.getContacts();
|
||||
for(const contact of contacts) {
|
||||
console.log(`Contact: ${contact.advName}`);
|
||||
}
|
||||
|
||||
// disconnect
|
||||
connection.close();
|
||||
|
||||
});
|
||||
|
||||
// connect to meshcore device
|
||||
await connection.connect();
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
There's a few other examples scripts in the [examples](./examples) folder.
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue