bt-sensors-plugin-sk 1.3.8-beta2 → 1.3.8-beta3
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 +1 -1
- package/package.json +1 -1
- package/sensor_classes/SensorPush.js +23 -6
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bt-sensors-plugin-sk",
|
|
3
|
-
"version": "1.3.8-
|
|
3
|
+
"version": "1.3.8-beta3",
|
|
4
4
|
"description": "Bluetooth Sensors for Signalk - see https://www.npmjs.com/package/bt-sensors-plugin-sk#supported-sensors for a list of supported sensors",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"dependencies": {
|
|
@@ -16,6 +16,7 @@ class SensorPush extends BTSensor{
|
|
|
16
16
|
static ServiceUUID = "EF090000-11D6-42BA-93B8-9DD7EC090AB0"
|
|
17
17
|
static Characteristics =
|
|
18
18
|
{
|
|
19
|
+
|
|
19
20
|
tx: "EF090003-11D6-42BA-93B8-9DD7EC090AA9",
|
|
20
21
|
adv: "EF090005-11D6-42BA-93B8-9DD7EC090AA9",
|
|
21
22
|
batt: "EF090007-11D6-42BA-93B8-9DD7EC090AA9",
|
|
@@ -32,10 +33,19 @@ class SensorPush extends BTSensor{
|
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
async emitGATT(){
|
|
36
|
+
await this.characteristics.temp.writeValue(Buffer.from([1,0,0,0]))
|
|
37
|
+
|
|
35
38
|
this.emitData("temp", await this.characteristics.temp.readValue())
|
|
39
|
+
|
|
40
|
+
await this.characteristics.hum.writeValue(Buffer.from([1,0,0,0]))
|
|
36
41
|
this.emitData("humidity", await this.characteristics.hum.readValue())
|
|
42
|
+
|
|
37
43
|
this.emitData("batt", await this.characteristics.batt.readValue())
|
|
38
|
-
|
|
44
|
+
|
|
45
|
+
if (this.characteristics.bar){
|
|
46
|
+
await this.characteristics.bar.writeValue(Buffer.from([1,0,0,0]))
|
|
47
|
+
this.emitData("pressure", await this.characteristics.bar.readValue())
|
|
48
|
+
}
|
|
39
49
|
}
|
|
40
50
|
|
|
41
51
|
initSchema(){
|
|
@@ -84,7 +94,7 @@ class SensorPush extends BTSensor{
|
|
|
84
94
|
.read=(buffer)=>{ return buffer.readUInt16LE()/1000}
|
|
85
95
|
|
|
86
96
|
this.addDefaultPath("temp","environment.temperature")
|
|
87
|
-
.read=(buffer)=>{ return buffer.readInt32LE()/100}
|
|
97
|
+
.read=(buffer)=>{ return 273.15+(buffer.readInt32LE()/100)}
|
|
88
98
|
|
|
89
99
|
this.addDefaultPath("humidity","environment.humidity")
|
|
90
100
|
.read=(buffer)=>{ return buffer.readInt32LE()/10000}
|
|
@@ -118,13 +128,20 @@ class SensorPush extends BTSensor{
|
|
|
118
128
|
const service = await gattServer.getPrimaryService(this.constructor.ServiceUUID.toLowerCase())
|
|
119
129
|
this.characteristics={}
|
|
120
130
|
for (const c in this.constructor.Characteristics) {
|
|
121
|
-
|
|
131
|
+
const uuid = this.constructor.Characteristics[c].toLowerCase()
|
|
132
|
+
try{
|
|
133
|
+
this.characteristics[c] = await service.getCharacteristic(uuid)
|
|
134
|
+
} catch (e) {
|
|
135
|
+
this.debug(`characteristic ${c} with uuid ${uuid} not available.`)
|
|
136
|
+
}
|
|
122
137
|
}
|
|
123
|
-
if (this.tx)
|
|
138
|
+
if (this.tx && this.characteristics.tx)
|
|
124
139
|
await writeInt8(this.characteristics.tx,this.tx)
|
|
125
|
-
|
|
140
|
+
|
|
141
|
+
if (this.LED && this.characteristics.LED)
|
|
126
142
|
await writeUInt8(this.characteristics.LED,this.LED)
|
|
127
|
-
|
|
143
|
+
|
|
144
|
+
if (this.adv && this.characteristics.adv)
|
|
128
145
|
await writeUInt16LE(this.characteristics.adv,Math.round((this.adv/625)*1000))
|
|
129
146
|
}
|
|
130
147
|
async initGATTNotifications() {
|