@stoprocent/bleno 0.10.2 → 0.10.4
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 +2 -13
- package/lib/bleno.js +4 -4
- package/lib/hci-socket/gatt.js +23 -11
- package/package.json +2 -2
- package/prebuilds/darwin-x64+arm64/@stoprocent+bleno.node +0 -0
- package/prebuilds/win32-ia32/@stoprocent+bleno.node +0 -0
- package/prebuilds/win32-x64/@stoprocent+bleno.node +0 -0
- package/FUNDING.yml +0 -15
package/README.md
CHANGED
|
@@ -1,18 +1,7 @@
|
|
|
1
1
|
# bleno
|
|
2
2
|
|
|
3
|
-
[
|
|
8
|
-
[](MIT)
|
|
11
|
-
[](
|
|
14
|
-
https://www.npmjs.com/package/@stoprocent/bleno
|
|
15
|
-
)
|
|
3
|
+
[](https://www.npmjs.com/package/@stoprocent/bleno)
|
|
4
|
+
[](https://www.npmjs.com/package/@stoprocent/bleno)
|
|
16
5
|
|
|
17
6
|
A Node.js module for implementing BLE (Bluetooth Low Energy) peripherals.
|
|
18
7
|
|
package/lib/bleno.js
CHANGED
|
@@ -76,11 +76,11 @@ class Bleno extends EventEmitter {
|
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
async waitForPoweredOnAsync (timeout = 10000) {
|
|
79
|
-
if (this.state === 'poweredOn') {
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
79
|
return new Promise((resolve, reject) => {
|
|
80
|
+
if (this.state === 'poweredOn') {
|
|
81
|
+
resolve();
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
84
|
const timeoutId = setTimeout(() => {
|
|
85
85
|
this.removeListener('stateChange', stateChangeHandler);
|
|
86
86
|
reject(new Error(`Timeout waiting for poweredOn state. Current state: ${this.state}`));
|
package/lib/hci-socket/gatt.js
CHANGED
|
@@ -5,6 +5,7 @@ const debug = require('debug')('gatt');
|
|
|
5
5
|
|
|
6
6
|
const { EventEmitter } = require('events');
|
|
7
7
|
const os = require('os');
|
|
8
|
+
const Characteristic = require('../characteristic');
|
|
8
9
|
|
|
9
10
|
const ATT_OP_ERROR = 0x01;
|
|
10
11
|
const ATT_OP_MTU_REQ = 0x02;
|
|
@@ -103,32 +104,34 @@ class Gatt extends EventEmitter {
|
|
|
103
104
|
{
|
|
104
105
|
uuid: '1800',
|
|
105
106
|
characteristics: [
|
|
106
|
-
{
|
|
107
|
+
new Characteristic({
|
|
107
108
|
uuid: '2a00',
|
|
108
109
|
properties: ['read'],
|
|
109
110
|
secure: [],
|
|
110
111
|
value: Buffer.from(this._name),
|
|
111
112
|
descriptors: []
|
|
112
|
-
},
|
|
113
|
-
{
|
|
113
|
+
}),
|
|
114
|
+
new Characteristic({
|
|
114
115
|
uuid: '2a01',
|
|
115
116
|
properties: ['read'],
|
|
116
117
|
secure: [],
|
|
117
118
|
value: Buffer.from([0x80, 0x00]),
|
|
118
119
|
descriptors: []
|
|
119
|
-
}
|
|
120
|
+
})
|
|
120
121
|
]
|
|
121
122
|
},
|
|
122
123
|
{
|
|
123
124
|
uuid: '1801',
|
|
124
125
|
characteristics: [
|
|
125
|
-
{
|
|
126
|
+
new Characteristic({
|
|
126
127
|
uuid: '2a05',
|
|
127
128
|
properties: ['indicate'],
|
|
128
129
|
secure: [],
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
130
|
+
descriptors: [],
|
|
131
|
+
onIndicate: function (connection) {
|
|
132
|
+
this.notify(connection, Buffer.from([0x00, 0x00, 0x00, 0x00]));
|
|
133
|
+
}
|
|
134
|
+
})
|
|
132
135
|
]
|
|
133
136
|
}
|
|
134
137
|
].concat(services);
|
|
@@ -743,7 +746,7 @@ class Gatt extends EventEmitter {
|
|
|
743
746
|
if (!data && this._handles[valueHandle].uuid === '2902' && this._connections.get(connection)) {
|
|
744
747
|
data = Buffer.from([0x00, 0x00]);
|
|
745
748
|
}
|
|
746
|
-
|
|
749
|
+
|
|
747
750
|
if (data) {
|
|
748
751
|
callback(ATT_ECODE_SUCCESS, data);
|
|
749
752
|
} else if (handleAttribute) {
|
|
@@ -777,7 +780,7 @@ class Gatt extends EventEmitter {
|
|
|
777
780
|
return function (result, data) {
|
|
778
781
|
let callbackResponse;
|
|
779
782
|
const { mtu } = this._connections.get(connection);
|
|
780
|
-
|
|
783
|
+
|
|
781
784
|
if (ATT_ECODE_SUCCESS === result) {
|
|
782
785
|
const dataLength = Math.min(data.length, mtu - 1);
|
|
783
786
|
callbackResponse = Buffer.alloc(1 + dataLength);
|
|
@@ -824,7 +827,16 @@ class Gatt extends EventEmitter {
|
|
|
824
827
|
if (handleSecure & 0x02 && !this._connections.get(connection).aclStream.encrypted) {
|
|
825
828
|
result = ATT_ECODE_AUTHENTICATION;
|
|
826
829
|
} else {
|
|
827
|
-
|
|
830
|
+
if (handle.values && handle.values.has(connection)) {
|
|
831
|
+
data = handle.values.get(connection);
|
|
832
|
+
}
|
|
833
|
+
else {
|
|
834
|
+
data = handle.value;
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
if (!data && handle.uuid === '2902' && this._connections.get(connection)) {
|
|
838
|
+
data = Buffer.from([0x00, 0x00]);
|
|
839
|
+
}
|
|
828
840
|
|
|
829
841
|
if (data) {
|
|
830
842
|
result = ATT_ECODE_SUCCESS;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stoprocent/bleno",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.4",
|
|
4
4
|
"description": "A Node.js module for implementing BLE (Bluetooth Low Energy) peripherals",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"types": "./index.d.ts",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"node-gyp-build": "^4.8.4"
|
|
70
70
|
},
|
|
71
71
|
"optionalDependencies": {
|
|
72
|
-
"@stoprocent/bluetooth-hci-socket": "^2.
|
|
72
|
+
"@stoprocent/bluetooth-hci-socket": "^2.2.0"
|
|
73
73
|
},
|
|
74
74
|
"publishConfig": {
|
|
75
75
|
"access": "public"
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/FUNDING.yml
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
# These are supported funding model platforms
|
|
2
|
-
|
|
3
|
-
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
|
|
4
|
-
patreon: # Replace with a single Patreon username
|
|
5
|
-
open_collective: # Replace with a single Open Collective username
|
|
6
|
-
ko_fi: # Replace with a single Ko-fi username
|
|
7
|
-
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
|
8
|
-
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
|
9
|
-
liberapay: # Replace with a single Liberapay username
|
|
10
|
-
issuehunt: # Replace with a single IssueHunt username
|
|
11
|
-
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
|
|
12
|
-
polar: # Replace with a single Polar username
|
|
13
|
-
buy_me_a_coffee: stoprocent # Replace with a single Buy Me a Coffee username
|
|
14
|
-
thanks_dev: # Replace with a single thanks.dev username
|
|
15
|
-
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|