@stoprocent/bleno 0.10.2 → 0.10.3
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/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
|
Binary file
|
|
Binary file
|
|
Binary file
|