-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathebyte-mesh.js
46 lines (37 loc) · 1022 Bytes
/
ebyte-mesh.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
http://www.ebyte.com/product-view-news.aspx?id=606
*/
import {SerialMesh} from "../res/serial-ebyte.js";
var client = new SerialMesh();
console.log("--open ebyte okey--");
// open connection to a serial port
client.connectDevice("/dev/ttyUSB0", { baudRate: 115200 }, read);
function read() {
console.log("--open uart okey--");
client.readVersion(1)
.then(function (t){
console.log("readVersion: " +t.value);
return client.readAppkey(2);
})
.then(function (t){
console.log("readAppkey: " +t.value);
return client.readNetID(2);
})
.then(function (t){
console.log("readNetID: " +t.value);
return client.readAddress(2);
})
.then(function (t){
console.log("readAddress: " +t.value);
return client.readPower(2);
})
.then(function (t){
console.log("readPower: " +t.value);
return client.joinNet(2);
})
.then(function (t){
console.log("joinNet: " +t.value);
//return client.joinNet(2);
})
}
const sleep = (ms) => new Promise(resolve => os.setTimeout(resolve,ms));