@autorunify/capacitor-nrfmesh 0.0.15 → 0.0.17
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 +3 -8
- package/android/src/main/java/com/autorunify/capacitor/nrfmesh/BleManager.kt +18 -30
- package/android/src/main/java/com/autorunify/capacitor/nrfmesh/FormatManager.kt +0 -4
- package/android/src/main/java/com/autorunify/capacitor/nrfmesh/MeshDevice.kt +6 -1
- package/android/src/main/java/com/autorunify/capacitor/nrfmesh/MeshManager.kt +15 -26
- package/android/src/main/java/com/autorunify/capacitor/nrfmesh/NrfMeshPlugin.kt +6 -14
- package/dist/docs.json +1 -36
- package/dist/esm/definitions.d.ts +1 -6
- package/dist/esm/definitions.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1397,7 +1397,6 @@ Creates a new function.
|
|
|
1397
1397
|
| **`name`** | <code>string</code> |
|
|
1398
1398
|
| **`provisioned`** | <code>boolean</code> |
|
|
1399
1399
|
| **`rssi`** | <code>number</code> |
|
|
1400
|
-
| **`uuid`** | <code>string</code> |
|
|
1401
1400
|
|
|
1402
1401
|
|
|
1403
1402
|
#### ScanOptions
|
|
@@ -1428,16 +1427,13 @@ Creates a new function.
|
|
|
1428
1427
|
| Prop | Type |
|
|
1429
1428
|
| ------------- | ------------------- |
|
|
1430
1429
|
| **`address`** | <code>string</code> |
|
|
1431
|
-
| **`uuid`** | <code>string</code> |
|
|
1432
1430
|
|
|
1433
1431
|
|
|
1434
1432
|
#### ProvisionResults
|
|
1435
1433
|
|
|
1436
|
-
| Prop | Type
|
|
1437
|
-
| -------------------- |
|
|
1438
|
-
| **`
|
|
1439
|
-
| **`uuid`** | <code>string</code> |
|
|
1440
|
-
| **`unicastAddress`** | <code>number</code> |
|
|
1434
|
+
| Prop | Type |
|
|
1435
|
+
| -------------------- | ------------------- |
|
|
1436
|
+
| **`unicastAddress`** | <code>number</code> |
|
|
1441
1437
|
|
|
1442
1438
|
|
|
1443
1439
|
#### ProvisionOptions
|
|
@@ -1445,7 +1441,6 @@ Creates a new function.
|
|
|
1445
1441
|
| Prop | Type |
|
|
1446
1442
|
| ------------- | ------------------- |
|
|
1447
1443
|
| **`address`** | <code>string</code> |
|
|
1448
|
-
| **`uuid`** | <code>string</code> |
|
|
1449
1444
|
|
|
1450
1445
|
|
|
1451
1446
|
#### CompositionResults
|
|
@@ -20,7 +20,6 @@ import no.nordicsemi.android.mesh.MeshManagerApi
|
|
|
20
20
|
import no.nordicsemi.android.support.v18.scanner.BluetoothLeScannerCompat
|
|
21
21
|
import no.nordicsemi.android.support.v18.scanner.ScanCallback
|
|
22
22
|
import no.nordicsemi.android.support.v18.scanner.ScanFilter
|
|
23
|
-
import no.nordicsemi.android.support.v18.scanner.ScanRecord
|
|
24
23
|
import no.nordicsemi.android.support.v18.scanner.ScanResult
|
|
25
24
|
import no.nordicsemi.android.support.v18.scanner.ScanSettings
|
|
26
25
|
import java.util.UUID
|
|
@@ -106,12 +105,10 @@ class BleManager {
|
|
|
106
105
|
if (record.bytes == null || record.serviceUuids == null) return
|
|
107
106
|
|
|
108
107
|
synchronized(ble.devices) {
|
|
109
|
-
val service = getService(
|
|
108
|
+
val service = device.getService(MeshManagerApi.MESH_PROVISIONING_UUID)
|
|
110
109
|
if (service == null || service.size < 18) return
|
|
111
110
|
|
|
112
|
-
|
|
113
|
-
ble.mesh.delNodeByService(service)
|
|
114
|
-
device.uuid = ble.mesh.uuidFromService(service).toString()
|
|
111
|
+
ble.mesh.delNodeByName(device.address.replace(":", ""))
|
|
115
112
|
device.provisioned = false
|
|
116
113
|
|
|
117
114
|
val _device = ble.devices.find { v ->
|
|
@@ -133,11 +130,13 @@ class BleManager {
|
|
|
133
130
|
if (record.bytes == null || record.serviceUuids == null) return
|
|
134
131
|
|
|
135
132
|
synchronized(ble.devices) {
|
|
136
|
-
val service = getService(
|
|
137
|
-
if (!ble.mesh.isProvisionedByService(service))
|
|
133
|
+
val service = device.getService(MeshManagerApi.MESH_PROXY_UUID) ?: return
|
|
134
|
+
if (!ble.mesh.isProvisionedByService(service)) {
|
|
135
|
+
ble.mesh.delNodeByName(device.address.replace("", ""))
|
|
136
|
+
return
|
|
137
|
+
}
|
|
138
138
|
|
|
139
139
|
device.provisioned = true
|
|
140
|
-
|
|
141
140
|
val _device = ble.devices.find { v ->
|
|
142
141
|
v.address == device.address
|
|
143
142
|
}
|
|
@@ -155,15 +154,6 @@ class BleManager {
|
|
|
155
154
|
override fun onScanFailed(errorCode: Int) {
|
|
156
155
|
ble.scan(false)
|
|
157
156
|
}
|
|
158
|
-
|
|
159
|
-
fun getService(scanResult: ScanResult, serviceUuid: UUID): ByteArray? {
|
|
160
|
-
val scanRecord: ScanRecord? = scanResult.scanRecord
|
|
161
|
-
if (scanRecord != null) {
|
|
162
|
-
return scanRecord.getServiceData(ParcelUuid((serviceUuid)))
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
return null
|
|
166
|
-
}
|
|
167
157
|
}
|
|
168
158
|
|
|
169
159
|
private val notify: NrfMeshPlugin
|
|
@@ -363,10 +353,11 @@ class BleManager {
|
|
|
363
353
|
return isConnected.value!!
|
|
364
354
|
}
|
|
365
355
|
|
|
366
|
-
suspend fun connectToUnprovisioned(address: String
|
|
356
|
+
suspend fun connectToUnprovisioned(address: String): UUID? {
|
|
367
357
|
if (isConnected.value == true) {
|
|
368
358
|
if (device?.provisioned == false && device?.address == address) {
|
|
369
|
-
|
|
359
|
+
val service = device!!.getService(MeshManagerApi.MESH_PROVISIONING_UUID)
|
|
360
|
+
return mesh.uuidFromService(service!!)
|
|
370
361
|
} else {
|
|
371
362
|
disconnect()
|
|
372
363
|
}
|
|
@@ -395,19 +386,16 @@ class BleManager {
|
|
|
395
386
|
|
|
396
387
|
|
|
397
388
|
_devices.sortBy { device -> device.rssi }
|
|
398
|
-
|
|
399
|
-
it.
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
deviceUUID.toString() == uuid
|
|
406
|
-
}
|
|
407
|
-
})
|
|
389
|
+
val _device = _devices.firstOrNull {
|
|
390
|
+
it.address.equals(address, true)
|
|
391
|
+
}
|
|
392
|
+
if (connect(_device)) {
|
|
393
|
+
val service = _device!!.getService(MeshManagerApi.MESH_PROVISIONING_UUID)
|
|
394
|
+
return mesh.uuidFromService(service!!)
|
|
395
|
+
}
|
|
408
396
|
}
|
|
409
397
|
|
|
410
|
-
return
|
|
398
|
+
return null
|
|
411
399
|
}
|
|
412
400
|
|
|
413
401
|
suspend fun connectToProvisioned(address: String? = null): Boolean {
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
package com.autorunify.capacitor.nrfmesh
|
|
2
2
|
|
|
3
3
|
import android.bluetooth.BluetoothDevice
|
|
4
|
+
import android.os.ParcelUuid
|
|
4
5
|
import no.nordicsemi.android.support.v18.scanner.ScanRecord
|
|
5
6
|
import no.nordicsemi.android.support.v18.scanner.ScanResult
|
|
7
|
+
import java.util.UUID
|
|
6
8
|
|
|
7
9
|
class MeshDevice {
|
|
8
10
|
val scanResult: ScanResult
|
|
@@ -16,7 +18,6 @@ class MeshDevice {
|
|
|
16
18
|
get() = device.address
|
|
17
19
|
|
|
18
20
|
var provisioned: Boolean = false
|
|
19
|
-
var uuid: String? = null
|
|
20
21
|
|
|
21
22
|
constructor(scanResult: ScanResult) {
|
|
22
23
|
this.scanResult = scanResult
|
|
@@ -46,4 +47,8 @@ class MeshDevice {
|
|
|
46
47
|
return result
|
|
47
48
|
}
|
|
48
49
|
|
|
50
|
+
fun getService(serviceUuid: UUID): ByteArray? {
|
|
51
|
+
val scanRecord: ScanRecord = scanResult.scanRecord ?: return null
|
|
52
|
+
return scanRecord.getServiceData(ParcelUuid((serviceUuid)))
|
|
53
|
+
}
|
|
49
54
|
}
|
|
@@ -171,7 +171,7 @@ class MeshManager {
|
|
|
171
171
|
address
|
|
172
172
|
)
|
|
173
173
|
|
|
174
|
-
is SensorStatus-> mesh.async.emit(
|
|
174
|
+
is SensorStatus -> mesh.async.emit(
|
|
175
175
|
mesh.formatter.toJSON(msg),
|
|
176
176
|
msg.opCode,
|
|
177
177
|
address
|
|
@@ -208,10 +208,7 @@ class MeshManager {
|
|
|
208
208
|
) {
|
|
209
209
|
if (state == ProvisioningState.States.PROVISIONING_FAILED) {
|
|
210
210
|
mesh.unodes.remove(meshNode!!)
|
|
211
|
-
mesh.async.
|
|
212
|
-
put("completed", false)
|
|
213
|
-
put("uuid", meshNode.deviceUuid)
|
|
214
|
-
}, MESH_NODE_PROVISION)
|
|
211
|
+
mesh.async.error("provisioning failed ${meshNode.nodeName}", MESH_NODE_PROVISION,0)
|
|
215
212
|
}
|
|
216
213
|
}
|
|
217
214
|
|
|
@@ -237,20 +234,13 @@ class MeshManager {
|
|
|
237
234
|
}
|
|
238
235
|
}
|
|
239
236
|
|
|
240
|
-
meshNode!!.nodeName=meshNode
|
|
241
|
-
.uuid
|
|
242
|
-
.replace("-","")
|
|
243
|
-
.substring(8,20)
|
|
244
|
-
|
|
245
237
|
mesh.async.emit(JSObject().apply {
|
|
246
|
-
put("
|
|
247
|
-
put("uuid", meshNode.uuid)
|
|
248
|
-
put("unicastAddress", meshNode.unicastAddress)
|
|
238
|
+
put("unicastAddress", meshNode!!.unicastAddress)
|
|
249
239
|
}, MESH_NODE_PROVISION)
|
|
250
240
|
|
|
251
241
|
mesh.notify.notifyListeners("node", JSObject().apply {
|
|
252
242
|
put("action", "add")
|
|
253
|
-
put("unicastAddress", meshNode
|
|
243
|
+
put("unicastAddress", meshNode!!.unicastAddress)
|
|
254
244
|
})
|
|
255
245
|
}
|
|
256
246
|
}
|
|
@@ -448,16 +438,15 @@ class MeshManager {
|
|
|
448
438
|
return api.getDeviceUuid(service)
|
|
449
439
|
}
|
|
450
440
|
|
|
451
|
-
fun
|
|
452
|
-
api.meshNetwork?.nodes?.
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
}
|
|
441
|
+
fun delNodeByName(name: String) {
|
|
442
|
+
api.meshNetwork?.nodes?.filter { node ->
|
|
443
|
+
node.nodeName.equals(name, true)
|
|
444
|
+
}?.forEach { node ->
|
|
445
|
+
api.meshNetwork?.deleteNode(node)
|
|
446
|
+
notify.notifyListeners("node", JSObject().apply {
|
|
447
|
+
put("action", "del")
|
|
448
|
+
put("unicastAddress", node.unicastAddress)
|
|
449
|
+
})
|
|
461
450
|
}
|
|
462
451
|
}
|
|
463
452
|
|
|
@@ -594,7 +583,7 @@ class MeshManager {
|
|
|
594
583
|
this.api.identifyNode(uuid)
|
|
595
584
|
}
|
|
596
585
|
|
|
597
|
-
fun provision(uuid: UUID) {
|
|
586
|
+
fun provision(uuid: UUID, name: String) {
|
|
598
587
|
val unode = unodes.find {
|
|
599
588
|
it.deviceUuid == uuid
|
|
600
589
|
}
|
|
@@ -604,7 +593,7 @@ class MeshManager {
|
|
|
604
593
|
unode!!.numberOfElements, provisioner!!
|
|
605
594
|
)
|
|
606
595
|
|
|
607
|
-
unode!!.nodeName =
|
|
596
|
+
unode!!.nodeName = name.uppercase()
|
|
608
597
|
|
|
609
598
|
api.meshNetwork!!.assignUnicastAddress(unicastAddress!!)
|
|
610
599
|
api.startProvisioning(unode)
|
|
@@ -68,7 +68,6 @@ import no.nordicsemi.android.mesh.transport.ConfigSigModelAppGet
|
|
|
68
68
|
import no.nordicsemi.android.mesh.transport.ConfigVendorModelAppGet
|
|
69
69
|
import no.nordicsemi.android.mesh.transport.GenericOnOffGet
|
|
70
70
|
import no.nordicsemi.android.mesh.transport.GenericOnOffSet
|
|
71
|
-
import java.util.UUID
|
|
72
71
|
import kotlin.random.Random
|
|
73
72
|
|
|
74
73
|
@CapacitorPlugin(
|
|
@@ -516,14 +515,11 @@ class NrfMeshPlugin : Plugin {
|
|
|
516
515
|
try {
|
|
517
516
|
val address = call.getString("address")
|
|
518
517
|
?: return@launch call.reject("address is required")
|
|
519
|
-
val uuid = call.getString("uuid")
|
|
520
|
-
?: return@launch call.reject("uuid is required")
|
|
521
518
|
|
|
522
|
-
|
|
523
|
-
return@launch call.reject("Failed to connect to device : $address
|
|
524
|
-
}
|
|
519
|
+
val uuid = ble.connectToUnprovisioned(address)
|
|
520
|
+
?: return@launch call.reject("Failed to connect to device : $address")
|
|
525
521
|
|
|
526
|
-
mesh.identify(
|
|
522
|
+
mesh.identify(uuid)
|
|
527
523
|
|
|
528
524
|
val timeout = call.getInt("timeout", defaultTimeout)
|
|
529
525
|
async.on(call, MESH_NODE_IDENTIFY).timeout(timeout!!)
|
|
@@ -544,14 +540,10 @@ class NrfMeshPlugin : Plugin {
|
|
|
544
540
|
try {
|
|
545
541
|
val address = call.getString("address")
|
|
546
542
|
?: return@launch call.reject("address is required")
|
|
547
|
-
val uuid =
|
|
548
|
-
?: return@launch call.reject("
|
|
549
|
-
|
|
550
|
-
if (!ble.connectToUnprovisioned(address, uuid)) {
|
|
551
|
-
return@launch call.reject("Failed to connect to device : $address $uuid")
|
|
552
|
-
}
|
|
543
|
+
val uuid = ble.connectToUnprovisioned(address)
|
|
544
|
+
?: return@launch call.reject("Failed to connect to device : $address")
|
|
553
545
|
|
|
554
|
-
mesh.provision(
|
|
546
|
+
mesh.provision(uuid, address.replace(":", ""))
|
|
555
547
|
|
|
556
548
|
val timeout = call.getInt("timeout", defaultTimeout)
|
|
557
549
|
async.on(call, MESH_NODE_PROVISION).timeout(timeout!!)
|
package/dist/docs.json
CHANGED
|
@@ -4947,13 +4947,6 @@
|
|
|
4947
4947
|
"docs": "",
|
|
4948
4948
|
"complexTypes": [],
|
|
4949
4949
|
"type": "number"
|
|
4950
|
-
},
|
|
4951
|
-
{
|
|
4952
|
-
"name": "uuid",
|
|
4953
|
-
"tags": [],
|
|
4954
|
-
"docs": "",
|
|
4955
|
-
"complexTypes": [],
|
|
4956
|
-
"type": "string | undefined"
|
|
4957
4950
|
}
|
|
4958
4951
|
]
|
|
4959
4952
|
},
|
|
@@ -5067,13 +5060,6 @@
|
|
|
5067
5060
|
"docs": "",
|
|
5068
5061
|
"complexTypes": [],
|
|
5069
5062
|
"type": "string"
|
|
5070
|
-
},
|
|
5071
|
-
{
|
|
5072
|
-
"name": "uuid",
|
|
5073
|
-
"tags": [],
|
|
5074
|
-
"docs": "",
|
|
5075
|
-
"complexTypes": [],
|
|
5076
|
-
"type": "string"
|
|
5077
5063
|
}
|
|
5078
5064
|
]
|
|
5079
5065
|
},
|
|
@@ -5084,26 +5070,12 @@
|
|
|
5084
5070
|
"tags": [],
|
|
5085
5071
|
"methods": [],
|
|
5086
5072
|
"properties": [
|
|
5087
|
-
{
|
|
5088
|
-
"name": "completed",
|
|
5089
|
-
"tags": [],
|
|
5090
|
-
"docs": "",
|
|
5091
|
-
"complexTypes": [],
|
|
5092
|
-
"type": "boolean"
|
|
5093
|
-
},
|
|
5094
|
-
{
|
|
5095
|
-
"name": "uuid",
|
|
5096
|
-
"tags": [],
|
|
5097
|
-
"docs": "",
|
|
5098
|
-
"complexTypes": [],
|
|
5099
|
-
"type": "string"
|
|
5100
|
-
},
|
|
5101
5073
|
{
|
|
5102
5074
|
"name": "unicastAddress",
|
|
5103
5075
|
"tags": [],
|
|
5104
5076
|
"docs": "",
|
|
5105
5077
|
"complexTypes": [],
|
|
5106
|
-
"type": "number
|
|
5078
|
+
"type": "number"
|
|
5107
5079
|
}
|
|
5108
5080
|
]
|
|
5109
5081
|
},
|
|
@@ -5120,13 +5092,6 @@
|
|
|
5120
5092
|
"docs": "",
|
|
5121
5093
|
"complexTypes": [],
|
|
5122
5094
|
"type": "string"
|
|
5123
|
-
},
|
|
5124
|
-
{
|
|
5125
|
-
"name": "uuid",
|
|
5126
|
-
"tags": [],
|
|
5127
|
-
"docs": "",
|
|
5128
|
-
"complexTypes": [],
|
|
5129
|
-
"type": "string"
|
|
5130
5095
|
}
|
|
5131
5096
|
]
|
|
5132
5097
|
},
|
|
@@ -252,7 +252,6 @@ export interface MeshDevice {
|
|
|
252
252
|
name: string;
|
|
253
253
|
provisioned: boolean;
|
|
254
254
|
rssi: number;
|
|
255
|
-
uuid?: string;
|
|
256
255
|
}
|
|
257
256
|
export interface ScanOptions extends TimeoutOptions {
|
|
258
257
|
filter?: 'all' | 'provisioned' | 'unprovisioned';
|
|
@@ -263,7 +262,6 @@ export interface ScanResults {
|
|
|
263
262
|
}
|
|
264
263
|
export interface IdentifyOptions extends TimeoutOptions {
|
|
265
264
|
address: string;
|
|
266
|
-
uuid: string;
|
|
267
265
|
}
|
|
268
266
|
export interface IdentifyResults {
|
|
269
267
|
numberOfElements: number;
|
|
@@ -278,12 +276,9 @@ export interface IdentifyResults {
|
|
|
278
276
|
}
|
|
279
277
|
export interface ProvisionOptions extends TimeoutOptions {
|
|
280
278
|
address: string;
|
|
281
|
-
uuid: string;
|
|
282
279
|
}
|
|
283
280
|
export interface ProvisionResults {
|
|
284
|
-
|
|
285
|
-
uuid: string;
|
|
286
|
-
unicastAddress?: number;
|
|
281
|
+
unicastAddress: number;
|
|
287
282
|
}
|
|
288
283
|
export interface CompositionOptions extends TimeoutOptions {
|
|
289
284
|
unicastAddress: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["import type { PluginListenerHandle } from '@capacitor/core'\n\ntype PartialAny<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;\n\nexport type PermissionState = 'denied' | 'granted'\n\nexport type PermissionKey =\n \"android.permission.BLUETOOTH\" |\n \"android.permission.BLUETOOTH_ADMIN\" |\n \"android.permission.ACCESS_COARSE_LOCATION\" |\n \"android.permission.ACCESS_FINE_LOCATION\" |\n \"android.permission.BLUETOOTH_SCAN\" |\n \"android.permission.BLUETOOTH_CONNECT\"\n\n\nexport type Permissions = {\n [key in PermissionKey]: PermissionState;\n}\n\nexport interface BluetoothState {\n enabled: boolean;\n}\n\nexport interface TimeoutOptions {\n timeout?: number\n}\n\nexport interface ConnectionState {\n connected: boolean\n}\n\nexport interface ConnectOptions extends TimeoutOptions {\n address: string;\n}\n\nexport interface NetKey {\n index: number;\n key: string;\n minSecurity: string;\n name: string;\n phase: number;\n timestamp: string;\n oldKey?: string;\n}\n\nexport interface AppKey {\n index: number\n boundNetKey: number\n key: string\n name: string\n}\n\nexport interface MeshGroup {\n name: string\n address: number\n addressHex: string\n}\n\nexport interface MeshNode {\n uuid: string\n name: string\n deviceKey: string\n unicastAddress: number\n security: string\n ttl: number\n netkeys: Array<{ index: number, updated: boolean }>\n appkeys: Array<{ index: number, updated: boolean }>\n elements: Array<{\n name: string\n elementAddress: number\n models: Array<{\n modelId: number\n appkeys: Array<number>\n subscriptions: Array<number>\n publication?: number\n }>\n }>\n features?: {\n friend: number\n lowPower: number\n proxy: number\n relay: number\n }\n networkTransmit?: {\n count: number\n interval: number\n steps: number\n }\n}\n\nexport interface OnOffModel {\n state: boolean\n}\n\nexport interface SensorRawValue {\n propertyId: number\n bytes: Array<number>\n}\n\nexport interface SensorModel {\n values: Array<SensorRawValue>\n}\n\nexport interface SensorPropertiesModel {\n properties: Array<number>\n}\n\nexport interface NetKeysResults {\n netkeys: Array<NetKey>\n}\n\nexport interface NetKeyOptions {\n add?: Omit<NetKey, 'index' | 'key' | 'minSecurity' | 'name' | 'phase' | 'timestamp' | 'oldKey'>\n del?: Omit<NetKey, 'key' | 'minSecurity' | 'name' | 'phase' | 'timestamp' | 'oldKey'>\n get?: Omit<NetKey, 'key' | 'minSecurity' | 'name' | 'phase' | 'timestamp' | 'oldKey'>\n}\n\nexport interface AppKeysOptions {\n boundNetKey: number\n}\n\nexport interface AppKeysResults {\n appkeys: Array<AppKey>\n}\n\nexport interface AppKeyOptions {\n add?: Partial<Omit<AppKey, 'index' | 'key' | 'name'>>\n del?: Omit<AppKey, 'boundNetKey' | 'key' | 'name'>\n get?: Omit<AppKey, 'boundNetKey' | 'key' | 'name'>\n}\n\nexport interface GroupsResults {\n groups: Array<MeshGroup>\n}\n\nexport interface GroupOptions {\n add?: Omit<MeshGroup, 'name' | 'addressHex'>\n del?: Omit<MeshGroup, 'name' | 'addressHex'>\n get?: Omit<MeshGroup, 'name' | 'addressHex'>\n}\n\nexport interface NodesResults {\n nodes: Array<MeshNode>\n}\n\nexport interface NodeDefaultTTL {\n ttl: number;\n}\n\nexport interface NodeNetworkTransmit {\n count: number\n intervalSteps: number\n}\n\nexport interface NodeNetkey {\n netkeyIndex: number\n}\n\nexport interface NodeNetkeys {\n netkeyIndexes: Array<number>\n}\n\nexport interface NodeAppkey {\n netkeyIndex: number\n appkeyIndex: number\n}\n\nexport interface NodeAppkeys {\n netkeyIndex: number\n appkeyIndexes: Array<number>\n}\n\nexport interface ModelAppkey {\n elementAddress: number;\n modelId: number;\n appkeyIndex: number;\n}\n\nexport interface ModelAppkeys {\n elementAddress: number;\n modelId: number;\n appkeyIndexs: Array<number>;\n}\n\nexport interface HeartbeatPub {\n address: number\n count: number\n period: number\n ttl: number\n netkeyIndex: number\n features: {\n friend: number\n proxy: number\n relay: number\n lowPower: number\n }\n}\n\nexport interface HeartbeatSub {\n srcAddress: number\n dstAddress: number\n period: number\n count: number\n minHops: number\n maxHops: number\n}\n\nexport interface NodeOptions extends TimeoutOptions {\n unicastAddress: number\n get?: Object\n defaultTTL?: { set?: NodeDefaultTTL }\n networkTransmit?: { set?: NodeNetworkTransmit }\n netkey?: {\n add?: NodeNetkey\n del?: NodeNetkey\n get?: Omit<NodeNetkeys, 'netkeyIndexes'>\n }\n appkey?: {\n add?: Omit<NodeAppkey, 'netkeyIndex'>\n del?: Omit<NodeAppkey, 'netkeyIndex'>\n get?: Partial<Omit<NodeAppkeys, 'appkeyIndexes'>>\n },\n heartbeat?: {\n pub?: { set?: PartialAny<Omit<HeartbeatPub, 'features'>, 'address' | 'count' | 'netkeyIndex'> }\n sub?: { set?: Omit<HeartbeatSub, 'count' | 'minHops' | 'maxHops'> }\n },\n bind?: {\n add?: ModelAppkey\n del?: ModelAppkey\n get?: Omit<ModelAppkeys, \"appkeyIndexs\">\n }\n}\n\nexport interface NodeResults {\n get?: MeshNode\n defaultTTL?: NodeDefaultTTL\n networkTransmit?: NodeNetworkTransmit\n netkey?: {\n add?: NodeNetkey\n del?: NodeNetkey\n get?: NodeNetkeys\n }\n appkey?: {\n add?: NodeAppkey\n del?: NodeAppkey\n get?: NodeAppkeys\n },\n heartbeat?: {\n pub?: HeartbeatPub\n sub?: HeartbeatSub\n },\n bind?: {\n add?: ModelAppkey\n del?: ModelAppkey\n get?: ModelAppkeys\n }\n}\n\nexport interface ModelOptions extends TimeoutOptions {\n elementAddress: number\n appkeyIndex: number\n onoff?: {\n set?: OnOffModel\n },\n sensor?: {\n propertyId?: number\n get?: Omit<SensorModel, 'values'>\n property?: PartialAny<SensorRawValue, 'bytes'>\n properties?: SensorPropertiesModel\n }\n}\n\nexport interface ModelResults {\n onoff?: OnOffModel,\n sensor?: {\n get?: SensorModel\n property?: SensorRawValue\n properties?: SensorPropertiesModel\n }\n}\n\nexport interface MeshDevice {\n address: string\n name: string\n provisioned: boolean\n rssi: number\n
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["import type { PluginListenerHandle } from '@capacitor/core'\n\ntype PartialAny<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;\n\nexport type PermissionState = 'denied' | 'granted'\n\nexport type PermissionKey =\n \"android.permission.BLUETOOTH\" |\n \"android.permission.BLUETOOTH_ADMIN\" |\n \"android.permission.ACCESS_COARSE_LOCATION\" |\n \"android.permission.ACCESS_FINE_LOCATION\" |\n \"android.permission.BLUETOOTH_SCAN\" |\n \"android.permission.BLUETOOTH_CONNECT\"\n\n\nexport type Permissions = {\n [key in PermissionKey]: PermissionState;\n}\n\nexport interface BluetoothState {\n enabled: boolean;\n}\n\nexport interface TimeoutOptions {\n timeout?: number\n}\n\nexport interface ConnectionState {\n connected: boolean\n}\n\nexport interface ConnectOptions extends TimeoutOptions {\n address: string;\n}\n\nexport interface NetKey {\n index: number;\n key: string;\n minSecurity: string;\n name: string;\n phase: number;\n timestamp: string;\n oldKey?: string;\n}\n\nexport interface AppKey {\n index: number\n boundNetKey: number\n key: string\n name: string\n}\n\nexport interface MeshGroup {\n name: string\n address: number\n addressHex: string\n}\n\nexport interface MeshNode {\n uuid: string\n name: string\n deviceKey: string\n unicastAddress: number\n security: string\n ttl: number\n netkeys: Array<{ index: number, updated: boolean }>\n appkeys: Array<{ index: number, updated: boolean }>\n elements: Array<{\n name: string\n elementAddress: number\n models: Array<{\n modelId: number\n appkeys: Array<number>\n subscriptions: Array<number>\n publication?: number\n }>\n }>\n features?: {\n friend: number\n lowPower: number\n proxy: number\n relay: number\n }\n networkTransmit?: {\n count: number\n interval: number\n steps: number\n }\n}\n\nexport interface OnOffModel {\n state: boolean\n}\n\nexport interface SensorRawValue {\n propertyId: number\n bytes: Array<number>\n}\n\nexport interface SensorModel {\n values: Array<SensorRawValue>\n}\n\nexport interface SensorPropertiesModel {\n properties: Array<number>\n}\n\nexport interface NetKeysResults {\n netkeys: Array<NetKey>\n}\n\nexport interface NetKeyOptions {\n add?: Omit<NetKey, 'index' | 'key' | 'minSecurity' | 'name' | 'phase' | 'timestamp' | 'oldKey'>\n del?: Omit<NetKey, 'key' | 'minSecurity' | 'name' | 'phase' | 'timestamp' | 'oldKey'>\n get?: Omit<NetKey, 'key' | 'minSecurity' | 'name' | 'phase' | 'timestamp' | 'oldKey'>\n}\n\nexport interface AppKeysOptions {\n boundNetKey: number\n}\n\nexport interface AppKeysResults {\n appkeys: Array<AppKey>\n}\n\nexport interface AppKeyOptions {\n add?: Partial<Omit<AppKey, 'index' | 'key' | 'name'>>\n del?: Omit<AppKey, 'boundNetKey' | 'key' | 'name'>\n get?: Omit<AppKey, 'boundNetKey' | 'key' | 'name'>\n}\n\nexport interface GroupsResults {\n groups: Array<MeshGroup>\n}\n\nexport interface GroupOptions {\n add?: Omit<MeshGroup, 'name' | 'addressHex'>\n del?: Omit<MeshGroup, 'name' | 'addressHex'>\n get?: Omit<MeshGroup, 'name' | 'addressHex'>\n}\n\nexport interface NodesResults {\n nodes: Array<MeshNode>\n}\n\nexport interface NodeDefaultTTL {\n ttl: number;\n}\n\nexport interface NodeNetworkTransmit {\n count: number\n intervalSteps: number\n}\n\nexport interface NodeNetkey {\n netkeyIndex: number\n}\n\nexport interface NodeNetkeys {\n netkeyIndexes: Array<number>\n}\n\nexport interface NodeAppkey {\n netkeyIndex: number\n appkeyIndex: number\n}\n\nexport interface NodeAppkeys {\n netkeyIndex: number\n appkeyIndexes: Array<number>\n}\n\nexport interface ModelAppkey {\n elementAddress: number;\n modelId: number;\n appkeyIndex: number;\n}\n\nexport interface ModelAppkeys {\n elementAddress: number;\n modelId: number;\n appkeyIndexs: Array<number>;\n}\n\nexport interface HeartbeatPub {\n address: number\n count: number\n period: number\n ttl: number\n netkeyIndex: number\n features: {\n friend: number\n proxy: number\n relay: number\n lowPower: number\n }\n}\n\nexport interface HeartbeatSub {\n srcAddress: number\n dstAddress: number\n period: number\n count: number\n minHops: number\n maxHops: number\n}\n\nexport interface NodeOptions extends TimeoutOptions {\n unicastAddress: number\n get?: Object\n defaultTTL?: { set?: NodeDefaultTTL }\n networkTransmit?: { set?: NodeNetworkTransmit }\n netkey?: {\n add?: NodeNetkey\n del?: NodeNetkey\n get?: Omit<NodeNetkeys, 'netkeyIndexes'>\n }\n appkey?: {\n add?: Omit<NodeAppkey, 'netkeyIndex'>\n del?: Omit<NodeAppkey, 'netkeyIndex'>\n get?: Partial<Omit<NodeAppkeys, 'appkeyIndexes'>>\n },\n heartbeat?: {\n pub?: { set?: PartialAny<Omit<HeartbeatPub, 'features'>, 'address' | 'count' | 'netkeyIndex'> }\n sub?: { set?: Omit<HeartbeatSub, 'count' | 'minHops' | 'maxHops'> }\n },\n bind?: {\n add?: ModelAppkey\n del?: ModelAppkey\n get?: Omit<ModelAppkeys, \"appkeyIndexs\">\n }\n}\n\nexport interface NodeResults {\n get?: MeshNode\n defaultTTL?: NodeDefaultTTL\n networkTransmit?: NodeNetworkTransmit\n netkey?: {\n add?: NodeNetkey\n del?: NodeNetkey\n get?: NodeNetkeys\n }\n appkey?: {\n add?: NodeAppkey\n del?: NodeAppkey\n get?: NodeAppkeys\n },\n heartbeat?: {\n pub?: HeartbeatPub\n sub?: HeartbeatSub\n },\n bind?: {\n add?: ModelAppkey\n del?: ModelAppkey\n get?: ModelAppkeys\n }\n}\n\nexport interface ModelOptions extends TimeoutOptions {\n elementAddress: number\n appkeyIndex: number\n onoff?: {\n set?: OnOffModel\n },\n sensor?: {\n propertyId?: number\n get?: Omit<SensorModel, 'values'>\n property?: PartialAny<SensorRawValue, 'bytes'>\n properties?: SensorPropertiesModel\n }\n}\n\nexport interface ModelResults {\n onoff?: OnOffModel,\n sensor?: {\n get?: SensorModel\n property?: SensorRawValue\n properties?: SensorPropertiesModel\n }\n}\n\nexport interface MeshDevice {\n address: string\n name: string\n provisioned: boolean\n rssi: number\n}\n\nexport interface ScanOptions extends TimeoutOptions {\n filter?: 'all' | 'provisioned' | 'unprovisioned'\n max?: number\n}\n\nexport interface ScanResults {\n devices: Array<MeshDevice>\n}\n\nexport interface IdentifyOptions extends TimeoutOptions {\n address: string;\n}\n\nexport interface IdentifyResults {\n numberOfElements: number;\n availableOOBTypes: Array<string>;\n algorithms: number;\n publicKeyType: number;\n staticOobTypes: number;\n outputOobSize: number;\n outputOobActions: number;\n inputOobSize: number;\n inputOobActions: number;\n}\n\nexport interface ProvisionOptions extends TimeoutOptions {\n address: string;\n}\n\nexport interface ProvisionResults {\n unicastAddress: number;\n}\n\nexport interface CompositionOptions extends TimeoutOptions {\n unicastAddress: number\n}\n\nexport interface CompositionResults {\n companyIdentifier: string;\n productIdentifier: string;\n productVersion: string;\n nodeFeaturesSupported: {\n relay: boolean;\n proxy: boolean;\n friend: boolean;\n lowPower: boolean;\n };\n elements: Array<{\n name: string;\n elementAddress: number;\n sigModelCount: number;\n vendorModelCount: number;\n location: number;\n models: Array<{\n modelId: number;\n modelName: string;\n boundAppKeyIndexes: Array<number>;\n }>;\n }>;\n}\n\nexport interface OnStateChangeEvent {\n action: 'enabled' | 'connected'\n state: boolean\n}\n\nexport interface OnNodeChangeEvent {\n action: 'del' | 'add' | 'heartbeat'\n unicastAddress: number\n}\n\nexport interface NrfMeshPlugin {\n checkPermissions(): Promise<Permissions>;\n requestPermissions(): Promise<Permissions>;\n isBluetoothEnabled(): Promise<BluetoothState>;\n\n isConnected(): Promise<ConnectionState>;\n connect(options?: ConnectOptions): Promise<void>;\n disconnect(options?: TimeoutOptions): Promise<void>;\n\n export(): Promise<any>\n import(options: any): Promise<void>\n\n netkeys(): Promise<NetKeysResults>\n netkey(options: NetKeyOptions): Promise<NetKey>\n\n appkeys(options?: AppKeysOptions): Promise<AppKeysResults>\n appkey(options: AppKeyOptions): Promise<AppKey>\n\n groups(): Promise<GroupsResults>\n group(options: GroupOptions): Promise<MeshGroup>\n\n nodes(): Promise<NodesResults>\n node(options: NodeOptions): Promise<NodeResults>\n\n model(options: ModelOptions): Promise<ModelResults>\n\n init(): Promise<any>;\n kill(): Promise<void>\n devices(options?: ScanOptions): Promise<ScanResults>;\n identify(options: IdentifyOptions): Promise<IdentifyResults>;\n provision(options: ProvisionOptions): Promise<ProvisionResults>;\n composition(options: CompositionOptions): Promise<CompositionResults>;\n\n addListener(\n event: 'state',\n callback: (e: OnStateChangeEvent) => void,\n ): Promise<PluginListenerHandle>;\n addListener(\n event: 'node',\n callback: (e: OnNodeChangeEvent) => void,\n ): Promise<PluginListenerHandle>;\n}\n"]}
|