@iotize/device-com-ble.cordova 3.7.2 → 4.0.0-alpha.2
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/CHANGELOG.md +143 -0
- package/package.json +7 -21
- package/plugin.cjs +35 -0
- package/plugin.js +35 -0
- package/plugin.xml +8 -3
- package/src/android/build.gradle +2 -11
- package/src/android/libs/iotize-device-com-ble-1.0.0-alpha.9.aar +0 -0
- package/{lib → src/lib}/ble-com-protocol.d.ts +20 -20
- package/{lib → src/lib}/cordova-ble-error.d.ts +29 -29
- package/{lib → src/lib}/cordova-interface.d.ts +5 -5
- package/{lib → src/lib}/cordova-service-adapter.d.ts +58 -58
- package/{lib → src/lib}/definitions.d.ts +43 -43
- package/{lib → src/lib}/iotize-ble-cordova-plugin.d.ts +27 -27
- package/src/lib/logger.d.ts +2 -0
- package/{lib → src/lib}/scanner.d.ts +55 -55
- package/{lib → src/lib}/utility.d.ts +6 -6
- package/src/plugin.d.ts +8 -0
- package/src/windows/iotize-ble-com.js +11 -11
- package/LICENSE +0 -23
- package/README.md +0 -174
- package/bundles/iotize-device-com-ble.cordova.umd.js +0 -1418
- package/bundles/iotize-device-com-ble.cordova.umd.js.map +0 -1
- package/bundles/iotize-device-com-ble.cordova.umd.min.js +0 -2
- package/bundles/iotize-device-com-ble.cordova.umd.min.js.map +0 -1
- package/esm2015/iotize-device-com-ble.cordova.js +0 -6
- package/esm2015/iotize-device-com-ble.cordova.js.map +0 -1
- package/esm2015/iotize-device-com-ble.cordova.metadata.json +0 -1
- package/esm2015/iotize-device-com-ble.cordova.ngsummary.json +0 -1
- package/esm2015/lib/ble-com-protocol.js +0 -76
- package/esm2015/lib/ble-com-protocol.js.map +0 -1
- package/esm2015/lib/ble-com-protocol.metadata.json +0 -1
- package/esm2015/lib/ble-com-protocol.ngsummary.json +0 -1
- package/esm2015/lib/cordova-ble-error.js +0 -36
- package/esm2015/lib/cordova-ble-error.js.map +0 -1
- package/esm2015/lib/cordova-ble-error.metadata.json +0 -1
- package/esm2015/lib/cordova-ble-error.ngsummary.json +0 -1
- package/esm2015/lib/cordova-interface.js +0 -2
- package/esm2015/lib/cordova-interface.js.map +0 -1
- package/esm2015/lib/cordova-interface.metadata.json +0 -1
- package/esm2015/lib/cordova-interface.ngsummary.json +0 -1
- package/esm2015/lib/cordova-service-adapter.js +0 -214
- package/esm2015/lib/cordova-service-adapter.js.map +0 -1
- package/esm2015/lib/cordova-service-adapter.metadata.json +0 -1
- package/esm2015/lib/cordova-service-adapter.ngsummary.json +0 -1
- package/esm2015/lib/definitions.js +0 -2
- package/esm2015/lib/definitions.js.map +0 -1
- package/esm2015/lib/definitions.metadata.json +0 -1
- package/esm2015/lib/definitions.ngsummary.json +0 -1
- package/esm2015/lib/iotize-ble-cordova-plugin.js +0 -170
- package/esm2015/lib/iotize-ble-cordova-plugin.js.map +0 -1
- package/esm2015/lib/iotize-ble-cordova-plugin.metadata.json +0 -1
- package/esm2015/lib/iotize-ble-cordova-plugin.ngsummary.json +0 -1
- package/esm2015/lib/logger.js +0 -3
- package/esm2015/lib/logger.js.map +0 -1
- package/esm2015/lib/logger.metadata.json +0 -1
- package/esm2015/lib/logger.ngsummary.json +0 -1
- package/esm2015/lib/scanner.js +0 -151
- package/esm2015/lib/scanner.js.map +0 -1
- package/esm2015/lib/scanner.metadata.json +0 -1
- package/esm2015/lib/scanner.ngsummary.json +0 -1
- package/esm2015/lib/utility.js +0 -26
- package/esm2015/lib/utility.js.map +0 -1
- package/esm2015/lib/utility.metadata.json +0 -1
- package/esm2015/lib/utility.ngsummary.json +0 -1
- package/esm2015/public_api.js +0 -5
- package/esm2015/public_api.js.map +0 -1
- package/esm2015/public_api.metadata.json +0 -1
- package/esm2015/public_api.ngsummary.json +0 -1
- package/fesm2015/iotize-device-com-ble.cordova.js +0 -660
- package/fesm2015/iotize-device-com-ble.cordova.js.map +0 -1
- package/iotize-device-com-ble.cordova.d.ts +0 -6
- package/iotize-device-com-ble.cordova.metadata.json +0 -1
- package/lib/logger.d.ts +0 -1
- package/public_api.d.ts +0 -5
- package/src/android/.gradle/4.8.1/fileChanges/last-build.bin +0 -0
- package/src/android/.gradle/4.8.1/fileHashes/fileHashes.bin +0 -0
- package/src/android/.gradle/4.8.1/fileHashes/fileHashes.lock +0 -0
- package/src/android/.gradle/6.8.2/fileChanges/last-build.bin +0 -0
- package/src/android/.gradle/6.8.2/fileHashes/fileHashes.lock +0 -0
- package/src/android/.gradle/6.8.2/gc.properties +0 -0
- package/src/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/src/android/.gradle/buildOutputCleanup/cache.properties +0 -2
- package/src/android/.gradle/checksums/checksums.lock +0 -0
- package/src/android/.gradle/configuration-cache/gc.properties +0 -0
- package/src/android/.gradle/vcs-1/gc.properties +0 -0
- package/src/android/.gradle/vcsWorkingDirs/gc.properties +0 -0
- package/src/android/.idea/android.iml +0 -9
- package/src/android/.idea/gradle.xml +0 -16
- package/src/android/.idea/modules.xml +0 -8
- package/src/android/.idea/vcs.xml +0 -6
- package/www/plugin.js +0 -2
- package/www/plugin.js.LICENSE.txt +0 -14
package/esm2015/lib/scanner.js
DELETED
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2018 IoTize SAS Inc. Licensed under the MIT license.
|
|
3
|
-
//
|
|
4
|
-
// scanner.ts
|
|
5
|
-
// device-com-ble.cordova BLE Cordova Plugin
|
|
6
|
-
//
|
|
7
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
8
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
9
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
10
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
11
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
12
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
13
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
14
|
-
});
|
|
15
|
-
};
|
|
16
|
-
import { BleComError } from "@iotize/tap/protocol/ble/common";
|
|
17
|
-
import { BehaviorSubject } from "rxjs";
|
|
18
|
-
import { debug } from "./logger";
|
|
19
|
-
import { getIoTizeBleCordovaPlugin } from "./utility";
|
|
20
|
-
/**
|
|
21
|
-
* BLE Tap scanner for cordova apps
|
|
22
|
-
*/
|
|
23
|
-
export class BLEScanner {
|
|
24
|
-
/**
|
|
25
|
-
*
|
|
26
|
-
* @param cordovaInterfaceOverwrite overwrite cordova interface. Used for testing
|
|
27
|
-
*/
|
|
28
|
-
constructor(cordovaInterfaceOverwrite,
|
|
29
|
-
/**
|
|
30
|
-
* Request device options used to filter scan results
|
|
31
|
-
*/
|
|
32
|
-
requestDeviceOptions) {
|
|
33
|
-
this.cordovaInterfaceOverwrite = cordovaInterfaceOverwrite;
|
|
34
|
-
this.requestDeviceOptions = requestDeviceOptions;
|
|
35
|
-
this._results = new BehaviorSubject([]);
|
|
36
|
-
this._scanning$ = new BehaviorSubject(false);
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Lazy reference to iotizeBLE.
|
|
40
|
-
* We don't want to reference iotizeBLE in constructor as it may be referenced
|
|
41
|
-
* before cordova plugin is loaded
|
|
42
|
-
*/
|
|
43
|
-
get cordovaInterface() {
|
|
44
|
-
return this.cordovaInterfaceOverwrite || getIoTizeBleCordovaPlugin();
|
|
45
|
-
}
|
|
46
|
-
get scanning() {
|
|
47
|
-
return this._scanning$.asObservable();
|
|
48
|
-
}
|
|
49
|
-
get isScanning() {
|
|
50
|
-
return this._scanning$.value;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Gets the observable on the devices$ Subject
|
|
54
|
-
* @return
|
|
55
|
-
*/
|
|
56
|
-
get results() {
|
|
57
|
-
return this._results.asObservable();
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Launches the scan for BLE devices
|
|
61
|
-
* Throws if BLE is not available
|
|
62
|
-
*/
|
|
63
|
-
start(options) {
|
|
64
|
-
var _a;
|
|
65
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
66
|
-
(_a = this.scanSubscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
|
|
67
|
-
this.scanSubscription = undefined;
|
|
68
|
-
this.clearResults();
|
|
69
|
-
const isAvailable = yield this.checkAvailable();
|
|
70
|
-
if (!isAvailable) {
|
|
71
|
-
throw BleComError.bleNotAvailable(`BLE is not available. Make sure that BLE is enabled on your device`);
|
|
72
|
-
}
|
|
73
|
-
debug("Start Scanning ...");
|
|
74
|
-
this._scanning$.next(true);
|
|
75
|
-
return new Promise((resolve, reject) => {
|
|
76
|
-
this.scanSubscription = this.cordovaInterface
|
|
77
|
-
.startScan(this.requestDeviceOptions)
|
|
78
|
-
.subscribe((result) => {
|
|
79
|
-
if (result == "Ok") {
|
|
80
|
-
resolve();
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
this.addOrRefreshDevice(result);
|
|
84
|
-
}, (error) => {
|
|
85
|
-
debug("Start scan failed with error: ", error);
|
|
86
|
-
this.cordovaInterface
|
|
87
|
-
.getLastError()
|
|
88
|
-
.then((lasterror) => {
|
|
89
|
-
debug("Last BLE error " + lasterror);
|
|
90
|
-
})
|
|
91
|
-
.catch((err) => {
|
|
92
|
-
debug("Cannot get last BLE error: ", err);
|
|
93
|
-
});
|
|
94
|
-
reject(error);
|
|
95
|
-
this._scanning$.next(false);
|
|
96
|
-
});
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
*
|
|
102
|
-
*/
|
|
103
|
-
stop() {
|
|
104
|
-
var _a;
|
|
105
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
106
|
-
debug("Stop Scanning ...");
|
|
107
|
-
try {
|
|
108
|
-
(_a = this.scanSubscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
|
|
109
|
-
this.scanSubscription = undefined;
|
|
110
|
-
yield this.cordovaInterface.stopScan();
|
|
111
|
-
this._scanning$.next(false);
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
catch (err) {
|
|
115
|
-
this._scanning$.next(false);
|
|
116
|
-
throw err;
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Returns true if this scanner is available
|
|
122
|
-
*/
|
|
123
|
-
checkAvailable() {
|
|
124
|
-
return this.cordovaInterface.checkAvailable();
|
|
125
|
-
}
|
|
126
|
-
get devices() {
|
|
127
|
-
return this._results.value;
|
|
128
|
-
}
|
|
129
|
-
clearResults() {
|
|
130
|
-
this._results.next([]);
|
|
131
|
-
}
|
|
132
|
-
addOrRefreshDevice(newDevice) {
|
|
133
|
-
let storedDeviceIndex = this.devices.findIndex((entry) => entry.address == newDevice.address);
|
|
134
|
-
if (storedDeviceIndex >= 0) {
|
|
135
|
-
let storedDevice = this.devices[storedDeviceIndex];
|
|
136
|
-
if (storedDevice.name != newDevice.name ||
|
|
137
|
-
storedDevice.rssi != newDevice.rssi) {
|
|
138
|
-
debug(`Updating device at index ${storedDeviceIndex}, name=${storedDevice.name} with rssi=${storedDevice.rssi}`);
|
|
139
|
-
this.devices[storedDeviceIndex] = newDevice;
|
|
140
|
-
// this.devices = [...this.devices];
|
|
141
|
-
this._results.next(this.devices);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
else {
|
|
145
|
-
debug(`Adding new device name=${newDevice.name} with rssi=${newDevice.rssi}`);
|
|
146
|
-
this.devices.push(newDevice);
|
|
147
|
-
this._results.next(this.devices);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
//# sourceMappingURL=scanner.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"scanner.js","sourceRoot":"","sources":["../../../../../src/lib/scanner.ts"],"names":[],"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CACvE,CAAC;YACF,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YAC7B,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;SAClC;IACH,CAAC;CACF","sourcesContent":["//\n// Copyright 2018 IoTize SAS Inc. Licensed under the MIT license.\n//\n// scanner.ts\n// device-com-ble.cordova BLE Cordova Plugin\n//\n\nimport { BleComError } from \"@iotize/tap/protocol/ble/common\";\nimport { DeviceScanner, DeviceScannerOptions } from \"@iotize/tap/scanner/api\";\nimport { BehaviorSubject, Observable, Subscription } from \"rxjs\";\nimport { CordovaBLEScanResult, RequestDeviceOptions } from \"./definitions\";\nimport { IoTizeBleCordovaPlugin } from \"./iotize-ble-cordova-plugin\";\nimport { debug } from \"./logger\";\nimport { getIoTizeBleCordovaPlugin } from \"./utility\";\n\n/**\n * BLE Tap scanner for cordova apps\n */\nexport class BLEScanner implements DeviceScanner<CordovaBLEScanResult> {\n private _results = new BehaviorSubject<CordovaBLEScanResult[]>([]);\n private _scanning$ = new BehaviorSubject<boolean>(false);\n private scanSubscription?: Subscription;\n\n /**\n * Lazy reference to iotizeBLE.\n * We don't want to reference iotizeBLE in constructor as it may be referenced\n * before cordova plugin is loaded\n */\n private get cordovaInterface(): IoTizeBleCordovaPlugin {\n return this.cordovaInterfaceOverwrite || getIoTizeBleCordovaPlugin();\n }\n\n /**\n *\n * @param cordovaInterfaceOverwrite overwrite cordova interface. Used for testing\n */\n constructor(\n private cordovaInterfaceOverwrite?: IoTizeBleCordovaPlugin,\n /**\n * Request device options used to filter scan results\n */\n readonly requestDeviceOptions?: RequestDeviceOptions\n ) {}\n\n get scanning(): Observable<boolean> {\n return this._scanning$.asObservable();\n }\n\n get isScanning(): boolean {\n return this._scanning$.value;\n }\n\n /**\n * Gets the observable on the devices$ Subject\n * @return\n */\n get results(): Observable<CordovaBLEScanResult[]> {\n return this._results.asObservable();\n }\n\n /**\n * Launches the scan for BLE devices\n * Throws if BLE is not available\n */\n async start(options?: DeviceScannerOptions): Promise<void> {\n this.scanSubscription?.unsubscribe();\n this.scanSubscription = undefined;\n this.clearResults();\n const isAvailable = await this.checkAvailable();\n if (!isAvailable) {\n throw BleComError.bleNotAvailable(\n `BLE is not available. Make sure that BLE is enabled on your device`\n );\n }\n debug(\"Start Scanning ...\");\n this._scanning$.next(true);\n return new Promise<void>((resolve, reject) => {\n this.scanSubscription = this.cordovaInterface\n .startScan(this.requestDeviceOptions)\n .subscribe(\n (result) => {\n if (result == \"Ok\") {\n resolve();\n return;\n }\n this.addOrRefreshDevice(result);\n },\n (error) => {\n debug(\"Start scan failed with error: \", error);\n this.cordovaInterface\n .getLastError()\n .then((lasterror) => {\n debug(\"Last BLE error \" + lasterror);\n })\n .catch((err) => {\n debug(\"Cannot get last BLE error: \", err);\n });\n reject(error);\n this._scanning$.next(false);\n }\n );\n });\n }\n\n /**\n *\n */\n async stop(): Promise<void> {\n debug(\"Stop Scanning ...\");\n try {\n this.scanSubscription?.unsubscribe();\n this.scanSubscription = undefined;\n await this.cordovaInterface.stopScan();\n this._scanning$.next(false);\n return;\n } catch (err) {\n this._scanning$.next(false);\n throw err;\n }\n }\n\n /**\n * Returns true if this scanner is available\n */\n checkAvailable(): Promise<boolean> {\n return this.cordovaInterface.checkAvailable();\n }\n\n private get devices() {\n return this._results.value;\n }\n\n private clearResults() {\n this._results.next([]);\n }\n\n private addOrRefreshDevice(newDevice: CordovaBLEScanResult) {\n let storedDeviceIndex = this.devices.findIndex(\n (entry) => entry.address == newDevice.address\n );\n if (storedDeviceIndex >= 0) {\n let storedDevice = this.devices[storedDeviceIndex];\n if (\n storedDevice.name != newDevice.name ||\n storedDevice.rssi != newDevice.rssi\n ) {\n debug(\n `Updating device at index ${storedDeviceIndex}, name=${storedDevice.name} with rssi=${storedDevice.rssi}`\n );\n this.devices[storedDeviceIndex] = newDevice;\n // this.devices = [...this.devices];\n this._results.next(this.devices);\n }\n } else {\n debug(\n `Adding new device name=${newDevice.name} with rssi=${newDevice.rssi}`\n );\n this.devices.push(newDevice);\n this._results.next(this.devices);\n }\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
[{"__symbolic":"module","version":4,"metadata":{"BLEScanner":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"./iotize-ble-cordova-plugin","name":"IoTizeBleCordovaPlugin","line":37,"character":40},{"__symbolic":"reference","module":"./definitions","name":"RequestDeviceOptions","line":41,"character":36}]}],"start":[{"__symbolic":"method"}],"stop":[{"__symbolic":"method"}],"checkAvailable":[{"__symbolic":"method"}],"clearResults":[{"__symbolic":"method"}],"addOrRefreshDevice":[{"__symbolic":"method"}]}}}}]
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"moduleName":null,"summaries":[{"symbol":{"__symbol":0,"members":[]},"metadata":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbol":1,"members":[]},{"__symbol":2,"members":[]}]}],"start":[{"__symbolic":"method"}],"stop":[{"__symbolic":"method"}],"checkAvailable":[{"__symbolic":"method"}],"clearResults":[{"__symbolic":"method"}],"addOrRefreshDevice":[{"__symbolic":"method"}]}}}],"symbols":[{"__symbol":0,"name":"BLEScanner","filePath":"./scanner"},{"__symbol":1,"name":"IoTizeBleCordovaPlugin","filePath":"./iotize-ble-cordova-plugin"},{"__symbol":2,"name":"RequestDeviceOptions","filePath":"./definitions"}]}
|
package/esm2015/lib/utility.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { CordovaBLEError } from "./cordova-ble-error";
|
|
2
|
-
export function getIoTizeBleCordovaPlugin() {
|
|
3
|
-
if (typeof iotizeBLE !== "object") {
|
|
4
|
-
throw CordovaBLEError.iotizeBLEMissing();
|
|
5
|
-
}
|
|
6
|
-
return iotizeBLE;
|
|
7
|
-
}
|
|
8
|
-
export function getScanRecordsFromBytes(bytes) {
|
|
9
|
-
//LTV encoding
|
|
10
|
-
const records = [];
|
|
11
|
-
for (let i = 0; i < bytes.length; i++) {
|
|
12
|
-
//first byte is length
|
|
13
|
-
let size = bytes[i];
|
|
14
|
-
if (size == 0) {
|
|
15
|
-
break;
|
|
16
|
-
}
|
|
17
|
-
let type = bytes[i + 1];
|
|
18
|
-
records.push({
|
|
19
|
-
type,
|
|
20
|
-
data: bytes.slice(i + 2, i + size + 1)
|
|
21
|
-
});
|
|
22
|
-
i += size;
|
|
23
|
-
}
|
|
24
|
-
return records;
|
|
25
|
-
}
|
|
26
|
-
//# sourceMappingURL=utility.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utility.js","sourceRoot":"","sources":["../../../../../src/lib/utility.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAKtD,MAAM,UAAU,yBAAyB;IACvC,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE;QACjC,MAAM,eAAe,CAAC,gBAAgB,EAAE,CAAC;KAC1C;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,KAAiB;IACvD,cAAc;IACd,MAAM,OAAO,GAAuC,EAAE,CAAC;IACvD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACrC,sBAAsB;QACtB,IAAI,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACpB,IAAI,IAAI,IAAI,CAAC,EAAE;YACb,MAAM;SACP;QACD,IAAI,IAAI,GAAG,KAAK,CAAC,CAAC,GAAC,CAAC,CAAC,CAAC;QACtB,OAAO,CAAC,IAAI,CAAC;YACX,IAAI;YACJ,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,GAAC,CAAC,EAAE,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC;SACrC,CAAC,CAAA;QACF,CAAC,IAAI,IAAI,CAAC;KACX;IACD,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import { CordovaBLEError } from \"./cordova-ble-error\";\nimport { IoTizeBleCordovaPlugin } from \"./iotize-ble-cordova-plugin\";\n\ndeclare var iotizeBLE: IoTizeBleCordovaPlugin;\n\nexport function getIoTizeBleCordovaPlugin(): IoTizeBleCordovaPlugin {\n if (typeof iotizeBLE !== \"object\") {\n throw CordovaBLEError.iotizeBLEMissing();\n }\n return iotizeBLE;\n}\n\nexport function getScanRecordsFromBytes(bytes: Uint8Array): {type: number; data: Uint8Array}[] {\n //LTV encoding\n const records: {type: number; data: Uint8Array}[] = [];\n for (let i = 0; i < bytes.length; i++) {\n //first byte is length\n let size = bytes[i];\n if (size == 0) {\n break;\n }\n let type = bytes[i+1];\n records.push({\n type,\n data: bytes.slice(i+2, i + size + 1)\n })\n i += size;\n }\n return records;\n}"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
[{"__symbolic":"module","version":4,"metadata":{"getIoTizeBleCordovaPlugin":{"__symbolic":"function"},"getScanRecordsFromBytes":{"__symbolic":"function"}}}]
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"moduleName":null,"summaries":[{"symbol":{"__symbol":0,"members":[]},"metadata":{"__symbolic":"function"}},{"symbol":{"__symbol":1,"members":[]},"metadata":{"__symbolic":"function"}}],"symbols":[{"__symbol":0,"name":"getIoTizeBleCordovaPlugin","filePath":"./utility"},{"__symbol":1,"name":"getScanRecordsFromBytes","filePath":"./utility"}]}
|
package/esm2015/public_api.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export { BLEComProtocol } from "./lib/ble-com-protocol";
|
|
2
|
-
export { CordovaCharacteristicAdapter, CordovaPeripheralAdapter, CordovaServiceAdapter, } from "./lib/cordova-service-adapter";
|
|
3
|
-
export { BLEScanner } from "./lib/scanner";
|
|
4
|
-
export { getIoTizeBleCordovaPlugin, getScanRecordsFromBytes } from "./lib/utility";
|
|
5
|
-
//# sourceMappingURL=public_api.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"public_api.js","sourceRoot":"","sources":["../../../../src/public_api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EACL,4BAA4B,EAC5B,wBAAwB,EACxB,qBAAqB,GACtB,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EACL,yBAAyB,EACzB,uBAAuB,EACxB,MAAM,eAAe,CAAC","sourcesContent":["export { BLEComProtocol } from \"./lib/ble-com-protocol\";\nexport {\n CordovaCharacteristicAdapter,\n CordovaPeripheralAdapter,\n CordovaServiceAdapter,\n} from \"./lib/cordova-service-adapter\";\nexport { CordovaBLEScanResult, RequestDeviceOptions } from \"./lib/definitions\";\nexport { BLEScanner } from \"./lib/scanner\";\nexport { \n getIoTizeBleCordovaPlugin,\n getScanRecordsFromBytes\n} from \"./lib/utility\";\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
[{"__symbolic":"module","version":4,"metadata":{},"exports":[{"from":"./lib/ble-com-protocol","export":["BLEComProtocol"]},{"from":"./lib/cordova-service-adapter","export":["CordovaCharacteristicAdapter","CordovaPeripheralAdapter","CordovaServiceAdapter"]},{"from":"./lib/definitions","export":["CordovaBLEScanResult","RequestDeviceOptions"]},{"from":"./lib/scanner","export":["BLEScanner"]},{"from":"./lib/utility","export":["getIoTizeBleCordovaPlugin","getScanRecordsFromBytes"]}]}]
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"moduleName":null,"summaries":[{"symbol":{"__symbol":0,"members":[]},"metadata":{"__symbol":1,"members":[]}},{"symbol":{"__symbol":2,"members":[]},"metadata":{"__symbol":3,"members":[]}},{"symbol":{"__symbol":4,"members":[]},"metadata":{"__symbol":5,"members":[]}},{"symbol":{"__symbol":6,"members":[]},"metadata":{"__symbol":7,"members":[]}},{"symbol":{"__symbol":8,"members":[]},"metadata":{"__symbol":9,"members":[]}},{"symbol":{"__symbol":10,"members":[]},"metadata":{"__symbol":11,"members":[]}},{"symbol":{"__symbol":12,"members":[]},"metadata":{"__symbol":13,"members":[]}},{"symbol":{"__symbol":14,"members":[]},"metadata":{"__symbol":15,"members":[]}},{"symbol":{"__symbol":16,"members":[]},"metadata":{"__symbol":17,"members":[]}}],"symbols":[{"__symbol":0,"name":"BLEComProtocol","filePath":"./public_api"},{"__symbol":1,"name":"BLEComProtocol","filePath":"./lib/ble-com-protocol"},{"__symbol":2,"name":"CordovaCharacteristicAdapter","filePath":"./public_api"},{"__symbol":3,"name":"CordovaCharacteristicAdapter","filePath":"./lib/cordova-service-adapter"},{"__symbol":4,"name":"CordovaPeripheralAdapter","filePath":"./public_api"},{"__symbol":5,"name":"CordovaPeripheralAdapter","filePath":"./lib/cordova-service-adapter"},{"__symbol":6,"name":"CordovaServiceAdapter","filePath":"./public_api"},{"__symbol":7,"name":"CordovaServiceAdapter","filePath":"./lib/cordova-service-adapter"},{"__symbol":8,"name":"CordovaBLEScanResult","filePath":"./public_api"},{"__symbol":9,"name":"CordovaBLEScanResult","filePath":"./lib/definitions"},{"__symbol":10,"name":"RequestDeviceOptions","filePath":"./public_api"},{"__symbol":11,"name":"RequestDeviceOptions","filePath":"./lib/definitions"},{"__symbol":12,"name":"BLEScanner","filePath":"./public_api"},{"__symbol":13,"name":"BLEScanner","filePath":"./lib/scanner"},{"__symbol":14,"name":"getIoTizeBleCordovaPlugin","filePath":"./public_api"},{"__symbol":15,"name":"getIoTizeBleCordovaPlugin","filePath":"./lib/utility"},{"__symbol":16,"name":"getScanRecordsFromBytes","filePath":"./public_api"},{"__symbol":17,"name":"getScanRecordsFromBytes","filePath":"./lib/utility"}]}
|