kard-network-ble-mesh 1.1.0 → 1.1.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.
|
@@ -145,6 +145,14 @@ class BleMeshModule(reactContext: ReactApplicationContext) : ReactContextBaseJav
|
|
|
145
145
|
fun start(nickname: String, promise: Promise) {
|
|
146
146
|
myNickname = nickname
|
|
147
147
|
|
|
148
|
+
// If already running, just update nickname and resolve
|
|
149
|
+
if (isRunning) {
|
|
150
|
+
Log.d(TAG, "Already running, updating nickname to: $nickname")
|
|
151
|
+
sendAnnounce()
|
|
152
|
+
promise.resolve(null)
|
|
153
|
+
return
|
|
154
|
+
}
|
|
155
|
+
|
|
148
156
|
scope.launch {
|
|
149
157
|
try {
|
|
150
158
|
startBleServices()
|
|
@@ -162,6 +170,13 @@ class BleMeshModule(reactContext: ReactApplicationContext) : ReactContextBaseJav
|
|
|
162
170
|
|
|
163
171
|
@ReactMethod
|
|
164
172
|
fun stop(promise: Promise) {
|
|
173
|
+
// If not running, just resolve
|
|
174
|
+
if (!isRunning) {
|
|
175
|
+
Log.d(TAG, "Already stopped, nothing to do")
|
|
176
|
+
promise.resolve(null)
|
|
177
|
+
return
|
|
178
|
+
}
|
|
179
|
+
|
|
165
180
|
scope.launch {
|
|
166
181
|
try {
|
|
167
182
|
sendLeaveAnnouncement()
|
package/ios/BleMesh.swift
CHANGED
|
@@ -776,7 +776,7 @@ extension BleMesh: CBCentralManagerDelegate {
|
|
|
776
776
|
if central.state == .poweredOn && isRunning {
|
|
777
777
|
central.scanForPeripherals(
|
|
778
778
|
withServices: [BleMesh.serviceUUID],
|
|
779
|
-
options: [CBCentralManagerScanOptionAllowDuplicatesKey:
|
|
779
|
+
options: [CBCentralManagerScanOptionAllowDuplicatesKey: true]
|
|
780
780
|
)
|
|
781
781
|
}
|
|
782
782
|
|
|
@@ -799,7 +799,11 @@ extension BleMesh: CBCentralManagerDelegate {
|
|
|
799
799
|
if peripherals[uuid] == nil {
|
|
800
800
|
peripherals[uuid] = peripheral
|
|
801
801
|
peripheral.delegate = self
|
|
802
|
-
|
|
802
|
+
// Use connection options for faster connection
|
|
803
|
+
central.connect(peripheral, options: [
|
|
804
|
+
CBConnectPeripheralOptionNotifyOnConnectionKey: true,
|
|
805
|
+
CBConnectPeripheralOptionNotifyOnDisconnectionKey: true
|
|
806
|
+
])
|
|
803
807
|
}
|
|
804
808
|
}
|
|
805
809
|
|
|
@@ -818,9 +822,12 @@ extension BleMesh: CBCentralManagerDelegate {
|
|
|
818
822
|
notifyPeerListUpdated()
|
|
819
823
|
}
|
|
820
824
|
|
|
821
|
-
// Reconnect
|
|
825
|
+
// Reconnect with optimized options
|
|
822
826
|
if isRunning {
|
|
823
|
-
central.connect(peripheral, options:
|
|
827
|
+
central.connect(peripheral, options: [
|
|
828
|
+
CBConnectPeripheralOptionNotifyOnConnectionKey: true,
|
|
829
|
+
CBConnectPeripheralOptionNotifyOnDisconnectionKey: true
|
|
830
|
+
])
|
|
824
831
|
}
|
|
825
832
|
}
|
|
826
833
|
}
|
|
@@ -877,7 +884,8 @@ extension BleMesh: CBPeripheralManagerDelegate {
|
|
|
877
884
|
characteristic = char
|
|
878
885
|
|
|
879
886
|
peripheralManager?.startAdvertising([
|
|
880
|
-
CBAdvertisementDataServiceUUIDsKey: [BleMesh.serviceUUID]
|
|
887
|
+
CBAdvertisementDataServiceUUIDsKey: [BleMesh.serviceUUID],
|
|
888
|
+
CBAdvertisementDataLocalNameKey: "Kard-\(myPeerID.prefix(4))"
|
|
881
889
|
])
|
|
882
890
|
}
|
|
883
891
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kard-network-ble-mesh",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "Kard Network BLE Mesh networking library for React Native with seamless permissions",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
@@ -49,14 +49,17 @@
|
|
|
49
49
|
],
|
|
50
50
|
"repository": {
|
|
51
51
|
"type": "git",
|
|
52
|
-
"url": "git+https://github.com/
|
|
52
|
+
"url": "git+https://github.com/kard-network/kard-network-ble-mesh.git"
|
|
53
|
+
},
|
|
54
|
+
"author": {
|
|
55
|
+
"name": "rrigoni",
|
|
56
|
+
"email": "rrigoni@gmail.com"
|
|
53
57
|
},
|
|
54
|
-
"author": "Kard Network",
|
|
55
58
|
"license": "MIT",
|
|
56
59
|
"bugs": {
|
|
57
|
-
"url": "https://github.com/
|
|
60
|
+
"url": "https://github.com/kard-network/kard-network-ble-mesh/issues"
|
|
58
61
|
},
|
|
59
|
-
"homepage": "https://github.com/
|
|
62
|
+
"homepage": "https://github.com/kard-network/kard-network-ble-mesh#readme",
|
|
60
63
|
"publishConfig": {
|
|
61
64
|
"registry": "https://registry.npmjs.org/"
|
|
62
65
|
},
|