@iotize/device-com-ble.cordova 3.6.0 → 3.6.2-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.
Files changed (64) hide show
  1. package/README.md +174 -174
  2. package/bundles/iotize-device-com-ble.cordova.umd.js +19 -0
  3. package/bundles/iotize-device-com-ble.cordova.umd.js.map +1 -1
  4. package/bundles/iotize-device-com-ble.cordova.umd.min.js +1 -1
  5. package/bundles/iotize-device-com-ble.cordova.umd.min.js.map +1 -1
  6. package/esm2015/iotize-device-com-ble.cordova.ngsummary.json +1 -1
  7. package/esm2015/lib/ble-com-protocol.js.map +1 -1
  8. package/esm2015/lib/cordova-ble-error.js.map +1 -1
  9. package/esm2015/lib/cordova-interface.js.map +1 -1
  10. package/esm2015/lib/cordova-service-adapter.js.map +1 -1
  11. package/esm2015/lib/definitions.js.map +1 -1
  12. package/esm2015/lib/iotize-ble-cordova-plugin.js.map +1 -1
  13. package/esm2015/lib/logger.js.map +1 -1
  14. package/esm2015/lib/scanner.js.map +1 -1
  15. package/esm2015/lib/utility.js +18 -0
  16. package/esm2015/lib/utility.js.map +1 -1
  17. package/esm2015/lib/utility.metadata.json +1 -1
  18. package/esm2015/lib/utility.ngsummary.json +1 -1
  19. package/esm2015/public_api.js +1 -1
  20. package/esm2015/public_api.js.map +1 -1
  21. package/esm2015/public_api.metadata.json +1 -1
  22. package/esm2015/public_api.ngsummary.json +1 -1
  23. package/fesm2015/iotize-device-com-ble.cordova.js +19 -1
  24. package/fesm2015/iotize-device-com-ble.cordova.js.map +1 -1
  25. package/iotize-device-com-ble.cordova.metadata.json +1 -1
  26. package/lib/definitions.d.ts +2 -0
  27. package/lib/utility.d.ts +4 -0
  28. package/package.json +1 -1
  29. package/plugin.xml +68 -68
  30. package/public_api.d.ts +1 -1
  31. package/src/android/.gradle/4.8.1/fileHashes/fileHashes.bin +0 -0
  32. package/src/android/.gradle/4.8.1/fileHashes/fileHashes.lock +0 -0
  33. package/src/android/src/ble/BLECom.java +5 -3
  34. package/src/android/src/ble/BLEProtocol.java +874 -0
  35. package/src/android/src/ble/PluginResponse.java +1 -1
  36. package/src/android/src/ble/characteristics/AbstractLwM2MRequestCharacteristic.java +48 -0
  37. package/src/android/src/ble/characteristics/CharacteristicAdapter.java +221 -0
  38. package/src/android/src/ble/characteristics/CharacteristicAdapterCallbacks.java +21 -0
  39. package/src/android/src/ble/characteristics/LwM2M20BytesRequestCharacteristicAdapter.java +161 -0
  40. package/src/android/src/ble/characteristics/LwM2MMTURequestCharacteristicAdapter.java +134 -0
  41. package/src/android/src/ble/commands/BLECommand.java +18 -0
  42. package/src/android/src/ble/commands/CharacteristicOperationCompletedNotifier.java +38 -0
  43. package/src/android/src/ble/commands/CommandCompletedNotifier.java +10 -0
  44. package/src/android/src/ble/commands/DescriptorOperationCompletedNotifier.java +37 -0
  45. package/src/android/src/ble/commands/GattOperationCompletedNotifier.java +29 -0
  46. package/src/ios/BLECom.swift +732 -732
  47. package/src/windows/iotize-ble-com.js +159 -159
  48. package/www/plugin.js +1 -1
  49. package/iotize-device-com-ble.cordova-3.6.0.tgz +0 -0
  50. package/src/android/.gradle/6.8.2/fileHashes/fileHashes.lock +0 -0
  51. package/src/android/.gradle/6.8.2/gc.properties +0 -0
  52. package/src/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  53. package/src/android/.gradle/buildOutputCleanup/cache.properties +0 -2
  54. package/src/android/.gradle/checksums/checksums.lock +0 -0
  55. package/src/android/.gradle/configuration-cache/gc.properties +0 -0
  56. package/src/android/.gradle/vcs-1/gc.properties +0 -0
  57. package/src/android/.gradle/vcsWorkingDirs/gc.properties +0 -0
  58. package/src/android/.idea/android.iml +0 -9
  59. package/src/android/.idea/gradle.xml +0 -16
  60. package/src/android/.idea/modules.xml +0 -8
  61. package/src/android/.idea/vcs.xml +0 -6
  62. package/src/windows/IoTizeBLE.pdb +0 -0
  63. package/src/windows/IoTizeBLE.pri +0 -0
  64. /package/src/android/.gradle/{6.8.2 → 4.8.1}/fileChanges/last-build.bin +0 -0
package/README.md CHANGED
@@ -1,174 +1,174 @@
1
- # Bluetooth Low Energy (BLE) for IoTize devices Plugin for Apache Cordova
2
-
3
- This plugin enables communication between a mobile and a BLE enabled IOTIZE device.
4
-
5
- The plugin provides a simple [JavaScript API](#api) for iOS, Android and Windows.
6
-
7
- - Scan for ble iotize devices
8
- - Connect to a device
9
- - Send a Request and returns the reponse from the device
10
-
11
- ## Supported Platforms
12
-
13
- - iOS
14
- - Android ()
15
- - Windows (10)
16
-
17
- # Installing
18
-
19
- ### Cordova
20
-
21
- $ cordova plugin add @iotize/device-com-ble.cordova
22
- $ ionic cordova plugin add @iotize/device-com-ble.cordova
23
- for iOS since the plugin is in swift language, before using iotize-ble plugin , cordova-plugin-add-swift-support:https://github.com/akofman/cordova-plugin-add-swift-support should be installed.
24
-
25
- # API
26
-
27
- ## Methods
28
-
29
- - [iotize-ble.checkAvailable](#checkAvailable)
30
- - [iotize-ble.startScan](#startScan)
31
- - [iotize-ble.stopScan](#stopScan)
32
- - [iotize-ble.connect](#connect)
33
- - [iotize-ble.disConnect](#disConnect)
34
- - [iotize-ble.isConnected](#isConnected)
35
- - [iotize-ble.send](#send)
36
-
37
- ## checkAvailable
38
-
39
- Check availability of BLE.
40
-
41
- iotize-ble.checkAvailable(success, failure);
42
-
43
- ### Description
44
-
45
- Function `checkAvailable` returns true or false upon the availability of BLE on device.
46
-
47
- For Android, BLE is available from version 4.3.
48
- iOS platform has had support for BLE since iPhone 4s and iOs 5.
49
- For Windows, BLE GATT and GAP roles have been introduced in Windows 10 version 1703.
50
-
51
- ## startScan
52
-
53
- Start scanning for Iotize BLE devices.
54
-
55
- iotize-ble.startScan(success, failure);
56
-
57
- ### Description
58
-
59
- Function `startScan` scans for IoTize BLE devices. Scanning will continue until `stopScan` is called or a connection is established. The success callback is called each time a new peripheral is discovered.
60
-
61
- Advertising information is different depending on your platform. For Android and Windows, the device is identified with its MAC address and for iOS the device is identified with a unique UUID. The success callback is called at each discovery with returning an object containing the following information:
62
-
63
- - name: name of the peripheral.
64
- - address: UUID or MAC address of the peripheral.
65
- - rssi: the threshold RSSI in dBm.
66
-
67
- ### Parameters
68
-
69
- - **success**: Success callback function that is invoked upon each discovery. The callback is called with the device information as parameter.
70
- - **failure**: Error callback function, invoked when error occurs. The error string is passed as a parameter.
71
-
72
- ## stopScan
73
-
74
- Stop scanning for BLE peripherals.
75
-
76
- iotize-ble.stopScan(success, failure);
77
-
78
- ### Description
79
-
80
- Function `stopScan` stops scanning for BLE devices.
81
-
82
- ### Parameters
83
-
84
- - **success**: Success callback function, invoked when scanning is stopped.
85
- - **failure**: Error callback function, invoked when error occurs.
86
-
87
- ### Quick Example
88
-
89
- iotize-ble.startScan([], function(device) {
90
- console.log(device);
91
- }, failure);
92
-
93
- setTimeout(function() {
94
- iotize-ble.stopScan(
95
- function() { console.log("Scan complete"); },
96
- function() { console.log("stopScan failed"); }
97
- );
98
- }, 2000);
99
-
100
- ## connect
101
-
102
- Connect to a peripheral.
103
-
104
- iotize-ble.connect(device_id, connectCallback, connectionErrorCallback);
105
-
106
- ### Description
107
-
108
- Function `connect` connects to an iotize BLE peripheral. The connectCallback callback will be called when the connection is successful.
109
-
110
- The connectionErrorCallback callback is called if the connection fails, or later if the peripheral disconnects for any reason. The connectionErrorCallback callback is only called when the peripheral initates the disconnection.
111
-
112
- ### Scanning before connecting
113
-
114
- Devices should be scanned before connection. Please note that for this version only one device at a time could be connected.
115
-
116
- ### Parameters
117
-
118
- - **device_id**: Mac address or UUID of the ble device.
119
- - **connectCallback**: Connect callback function that is invoked when the connection is successful.
120
- - **connectionErrorCallback**: Disconnect callback function, invoked when the peripheral disconnects or an error occurs.
121
-
122
- ## disconnect
123
-
124
- Disconnect.
125
-
126
- iotize-ble.disConnect(device_id, success, failure);
127
-
128
- ### Description
129
-
130
- Function `disConnect` disconnects the selected device.
131
-
132
- ### Parameters
133
-
134
- - **device_id**: Mac address or UUID of the device.
135
- - **success**: Success callback function that is invoked when the connection is successful.
136
- - **failure**: Error callback function, invoked when error occurs.
137
-
138
- ## send
139
-
140
- sends a frame of byte to ioTize device using SPP characteristic.
141
-
142
- iotize-ble.send(device_id, __data__, success, failure);
143
-
144
- ### Parameters
145
-
146
- - **device_id**: Mac address or UUID of the device.
147
- - **data**: binary data as a string ex:"A2CA000007010003FFFF0002"
148
- - **success**: Success callback function that is invoked when the connection is successful. The result parameter is the response as a string :"45496F547A50723030343130303030313039429000"
149
- - **failure**: Error callback function, invoked when error occurs.
150
-
151
- ### Quick Example
152
-
153
- // read data from a characteristic, do something with received data
154
- iotize-ble.send(
155
- name,
156
- data,
157
- function successHandler(result) {
158
- console.log("received result " + result);
159
- observer.complete();
160
- },
161
- function errorHandler(err) {
162
- observer.error(err);
163
- });
164
- });
165
-
166
- # Testing the Plugin
167
-
168
- # License
169
-
170
- MIT
171
-
172
- # Feedback
173
-
174
- Try the code. If you find an problem or missing feature pluease contact Iotize support team .
1
+ # Bluetooth Low Energy (BLE) for IoTize devices Plugin for Apache Cordova
2
+
3
+ This plugin enables communication between a mobile and a BLE enabled IOTIZE device.
4
+
5
+ The plugin provides a simple [JavaScript API](#api) for iOS, Android and Windows.
6
+
7
+ - Scan for ble iotize devices
8
+ - Connect to a device
9
+ - Send a Request and returns the reponse from the device
10
+
11
+ ## Supported Platforms
12
+
13
+ - iOS
14
+ - Android ()
15
+ - Windows (10)
16
+
17
+ # Installing
18
+
19
+ ### Cordova
20
+
21
+ $ cordova plugin add @iotize/device-com-ble.cordova
22
+ $ ionic cordova plugin add @iotize/device-com-ble.cordova
23
+ for iOS since the plugin is in swift language, before using iotize-ble plugin , cordova-plugin-add-swift-support:https://github.com/akofman/cordova-plugin-add-swift-support should be installed.
24
+
25
+ # API
26
+
27
+ ## Methods
28
+
29
+ - [iotize-ble.checkAvailable](#checkAvailable)
30
+ - [iotize-ble.startScan](#startScan)
31
+ - [iotize-ble.stopScan](#stopScan)
32
+ - [iotize-ble.connect](#connect)
33
+ - [iotize-ble.disConnect](#disConnect)
34
+ - [iotize-ble.isConnected](#isConnected)
35
+ - [iotize-ble.send](#send)
36
+
37
+ ## checkAvailable
38
+
39
+ Check availability of BLE.
40
+
41
+ iotize-ble.checkAvailable(success, failure);
42
+
43
+ ### Description
44
+
45
+ Function `checkAvailable` returns true or false upon the availability of BLE on device.
46
+
47
+ For Android, BLE is available from version 4.3.
48
+ iOS platform has had support for BLE since iPhone 4s and iOs 5.
49
+ For Windows, BLE GATT and GAP roles have been introduced in Windows 10 version 1703.
50
+
51
+ ## startScan
52
+
53
+ Start scanning for Iotize BLE devices.
54
+
55
+ iotize-ble.startScan(success, failure);
56
+
57
+ ### Description
58
+
59
+ Function `startScan` scans for IoTize BLE devices. Scanning will continue until `stopScan` is called or a connection is established. The success callback is called each time a new peripheral is discovered.
60
+
61
+ Advertising information is different depending on your platform. For Android and Windows, the device is identified with its MAC address and for iOS the device is identified with a unique UUID. The success callback is called at each discovery with returning an object containing the following information:
62
+
63
+ - name: name of the peripheral.
64
+ - address: UUID or MAC address of the peripheral.
65
+ - rssi: the threshold RSSI in dBm.
66
+
67
+ ### Parameters
68
+
69
+ - **success**: Success callback function that is invoked upon each discovery. The callback is called with the device information as parameter.
70
+ - **failure**: Error callback function, invoked when error occurs. The error string is passed as a parameter.
71
+
72
+ ## stopScan
73
+
74
+ Stop scanning for BLE peripherals.
75
+
76
+ iotize-ble.stopScan(success, failure);
77
+
78
+ ### Description
79
+
80
+ Function `stopScan` stops scanning for BLE devices.
81
+
82
+ ### Parameters
83
+
84
+ - **success**: Success callback function, invoked when scanning is stopped.
85
+ - **failure**: Error callback function, invoked when error occurs.
86
+
87
+ ### Quick Example
88
+
89
+ iotize-ble.startScan([], function(device) {
90
+ console.log(device);
91
+ }, failure);
92
+
93
+ setTimeout(function() {
94
+ iotize-ble.stopScan(
95
+ function() { console.log("Scan complete"); },
96
+ function() { console.log("stopScan failed"); }
97
+ );
98
+ }, 2000);
99
+
100
+ ## connect
101
+
102
+ Connect to a peripheral.
103
+
104
+ iotize-ble.connect(device_id, connectCallback, connectionErrorCallback);
105
+
106
+ ### Description
107
+
108
+ Function `connect` connects to an iotize BLE peripheral. The connectCallback callback will be called when the connection is successful.
109
+
110
+ The connectionErrorCallback callback is called if the connection fails, or later if the peripheral disconnects for any reason. The connectionErrorCallback callback is only called when the peripheral initates the disconnection.
111
+
112
+ ### Scanning before connecting
113
+
114
+ Devices should be scanned before connection. Please note that for this version only one device at a time could be connected.
115
+
116
+ ### Parameters
117
+
118
+ - **device_id**: Mac address or UUID of the ble device.
119
+ - **connectCallback**: Connect callback function that is invoked when the connection is successful.
120
+ - **connectionErrorCallback**: Disconnect callback function, invoked when the peripheral disconnects or an error occurs.
121
+
122
+ ## disconnect
123
+
124
+ Disconnect.
125
+
126
+ iotize-ble.disConnect(device_id, success, failure);
127
+
128
+ ### Description
129
+
130
+ Function `disConnect` disconnects the selected device.
131
+
132
+ ### Parameters
133
+
134
+ - **device_id**: Mac address or UUID of the device.
135
+ - **success**: Success callback function that is invoked when the connection is successful.
136
+ - **failure**: Error callback function, invoked when error occurs.
137
+
138
+ ## send
139
+
140
+ sends a frame of byte to ioTize device using SPP characteristic.
141
+
142
+ iotize-ble.send(device_id, __data__, success, failure);
143
+
144
+ ### Parameters
145
+
146
+ - **device_id**: Mac address or UUID of the device.
147
+ - **data**: binary data as a string ex:"A2CA000007010003FFFF0002"
148
+ - **success**: Success callback function that is invoked when the connection is successful. The result parameter is the response as a string :"45496F547A50723030343130303030313039429000"
149
+ - **failure**: Error callback function, invoked when error occurs.
150
+
151
+ ### Quick Example
152
+
153
+ // read data from a characteristic, do something with received data
154
+ iotize-ble.send(
155
+ name,
156
+ data,
157
+ function successHandler(result) {
158
+ console.log("received result " + result);
159
+ observer.complete();
160
+ },
161
+ function errorHandler(err) {
162
+ observer.error(err);
163
+ });
164
+ });
165
+
166
+ # Testing the Plugin
167
+
168
+ # License
169
+
170
+ MIT
171
+
172
+ # Feedback
173
+
174
+ Try the code. If you find an problem or missing feature pluease contact Iotize support team .
@@ -515,6 +515,24 @@
515
515
  throw CordovaBLEError.iotizeBLEMissing();
516
516
  }
517
517
  return iotizeBLE;
518
+ }
519
+ function getScanRecordsFromBytes(bytes) {
520
+ //LTV encoding
521
+ var records = [];
522
+ for (var i = 0; i < bytes.length; i++) {
523
+ //first byte is length
524
+ var size = bytes[i];
525
+ if (size == 0) {
526
+ break;
527
+ }
528
+ var type = bytes[i + 1];
529
+ records.push({
530
+ type: type,
531
+ data: bytes.slice(i + 2, i + size + 1)
532
+ });
533
+ i += size;
534
+ }
535
+ return records;
518
536
  }
519
537
 
520
538
  var __awaiter$3 = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
@@ -1391,6 +1409,7 @@
1391
1409
  exports.CordovaPeripheralAdapter = CordovaPeripheralAdapter;
1392
1410
  exports.CordovaServiceAdapter = CordovaServiceAdapter;
1393
1411
  exports.getIoTizeBleCordovaPlugin = getIoTizeBleCordovaPlugin;
1412
+ exports.getScanRecordsFromBytes = getScanRecordsFromBytes;
1394
1413
  exports["ɵc"] = IoTizeBleCordovaPlugin;
1395
1414
 
1396
1415
  Object.defineProperty(exports, '__esModule', { value: true });