@iotize/device-com-nfc.cordova 3.2.4 → 3.3.0
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.
|
@@ -1,558 +1,761 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@iotize/common/byte-converter'), require('@iotize/tap/protocol/api'), require('@iotize/tap/protocol/core'), require('rxjs'), require('@iotize/common/debug')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define('@iotize/device-com-nfc.cordova', ['exports', '@iotize/common/byte-converter', '@iotize/tap/protocol/api', '@iotize/tap/protocol/core', 'rxjs', '@iotize/common/debug'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.iotize = global.iotize || {}, global.iotize["device-com-nfc"] = global.iotize["device-com-nfc"] || {}, global.iotize["device-com-nfc"].cordova = {}), global.byteConverter, global.api, global.core, global.rxjs, global.debug$1));
|
|
5
5
|
})(this, (function (exports, byteConverter, api, core, rxjs, debug$1) { 'use strict';
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
10
|
-
this file except in compliance with the License. You may obtain a copy of the
|
|
11
|
-
License at http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
/******************************************************************************
|
|
8
|
+
Copyright (c) Microsoft Corporation.
|
|
12
9
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
|
16
|
-
MERCHANTABLITY OR NON-INFRINGEMENT.
|
|
10
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
11
|
+
purpose with or without fee is hereby granted.
|
|
17
12
|
|
|
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
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
14
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
15
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
16
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
17
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
18
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
19
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
20
|
+
***************************************************************************** */
|
|
21
|
+
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
22
|
+
var extendStatics = function (d, b) {
|
|
23
|
+
extendStatics = Object.setPrototypeOf ||
|
|
24
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
25
|
+
function (d, b) { for (var p in b)
|
|
26
|
+
if (Object.prototype.hasOwnProperty.call(b, p))
|
|
27
|
+
d[p] = b[p]; };
|
|
28
|
+
return extendStatics(d, b);
|
|
29
|
+
};
|
|
30
|
+
function __extends(d, b) {
|
|
31
|
+
if (typeof b !== "function" && b !== null)
|
|
32
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
33
|
+
extendStatics(d, b);
|
|
34
|
+
function __() { this.constructor = d; }
|
|
35
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
36
|
+
}
|
|
37
|
+
var __assign = function () {
|
|
38
|
+
__assign = Object.assign || function __assign(t) {
|
|
39
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
40
|
+
s = arguments[i];
|
|
41
|
+
for (var p in s)
|
|
42
|
+
if (Object.prototype.hasOwnProperty.call(s, p))
|
|
43
|
+
t[p] = s[p];
|
|
44
|
+
}
|
|
45
|
+
return t;
|
|
46
|
+
};
|
|
47
|
+
return __assign.apply(this, arguments);
|
|
48
|
+
};
|
|
49
|
+
function __rest(s, e) {
|
|
50
|
+
var t = {};
|
|
51
|
+
for (var p in s)
|
|
52
|
+
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
53
|
+
t[p] = s[p];
|
|
54
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
55
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
56
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
57
|
+
t[p[i]] = s[p[i]];
|
|
58
|
+
}
|
|
59
|
+
return t;
|
|
60
|
+
}
|
|
61
|
+
function __decorate(decorators, target, key, desc) {
|
|
62
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
63
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
64
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
65
|
+
else
|
|
66
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
67
|
+
if (d = decorators[i])
|
|
68
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
69
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
70
|
+
}
|
|
71
|
+
function __param(paramIndex, decorator) {
|
|
72
|
+
return function (target, key) { decorator(target, key, paramIndex); };
|
|
73
|
+
}
|
|
74
|
+
function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
75
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function")
|
|
76
|
+
throw new TypeError("Function expected"); return f; }
|
|
77
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
78
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
79
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
80
|
+
var _, done = false;
|
|
81
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
82
|
+
var context = {};
|
|
83
|
+
for (var p in contextIn)
|
|
84
|
+
context[p] = p === "access" ? {} : contextIn[p];
|
|
85
|
+
for (var p in contextIn.access)
|
|
86
|
+
context.access[p] = contextIn.access[p];
|
|
87
|
+
context.addInitializer = function (f) { if (done)
|
|
88
|
+
throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
89
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
90
|
+
if (kind === "accessor") {
|
|
91
|
+
if (result === void 0)
|
|
92
|
+
continue;
|
|
93
|
+
if (result === null || typeof result !== "object")
|
|
94
|
+
throw new TypeError("Object expected");
|
|
95
|
+
if (_ = accept(result.get))
|
|
96
|
+
descriptor.get = _;
|
|
97
|
+
if (_ = accept(result.set))
|
|
98
|
+
descriptor.set = _;
|
|
99
|
+
if (_ = accept(result.init))
|
|
100
|
+
initializers.unshift(_);
|
|
101
|
+
}
|
|
102
|
+
else if (_ = accept(result)) {
|
|
103
|
+
if (kind === "field")
|
|
104
|
+
initializers.unshift(_);
|
|
105
|
+
else
|
|
106
|
+
descriptor[key] = _;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
if (target)
|
|
110
|
+
Object.defineProperty(target, contextIn.name, descriptor);
|
|
111
|
+
done = true;
|
|
112
|
+
}
|
|
113
|
+
;
|
|
114
|
+
function __runInitializers(thisArg, initializers, value) {
|
|
115
|
+
var useValue = arguments.length > 2;
|
|
116
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
117
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
118
|
+
}
|
|
119
|
+
return useValue ? value : void 0;
|
|
120
|
+
}
|
|
121
|
+
;
|
|
122
|
+
function __propKey(x) {
|
|
123
|
+
return typeof x === "symbol" ? x : "".concat(x);
|
|
124
|
+
}
|
|
125
|
+
;
|
|
126
|
+
function __setFunctionName(f, name, prefix) {
|
|
127
|
+
if (typeof name === "symbol")
|
|
128
|
+
name = name.description ? "[".concat(name.description, "]") : "";
|
|
129
|
+
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
|
|
130
|
+
}
|
|
131
|
+
;
|
|
132
|
+
function __metadata(metadataKey, metadataValue) {
|
|
133
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
134
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
135
|
+
}
|
|
136
|
+
function __awaiter$1(thisArg, _arguments, P, generator) {
|
|
137
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
138
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
139
|
+
function fulfilled(value) { try {
|
|
140
|
+
step(generator.next(value));
|
|
141
|
+
}
|
|
142
|
+
catch (e) {
|
|
143
|
+
reject(e);
|
|
144
|
+
} }
|
|
145
|
+
function rejected(value) { try {
|
|
146
|
+
step(generator["throw"](value));
|
|
147
|
+
}
|
|
148
|
+
catch (e) {
|
|
149
|
+
reject(e);
|
|
150
|
+
} }
|
|
151
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
152
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
function __generator(thisArg, body) {
|
|
156
|
+
var _ = { label: 0, sent: function () { if (t[0] & 1)
|
|
157
|
+
throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
158
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
|
|
159
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
160
|
+
function step(op) {
|
|
161
|
+
if (f)
|
|
162
|
+
throw new TypeError("Generator is already executing.");
|
|
163
|
+
while (g && (g = 0, op[0] && (_ = 0)), _)
|
|
164
|
+
try {
|
|
165
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
|
|
166
|
+
return t;
|
|
167
|
+
if (y = 0, t)
|
|
168
|
+
op = [op[0] & 2, t.value];
|
|
169
|
+
switch (op[0]) {
|
|
170
|
+
case 0:
|
|
171
|
+
case 1:
|
|
172
|
+
t = op;
|
|
173
|
+
break;
|
|
174
|
+
case 4:
|
|
175
|
+
_.label++;
|
|
176
|
+
return { value: op[1], done: false };
|
|
177
|
+
case 5:
|
|
178
|
+
_.label++;
|
|
179
|
+
y = op[1];
|
|
180
|
+
op = [0];
|
|
181
|
+
continue;
|
|
182
|
+
case 7:
|
|
183
|
+
op = _.ops.pop();
|
|
184
|
+
_.trys.pop();
|
|
185
|
+
continue;
|
|
186
|
+
default:
|
|
187
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
188
|
+
_ = 0;
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
191
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
|
|
192
|
+
_.label = op[1];
|
|
193
|
+
break;
|
|
194
|
+
}
|
|
195
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
196
|
+
_.label = t[1];
|
|
197
|
+
t = op;
|
|
198
|
+
break;
|
|
199
|
+
}
|
|
200
|
+
if (t && _.label < t[2]) {
|
|
201
|
+
_.label = t[2];
|
|
202
|
+
_.ops.push(op);
|
|
203
|
+
break;
|
|
204
|
+
}
|
|
205
|
+
if (t[2])
|
|
206
|
+
_.ops.pop();
|
|
207
|
+
_.trys.pop();
|
|
208
|
+
continue;
|
|
209
|
+
}
|
|
210
|
+
op = body.call(thisArg, _);
|
|
211
|
+
}
|
|
212
|
+
catch (e) {
|
|
213
|
+
op = [6, e];
|
|
214
|
+
y = 0;
|
|
215
|
+
}
|
|
216
|
+
finally {
|
|
217
|
+
f = t = 0;
|
|
218
|
+
}
|
|
219
|
+
if (op[0] & 5)
|
|
220
|
+
throw op[1];
|
|
221
|
+
return { value: op[0] ? op[1] : void 0, done: true };
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
var __createBinding = Object.create ? (function (o, m, k, k2) {
|
|
225
|
+
if (k2 === undefined)
|
|
226
|
+
k2 = k;
|
|
227
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
228
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
229
|
+
desc = { enumerable: true, get: function () { return m[k]; } };
|
|
230
|
+
}
|
|
231
|
+
Object.defineProperty(o, k2, desc);
|
|
232
|
+
}) : (function (o, m, k, k2) {
|
|
233
|
+
if (k2 === undefined)
|
|
234
|
+
k2 = k;
|
|
235
|
+
o[k2] = m[k];
|
|
236
|
+
});
|
|
237
|
+
function __exportStar(m, o) {
|
|
238
|
+
for (var p in m)
|
|
239
|
+
if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
|
|
240
|
+
__createBinding(o, m, p);
|
|
241
|
+
}
|
|
242
|
+
function __values(o) {
|
|
243
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
244
|
+
if (m)
|
|
245
|
+
return m.call(o);
|
|
246
|
+
if (o && typeof o.length === "number")
|
|
247
|
+
return {
|
|
248
|
+
next: function () {
|
|
249
|
+
if (o && i >= o.length)
|
|
250
|
+
o = void 0;
|
|
251
|
+
return { value: o && o[i++], done: !o };
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
255
|
+
}
|
|
256
|
+
function __read(o, n) {
|
|
257
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
258
|
+
if (!m)
|
|
259
|
+
return o;
|
|
260
|
+
var i = m.call(o), r, ar = [], e;
|
|
261
|
+
try {
|
|
262
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
|
|
263
|
+
ar.push(r.value);
|
|
264
|
+
}
|
|
265
|
+
catch (error) {
|
|
266
|
+
e = { error: error };
|
|
267
|
+
}
|
|
268
|
+
finally {
|
|
269
|
+
try {
|
|
270
|
+
if (r && !r.done && (m = i["return"]))
|
|
271
|
+
m.call(i);
|
|
272
|
+
}
|
|
273
|
+
finally {
|
|
274
|
+
if (e)
|
|
275
|
+
throw e.error;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
return ar;
|
|
279
|
+
}
|
|
280
|
+
/** @deprecated */
|
|
281
|
+
function __spread() {
|
|
282
|
+
for (var ar = [], i = 0; i < arguments.length; i++)
|
|
283
|
+
ar = ar.concat(__read(arguments[i]));
|
|
284
|
+
return ar;
|
|
285
|
+
}
|
|
286
|
+
/** @deprecated */
|
|
287
|
+
function __spreadArrays() {
|
|
288
|
+
for (var s = 0, i = 0, il = arguments.length; i < il; i++)
|
|
289
|
+
s += arguments[i].length;
|
|
290
|
+
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
291
|
+
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
292
|
+
r[k] = a[j];
|
|
293
|
+
return r;
|
|
294
|
+
}
|
|
295
|
+
function __spreadArray(to, from, pack) {
|
|
296
|
+
if (pack || arguments.length === 2)
|
|
297
|
+
for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
298
|
+
if (ar || !(i in from)) {
|
|
299
|
+
if (!ar)
|
|
300
|
+
ar = Array.prototype.slice.call(from, 0, i);
|
|
301
|
+
ar[i] = from[i];
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
305
|
+
}
|
|
306
|
+
function __await(v) {
|
|
307
|
+
return this instanceof __await ? (this.v = v, this) : new __await(v);
|
|
308
|
+
}
|
|
309
|
+
function __asyncGenerator(thisArg, _arguments, generator) {
|
|
310
|
+
if (!Symbol.asyncIterator)
|
|
311
|
+
throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
312
|
+
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
313
|
+
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
314
|
+
function verb(n) { if (g[n])
|
|
315
|
+
i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
|
|
316
|
+
function resume(n, v) { try {
|
|
317
|
+
step(g[n](v));
|
|
318
|
+
}
|
|
319
|
+
catch (e) {
|
|
320
|
+
settle(q[0][3], e);
|
|
321
|
+
} }
|
|
322
|
+
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
323
|
+
function fulfill(value) { resume("next", value); }
|
|
324
|
+
function reject(value) { resume("throw", value); }
|
|
325
|
+
function settle(f, v) { if (f(v), q.shift(), q.length)
|
|
326
|
+
resume(q[0][0], q[0][1]); }
|
|
327
|
+
}
|
|
328
|
+
function __asyncDelegator(o) {
|
|
329
|
+
var i, p;
|
|
330
|
+
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
|
331
|
+
function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }
|
|
332
|
+
}
|
|
333
|
+
function __asyncValues(o) {
|
|
334
|
+
if (!Symbol.asyncIterator)
|
|
335
|
+
throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
336
|
+
var m = o[Symbol.asyncIterator], i;
|
|
337
|
+
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
338
|
+
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
339
|
+
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
|
|
340
|
+
}
|
|
341
|
+
function __makeTemplateObject(cooked, raw) {
|
|
342
|
+
if (Object.defineProperty) {
|
|
343
|
+
Object.defineProperty(cooked, "raw", { value: raw });
|
|
344
|
+
}
|
|
345
|
+
else {
|
|
346
|
+
cooked.raw = raw;
|
|
347
|
+
}
|
|
348
|
+
return cooked;
|
|
349
|
+
}
|
|
350
|
+
;
|
|
351
|
+
var __setModuleDefault = Object.create ? (function (o, v) {
|
|
352
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
353
|
+
}) : function (o, v) {
|
|
354
|
+
o["default"] = v;
|
|
355
|
+
};
|
|
356
|
+
function __importStar(mod) {
|
|
357
|
+
if (mod && mod.__esModule)
|
|
358
|
+
return mod;
|
|
359
|
+
var result = {};
|
|
360
|
+
if (mod != null)
|
|
361
|
+
for (var k in mod)
|
|
362
|
+
if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
|
|
363
|
+
__createBinding(result, mod, k);
|
|
364
|
+
__setModuleDefault(result, mod);
|
|
365
|
+
return result;
|
|
366
|
+
}
|
|
367
|
+
function __importDefault(mod) {
|
|
368
|
+
return (mod && mod.__esModule) ? mod : { default: mod };
|
|
369
|
+
}
|
|
370
|
+
function __classPrivateFieldGet(receiver, state, kind, f) {
|
|
371
|
+
if (kind === "a" && !f)
|
|
372
|
+
throw new TypeError("Private accessor was defined without a getter");
|
|
373
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
374
|
+
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
375
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
376
|
+
}
|
|
377
|
+
function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
|
378
|
+
if (kind === "m")
|
|
379
|
+
throw new TypeError("Private method is not writable");
|
|
380
|
+
if (kind === "a" && !f)
|
|
381
|
+
throw new TypeError("Private accessor was defined without a setter");
|
|
382
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
383
|
+
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
384
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
385
|
+
}
|
|
386
|
+
function __classPrivateFieldIn(state, receiver) {
|
|
387
|
+
if (receiver === null || (typeof receiver !== "object" && typeof receiver !== "function"))
|
|
388
|
+
throw new TypeError("Cannot use 'in' operator on non-object");
|
|
389
|
+
return typeof state === "function" ? receiver === state : state.has(receiver);
|
|
390
|
+
}
|
|
391
|
+
function __addDisposableResource(env, value, async) {
|
|
392
|
+
if (value !== null && value !== void 0) {
|
|
393
|
+
if (typeof value !== "object" && typeof value !== "function")
|
|
394
|
+
throw new TypeError("Object expected.");
|
|
395
|
+
var dispose;
|
|
396
|
+
if (async) {
|
|
397
|
+
if (!Symbol.asyncDispose)
|
|
398
|
+
throw new TypeError("Symbol.asyncDispose is not defined.");
|
|
399
|
+
dispose = value[Symbol.asyncDispose];
|
|
400
|
+
}
|
|
401
|
+
if (dispose === void 0) {
|
|
402
|
+
if (!Symbol.dispose)
|
|
403
|
+
throw new TypeError("Symbol.dispose is not defined.");
|
|
404
|
+
dispose = value[Symbol.dispose];
|
|
405
|
+
}
|
|
406
|
+
if (typeof dispose !== "function")
|
|
407
|
+
throw new TypeError("Object not disposable.");
|
|
408
|
+
env.stack.push({ value: value, dispose: dispose, async: async });
|
|
409
|
+
}
|
|
410
|
+
else if (async) {
|
|
411
|
+
env.stack.push({ async: true });
|
|
412
|
+
}
|
|
413
|
+
return value;
|
|
414
|
+
}
|
|
415
|
+
var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
416
|
+
var e = new Error(message);
|
|
417
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
418
|
+
};
|
|
419
|
+
function __disposeResources(env) {
|
|
420
|
+
function fail(e) {
|
|
421
|
+
env.error = env.hasError ? new _SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
|
|
422
|
+
env.hasError = true;
|
|
423
|
+
}
|
|
424
|
+
function next() {
|
|
425
|
+
while (env.stack.length) {
|
|
426
|
+
var rec = env.stack.pop();
|
|
427
|
+
try {
|
|
428
|
+
var result = rec.dispose && rec.dispose.call(rec.value);
|
|
429
|
+
if (rec.async)
|
|
430
|
+
return Promise.resolve(result).then(next, function (e) { fail(e); return next(); });
|
|
431
|
+
}
|
|
432
|
+
catch (e) {
|
|
433
|
+
fail(e);
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
if (env.hasError)
|
|
437
|
+
throw env.error;
|
|
438
|
+
}
|
|
439
|
+
return next();
|
|
440
|
+
}
|
|
441
|
+
var tslib_es6 = {
|
|
442
|
+
__extends: __extends,
|
|
443
|
+
__assign: __assign,
|
|
444
|
+
__rest: __rest,
|
|
445
|
+
__decorate: __decorate,
|
|
446
|
+
__param: __param,
|
|
447
|
+
__metadata: __metadata,
|
|
448
|
+
__awaiter: __awaiter$1,
|
|
449
|
+
__generator: __generator,
|
|
450
|
+
__createBinding: __createBinding,
|
|
451
|
+
__exportStar: __exportStar,
|
|
452
|
+
__values: __values,
|
|
453
|
+
__read: __read,
|
|
454
|
+
__spread: __spread,
|
|
455
|
+
__spreadArrays: __spreadArrays,
|
|
456
|
+
__spreadArray: __spreadArray,
|
|
457
|
+
__await: __await,
|
|
458
|
+
__asyncGenerator: __asyncGenerator,
|
|
459
|
+
__asyncDelegator: __asyncDelegator,
|
|
460
|
+
__asyncValues: __asyncValues,
|
|
461
|
+
__makeTemplateObject: __makeTemplateObject,
|
|
462
|
+
__importStar: __importStar,
|
|
463
|
+
__importDefault: __importDefault,
|
|
464
|
+
__classPrivateFieldGet: __classPrivateFieldGet,
|
|
465
|
+
__classPrivateFieldSet: __classPrivateFieldSet,
|
|
466
|
+
__classPrivateFieldIn: __classPrivateFieldIn,
|
|
467
|
+
__addDisposableResource: __addDisposableResource,
|
|
468
|
+
__disposeResources: __disposeResources,
|
|
469
|
+
};
|
|
267
470
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
471
|
+
exports.NfcError = /** @class */ (function (_super) {
|
|
472
|
+
__extends(NfcError, _super);
|
|
473
|
+
function NfcError(code, message) {
|
|
474
|
+
var _this = _super.call(this, message) || this;
|
|
475
|
+
_this.code = code;
|
|
476
|
+
return _this;
|
|
477
|
+
}
|
|
478
|
+
NfcError.tagLostError = function () {
|
|
479
|
+
return new NfcError(NfcError.ErrorCode.TagLostError, 'NFC tag lost');
|
|
480
|
+
};
|
|
481
|
+
NfcError.notConnectedError = function () {
|
|
482
|
+
return new NfcError(NfcError.ErrorCode.NotConnectedError, 'NFC tag is not connected');
|
|
483
|
+
};
|
|
484
|
+
NfcError.unknownError = function (errString) {
|
|
485
|
+
throw new NfcError(NfcError.ErrorCode.Unknown, errString);
|
|
486
|
+
};
|
|
487
|
+
NfcError.tagConnectionFailed = function () {
|
|
488
|
+
throw new NfcError(NfcError.ErrorCode.NotConnectedError, "Tag connection failed");
|
|
489
|
+
};
|
|
490
|
+
NfcError.internalError = function (message) {
|
|
491
|
+
throw new NfcError(NfcError.ErrorCode.InternalError, message);
|
|
492
|
+
};
|
|
493
|
+
return NfcError;
|
|
494
|
+
}(Error));
|
|
495
|
+
(function (NfcError) {
|
|
496
|
+
var ErrorCode;
|
|
497
|
+
(function (ErrorCode) {
|
|
498
|
+
ErrorCode["Unknown"] = "NfcUnknownError";
|
|
499
|
+
ErrorCode["InternalError"] = "NfcInternalError";
|
|
500
|
+
ErrorCode["TagLostError"] = "NfcTagLostError";
|
|
501
|
+
ErrorCode["NotConnectedError"] = "NfcNotConnectedError";
|
|
502
|
+
})(ErrorCode = NfcError.ErrorCode || (NfcError.ErrorCode = {}));
|
|
503
|
+
})(exports.NfcError || (exports.NfcError = {}));
|
|
301
504
|
|
|
302
|
-
|
|
505
|
+
var debug = debug$1.createDebugger("@iotize/device-com-nfc.cordova");
|
|
303
506
|
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
507
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
508
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
509
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
510
|
+
function fulfilled(value) { try {
|
|
511
|
+
step(generator.next(value));
|
|
512
|
+
}
|
|
513
|
+
catch (e) {
|
|
514
|
+
reject(e);
|
|
515
|
+
} }
|
|
516
|
+
function rejected(value) { try {
|
|
517
|
+
step(generator["throw"](value));
|
|
518
|
+
}
|
|
519
|
+
catch (e) {
|
|
520
|
+
reject(e);
|
|
521
|
+
} }
|
|
522
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
523
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
524
|
+
});
|
|
525
|
+
};
|
|
526
|
+
var NFCComProtocol = /** @class */ (function (_super) {
|
|
527
|
+
__extends(NFCComProtocol, _super);
|
|
528
|
+
function NFCComProtocol(options) {
|
|
529
|
+
if (options === void 0) { options = {
|
|
530
|
+
connect: {
|
|
531
|
+
timeout: 2000,
|
|
532
|
+
},
|
|
533
|
+
disconnect: {
|
|
534
|
+
timeout: 1000,
|
|
535
|
+
},
|
|
536
|
+
send: {
|
|
537
|
+
timeout: 1000,
|
|
538
|
+
},
|
|
539
|
+
}; }
|
|
540
|
+
var _this = _super.call(this) || this;
|
|
541
|
+
_this.options = options;
|
|
542
|
+
if (typeof nfc == undefined) {
|
|
543
|
+
console.warn('NFC plugin has not been setup properly. Global variable NFC does not exist');
|
|
544
|
+
}
|
|
545
|
+
return _this;
|
|
546
|
+
}
|
|
547
|
+
NFCComProtocol.iOSProtocol = function () {
|
|
548
|
+
return new NFCComProtocol({
|
|
549
|
+
connect: {
|
|
550
|
+
timeout: 10000, // bigger timer on connect as connect launches a reading session
|
|
551
|
+
},
|
|
552
|
+
disconnect: {
|
|
553
|
+
timeout: 1000,
|
|
554
|
+
},
|
|
555
|
+
send: {
|
|
556
|
+
timeout: 1000,
|
|
557
|
+
},
|
|
558
|
+
});
|
|
559
|
+
};
|
|
560
|
+
/**
|
|
561
|
+
* We force tag connection with nfc as we need to refresh tag
|
|
562
|
+
* @param options
|
|
563
|
+
* @returns
|
|
564
|
+
*/
|
|
565
|
+
NFCComProtocol.prototype.connect = function (options) {
|
|
566
|
+
this.connectionState = api.ConnectionState.CONNECTING; // Hack to force NFC tag connect call even if we are already connected
|
|
567
|
+
return _super.prototype.connect.call(this, options);
|
|
568
|
+
};
|
|
569
|
+
/**
|
|
570
|
+
* Not used as we have rewrote "connect()" function
|
|
571
|
+
* @param options
|
|
572
|
+
* @returns
|
|
573
|
+
*/
|
|
574
|
+
NFCComProtocol.prototype._connect = function (options) {
|
|
575
|
+
var _this = this;
|
|
576
|
+
return rxjs.defer(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
577
|
+
var err_1;
|
|
578
|
+
return __generator(this, function (_a) {
|
|
579
|
+
switch (_a.label) {
|
|
580
|
+
case 0:
|
|
581
|
+
debug('_connect', options);
|
|
582
|
+
_a.label = 1;
|
|
583
|
+
case 1:
|
|
584
|
+
_a.trys.push([1, 3, , 4]);
|
|
585
|
+
return [4 /*yield*/, nfc.connect('android.nfc.tech.NfcV', this.options.connect.timeout)];
|
|
586
|
+
case 2:
|
|
587
|
+
_a.sent();
|
|
588
|
+
return [3 /*break*/, 4];
|
|
589
|
+
case 3:
|
|
590
|
+
err_1 = _a.sent();
|
|
591
|
+
if (typeof err_1 === 'string') {
|
|
592
|
+
if (err_1 === 'Tag connection failed') {
|
|
593
|
+
throw exports.NfcError.tagConnectionFailed();
|
|
594
|
+
}
|
|
595
|
+
else {
|
|
596
|
+
throw exports.NfcError.unknownError(err_1);
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
throw err_1;
|
|
600
|
+
case 4: return [2 /*return*/];
|
|
601
|
+
}
|
|
602
|
+
});
|
|
603
|
+
}); });
|
|
604
|
+
};
|
|
605
|
+
NFCComProtocol.prototype._disconnect = function (options) {
|
|
606
|
+
return rxjs.defer(function () { return nfc.close(); });
|
|
607
|
+
};
|
|
608
|
+
/**
|
|
609
|
+
* Not used
|
|
610
|
+
* @param options
|
|
611
|
+
* @returns
|
|
612
|
+
*/
|
|
613
|
+
NFCComProtocol.prototype.write = function (data) {
|
|
614
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
615
|
+
return __generator(this, function (_a) {
|
|
616
|
+
throw new Error('Method not implemented.');
|
|
617
|
+
});
|
|
618
|
+
});
|
|
619
|
+
};
|
|
620
|
+
/**
|
|
621
|
+
* Not used
|
|
622
|
+
* @param options
|
|
623
|
+
* @returns
|
|
624
|
+
*/
|
|
625
|
+
NFCComProtocol.prototype.read = function () {
|
|
626
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
627
|
+
return __generator(this, function (_a) {
|
|
628
|
+
throw new Error('Method not implemented.');
|
|
629
|
+
});
|
|
630
|
+
});
|
|
631
|
+
};
|
|
632
|
+
NFCComProtocol.prototype.send = function (data, options) {
|
|
633
|
+
var _this = this;
|
|
634
|
+
return rxjs.defer(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
635
|
+
var response, errString_1, error;
|
|
636
|
+
return __generator(this, function (_a) {
|
|
637
|
+
switch (_a.label) {
|
|
638
|
+
case 0:
|
|
639
|
+
_a.trys.push([0, 2, , 3]);
|
|
640
|
+
return [4 /*yield*/, nfc.transceive(byteConverter.bufferToHexString(data))];
|
|
641
|
+
case 1:
|
|
642
|
+
response = _a.sent();
|
|
643
|
+
if (typeof response != 'string') {
|
|
644
|
+
throw exports.NfcError.internalError("Internal error. Plugin should respond a hexadecimal string");
|
|
645
|
+
}
|
|
646
|
+
debug('NFC plugin response: ', response);
|
|
647
|
+
return [2 /*return*/, byteConverter.hexStringToBuffer(response)];
|
|
648
|
+
case 2:
|
|
649
|
+
errString_1 = _a.sent();
|
|
650
|
+
if (typeof errString_1 === 'string') {
|
|
651
|
+
error = stringToError(errString_1);
|
|
652
|
+
if (error.code === exports.NfcError.ErrorCode.NotConnectedError ||
|
|
653
|
+
error.code === exports.NfcError.ErrorCode.TagLostError) {
|
|
654
|
+
this._onConnectionLost(error);
|
|
655
|
+
}
|
|
656
|
+
throw error;
|
|
657
|
+
}
|
|
658
|
+
else {
|
|
659
|
+
throw errString_1;
|
|
660
|
+
}
|
|
661
|
+
return [3 /*break*/, 3];
|
|
662
|
+
case 3: return [2 /*return*/];
|
|
663
|
+
}
|
|
664
|
+
});
|
|
665
|
+
}); });
|
|
666
|
+
};
|
|
667
|
+
NFCComProtocol.prototype._onConnectionLost = function (error) {
|
|
668
|
+
if (this.connectionState !== api.ConnectionState.DISCONNECTED) {
|
|
669
|
+
this.setConnectionState(api.ConnectionState.DISCONNECTED);
|
|
670
|
+
}
|
|
671
|
+
};
|
|
672
|
+
return NFCComProtocol;
|
|
673
|
+
}(core.QueueComProtocol));
|
|
674
|
+
/**
|
|
675
|
+
* Convert error string returned by the plugin into an error object
|
|
676
|
+
* It only checks a few Android error string for now
|
|
677
|
+
*
|
|
678
|
+
* TODO complete implementation with other error types
|
|
679
|
+
*
|
|
680
|
+
* @param errString
|
|
681
|
+
*/
|
|
682
|
+
function stringToError(errString) {
|
|
683
|
+
var errStringLc = errString.toLowerCase();
|
|
684
|
+
if (errStringLc.indexOf('tag was lost') >= 0) {
|
|
685
|
+
return exports.NfcError.tagLostError();
|
|
686
|
+
}
|
|
687
|
+
else if (errStringLc.indexOf('not connected') >= 0) {
|
|
688
|
+
return exports.NfcError.notConnectedError();
|
|
689
|
+
}
|
|
690
|
+
else {
|
|
691
|
+
return exports.NfcError.unknownError(errString);
|
|
692
|
+
}
|
|
693
|
+
}
|
|
491
694
|
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
695
|
+
/**
|
|
696
|
+
* We manage only on NDEF message with 3 records:
|
|
697
|
+
* record 0 = URI; record 1 = AAR; record 2 = BLE MAC ADDRESS / BSSID; record 3: universal link
|
|
698
|
+
*/
|
|
699
|
+
function parseTapNdefMessage(messages) {
|
|
700
|
+
var result = {};
|
|
701
|
+
if (messages.length >= 1) {
|
|
702
|
+
var asciiUri = messages[0].payload;
|
|
703
|
+
result.uri = toAsciiString(asciiUri);
|
|
704
|
+
}
|
|
705
|
+
if (messages.length >= 2) {
|
|
706
|
+
result.aar = toAsciiString(messages[1].payload);
|
|
707
|
+
}
|
|
708
|
+
if (messages.length >= 3) {
|
|
709
|
+
var payload3 = messages[2].payload;
|
|
710
|
+
var type = payload3[0];
|
|
711
|
+
var content = payload3.slice(1);
|
|
712
|
+
result.type = type;
|
|
713
|
+
switch (type) {
|
|
714
|
+
case TapNdefProtocolType.BLE:
|
|
715
|
+
result.macAddress = convertBytesToBLEAddress(content);
|
|
716
|
+
break;
|
|
717
|
+
case TapNdefProtocolType.WiFi:
|
|
718
|
+
result.ssid = toAsciiString(content);
|
|
719
|
+
break;
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
if (messages.length >= 4) {
|
|
723
|
+
result.name = toAsciiString(messages[3].payload);
|
|
724
|
+
}
|
|
725
|
+
return result;
|
|
726
|
+
}
|
|
727
|
+
var TapNdefProtocolType;
|
|
728
|
+
(function (TapNdefProtocolType) {
|
|
729
|
+
TapNdefProtocolType[TapNdefProtocolType["WiFi"] = 32] = "WiFi";
|
|
730
|
+
TapNdefProtocolType[TapNdefProtocolType["BLE"] = 64] = "BLE";
|
|
731
|
+
})(TapNdefProtocolType || (TapNdefProtocolType = {}));
|
|
732
|
+
function toAsciiString(payload) {
|
|
733
|
+
if (payload.length > 0 && payload[0] === 0) {
|
|
734
|
+
payload = payload.slice(1);
|
|
735
|
+
}
|
|
736
|
+
return byteConverter.bufferToAsciiString(payload);
|
|
737
|
+
}
|
|
738
|
+
function convertBytesToBLEAddress(bytes) {
|
|
739
|
+
return bytes.map(function (byte) {
|
|
740
|
+
if (byte < 0) {
|
|
741
|
+
byte += 256;
|
|
742
|
+
}
|
|
743
|
+
var byteString = '0' + byte.toString(16).toUpperCase();
|
|
744
|
+
byteString = byteString.slice(-2);
|
|
745
|
+
return byteString;
|
|
746
|
+
})
|
|
747
|
+
.reverse()
|
|
748
|
+
.join(':');
|
|
749
|
+
}
|
|
547
750
|
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
751
|
+
/**
|
|
752
|
+
* Generated bundle index. Do not edit.
|
|
753
|
+
*/
|
|
551
754
|
|
|
552
|
-
|
|
553
|
-
|
|
755
|
+
exports.NFCComProtocol = NFCComProtocol;
|
|
756
|
+
exports.parseTapNdefMessage = parseTapNdefMessage;
|
|
554
757
|
|
|
555
|
-
|
|
758
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
556
759
|
|
|
557
760
|
}));
|
|
558
761
|
//# sourceMappingURL=iotize-device-com-nfc.cordova.umd.js.map
|