react-native-bluebreeze 1.0.0 → 1.0.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/android/build.gradle +8 -1
- package/android/generated/java/com/bluebreeze/NativeBlueBreezeSpec.java +8 -0
- package/android/generated/jni/RNBlueBreezeSpec-generated.cpp +7 -0
- package/android/generated/jni/react/renderer/components/RNBlueBreezeSpec/RNBlueBreezeSpecJSI.h +78 -0
- package/android/src/main/java/com/bluebreeze/BlueBreezeModule.kt +37 -4
- package/ios/BlueBreezeImpl.swift +20 -5
- package/ios/Bluebreeze.mm +9 -0
- package/ios/generated/ReactCodegen/RNBlueBreezeSpec/RNBlueBreezeSpec-generated.mm +12 -0
- package/ios/generated/ReactCodegen/RNBlueBreezeSpec/RNBlueBreezeSpec.h +4 -0
- package/ios/generated/ReactCodegen/RNBlueBreezeSpecJSI.h +78 -0
- package/lib/commonjs/NativeBlueBreeze.js.map +1 -1
- package/lib/commonjs/implementation/bluebreeze_characteristic.js +5 -1
- package/lib/commonjs/implementation/bluebreeze_characteristic.js.map +1 -1
- package/lib/commonjs/implementation/native_bridge.js +22 -9
- package/lib/commonjs/implementation/native_bridge.js.map +1 -1
- package/lib/module/NativeBlueBreeze.js.map +1 -1
- package/lib/module/implementation/bluebreeze_characteristic.js +6 -2
- package/lib/module/implementation/bluebreeze_characteristic.js.map +1 -1
- package/lib/module/implementation/native_bridge.js +20 -8
- package/lib/module/implementation/native_bridge.js.map +1 -1
- package/lib/typescript/commonjs/src/NativeBlueBreeze.d.ts +8 -0
- package/lib/typescript/commonjs/src/NativeBlueBreeze.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/implementation/bluebreeze_characteristic.d.ts +5 -2
- package/lib/typescript/commonjs/src/implementation/bluebreeze_characteristic.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/implementation/native_bridge.d.ts +3 -2
- package/lib/typescript/commonjs/src/implementation/native_bridge.d.ts.map +1 -1
- package/lib/typescript/module/src/NativeBlueBreeze.d.ts +8 -0
- package/lib/typescript/module/src/NativeBlueBreeze.d.ts.map +1 -1
- package/lib/typescript/module/src/implementation/bluebreeze_characteristic.d.ts +5 -2
- package/lib/typescript/module/src/implementation/bluebreeze_characteristic.d.ts.map +1 -1
- package/lib/typescript/module/src/implementation/native_bridge.d.ts +3 -2
- package/lib/typescript/module/src/implementation/native_bridge.d.ts.map +1 -1
- package/package.json +3 -2
- package/react-native-bluebreeze.podspec +1 -1
- package/src/NativeBlueBreeze.ts +11 -0
- package/src/implementation/bluebreeze_characteristic.ts +9 -2
- package/src/implementation/native_bridge.ts +45 -13
package/android/build.gradle
CHANGED
|
@@ -22,6 +22,13 @@ def isNewArchitectureEnabled() {
|
|
|
22
22
|
|
|
23
23
|
apply plugin: "com.android.library"
|
|
24
24
|
|
|
25
|
+
// Some AGP versions register their own "kotlin" extension. We only apply
|
|
26
|
+
// the Kotlin Gradle plugin if that hasn't already happened, to avoid
|
|
27
|
+
// "Cannot add extension with name 'kotlin'" failures.
|
|
28
|
+
if (project.extensions.findByName("kotlin") == null) {
|
|
29
|
+
apply plugin: "kotlin-android"
|
|
30
|
+
}
|
|
31
|
+
|
|
25
32
|
if (isNewArchitectureEnabled()) {
|
|
26
33
|
apply plugin: "com.facebook.react"
|
|
27
34
|
}
|
|
@@ -100,7 +107,7 @@ dependencies {
|
|
|
100
107
|
implementation "com.facebook.react:react-android"
|
|
101
108
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
102
109
|
|
|
103
|
-
implementation "dev.likemagic:bluebreeze:1.0.
|
|
110
|
+
implementation "dev.likemagic:bluebreeze:1.0.3"
|
|
104
111
|
}
|
|
105
112
|
|
|
106
113
|
if (isNewArchitectureEnabled()) {
|
|
@@ -76,6 +76,10 @@ public abstract class NativeBlueBreezeSpec extends ReactContextBaseJavaModule im
|
|
|
76
76
|
mEventEmitterCallback.invoke("deviceCharacteristicNotifyEnabledEmitter", value);
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
+
protected final void emitDeviceCharacteristicNotificationsEmitter(ReadableMap value) {
|
|
80
|
+
mEventEmitterCallback.invoke("deviceCharacteristicNotificationsEmitter", value);
|
|
81
|
+
}
|
|
82
|
+
|
|
79
83
|
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
80
84
|
@DoNotStrip
|
|
81
85
|
public abstract String state();
|
|
@@ -144,6 +148,10 @@ public abstract class NativeBlueBreezeSpec extends ReactContextBaseJavaModule im
|
|
|
144
148
|
@DoNotStrip
|
|
145
149
|
public abstract boolean deviceCharacteristicNotifyEnabled(String id, String serviceId, String characteristicId);
|
|
146
150
|
|
|
151
|
+
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
152
|
+
@DoNotStrip
|
|
153
|
+
public abstract WritableArray deviceCharacteristicNotifications(String id, String serviceId, String characteristicId);
|
|
154
|
+
|
|
147
155
|
@ReactMethod
|
|
148
156
|
@DoNotStrip
|
|
149
157
|
public abstract void deviceCharacteristicRead(String id, String serviceId, String characteristicId, Promise promise);
|
|
@@ -97,6 +97,11 @@ static facebook::jsi::Value __hostFunction_NativeBlueBreezeSpecJSI_deviceCharact
|
|
|
97
97
|
return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, BooleanKind, "deviceCharacteristicNotifyEnabled", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Z", args, count, cachedMethodId);
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
+
static facebook::jsi::Value __hostFunction_NativeBlueBreezeSpecJSI_deviceCharacteristicNotifications(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
101
|
+
static jmethodID cachedMethodId = nullptr;
|
|
102
|
+
return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, ArrayKind, "deviceCharacteristicNotifications", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Lcom/facebook/react/bridge/WritableArray;", args, count, cachedMethodId);
|
|
103
|
+
}
|
|
104
|
+
|
|
100
105
|
static facebook::jsi::Value __hostFunction_NativeBlueBreezeSpecJSI_deviceCharacteristicRead(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
101
106
|
static jmethodID cachedMethodId = nullptr;
|
|
102
107
|
return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, PromiseKind, "deviceCharacteristicRead", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lcom/facebook/react/bridge/Promise;)V", args, count, cachedMethodId);
|
|
@@ -136,6 +141,7 @@ NativeBlueBreezeSpecJSI::NativeBlueBreezeSpecJSI(const JavaTurboModule::InitPara
|
|
|
136
141
|
methodMap_["deviceRequestMTU"] = MethodMetadata {2, __hostFunction_NativeBlueBreezeSpecJSI_deviceRequestMTU};
|
|
137
142
|
methodMap_["deviceCharacteristicData"] = MethodMetadata {3, __hostFunction_NativeBlueBreezeSpecJSI_deviceCharacteristicData};
|
|
138
143
|
methodMap_["deviceCharacteristicNotifyEnabled"] = MethodMetadata {3, __hostFunction_NativeBlueBreezeSpecJSI_deviceCharacteristicNotifyEnabled};
|
|
144
|
+
methodMap_["deviceCharacteristicNotifications"] = MethodMetadata {3, __hostFunction_NativeBlueBreezeSpecJSI_deviceCharacteristicNotifications};
|
|
139
145
|
methodMap_["deviceCharacteristicRead"] = MethodMetadata {3, __hostFunction_NativeBlueBreezeSpecJSI_deviceCharacteristicRead};
|
|
140
146
|
methodMap_["deviceCharacteristicWrite"] = MethodMetadata {5, __hostFunction_NativeBlueBreezeSpecJSI_deviceCharacteristicWrite};
|
|
141
147
|
methodMap_["deviceCharacteristicSubscribe"] = MethodMetadata {3, __hostFunction_NativeBlueBreezeSpecJSI_deviceCharacteristicSubscribe};
|
|
@@ -150,6 +156,7 @@ NativeBlueBreezeSpecJSI::NativeBlueBreezeSpecJSI(const JavaTurboModule::InitPara
|
|
|
150
156
|
eventEmitterMap_["deviceMTUEmitter"] = std::make_shared<AsyncEventEmitter<folly::dynamic>>();
|
|
151
157
|
eventEmitterMap_["deviceCharacteristicDataEmitter"] = std::make_shared<AsyncEventEmitter<folly::dynamic>>();
|
|
152
158
|
eventEmitterMap_["deviceCharacteristicNotifyEnabledEmitter"] = std::make_shared<AsyncEventEmitter<folly::dynamic>>();
|
|
159
|
+
eventEmitterMap_["deviceCharacteristicNotificationsEmitter"] = std::make_shared<AsyncEventEmitter<folly::dynamic>>();
|
|
153
160
|
configureEventEmitterCallback();
|
|
154
161
|
}
|
|
155
162
|
|
package/android/generated/jni/react/renderer/components/RNBlueBreezeSpec/RNBlueBreezeSpecJSI.h
CHANGED
|
@@ -74,6 +74,65 @@ struct NativeBlueBreezeBBDeviceCharacteristicDataEventBridging {
|
|
|
74
74
|
|
|
75
75
|
|
|
76
76
|
|
|
77
|
+
#pragma mark - NativeBlueBreezeBBDeviceCharacteristicNotificationsEvent
|
|
78
|
+
|
|
79
|
+
template <typename P0, typename P1, typename P2, typename P3>
|
|
80
|
+
struct NativeBlueBreezeBBDeviceCharacteristicNotificationsEvent {
|
|
81
|
+
P0 id{};
|
|
82
|
+
P1 serviceId{};
|
|
83
|
+
P2 characteristicId{};
|
|
84
|
+
P3 value;
|
|
85
|
+
bool operator==(const NativeBlueBreezeBBDeviceCharacteristicNotificationsEvent &other) const {
|
|
86
|
+
return id == other.id && serviceId == other.serviceId && characteristicId == other.characteristicId && value == other.value;
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
template <typename T>
|
|
91
|
+
struct NativeBlueBreezeBBDeviceCharacteristicNotificationsEventBridging {
|
|
92
|
+
static T types;
|
|
93
|
+
|
|
94
|
+
static T fromJs(
|
|
95
|
+
jsi::Runtime &rt,
|
|
96
|
+
const jsi::Object &value,
|
|
97
|
+
const std::shared_ptr<CallInvoker> &jsInvoker) {
|
|
98
|
+
T result{
|
|
99
|
+
bridging::fromJs<decltype(types.id)>(rt, value.getProperty(rt, "id"), jsInvoker),
|
|
100
|
+
bridging::fromJs<decltype(types.serviceId)>(rt, value.getProperty(rt, "serviceId"), jsInvoker),
|
|
101
|
+
bridging::fromJs<decltype(types.characteristicId)>(rt, value.getProperty(rt, "characteristicId"), jsInvoker),
|
|
102
|
+
bridging::fromJs<decltype(types.value)>(rt, value.getProperty(rt, "value"), jsInvoker)};
|
|
103
|
+
return result;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
#ifdef DEBUG
|
|
107
|
+
static jsi::String idToJs(jsi::Runtime &rt, decltype(types.id) value) {
|
|
108
|
+
return bridging::toJs(rt, value);
|
|
109
|
+
}
|
|
110
|
+
static jsi::String serviceIdToJs(jsi::Runtime &rt, decltype(types.serviceId) value) {
|
|
111
|
+
return bridging::toJs(rt, value);
|
|
112
|
+
}
|
|
113
|
+
static jsi::String characteristicIdToJs(jsi::Runtime &rt, decltype(types.characteristicId) value) {
|
|
114
|
+
return bridging::toJs(rt, value);
|
|
115
|
+
}
|
|
116
|
+
static jsi::Array valueToJs(jsi::Runtime &rt, decltype(types.value) value) {
|
|
117
|
+
return bridging::toJs(rt, value);
|
|
118
|
+
}
|
|
119
|
+
#endif
|
|
120
|
+
|
|
121
|
+
static jsi::Object toJs(
|
|
122
|
+
jsi::Runtime &rt,
|
|
123
|
+
const T &value,
|
|
124
|
+
const std::shared_ptr<CallInvoker> &jsInvoker) {
|
|
125
|
+
auto result = facebook::jsi::Object(rt);
|
|
126
|
+
result.setProperty(rt, "id", bridging::toJs(rt, value.id, jsInvoker));
|
|
127
|
+
result.setProperty(rt, "serviceId", bridging::toJs(rt, value.serviceId, jsInvoker));
|
|
128
|
+
result.setProperty(rt, "characteristicId", bridging::toJs(rt, value.characteristicId, jsInvoker));
|
|
129
|
+
result.setProperty(rt, "value", bridging::toJs(rt, value.value, jsInvoker));
|
|
130
|
+
return result;
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
|
|
77
136
|
#pragma mark - NativeBlueBreezeBBDeviceCharacteristicNotifyEnabledEvent
|
|
78
137
|
|
|
79
138
|
template <typename P0, typename P1, typename P2, typename P3>
|
|
@@ -547,6 +606,7 @@ protected:
|
|
|
547
606
|
methodMap_["deviceRequestMTU"] = MethodMetadata {.argCount = 2, .invoker = __deviceRequestMTU};
|
|
548
607
|
methodMap_["deviceCharacteristicData"] = MethodMetadata {.argCount = 3, .invoker = __deviceCharacteristicData};
|
|
549
608
|
methodMap_["deviceCharacteristicNotifyEnabled"] = MethodMetadata {.argCount = 3, .invoker = __deviceCharacteristicNotifyEnabled};
|
|
609
|
+
methodMap_["deviceCharacteristicNotifications"] = MethodMetadata {.argCount = 3, .invoker = __deviceCharacteristicNotifications};
|
|
550
610
|
methodMap_["deviceCharacteristicRead"] = MethodMetadata {.argCount = 3, .invoker = __deviceCharacteristicRead};
|
|
551
611
|
methodMap_["deviceCharacteristicWrite"] = MethodMetadata {.argCount = 5, .invoker = __deviceCharacteristicWrite};
|
|
552
612
|
methodMap_["deviceCharacteristicSubscribe"] = MethodMetadata {.argCount = 3, .invoker = __deviceCharacteristicSubscribe};
|
|
@@ -561,6 +621,7 @@ protected:
|
|
|
561
621
|
eventEmitterMap_["deviceMTUEmitter"] = std::make_shared<AsyncEventEmitter<jsi::Value>>();
|
|
562
622
|
eventEmitterMap_["deviceCharacteristicDataEmitter"] = std::make_shared<AsyncEventEmitter<jsi::Value>>();
|
|
563
623
|
eventEmitterMap_["deviceCharacteristicNotifyEnabledEmitter"] = std::make_shared<AsyncEventEmitter<jsi::Value>>();
|
|
624
|
+
eventEmitterMap_["deviceCharacteristicNotificationsEmitter"] = std::make_shared<AsyncEventEmitter<jsi::Value>>();
|
|
564
625
|
}
|
|
565
626
|
|
|
566
627
|
template <typename StateEmitterType> void emitStateEmitter(StateEmitterType value) {
|
|
@@ -632,6 +693,13 @@ protected:
|
|
|
632
693
|
return bridging::toJs(rt, eventValue, jsInvoker);
|
|
633
694
|
});
|
|
634
695
|
}
|
|
696
|
+
|
|
697
|
+
template <typename DeviceCharacteristicNotificationsEmitterType> void emitDeviceCharacteristicNotificationsEmitter(DeviceCharacteristicNotificationsEmitterType value) {
|
|
698
|
+
static_assert(bridging::supportsFromJs<DeviceCharacteristicNotificationsEmitterType, jsi::Object>, "value cannnot be converted to jsi::Object");
|
|
699
|
+
static_cast<AsyncEventEmitter<jsi::Value>&>(*eventEmitterMap_["deviceCharacteristicNotificationsEmitter"]).emit([jsInvoker = jsInvoker_, eventValue = value](jsi::Runtime& rt) -> jsi::Value {
|
|
700
|
+
return bridging::toJs(rt, eventValue, jsInvoker);
|
|
701
|
+
});
|
|
702
|
+
}
|
|
635
703
|
private:
|
|
636
704
|
static jsi::Value __state(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* /*args*/, size_t /*count*/) {
|
|
637
705
|
static_assert(
|
|
@@ -767,6 +835,16 @@ private:
|
|
|
767
835
|
count <= 2 ? throw jsi::JSError(rt, "Expected argument in position 2 to be passed") : args[2].asString(rt));
|
|
768
836
|
}
|
|
769
837
|
|
|
838
|
+
static jsi::Value __deviceCharacteristicNotifications(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
839
|
+
static_assert(
|
|
840
|
+
bridging::getParameterCount(&T::deviceCharacteristicNotifications) == 4,
|
|
841
|
+
"Expected deviceCharacteristicNotifications(...) to have 4 parameters");
|
|
842
|
+
return bridging::callFromJs<jsi::Array>(rt, &T::deviceCharacteristicNotifications, static_cast<NativeBlueBreezeCxxSpec*>(&turboModule)->jsInvoker_, static_cast<T*>(&turboModule),
|
|
843
|
+
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt),
|
|
844
|
+
count <= 1 ? throw jsi::JSError(rt, "Expected argument in position 1 to be passed") : args[1].asString(rt),
|
|
845
|
+
count <= 2 ? throw jsi::JSError(rt, "Expected argument in position 2 to be passed") : args[2].asString(rt));
|
|
846
|
+
}
|
|
847
|
+
|
|
770
848
|
static jsi::Value __deviceCharacteristicRead(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
771
849
|
static_assert(
|
|
772
850
|
bridging::getParameterCount(&T::deviceCharacteristicRead) == 4,
|
|
@@ -23,6 +23,7 @@ import kotlinx.coroutines.Dispatchers
|
|
|
23
23
|
import kotlinx.coroutines.Job
|
|
24
24
|
import kotlinx.coroutines.SupervisorJob
|
|
25
25
|
import kotlinx.coroutines.cancel
|
|
26
|
+
import kotlinx.coroutines.flow.Flow
|
|
26
27
|
import kotlinx.coroutines.flow.FlowCollector
|
|
27
28
|
import kotlinx.coroutines.flow.SharedFlow
|
|
28
29
|
import kotlinx.coroutines.launch
|
|
@@ -42,14 +43,18 @@ class BlueBreezeModule(reactContext: ReactApplicationContext) : NativeBlueBreeze
|
|
|
42
43
|
|
|
43
44
|
// Per characteristic data and notification state subscriptions
|
|
44
45
|
val characteristicDataJobs = mutableMapOf<String, Job>()
|
|
45
|
-
val
|
|
46
|
+
val characteristicIsNotifyingJobs = mutableMapOf<String, Job>()
|
|
47
|
+
val characteristicNotificationsJobs = mutableMapOf<String, Job>()
|
|
46
48
|
|
|
47
49
|
fun cancelCharacteristics() {
|
|
48
50
|
characteristicDataJobs.values.forEach { it.cancel() }
|
|
49
51
|
characteristicDataJobs.clear()
|
|
50
52
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
+
characteristicIsNotifyingJobs.values.forEach { it.cancel() }
|
|
54
|
+
characteristicIsNotifyingJobs.clear()
|
|
55
|
+
|
|
56
|
+
characteristicNotificationsJobs.values.forEach { it.cancel() }
|
|
57
|
+
characteristicNotificationsJobs.clear()
|
|
53
58
|
}
|
|
54
59
|
|
|
55
60
|
fun cancelAll() {
|
|
@@ -183,7 +188,7 @@ class BlueBreezeModule(reactContext: ReactApplicationContext) : NativeBlueBreeze
|
|
|
183
188
|
}
|
|
184
189
|
}
|
|
185
190
|
|
|
186
|
-
tracking.
|
|
191
|
+
tracking.characteristicIsNotifyingJobs[trackingKey] = characteristic.isNotifying.collectAsync { value ->
|
|
187
192
|
safeEmit {
|
|
188
193
|
emitDeviceCharacteristicNotifyEnabledEmitter(
|
|
189
194
|
writableMapOf(
|
|
@@ -195,6 +200,19 @@ class BlueBreezeModule(reactContext: ReactApplicationContext) : NativeBlueBreeze
|
|
|
195
200
|
)
|
|
196
201
|
}
|
|
197
202
|
}
|
|
203
|
+
|
|
204
|
+
tracking.characteristicNotificationsJobs[trackingKey] = characteristic.notifications.collectAsync { value ->
|
|
205
|
+
safeEmit {
|
|
206
|
+
emitDeviceCharacteristicNotificationsEmitter(
|
|
207
|
+
writableMapOf(
|
|
208
|
+
"id" to deviceId,
|
|
209
|
+
"serviceId" to serviceId.toJs,
|
|
210
|
+
"characteristicId" to characteristicId.toJs,
|
|
211
|
+
"value" to value.toJs
|
|
212
|
+
)
|
|
213
|
+
)
|
|
214
|
+
}
|
|
215
|
+
}
|
|
198
216
|
}
|
|
199
217
|
}
|
|
200
218
|
}
|
|
@@ -356,6 +374,16 @@ class BlueBreezeModule(reactContext: ReactApplicationContext) : NativeBlueBreeze
|
|
|
356
374
|
return characteristic.isNotifying.value
|
|
357
375
|
}
|
|
358
376
|
|
|
377
|
+
// Device characteristic notifications
|
|
378
|
+
|
|
379
|
+
override fun deviceCharacteristicNotifications(
|
|
380
|
+
id: String?,
|
|
381
|
+
serviceId: String?,
|
|
382
|
+
characteristicId: String?
|
|
383
|
+
): WritableArray? {
|
|
384
|
+
return emptyWritableArray()
|
|
385
|
+
}
|
|
386
|
+
|
|
359
387
|
// Device characteristic operations
|
|
360
388
|
|
|
361
389
|
override fun deviceCharacteristicRead(
|
|
@@ -526,6 +554,10 @@ class BlueBreezeModule(reactContext: ReactApplicationContext) : NativeBlueBreeze
|
|
|
526
554
|
block: suspend CoroutineScope.() -> Unit,
|
|
527
555
|
): Job = moduleScope.launch(block = block)
|
|
528
556
|
|
|
557
|
+
private fun <T> Flow<T>.collectAsync(
|
|
558
|
+
collector: FlowCollector<T>,
|
|
559
|
+
): Job = moduleScope.launch { collect(collector) }
|
|
560
|
+
|
|
529
561
|
private fun <T> SharedFlow<T>.collectAsync(
|
|
530
562
|
collector: FlowCollector<T>,
|
|
531
563
|
): Job = moduleScope.launch { collect(collector) }
|
|
@@ -569,6 +601,7 @@ val BBCharacteristicProperty.toJs: String
|
|
|
569
601
|
val BBScanResult.toJs: WritableMap
|
|
570
602
|
get() = writableMapOf(
|
|
571
603
|
"id" to device.address,
|
|
604
|
+
"name" to name,
|
|
572
605
|
"rssi" to rssi,
|
|
573
606
|
"connectable" to connectable,
|
|
574
607
|
"advertisedServices" to advertisedServices.map { it.toJs },
|
package/ios/BlueBreezeImpl.swift
CHANGED
|
@@ -30,7 +30,8 @@ struct BlueBreezeError : Error {
|
|
|
30
30
|
var deviceMTUObserve: ((String, Int) -> Void)?
|
|
31
31
|
var deviceCharacteristicDataObserve: ((String, String, String, Array<UInt8>) -> Void)?
|
|
32
32
|
var deviceCharacteristicNotifyEnabledObserve: ((String, String, String, Bool) -> Void)?
|
|
33
|
-
|
|
33
|
+
var deviceCharacteristicNotificationsObserve: ((String, String, String, Array<UInt8>) -> Void)?
|
|
34
|
+
|
|
34
35
|
@objc public func subscribe(
|
|
35
36
|
stateObserve: (@escaping (String) -> Void),
|
|
36
37
|
authorizationObserve: (@escaping (String) -> Void),
|
|
@@ -41,7 +42,8 @@ struct BlueBreezeError : Error {
|
|
|
41
42
|
deviceServicesObserve: (@escaping (String, [[String: Any]]) -> Void),
|
|
42
43
|
deviceMTUObserve: (@escaping (String, Int) -> Void),
|
|
43
44
|
deviceCharacteristicDataObserve: (@escaping (String, String, String, Array<UInt8>) -> Void),
|
|
44
|
-
deviceCharacteristicNotifyEnabledObserve: (@escaping (String, String, String, Bool) -> Void)
|
|
45
|
+
deviceCharacteristicNotifyEnabledObserve: (@escaping (String, String, String, Bool) -> Void),
|
|
46
|
+
deviceCharacteristicNotificationsObserve: (@escaping (String, String, String, Array<UInt8>) -> Void)
|
|
45
47
|
) {
|
|
46
48
|
self.stateObserve = stateObserve
|
|
47
49
|
self.authorizationObserve = authorizationObserve
|
|
@@ -53,6 +55,7 @@ struct BlueBreezeError : Error {
|
|
|
53
55
|
self.deviceMTUObserve = deviceMTUObserve
|
|
54
56
|
self.deviceCharacteristicDataObserve = deviceCharacteristicDataObserve
|
|
55
57
|
self.deviceCharacteristicNotifyEnabledObserve = deviceCharacteristicNotifyEnabledObserve
|
|
58
|
+
self.deviceCharacteristicNotificationsObserve = deviceCharacteristicNotificationsObserve
|
|
56
59
|
|
|
57
60
|
manager.state
|
|
58
61
|
.receive(on: DispatchQueue.main)
|
|
@@ -136,6 +139,18 @@ struct BlueBreezeError : Error {
|
|
|
136
139
|
|
|
137
140
|
disposeBagServices[device.id]![serviceId]![characteristic.uuid] = []
|
|
138
141
|
|
|
142
|
+
characteristic.data
|
|
143
|
+
.receive(on: DispatchQueue.main)
|
|
144
|
+
.sink {
|
|
145
|
+
self.deviceCharacteristicDataObserve?(
|
|
146
|
+
device.id.toJs,
|
|
147
|
+
serviceId.toJs,
|
|
148
|
+
characteristic.uuid.toJs,
|
|
149
|
+
$0?.toJs ?? []
|
|
150
|
+
)
|
|
151
|
+
}
|
|
152
|
+
.store(in: &disposeBagServices[device.id]![serviceId]![characteristic.uuid]!)
|
|
153
|
+
|
|
139
154
|
characteristic.isNotifying
|
|
140
155
|
.receive(on: DispatchQueue.main)
|
|
141
156
|
.sink {
|
|
@@ -148,14 +163,14 @@ struct BlueBreezeError : Error {
|
|
|
148
163
|
}
|
|
149
164
|
.store(in: &disposeBagServices[device.id]![serviceId]![characteristic.uuid]!)
|
|
150
165
|
|
|
151
|
-
characteristic.
|
|
166
|
+
characteristic.notifications
|
|
152
167
|
.receive(on: DispatchQueue.main)
|
|
153
168
|
.sink {
|
|
154
|
-
self.
|
|
169
|
+
self.deviceCharacteristicNotificationsObserve?(
|
|
155
170
|
device.id.toJs,
|
|
156
171
|
serviceId.toJs,
|
|
157
172
|
characteristic.uuid.toJs,
|
|
158
|
-
$0
|
|
173
|
+
$0.toJs
|
|
159
174
|
)
|
|
160
175
|
}
|
|
161
176
|
.store(in: &disposeBagServices[device.id]![serviceId]![characteristic.uuid]!)
|
package/ios/Bluebreeze.mm
CHANGED
|
@@ -83,6 +83,15 @@ typedef void (^EmitterCallback)();
|
|
|
83
83
|
@"value": [NSNumber numberWithBool:value]
|
|
84
84
|
}];
|
|
85
85
|
}];
|
|
86
|
+
} deviceCharacteristicNotificationsObserve:^(NSString * _Nonnull deviceId, NSString * _Nonnull serviceId, NSString * _Nonnull characteristicId, NSArray<NSNumber *> * _Nonnull value) {
|
|
87
|
+
[self wrapEventEmitter:^{
|
|
88
|
+
[self emitDeviceCharacteristicNotificationsEmitter:@{
|
|
89
|
+
@"id": deviceId,
|
|
90
|
+
@"serviceId": serviceId,
|
|
91
|
+
@"characteristicId": characteristicId,
|
|
92
|
+
@"value": value
|
|
93
|
+
}];
|
|
94
|
+
}];
|
|
86
95
|
}];
|
|
87
96
|
|
|
88
97
|
}
|
|
@@ -55,6 +55,10 @@
|
|
|
55
55
|
{
|
|
56
56
|
_eventEmitterCallback("deviceCharacteristicNotifyEnabledEmitter", value);
|
|
57
57
|
}
|
|
58
|
+
- (void)emitDeviceCharacteristicNotificationsEmitter:(NSDictionary *)value
|
|
59
|
+
{
|
|
60
|
+
_eventEmitterCallback("deviceCharacteristicNotificationsEmitter", value);
|
|
61
|
+
}
|
|
58
62
|
|
|
59
63
|
- (void)setEventEmitterCallback:(EventEmitterCallbackWrapper *)eventEmitterCallbackWrapper
|
|
60
64
|
{
|
|
@@ -133,6 +137,10 @@ namespace facebook::react {
|
|
|
133
137
|
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, BooleanKind, "deviceCharacteristicNotifyEnabled", @selector(deviceCharacteristicNotifyEnabled:serviceId:characteristicId:), args, count);
|
|
134
138
|
}
|
|
135
139
|
|
|
140
|
+
static facebook::jsi::Value __hostFunction_NativeBlueBreezeSpecJSI_deviceCharacteristicNotifications(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
141
|
+
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, ArrayKind, "deviceCharacteristicNotifications", @selector(deviceCharacteristicNotifications:serviceId:characteristicId:), args, count);
|
|
142
|
+
}
|
|
143
|
+
|
|
136
144
|
static facebook::jsi::Value __hostFunction_NativeBlueBreezeSpecJSI_deviceCharacteristicRead(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
137
145
|
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, PromiseKind, "deviceCharacteristicRead", @selector(deviceCharacteristicRead:serviceId:characteristicId:resolve:reject:), args, count);
|
|
138
146
|
}
|
|
@@ -203,6 +211,9 @@ namespace facebook::react {
|
|
|
203
211
|
methodMap_["deviceCharacteristicNotifyEnabled"] = MethodMetadata {3, __hostFunction_NativeBlueBreezeSpecJSI_deviceCharacteristicNotifyEnabled};
|
|
204
212
|
|
|
205
213
|
|
|
214
|
+
methodMap_["deviceCharacteristicNotifications"] = MethodMetadata {3, __hostFunction_NativeBlueBreezeSpecJSI_deviceCharacteristicNotifications};
|
|
215
|
+
|
|
216
|
+
|
|
206
217
|
methodMap_["deviceCharacteristicRead"] = MethodMetadata {3, __hostFunction_NativeBlueBreezeSpecJSI_deviceCharacteristicRead};
|
|
207
218
|
|
|
208
219
|
|
|
@@ -224,6 +235,7 @@ namespace facebook::react {
|
|
|
224
235
|
eventEmitterMap_["deviceMTUEmitter"] = std::make_shared<AsyncEventEmitter<id>>();
|
|
225
236
|
eventEmitterMap_["deviceCharacteristicDataEmitter"] = std::make_shared<AsyncEventEmitter<id>>();
|
|
226
237
|
eventEmitterMap_["deviceCharacteristicNotifyEnabledEmitter"] = std::make_shared<AsyncEventEmitter<id>>();
|
|
238
|
+
eventEmitterMap_["deviceCharacteristicNotificationsEmitter"] = std::make_shared<AsyncEventEmitter<id>>();
|
|
227
239
|
setEventEmitterCallback([&](const std::string &name, id value) {
|
|
228
240
|
static_cast<AsyncEventEmitter<id> &>(*eventEmitterMap_[name]).emit(value);
|
|
229
241
|
});
|
|
@@ -65,6 +65,9 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
65
65
|
- (NSNumber *)deviceCharacteristicNotifyEnabled:(NSString *)id
|
|
66
66
|
serviceId:(NSString *)serviceId
|
|
67
67
|
characteristicId:(NSString *)characteristicId;
|
|
68
|
+
- (NSArray<NSNumber *> *)deviceCharacteristicNotifications:(NSString *)id
|
|
69
|
+
serviceId:(NSString *)serviceId
|
|
70
|
+
characteristicId:(NSString *)characteristicId;
|
|
68
71
|
- (void)deviceCharacteristicRead:(NSString *)id
|
|
69
72
|
serviceId:(NSString *)serviceId
|
|
70
73
|
characteristicId:(NSString *)characteristicId
|
|
@@ -106,6 +109,7 @@ facebook::react::EventEmitterCallback _eventEmitterCallback;
|
|
|
106
109
|
- (void)emitDeviceMTUEmitter:(NSDictionary *)value;
|
|
107
110
|
- (void)emitDeviceCharacteristicDataEmitter:(NSDictionary *)value;
|
|
108
111
|
- (void)emitDeviceCharacteristicNotifyEnabledEmitter:(NSDictionary *)value;
|
|
112
|
+
- (void)emitDeviceCharacteristicNotificationsEmitter:(NSDictionary *)value;
|
|
109
113
|
@end
|
|
110
114
|
|
|
111
115
|
namespace facebook::react {
|
|
@@ -74,6 +74,65 @@ struct NativeBlueBreezeBBDeviceCharacteristicDataEventBridging {
|
|
|
74
74
|
|
|
75
75
|
|
|
76
76
|
|
|
77
|
+
#pragma mark - NativeBlueBreezeBBDeviceCharacteristicNotificationsEvent
|
|
78
|
+
|
|
79
|
+
template <typename P0, typename P1, typename P2, typename P3>
|
|
80
|
+
struct NativeBlueBreezeBBDeviceCharacteristicNotificationsEvent {
|
|
81
|
+
P0 id{};
|
|
82
|
+
P1 serviceId{};
|
|
83
|
+
P2 characteristicId{};
|
|
84
|
+
P3 value;
|
|
85
|
+
bool operator==(const NativeBlueBreezeBBDeviceCharacteristicNotificationsEvent &other) const {
|
|
86
|
+
return id == other.id && serviceId == other.serviceId && characteristicId == other.characteristicId && value == other.value;
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
template <typename T>
|
|
91
|
+
struct NativeBlueBreezeBBDeviceCharacteristicNotificationsEventBridging {
|
|
92
|
+
static T types;
|
|
93
|
+
|
|
94
|
+
static T fromJs(
|
|
95
|
+
jsi::Runtime &rt,
|
|
96
|
+
const jsi::Object &value,
|
|
97
|
+
const std::shared_ptr<CallInvoker> &jsInvoker) {
|
|
98
|
+
T result{
|
|
99
|
+
bridging::fromJs<decltype(types.id)>(rt, value.getProperty(rt, "id"), jsInvoker),
|
|
100
|
+
bridging::fromJs<decltype(types.serviceId)>(rt, value.getProperty(rt, "serviceId"), jsInvoker),
|
|
101
|
+
bridging::fromJs<decltype(types.characteristicId)>(rt, value.getProperty(rt, "characteristicId"), jsInvoker),
|
|
102
|
+
bridging::fromJs<decltype(types.value)>(rt, value.getProperty(rt, "value"), jsInvoker)};
|
|
103
|
+
return result;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
#ifdef DEBUG
|
|
107
|
+
static jsi::String idToJs(jsi::Runtime &rt, decltype(types.id) value) {
|
|
108
|
+
return bridging::toJs(rt, value);
|
|
109
|
+
}
|
|
110
|
+
static jsi::String serviceIdToJs(jsi::Runtime &rt, decltype(types.serviceId) value) {
|
|
111
|
+
return bridging::toJs(rt, value);
|
|
112
|
+
}
|
|
113
|
+
static jsi::String characteristicIdToJs(jsi::Runtime &rt, decltype(types.characteristicId) value) {
|
|
114
|
+
return bridging::toJs(rt, value);
|
|
115
|
+
}
|
|
116
|
+
static jsi::Array valueToJs(jsi::Runtime &rt, decltype(types.value) value) {
|
|
117
|
+
return bridging::toJs(rt, value);
|
|
118
|
+
}
|
|
119
|
+
#endif
|
|
120
|
+
|
|
121
|
+
static jsi::Object toJs(
|
|
122
|
+
jsi::Runtime &rt,
|
|
123
|
+
const T &value,
|
|
124
|
+
const std::shared_ptr<CallInvoker> &jsInvoker) {
|
|
125
|
+
auto result = facebook::jsi::Object(rt);
|
|
126
|
+
result.setProperty(rt, "id", bridging::toJs(rt, value.id, jsInvoker));
|
|
127
|
+
result.setProperty(rt, "serviceId", bridging::toJs(rt, value.serviceId, jsInvoker));
|
|
128
|
+
result.setProperty(rt, "characteristicId", bridging::toJs(rt, value.characteristicId, jsInvoker));
|
|
129
|
+
result.setProperty(rt, "value", bridging::toJs(rt, value.value, jsInvoker));
|
|
130
|
+
return result;
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
|
|
77
136
|
#pragma mark - NativeBlueBreezeBBDeviceCharacteristicNotifyEnabledEvent
|
|
78
137
|
|
|
79
138
|
template <typename P0, typename P1, typename P2, typename P3>
|
|
@@ -547,6 +606,7 @@ protected:
|
|
|
547
606
|
methodMap_["deviceRequestMTU"] = MethodMetadata {.argCount = 2, .invoker = __deviceRequestMTU};
|
|
548
607
|
methodMap_["deviceCharacteristicData"] = MethodMetadata {.argCount = 3, .invoker = __deviceCharacteristicData};
|
|
549
608
|
methodMap_["deviceCharacteristicNotifyEnabled"] = MethodMetadata {.argCount = 3, .invoker = __deviceCharacteristicNotifyEnabled};
|
|
609
|
+
methodMap_["deviceCharacteristicNotifications"] = MethodMetadata {.argCount = 3, .invoker = __deviceCharacteristicNotifications};
|
|
550
610
|
methodMap_["deviceCharacteristicRead"] = MethodMetadata {.argCount = 3, .invoker = __deviceCharacteristicRead};
|
|
551
611
|
methodMap_["deviceCharacteristicWrite"] = MethodMetadata {.argCount = 5, .invoker = __deviceCharacteristicWrite};
|
|
552
612
|
methodMap_["deviceCharacteristicSubscribe"] = MethodMetadata {.argCount = 3, .invoker = __deviceCharacteristicSubscribe};
|
|
@@ -561,6 +621,7 @@ protected:
|
|
|
561
621
|
eventEmitterMap_["deviceMTUEmitter"] = std::make_shared<AsyncEventEmitter<jsi::Value>>();
|
|
562
622
|
eventEmitterMap_["deviceCharacteristicDataEmitter"] = std::make_shared<AsyncEventEmitter<jsi::Value>>();
|
|
563
623
|
eventEmitterMap_["deviceCharacteristicNotifyEnabledEmitter"] = std::make_shared<AsyncEventEmitter<jsi::Value>>();
|
|
624
|
+
eventEmitterMap_["deviceCharacteristicNotificationsEmitter"] = std::make_shared<AsyncEventEmitter<jsi::Value>>();
|
|
564
625
|
}
|
|
565
626
|
|
|
566
627
|
template <typename StateEmitterType> void emitStateEmitter(StateEmitterType value) {
|
|
@@ -632,6 +693,13 @@ protected:
|
|
|
632
693
|
return bridging::toJs(rt, eventValue, jsInvoker);
|
|
633
694
|
});
|
|
634
695
|
}
|
|
696
|
+
|
|
697
|
+
template <typename DeviceCharacteristicNotificationsEmitterType> void emitDeviceCharacteristicNotificationsEmitter(DeviceCharacteristicNotificationsEmitterType value) {
|
|
698
|
+
static_assert(bridging::supportsFromJs<DeviceCharacteristicNotificationsEmitterType, jsi::Object>, "value cannnot be converted to jsi::Object");
|
|
699
|
+
static_cast<AsyncEventEmitter<jsi::Value>&>(*eventEmitterMap_["deviceCharacteristicNotificationsEmitter"]).emit([jsInvoker = jsInvoker_, eventValue = value](jsi::Runtime& rt) -> jsi::Value {
|
|
700
|
+
return bridging::toJs(rt, eventValue, jsInvoker);
|
|
701
|
+
});
|
|
702
|
+
}
|
|
635
703
|
private:
|
|
636
704
|
static jsi::Value __state(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* /*args*/, size_t /*count*/) {
|
|
637
705
|
static_assert(
|
|
@@ -767,6 +835,16 @@ private:
|
|
|
767
835
|
count <= 2 ? throw jsi::JSError(rt, "Expected argument in position 2 to be passed") : args[2].asString(rt));
|
|
768
836
|
}
|
|
769
837
|
|
|
838
|
+
static jsi::Value __deviceCharacteristicNotifications(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
839
|
+
static_assert(
|
|
840
|
+
bridging::getParameterCount(&T::deviceCharacteristicNotifications) == 4,
|
|
841
|
+
"Expected deviceCharacteristicNotifications(...) to have 4 parameters");
|
|
842
|
+
return bridging::callFromJs<jsi::Array>(rt, &T::deviceCharacteristicNotifications, static_cast<NativeBlueBreezeCxxSpec*>(&turboModule)->jsInvoker_, static_cast<T*>(&turboModule),
|
|
843
|
+
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt),
|
|
844
|
+
count <= 1 ? throw jsi::JSError(rt, "Expected argument in position 1 to be passed") : args[1].asString(rt),
|
|
845
|
+
count <= 2 ? throw jsi::JSError(rt, "Expected argument in position 2 to be passed") : args[2].asString(rt));
|
|
846
|
+
}
|
|
847
|
+
|
|
770
848
|
static jsi::Value __deviceCharacteristicRead(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
771
849
|
static_assert(
|
|
772
850
|
bridging::getParameterCount(&T::deviceCharacteristicRead) == 4,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_default","exports","default","TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeBlueBreeze.ts"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AAGA;
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_default","exports","default","TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeBlueBreeze.ts"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AAGA;AAkEA;AAAA,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GA6DeC,gCAAmB,CAACC,YAAY,CAAO,YAAY,CAAC","ignoreList":[]}
|
|
@@ -18,6 +18,7 @@ class BBCharacteristic {
|
|
|
18
18
|
this.properties = properties;
|
|
19
19
|
this.data = (0, _native_bridge.deviceCharacteristicData)(deviceId, serviceId, id);
|
|
20
20
|
this.notifyEnabled = (0, _native_bridge.deviceCharacteristicNotifyEnabled)(deviceId, serviceId, id);
|
|
21
|
+
this.notifications = (0, _native_bridge.deviceCharacteristicNotifications)(deviceId, serviceId, id);
|
|
21
22
|
this.read = () => (0, _native_bridge.deviceCharacteristicRead)(deviceId, serviceId, id);
|
|
22
23
|
this.write = (data, withResponse) => (0, _native_bridge.deviceCharacteristicWrite)(deviceId, serviceId, id, data, withResponse);
|
|
23
24
|
this.subscribe = () => (0, _native_bridge.deviceCharacteristicSubscribe)(deviceId, serviceId, id);
|
|
@@ -30,10 +31,13 @@ class BBCharacteristic {
|
|
|
30
31
|
|
|
31
32
|
/** The GATT properties this characteristic declares. */
|
|
32
33
|
|
|
33
|
-
/** The last value read or notified for this characteristic
|
|
34
|
+
/** The last value read or notified for this characteristic, replays the most recent value.
|
|
35
|
+
* Empty until first populated. */
|
|
34
36
|
|
|
35
37
|
/** Whether this app is currently subscribed to notifications for this characteristic. */
|
|
36
38
|
|
|
39
|
+
/** The notification stream for this characteristic. Does not replay past values. */
|
|
40
|
+
|
|
37
41
|
/**
|
|
38
42
|
* Reads this characteristic's current value, also updating {@link data}.
|
|
39
43
|
* @throws if the read fails or times out.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_native_bridge","require","BBCharacteristic","constructor","deviceId","serviceId","id","name","properties","data","deviceCharacteristicData","notifyEnabled","deviceCharacteristicNotifyEnabled","read","deviceCharacteristicRead","write","withResponse","deviceCharacteristicWrite","subscribe","deviceCharacteristicSubscribe","unsubscribe","deviceCharacteristicUnsubscribe","exports"],"sourceRoot":"../../../src","sources":["implementation/bluebreeze_characteristic.ts"],"mappings":";;;;;;AACA,IAAAA,cAAA,GAAAC,OAAA;
|
|
1
|
+
{"version":3,"names":["_native_bridge","require","BBCharacteristic","constructor","deviceId","serviceId","id","name","properties","data","deviceCharacteristicData","notifyEnabled","deviceCharacteristicNotifyEnabled","notifications","deviceCharacteristicNotifications","read","deviceCharacteristicRead","write","withResponse","deviceCharacteristicWrite","subscribe","deviceCharacteristicSubscribe","unsubscribe","deviceCharacteristicUnsubscribe","exports"],"sourceRoot":"../../../src","sources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AAAtB,gBAAA,GAAAA,gBAAA","ignoreList":[]}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.deviceServices = exports.deviceRequestMTU = exports.deviceMTU = exports.deviceDiscoverServices = exports.deviceDisconnect = exports.deviceConnectionStatus = exports.deviceConnect = exports.deviceCharacteristicWrite = exports.deviceCharacteristicUnsubscribe = exports.deviceCharacteristicSubscribe = exports.deviceCharacteristicRead = exports.deviceCharacteristicNotifyEnabled = exports.deviceCharacteristicData = void 0;
|
|
6
|
+
exports.deviceServices = exports.deviceRequestMTU = exports.deviceMTU = exports.deviceDiscoverServices = exports.deviceDisconnect = exports.deviceConnectionStatus = exports.deviceConnect = exports.deviceCharacteristicWrite = exports.deviceCharacteristicUnsubscribe = exports.deviceCharacteristicSubscribe = exports.deviceCharacteristicRead = exports.deviceCharacteristicNotifyEnabled = exports.deviceCharacteristicNotifications = exports.deviceCharacteristicData = void 0;
|
|
7
7
|
var _reactNativeValueEmitter = require("react-native-value-emitter");
|
|
8
8
|
var _NativeBlueBreeze = _interopRequireDefault(require("../NativeBlueBreeze.js"));
|
|
9
9
|
var _bluebreeze_characteristic = require("./bluebreeze_characteristic.js");
|
|
@@ -64,6 +64,19 @@ const deviceDisconnect = exports.deviceDisconnect = _NativeBlueBreeze.default.de
|
|
|
64
64
|
const deviceDiscoverServices = exports.deviceDiscoverServices = _NativeBlueBreeze.default.deviceDiscoverServices;
|
|
65
65
|
const deviceRequestMTU = exports.deviceRequestMTU = _NativeBlueBreeze.default.deviceRequestMTU;
|
|
66
66
|
|
|
67
|
+
// Device characteristic data
|
|
68
|
+
|
|
69
|
+
const _deviceCharacteristicData = new Map();
|
|
70
|
+
const deviceCharacteristicData = (id, serviceId, characteristicId) => {
|
|
71
|
+
const deviceMap = mapGetOrSet(_deviceCharacteristicData, id, () => new Map());
|
|
72
|
+
const serviceMap = mapGetOrSet(deviceMap, serviceId, () => new Map());
|
|
73
|
+
return mapGetOrSet(serviceMap, characteristicId, () => new _reactNativeValueEmitter.StateValueEmitter(_NativeBlueBreeze.default.deviceCharacteristicData(id, serviceId, characteristicId)));
|
|
74
|
+
};
|
|
75
|
+
exports.deviceCharacteristicData = deviceCharacteristicData;
|
|
76
|
+
_NativeBlueBreeze.default.deviceCharacteristicDataEmitter(value => {
|
|
77
|
+
deviceCharacteristicData(value.id, value.serviceId, value.characteristicId).add(value.value);
|
|
78
|
+
});
|
|
79
|
+
|
|
67
80
|
// Device characteristic notify enabled
|
|
68
81
|
|
|
69
82
|
const _deviceCharacteristicNotifyEnabled = new Map();
|
|
@@ -77,17 +90,17 @@ _NativeBlueBreeze.default.deviceCharacteristicNotifyEnabledEmitter(value => {
|
|
|
77
90
|
deviceCharacteristicNotifyEnabled(value.id, value.serviceId, value.characteristicId).add(value.value);
|
|
78
91
|
});
|
|
79
92
|
|
|
80
|
-
// Device characteristic
|
|
93
|
+
// Device characteristic notifications
|
|
81
94
|
|
|
82
|
-
const
|
|
83
|
-
const
|
|
84
|
-
const deviceMap = mapGetOrSet(
|
|
95
|
+
const _deviceCharacteristicNotifications = new Map();
|
|
96
|
+
const deviceCharacteristicNotifications = (id, serviceId, characteristicId) => {
|
|
97
|
+
const deviceMap = mapGetOrSet(_deviceCharacteristicNotifications, id, () => new Map());
|
|
85
98
|
const serviceMap = mapGetOrSet(deviceMap, serviceId, () => new Map());
|
|
86
|
-
return mapGetOrSet(serviceMap, characteristicId, () => new _reactNativeValueEmitter.
|
|
99
|
+
return mapGetOrSet(serviceMap, characteristicId, () => new _reactNativeValueEmitter.ValueEmitter());
|
|
87
100
|
};
|
|
88
|
-
exports.
|
|
89
|
-
_NativeBlueBreeze.default.
|
|
90
|
-
|
|
101
|
+
exports.deviceCharacteristicNotifications = deviceCharacteristicNotifications;
|
|
102
|
+
_NativeBlueBreeze.default.deviceCharacteristicNotificationsEmitter(value => {
|
|
103
|
+
deviceCharacteristicNotifications(value.id, value.serviceId, value.characteristicId).add(value.value);
|
|
91
104
|
});
|
|
92
105
|
|
|
93
106
|
// Device characteristic operations
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNativeValueEmitter","require","_NativeBlueBreeze","_interopRequireDefault","_bluebreeze_characteristic","_bluebreeze_service","e","__esModule","default","mapGetOrSet","map","key","defaultValue","get","undefined","set","_deviceServices","Map","deviceServices","id","StateValueEmitter","NativeBlueBreeze","s","convertDeviceService","exports","deviceServicesEmitter","value","add","_deviceConnectionStatus","deviceConnectionStatus","deviceConnectionStatusEmitter","_deviceMTU","deviceMTU","deviceMTUEmitter","deviceConnect","deviceDisconnect","deviceDiscoverServices","deviceRequestMTU","
|
|
1
|
+
{"version":3,"names":["_reactNativeValueEmitter","require","_NativeBlueBreeze","_interopRequireDefault","_bluebreeze_characteristic","_bluebreeze_service","e","__esModule","default","mapGetOrSet","map","key","defaultValue","get","undefined","set","_deviceServices","Map","deviceServices","id","StateValueEmitter","NativeBlueBreeze","s","convertDeviceService","exports","deviceServicesEmitter","value","add","_deviceConnectionStatus","deviceConnectionStatus","deviceConnectionStatusEmitter","_deviceMTU","deviceMTU","deviceMTUEmitter","deviceConnect","deviceDisconnect","deviceDiscoverServices","deviceRequestMTU","_deviceCharacteristicData","deviceCharacteristicData","serviceId","characteristicId","deviceMap","serviceMap","deviceCharacteristicDataEmitter","_deviceCharacteristicNotifyEnabled","deviceCharacteristicNotifyEnabled","deviceCharacteristicNotifyEnabledEmitter","_deviceCharacteristicNotifications","deviceCharacteristicNotifications","ValueEmitter","deviceCharacteristicNotificationsEmitter","deviceCharacteristicRead","deviceCharacteristicWrite","deviceCharacteristicSubscribe","deviceCharacteristicUnsubscribe","deviceId","service","BBService","name","characteristics","c","convertDeviceCharacteristic","characteristic","BBCharacteristic","properties"],"sourceRoot":"../../../src","sources":["implementation/native_bridge.ts"],"mappings":";;;;;;AAAA,IAAAA,wBAAA,GAAAC,OAAA;AACA,IAAAC,iBA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,MAAMC,+BAA+B,GAAA/B,OAAA,CAAA+B,+BAAA,GAAGlC,yBAAgB,CAACkC,+BAA+B;;AAE/F;;AAEA,MAAMhC,oBAAoB,GAAGA,CACzBiC,QAAgB,EAChBC,OAA0B,KACd;EACZ,OAAO,IAAIC,6BAAS,CAChBD,OAAO,CAACtC,EAAE,EACVsC,OAAO,CAACE,IAAI,EACZF,OAAO,CAACG,eAAe,CAAClD,GAAG,CACtBmD,CAAC,IAAKC,2BAA2B,CAACN,QAAQ,EAAEC,OAAO,CAACtC,EAAE,EAAE0C,CAAC,CAC9D,CACJ,CAAC;AACL,CAAC;AAED,MAAMC,2BAA2B,GAAGA,CAChCN,QAAgB,EAChBhB,SAAiB,EACjBuB,cAAwC,KACrB;EACnB,OAAO,IAAIC,2CAAgB,CACvBR,QAAQ,EACRhB,SAAS,EACTuB,cAAc,CAAC5C,EAAE,EACjB4C,cAAc,CAACJ,IAAI,EACnBI,cAAc,CAACE,UACnB,CAAC;AACL,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeBlueBreeze.ts"],"mappings":";;AACA,SAASA,mBAAmB,QAAQ,cAAc;;AAGlD;;
|
|
1
|
+
{"version":3,"names":["TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeBlueBreeze.ts"],"mappings":";;AACA,SAASA,mBAAmB,QAAQ,cAAc;;AAGlD;;AAkEA;;AA6DA,eAAeA,mBAAmB,CAACC,YAAY,CAAO,YAAY,CAAC","ignoreList":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import { deviceCharacteristicData, deviceCharacteristicNotifyEnabled, deviceCharacteristicRead, deviceCharacteristicSubscribe, deviceCharacteristicUnsubscribe, deviceCharacteristicWrite } from "./native_bridge.js";
|
|
3
|
+
import { deviceCharacteristicData, deviceCharacteristicNotifications, deviceCharacteristicNotifyEnabled, deviceCharacteristicRead, deviceCharacteristicSubscribe, deviceCharacteristicUnsubscribe, deviceCharacteristicWrite } from "./native_bridge.js";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* A GATT characteristic belonging to a {@link BBService}.
|
|
@@ -15,6 +15,7 @@ export class BBCharacteristic {
|
|
|
15
15
|
this.properties = properties;
|
|
16
16
|
this.data = deviceCharacteristicData(deviceId, serviceId, id);
|
|
17
17
|
this.notifyEnabled = deviceCharacteristicNotifyEnabled(deviceId, serviceId, id);
|
|
18
|
+
this.notifications = deviceCharacteristicNotifications(deviceId, serviceId, id);
|
|
18
19
|
this.read = () => deviceCharacteristicRead(deviceId, serviceId, id);
|
|
19
20
|
this.write = (data, withResponse) => deviceCharacteristicWrite(deviceId, serviceId, id, data, withResponse);
|
|
20
21
|
this.subscribe = () => deviceCharacteristicSubscribe(deviceId, serviceId, id);
|
|
@@ -27,10 +28,13 @@ export class BBCharacteristic {
|
|
|
27
28
|
|
|
28
29
|
/** The GATT properties this characteristic declares. */
|
|
29
30
|
|
|
30
|
-
/** The last value read or notified for this characteristic
|
|
31
|
+
/** The last value read or notified for this characteristic, replays the most recent value.
|
|
32
|
+
* Empty until first populated. */
|
|
31
33
|
|
|
32
34
|
/** Whether this app is currently subscribed to notifications for this characteristic. */
|
|
33
35
|
|
|
36
|
+
/** The notification stream for this characteristic. Does not replay past values. */
|
|
37
|
+
|
|
34
38
|
/**
|
|
35
39
|
* Reads this characteristic's current value, also updating {@link data}.
|
|
36
40
|
* @throws if the read fails or times out.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["deviceCharacteristicData","deviceCharacteristicNotifyEnabled","deviceCharacteristicRead","deviceCharacteristicSubscribe","deviceCharacteristicUnsubscribe","deviceCharacteristicWrite","BBCharacteristic","constructor","deviceId","serviceId","id","name","properties","data","notifyEnabled","read","write","withResponse","subscribe","unsubscribe"],"sourceRoot":"../../../src","sources":["implementation/bluebreeze_characteristic.ts"],"mappings":";;AACA,SACIA,wBAAwB,EACxBC,iCAAiC,EACjCC,wBAAwB,EACxBC,6BAA6B,EAC7BC,+BAA+B,EAC/BC,yBAAyB,QACtB,oBAAiB;;AAExB;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,gBAAgB,CAAC;EAC1BC,WAAWA,CACPC,QAAgB,EAChBC,SAAiB,EACjBC,EAAU,EACVC,IAAwB,EACxBC,UAAoB,EACtB;IACE,IAAI,CAACF,EAAE,GAAGA,EAAE;IACZ,IAAI,CAACC,IAAI,GAAGA,IAAI;IAChB,IAAI,CAACC,UAAU,GAAGA,UAAU;IAE5B,IAAI,CAACC,IAAI,
|
|
1
|
+
{"version":3,"names":["deviceCharacteristicData","deviceCharacteristicNotifications","deviceCharacteristicNotifyEnabled","deviceCharacteristicRead","deviceCharacteristicSubscribe","deviceCharacteristicUnsubscribe","deviceCharacteristicWrite","BBCharacteristic","constructor","deviceId","serviceId","id","name","properties","data","notifyEnabled","notifications","read","write","withResponse","subscribe","unsubscribe"],"sourceRoot":"../../../src","sources":["implementation/bluebreeze_characteristic.ts"],"mappings":";;AACA,SACIA,wBAAwB,EACxBC,iCAAiC,EACjCC,iCAAiC,EACjCC,wBAAwB,EACxBC,6BAA6B,EAC7BC,+BAA+B,EAC/BC,yBAAyB,QACtB,oBAAiB;;AAExB;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,gBAAgB,CAAC;EAC1BC,WAAWA,CACPC,QAAgB,EAChBC,SAAiB,EACjBC,EAAU,EACVC,IAAwB,EACxBC,UAAoB,EACtB;IACE,IAAI,CAACF,EAAE,GAAGA,EAAE;IACZ,IAAI,CAACC,IAAI,GAAGA,IAAI;IAChB,IAAI,CAACC,UAAU,GAAGA,UAAU;IAE5B,IAAI,CAACC,IAAI,GAAGd,wBAAwB,CAACS,QAAQ,EAAEC,SAAS,EAAEC,EAAE,CAAC;IAE7D,IAAI,CAACI,aAAa,GAAGb,iCAAiC,CAACO,QAAQ,EAAEC,SAAS,EAAEC,EAAE,CAAC;IAC/E,IAAI,CAACK,aAAa,GAAGf,iCAAiC,CAACQ,QAAQ,EAAEC,SAAS,EAAEC,EAAE,CAAC;IAE/E,IAAI,CAACM,IAAI,GAAG,MAAMd,wBAAwB,CAACM,QAAQ,EAAEC,SAAS,EAAEC,EAAE,CAAC;IACnE,IAAI,CAACO,KAAK,GAAG,CAACJ,IAAc,EAAEK,YAAqB,KAAKb,yBAAyB,CAACG,QAAQ,EAAEC,SAAS,EAAEC,EAAE,EAAEG,IAAI,EAAEK,YAAY,CAAC;IAC9H,IAAI,CAACC,SAAS,GAAG,MAAMhB,6BAA6B,CAACK,QAAQ,EAAEC,SAAS,EAAEC,EAAE,CAAC;IAC7E,IAAI,CAACU,WAAW,GAAG,MAAMhB,+BAA+B,CAACI,QAAQ,EAAEC,SAAS,EAAEC,EAAE,CAAC;EACrF;;EAEA;;EAGA;;EAGA;;EAGA;AACJ;;EAGI;;EAGA;;EAGA;AACJ;AACA;AACA;;EAGI;AACJ;AACA;AACA;AACA;AACA;;EAGI;AACJ;AACA;AACA;;EAGI;AACJ;AACA;AACA;AAEA","ignoreList":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import { StateValueEmitter } from 'react-native-value-emitter';
|
|
3
|
+
import { StateValueEmitter, ValueEmitter } from 'react-native-value-emitter';
|
|
4
4
|
import NativeBlueBreeze from "../NativeBlueBreeze.js";
|
|
5
5
|
import { BBCharacteristic } from "./bluebreeze_characteristic.js";
|
|
6
6
|
import { BBService } from "./bluebreeze_service.js";
|
|
@@ -57,6 +57,18 @@ export const deviceDisconnect = NativeBlueBreeze.deviceDisconnect;
|
|
|
57
57
|
export const deviceDiscoverServices = NativeBlueBreeze.deviceDiscoverServices;
|
|
58
58
|
export const deviceRequestMTU = NativeBlueBreeze.deviceRequestMTU;
|
|
59
59
|
|
|
60
|
+
// Device characteristic data
|
|
61
|
+
|
|
62
|
+
const _deviceCharacteristicData = new Map();
|
|
63
|
+
export const deviceCharacteristicData = (id, serviceId, characteristicId) => {
|
|
64
|
+
const deviceMap = mapGetOrSet(_deviceCharacteristicData, id, () => new Map());
|
|
65
|
+
const serviceMap = mapGetOrSet(deviceMap, serviceId, () => new Map());
|
|
66
|
+
return mapGetOrSet(serviceMap, characteristicId, () => new StateValueEmitter(NativeBlueBreeze.deviceCharacteristicData(id, serviceId, characteristicId)));
|
|
67
|
+
};
|
|
68
|
+
NativeBlueBreeze.deviceCharacteristicDataEmitter(value => {
|
|
69
|
+
deviceCharacteristicData(value.id, value.serviceId, value.characteristicId).add(value.value);
|
|
70
|
+
});
|
|
71
|
+
|
|
60
72
|
// Device characteristic notify enabled
|
|
61
73
|
|
|
62
74
|
const _deviceCharacteristicNotifyEnabled = new Map();
|
|
@@ -69,16 +81,16 @@ NativeBlueBreeze.deviceCharacteristicNotifyEnabledEmitter(value => {
|
|
|
69
81
|
deviceCharacteristicNotifyEnabled(value.id, value.serviceId, value.characteristicId).add(value.value);
|
|
70
82
|
});
|
|
71
83
|
|
|
72
|
-
// Device characteristic
|
|
84
|
+
// Device characteristic notifications
|
|
73
85
|
|
|
74
|
-
const
|
|
75
|
-
export const
|
|
76
|
-
const deviceMap = mapGetOrSet(
|
|
86
|
+
const _deviceCharacteristicNotifications = new Map();
|
|
87
|
+
export const deviceCharacteristicNotifications = (id, serviceId, characteristicId) => {
|
|
88
|
+
const deviceMap = mapGetOrSet(_deviceCharacteristicNotifications, id, () => new Map());
|
|
77
89
|
const serviceMap = mapGetOrSet(deviceMap, serviceId, () => new Map());
|
|
78
|
-
return mapGetOrSet(serviceMap, characteristicId, () => new
|
|
90
|
+
return mapGetOrSet(serviceMap, characteristicId, () => new ValueEmitter());
|
|
79
91
|
};
|
|
80
|
-
NativeBlueBreeze.
|
|
81
|
-
|
|
92
|
+
NativeBlueBreeze.deviceCharacteristicNotificationsEmitter(value => {
|
|
93
|
+
deviceCharacteristicNotifications(value.id, value.serviceId, value.characteristicId).add(value.value);
|
|
82
94
|
});
|
|
83
95
|
|
|
84
96
|
// Device characteristic operations
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["StateValueEmitter","NativeBlueBreeze","BBCharacteristic","BBService","mapGetOrSet","map","key","defaultValue","get","undefined","set","_deviceServices","Map","deviceServices","id","s","convertDeviceService","deviceServicesEmitter","value","add","_deviceConnectionStatus","deviceConnectionStatus","deviceConnectionStatusEmitter","_deviceMTU","deviceMTU","deviceMTUEmitter","deviceConnect","deviceDisconnect","deviceDiscoverServices","deviceRequestMTU","
|
|
1
|
+
{"version":3,"names":["StateValueEmitter","ValueEmitter","NativeBlueBreeze","BBCharacteristic","BBService","mapGetOrSet","map","key","defaultValue","get","undefined","set","_deviceServices","Map","deviceServices","id","s","convertDeviceService","deviceServicesEmitter","value","add","_deviceConnectionStatus","deviceConnectionStatus","deviceConnectionStatusEmitter","_deviceMTU","deviceMTU","deviceMTUEmitter","deviceConnect","deviceDisconnect","deviceDiscoverServices","deviceRequestMTU","_deviceCharacteristicData","deviceCharacteristicData","serviceId","characteristicId","deviceMap","serviceMap","deviceCharacteristicDataEmitter","_deviceCharacteristicNotifyEnabled","deviceCharacteristicNotifyEnabled","deviceCharacteristicNotifyEnabledEmitter","_deviceCharacteristicNotifications","deviceCharacteristicNotifications","deviceCharacteristicNotificationsEmitter","deviceCharacteristicRead","deviceCharacteristicWrite","deviceCharacteristicSubscribe","deviceCharacteristicUnsubscribe","deviceId","service","name","characteristics","c","convertDeviceCharacteristic","characteristic","properties"],"sourceRoot":"../../../src","sources":["implementation/native_bridge.ts"],"mappings":";;AAAA,SAASA,iBAAiB,EAAEC,YAAY,QAAQ,4BAA4B;AAC5E,OAAOC,gBAAgB,MAAiE,wBAAqB;AAC7G,SAASC,gBAAgB,QAAQ,gCAA6B;AAE9D,SAASC,SAAS,QAAQ,yBAAsB;;AAEhD;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASC,WAAWA,C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@@ export interface BBDeviceCharacteristicNotifyEnabledEvent {
|
|
|
48
48
|
characteristicId: string;
|
|
49
49
|
value: boolean;
|
|
50
50
|
}
|
|
51
|
+
export interface BBDeviceCharacteristicNotificationsEvent {
|
|
52
|
+
id: string;
|
|
53
|
+
serviceId: string;
|
|
54
|
+
characteristicId: string;
|
|
55
|
+
value: number[];
|
|
56
|
+
}
|
|
51
57
|
export interface Spec extends TurboModule {
|
|
52
58
|
state(): string;
|
|
53
59
|
readonly stateEmitter: EventEmitter<string>;
|
|
@@ -76,6 +82,8 @@ export interface Spec extends TurboModule {
|
|
|
76
82
|
readonly deviceCharacteristicDataEmitter: EventEmitter<BBDeviceCharacteristicDataEvent>;
|
|
77
83
|
deviceCharacteristicNotifyEnabled(id: string, serviceId: string, characteristicId: string): boolean;
|
|
78
84
|
readonly deviceCharacteristicNotifyEnabledEmitter: EventEmitter<BBDeviceCharacteristicNotifyEnabledEvent>;
|
|
85
|
+
deviceCharacteristicNotifications(id: string, serviceId: string, characteristicId: string): number[];
|
|
86
|
+
readonly deviceCharacteristicNotificationsEmitter: EventEmitter<BBDeviceCharacteristicNotificationsEvent>;
|
|
79
87
|
deviceCharacteristicRead(id: string, serviceId: string, characteristicId: string): Promise<number[]>;
|
|
80
88
|
deviceCharacteristicWrite(id: string, serviceId: string, characteristicId: string, data: number[], withResponse: boolean): Promise<void>;
|
|
81
89
|
deviceCharacteristicSubscribe(id: string, serviceId: string, characteristicId: string): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NativeBlueBreeze.d.ts","sourceRoot":"","sources":["../../../../src/NativeBlueBreeze.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAE/C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oDAAoD,CAAA;AAItF,MAAM,WAAW,cAAc;IAC3B,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,CAAC,EAAE,MAAM,CAAA;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E,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACrG,+BAA+B,CAAC,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CAC1G;;AAED,wBAAmE"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { StateValueEmitter } from "react-native-value-emitter";
|
|
1
|
+
import type { StateValueEmitter, ValueEmitter } from "react-native-value-emitter";
|
|
2
2
|
/**
|
|
3
3
|
* A GATT characteristic belonging to a {@link BBService}.
|
|
4
4
|
*
|
|
@@ -13,10 +13,13 @@ export declare class BBCharacteristic {
|
|
|
13
13
|
name?: string;
|
|
14
14
|
/** The GATT properties this characteristic declares. */
|
|
15
15
|
properties: string[];
|
|
16
|
-
/** The last value read or notified for this characteristic
|
|
16
|
+
/** The last value read or notified for this characteristic, replays the most recent value.
|
|
17
|
+
* Empty until first populated. */
|
|
17
18
|
data: StateValueEmitter<number[]>;
|
|
18
19
|
/** Whether this app is currently subscribed to notifications for this characteristic. */
|
|
19
20
|
notifyEnabled: StateValueEmitter<boolean>;
|
|
21
|
+
/** The notification stream for this characteristic. Does not replay past values. */
|
|
22
|
+
notifications: ValueEmitter<number[]>;
|
|
20
23
|
/**
|
|
21
24
|
* Reads this characteristic's current value, also updating {@link data}.
|
|
22
25
|
* @throws if the read fails or times out.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bluebreeze_characteristic.d.ts","sourceRoot":"","sources":["../../../../../src/implementation/bluebreeze_characteristic.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;
|
|
1
|
+
{"version":3,"file":"bluebreeze_characteristic.d.ts","sourceRoot":"","sources":["../../../../../src/implementation/bluebreeze_characteristic.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAWjF;;;;;GAKG;AACH,qBAAa,gBAAgB;gBAErB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,MAAM,GAAG,SAAS,EACxB,UAAU,EAAE,MAAM,EAAE;IAiBxB,iCAAiC;IACjC,EAAE,EAAE,MAAM,CAAA;IAEV,2GAA2G;IAC3G,IAAI,CAAC,EAAE,MAAM,CAAA;IAEb,wDAAwD;IACxD,UAAU,EAAE,MAAM,EAAE,CAAA;IAEpB;uCACmC;IACnC,IAAI,EAAE,iBAAiB,CAAC,MAAM,EAAE,CAAC,CAAA;IAEjC,yFAAyF;IACzF,aAAa,EAAE,iBAAiB,CAAC,OAAO,CAAC,CAAA;IAEzC,oFAAoF;IACpF,aAAa,EAAE,YAAY,CAAC,MAAM,EAAE,CAAC,CAAA;IAErC;;;OAGG;IACH,IAAI,EAAE,MAAM,OAAO,CAAC,MAAM,EAAE,CAAC,CAAA;IAE7B;;;;;OAKG;IACH,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,YAAY,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IAE/D;;;OAGG;IACH,SAAS,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IAE9B;;;OAGG;IACH,WAAW,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CACnC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { StateValueEmitter } from 'react-native-value-emitter';
|
|
1
|
+
import { StateValueEmitter, ValueEmitter } from 'react-native-value-emitter';
|
|
2
2
|
import type { BBDeviceConnectionStatus } from './bluebreeze_connection_status';
|
|
3
3
|
import { BBService } from './bluebreeze_service';
|
|
4
4
|
export declare const deviceServices: (id: string) => StateValueEmitter<BBService[]>;
|
|
@@ -8,8 +8,9 @@ export declare const deviceConnect: (id: string) => Promise<void>;
|
|
|
8
8
|
export declare const deviceDisconnect: (id: string) => Promise<void>;
|
|
9
9
|
export declare const deviceDiscoverServices: (id: string) => Promise<void>;
|
|
10
10
|
export declare const deviceRequestMTU: (id: string, mtu: number) => Promise<number>;
|
|
11
|
-
export declare const deviceCharacteristicNotifyEnabled: (id: string, serviceId: string, characteristicId: string) => StateValueEmitter<boolean>;
|
|
12
11
|
export declare const deviceCharacteristicData: (id: string, serviceId: string, characteristicId: string) => StateValueEmitter<number[]>;
|
|
12
|
+
export declare const deviceCharacteristicNotifyEnabled: (id: string, serviceId: string, characteristicId: string) => StateValueEmitter<boolean>;
|
|
13
|
+
export declare const deviceCharacteristicNotifications: (id: string, serviceId: string, characteristicId: string) => ValueEmitter<number[]>;
|
|
13
14
|
export declare const deviceCharacteristicRead: (id: string, serviceId: string, characteristicId: string) => Promise<number[]>;
|
|
14
15
|
export declare const deviceCharacteristicWrite: (id: string, serviceId: string, characteristicId: string, data: number[], withResponse: boolean) => Promise<void>;
|
|
15
16
|
export declare const deviceCharacteristicSubscribe: (id: string, serviceId: string, characteristicId: string) => Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native_bridge.d.ts","sourceRoot":"","sources":["../../../../../src/implementation/native_bridge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;
|
|
1
|
+
{"version":3,"file":"native_bridge.d.ts","sourceRoot":"","sources":["../../../../../src/implementation/native_bridge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAG5E,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAA;AAC9E,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAsBhD,eAAO,MAAM,cAAc,OAAQ,MAAM,KAAG,iBAAiB,CAAC,SAAS,EAAE,CAUxE,CAAA;AAYD,eAAO,MAAM,sBAAsB,OAAQ,MAAM,KAAG,iBAAiB,CAAC,wBAAwB,CAQ7F,CAAA;AAUD,eAAO,MAAM,SAAS,OAAQ,MAAM,KAAG,iBAAiB,CAAC,MAAM,CAQ9D,CAAA;AAQD,eAAO,MAAM,aAAa,+BAAiC,CAAA;AAE3D,eAAO,MAAM,gBAAgB,+BAAoC,CAAA;AAEjE,eAAO,MAAM,sBAAsB,+BAA0C,CAAA;AAE7E,eAAO,MAAM,gBAAgB,8CAAoC,CAAA;AAMjE,eAAO,MAAM,wBAAwB,OAC7B,MAAM,aACC,MAAM,oBACC,MAAM,KACzB,iBAAiB,CAAC,MAAM,EAAE,CAoB5B,CAAA;AAUD,eAAO,MAAM,iCAAiC,OACtC,MAAM,aACC,MAAM,oBACC,MAAM,KACzB,iBAAiB,CAAC,OAAO,CAoB3B,CAAA;AAUD,eAAO,MAAM,iCAAiC,OACtC,MAAM,aACC,MAAM,oBACC,MAAM,KACzB,YAAY,CAAC,MAAM,EAAE,CAkBvB,CAAA;AAQD,eAAO,MAAM,wBAAwB,gFAA4C,CAAA;AAEjF,eAAO,MAAM,yBAAyB,mHAA6C,CAAA;AAEnF,eAAO,MAAM,6BAA6B,4EAAiD,CAAA;AAE3F,eAAO,MAAM,+BAA+B,4EAAmD,CAAA"}
|
|
@@ -48,6 +48,12 @@ export interface BBDeviceCharacteristicNotifyEnabledEvent {
|
|
|
48
48
|
characteristicId: string;
|
|
49
49
|
value: boolean;
|
|
50
50
|
}
|
|
51
|
+
export interface BBDeviceCharacteristicNotificationsEvent {
|
|
52
|
+
id: string;
|
|
53
|
+
serviceId: string;
|
|
54
|
+
characteristicId: string;
|
|
55
|
+
value: number[];
|
|
56
|
+
}
|
|
51
57
|
export interface Spec extends TurboModule {
|
|
52
58
|
state(): string;
|
|
53
59
|
readonly stateEmitter: EventEmitter<string>;
|
|
@@ -76,6 +82,8 @@ export interface Spec extends TurboModule {
|
|
|
76
82
|
readonly deviceCharacteristicDataEmitter: EventEmitter<BBDeviceCharacteristicDataEvent>;
|
|
77
83
|
deviceCharacteristicNotifyEnabled(id: string, serviceId: string, characteristicId: string): boolean;
|
|
78
84
|
readonly deviceCharacteristicNotifyEnabledEmitter: EventEmitter<BBDeviceCharacteristicNotifyEnabledEvent>;
|
|
85
|
+
deviceCharacteristicNotifications(id: string, serviceId: string, characteristicId: string): number[];
|
|
86
|
+
readonly deviceCharacteristicNotificationsEmitter: EventEmitter<BBDeviceCharacteristicNotificationsEvent>;
|
|
79
87
|
deviceCharacteristicRead(id: string, serviceId: string, characteristicId: string): Promise<number[]>;
|
|
80
88
|
deviceCharacteristicWrite(id: string, serviceId: string, characteristicId: string, data: number[], withResponse: boolean): Promise<void>;
|
|
81
89
|
deviceCharacteristicSubscribe(id: string, serviceId: string, characteristicId: string): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NativeBlueBreeze.d.ts","sourceRoot":"","sources":["../../../../src/NativeBlueBreeze.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAE/C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oDAAoD,CAAA;AAItF,MAAM,WAAW,cAAc;IAC3B,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,OAAO,CAAA;IACpB,kBAAkB,EAAE,MAAM,EAAE,CAAA;IAC5B,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAA;CAC9B;AAED,MAAM,WAAW,UAAU;IACvB,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,wBAAwB;IACrC,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,UAAU,EAAE,MAAM,EAAE,CAAA;CACvB;AAED,MAAM,W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C,+BAA+B,CAAC,CAAA;IAGvF,iCAAiC,CAAC,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,GAAG,OAAO,CAAA;IACnG,QAAQ,CAAC,wCAAwC,EAAE,YAAY,CAAC,wCAAwC,CAAC,CAAA;IAGzG,iCAAiC,CAAC,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;IACpG,QAAQ,CAAC,wCAAwC,EAAE,YAAY,CAAC,wCAAwC,CAAC,CAAA;IAGzG,wBAAwB,CAAC,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAA;IACpG,yBAAyB,CAAC,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,YAAY,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACxI,6BAA6B,CAAC,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACrG,+BAA+B,CAAC,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CAC1G;;AAED,wBAAmE"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { StateValueEmitter } from "react-native-value-emitter";
|
|
1
|
+
import type { StateValueEmitter, ValueEmitter } from "react-native-value-emitter";
|
|
2
2
|
/**
|
|
3
3
|
* A GATT characteristic belonging to a {@link BBService}.
|
|
4
4
|
*
|
|
@@ -13,10 +13,13 @@ export declare class BBCharacteristic {
|
|
|
13
13
|
name?: string;
|
|
14
14
|
/** The GATT properties this characteristic declares. */
|
|
15
15
|
properties: string[];
|
|
16
|
-
/** The last value read or notified for this characteristic
|
|
16
|
+
/** The last value read or notified for this characteristic, replays the most recent value.
|
|
17
|
+
* Empty until first populated. */
|
|
17
18
|
data: StateValueEmitter<number[]>;
|
|
18
19
|
/** Whether this app is currently subscribed to notifications for this characteristic. */
|
|
19
20
|
notifyEnabled: StateValueEmitter<boolean>;
|
|
21
|
+
/** The notification stream for this characteristic. Does not replay past values. */
|
|
22
|
+
notifications: ValueEmitter<number[]>;
|
|
20
23
|
/**
|
|
21
24
|
* Reads this characteristic's current value, also updating {@link data}.
|
|
22
25
|
* @throws if the read fails or times out.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bluebreeze_characteristic.d.ts","sourceRoot":"","sources":["../../../../../src/implementation/bluebreeze_characteristic.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;
|
|
1
|
+
{"version":3,"file":"bluebreeze_characteristic.d.ts","sourceRoot":"","sources":["../../../../../src/implementation/bluebreeze_characteristic.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAWjF;;;;;GAKG;AACH,qBAAa,gBAAgB;gBAErB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,MAAM,GAAG,SAAS,EACxB,UAAU,EAAE,MAAM,EAAE;IAiBxB,iCAAiC;IACjC,EAAE,EAAE,MAAM,CAAA;IAEV,2GAA2G;IAC3G,IAAI,CAAC,EAAE,MAAM,CAAA;IAEb,wDAAwD;IACxD,UAAU,EAAE,MAAM,EAAE,CAAA;IAEpB;uCACmC;IACnC,IAAI,EAAE,iBAAiB,CAAC,MAAM,EAAE,CAAC,CAAA;IAEjC,yFAAyF;IACzF,aAAa,EAAE,iBAAiB,CAAC,OAAO,CAAC,CAAA;IAEzC,oFAAoF;IACpF,aAAa,EAAE,YAAY,CAAC,MAAM,EAAE,CAAC,CAAA;IAErC;;;OAGG;IACH,IAAI,EAAE,MAAM,OAAO,CAAC,MAAM,EAAE,CAAC,CAAA;IAE7B;;;;;OAKG;IACH,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,YAAY,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IAE/D;;;OAGG;IACH,SAAS,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IAE9B;;;OAGG;IACH,WAAW,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CACnC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { StateValueEmitter } from 'react-native-value-emitter';
|
|
1
|
+
import { StateValueEmitter, ValueEmitter } from 'react-native-value-emitter';
|
|
2
2
|
import type { BBDeviceConnectionStatus } from './bluebreeze_connection_status.js';
|
|
3
3
|
import { BBService } from './bluebreeze_service.js';
|
|
4
4
|
export declare const deviceServices: (id: string) => StateValueEmitter<BBService[]>;
|
|
@@ -8,8 +8,9 @@ export declare const deviceConnect: (id: string) => Promise<void>;
|
|
|
8
8
|
export declare const deviceDisconnect: (id: string) => Promise<void>;
|
|
9
9
|
export declare const deviceDiscoverServices: (id: string) => Promise<void>;
|
|
10
10
|
export declare const deviceRequestMTU: (id: string, mtu: number) => Promise<number>;
|
|
11
|
-
export declare const deviceCharacteristicNotifyEnabled: (id: string, serviceId: string, characteristicId: string) => StateValueEmitter<boolean>;
|
|
12
11
|
export declare const deviceCharacteristicData: (id: string, serviceId: string, characteristicId: string) => StateValueEmitter<number[]>;
|
|
12
|
+
export declare const deviceCharacteristicNotifyEnabled: (id: string, serviceId: string, characteristicId: string) => StateValueEmitter<boolean>;
|
|
13
|
+
export declare const deviceCharacteristicNotifications: (id: string, serviceId: string, characteristicId: string) => ValueEmitter<number[]>;
|
|
13
14
|
export declare const deviceCharacteristicRead: (id: string, serviceId: string, characteristicId: string) => Promise<number[]>;
|
|
14
15
|
export declare const deviceCharacteristicWrite: (id: string, serviceId: string, characteristicId: string, data: number[], withResponse: boolean) => Promise<void>;
|
|
15
16
|
export declare const deviceCharacteristicSubscribe: (id: string, serviceId: string, characteristicId: string) => Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native_bridge.d.ts","sourceRoot":"","sources":["../../../../../src/implementation/native_bridge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;
|
|
1
|
+
{"version":3,"file":"native_bridge.d.ts","sourceRoot":"","sources":["../../../../../src/implementation/native_bridge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAG5E,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,mCAAgC,CAAA;AAC9E,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAsB,CAAA;AAsBhD,eAAO,MAAM,cAAc,OAAQ,MAAM,KAAG,iBAAiB,CAAC,SAAS,EAAE,CAUxE,CAAA;AAYD,eAAO,MAAM,sBAAsB,OAAQ,MAAM,KAAG,iBAAiB,CAAC,wBAAwB,CAQ7F,CAAA;AAUD,eAAO,MAAM,SAAS,OAAQ,MAAM,KAAG,iBAAiB,CAAC,MAAM,CAQ9D,CAAA;AAQD,eAAO,MAAM,aAAa,+BAAiC,CAAA;AAE3D,eAAO,MAAM,gBAAgB,+BAAoC,CAAA;AAEjE,eAAO,MAAM,sBAAsB,+BAA0C,CAAA;AAE7E,eAAO,MAAM,gBAAgB,8CAAoC,CAAA;AAMjE,eAAO,MAAM,wBAAwB,OAC7B,MAAM,aACC,MAAM,oBACC,MAAM,KACzB,iBAAiB,CAAC,MAAM,EAAE,CAoB5B,CAAA;AAUD,eAAO,MAAM,iCAAiC,OACtC,MAAM,aACC,MAAM,oBACC,MAAM,KACzB,iBAAiB,CAAC,OAAO,CAoB3B,CAAA;AAUD,eAAO,MAAM,iCAAiC,OACtC,MAAM,aACC,MAAM,oBACC,MAAM,KACzB,YAAY,CAAC,MAAM,EAAE,CAkBvB,CAAA;AAQD,eAAO,MAAM,wBAAwB,gFAA4C,CAAA;AAEjF,eAAO,MAAM,yBAAyB,mHAA6C,CAAA;AAEnF,eAAO,MAAM,6BAA6B,4EAAiD,CAAA;AAE3F,eAAO,MAAM,+BAA+B,4EAAmD,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-bluebreeze",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "BlueBreeze bindings for React Native. A modern Bluetooth LE library.",
|
|
5
5
|
"source": "./src/index.tsx",
|
|
6
6
|
"main": "./lib/commonjs/index.js",
|
|
@@ -42,7 +42,8 @@
|
|
|
42
42
|
"typecheck": "tsc",
|
|
43
43
|
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
44
44
|
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
|
|
45
|
-
"prepare": "bob build"
|
|
45
|
+
"prepare": "bob build",
|
|
46
|
+
"codegen": "bob build --target codegen"
|
|
46
47
|
},
|
|
47
48
|
"keywords": [
|
|
48
49
|
"react-native",
|
|
@@ -17,7 +17,7 @@ Pod::Spec.new do |s|
|
|
|
17
17
|
s.source_files = "ios/**/*.{h,m,mm,cpp,swift}"
|
|
18
18
|
s.private_header_files = "ios/**/*.h"
|
|
19
19
|
|
|
20
|
-
s.dependency "BlueBreeze", "1.0.
|
|
20
|
+
s.dependency "BlueBreeze", "1.0.2"
|
|
21
21
|
|
|
22
22
|
# Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
|
|
23
23
|
# See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
|
package/src/NativeBlueBreeze.ts
CHANGED
|
@@ -61,6 +61,13 @@ export interface BBDeviceCharacteristicNotifyEnabledEvent {
|
|
|
61
61
|
value: boolean
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
+
export interface BBDeviceCharacteristicNotificationsEvent {
|
|
65
|
+
id: string
|
|
66
|
+
serviceId: string
|
|
67
|
+
characteristicId: string
|
|
68
|
+
value: number[]
|
|
69
|
+
}
|
|
70
|
+
|
|
64
71
|
/// Module specifications
|
|
65
72
|
|
|
66
73
|
export interface Spec extends TurboModule {
|
|
@@ -111,6 +118,10 @@ export interface Spec extends TurboModule {
|
|
|
111
118
|
deviceCharacteristicNotifyEnabled(id: string, serviceId: string, characteristicId: string): boolean
|
|
112
119
|
readonly deviceCharacteristicNotifyEnabledEmitter: EventEmitter<BBDeviceCharacteristicNotifyEnabledEvent>
|
|
113
120
|
|
|
121
|
+
// Device characteristic notifications
|
|
122
|
+
deviceCharacteristicNotifications(id: string, serviceId: string, characteristicId: string): number[]
|
|
123
|
+
readonly deviceCharacteristicNotificationsEmitter: EventEmitter<BBDeviceCharacteristicNotificationsEvent>
|
|
124
|
+
|
|
114
125
|
// Device characteristic operations
|
|
115
126
|
deviceCharacteristicRead(id: string, serviceId: string, characteristicId: string): Promise<number[]>
|
|
116
127
|
deviceCharacteristicWrite(id: string, serviceId: string, characteristicId: string, data: number[], withResponse: boolean): Promise<void>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { StateValueEmitter } from "react-native-value-emitter"
|
|
1
|
+
import type { StateValueEmitter, ValueEmitter } from "react-native-value-emitter"
|
|
2
2
|
import {
|
|
3
3
|
deviceCharacteristicData,
|
|
4
|
+
deviceCharacteristicNotifications,
|
|
4
5
|
deviceCharacteristicNotifyEnabled,
|
|
5
6
|
deviceCharacteristicRead,
|
|
6
7
|
deviceCharacteristicSubscribe,
|
|
@@ -27,7 +28,9 @@ export class BBCharacteristic {
|
|
|
27
28
|
this.properties = properties
|
|
28
29
|
|
|
29
30
|
this.data = deviceCharacteristicData(deviceId, serviceId, id)
|
|
31
|
+
|
|
30
32
|
this.notifyEnabled = deviceCharacteristicNotifyEnabled(deviceId, serviceId, id)
|
|
33
|
+
this.notifications = deviceCharacteristicNotifications(deviceId, serviceId, id)
|
|
31
34
|
|
|
32
35
|
this.read = () => deviceCharacteristicRead(deviceId, serviceId, id)
|
|
33
36
|
this.write = (data: number[], withResponse: boolean) => deviceCharacteristicWrite(deviceId, serviceId, id, data, withResponse)
|
|
@@ -44,12 +47,16 @@ export class BBCharacteristic {
|
|
|
44
47
|
/** The GATT properties this characteristic declares. */
|
|
45
48
|
properties: string[]
|
|
46
49
|
|
|
47
|
-
/** The last value read or notified for this characteristic
|
|
50
|
+
/** The last value read or notified for this characteristic, replays the most recent value.
|
|
51
|
+
* Empty until first populated. */
|
|
48
52
|
data: StateValueEmitter<number[]>
|
|
49
53
|
|
|
50
54
|
/** Whether this app is currently subscribed to notifications for this characteristic. */
|
|
51
55
|
notifyEnabled: StateValueEmitter<boolean>
|
|
52
56
|
|
|
57
|
+
/** The notification stream for this characteristic. Does not replay past values. */
|
|
58
|
+
notifications: ValueEmitter<number[]>
|
|
59
|
+
|
|
53
60
|
/**
|
|
54
61
|
* Reads this characteristic's current value, also updating {@link data}.
|
|
55
62
|
* @throws if the read fails or times out.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { StateValueEmitter } from 'react-native-value-emitter'
|
|
1
|
+
import { StateValueEmitter, ValueEmitter } from 'react-native-value-emitter'
|
|
2
2
|
import NativeBlueBreeze, { type SpecDeviceCharacteristic, type SpecDeviceService } from '../NativeBlueBreeze'
|
|
3
3
|
import { BBCharacteristic } from './bluebreeze_characteristic'
|
|
4
4
|
import type { BBDeviceConnectionStatus } from './bluebreeze_connection_status'
|
|
@@ -88,6 +88,40 @@ export const deviceDiscoverServices = NativeBlueBreeze.deviceDiscoverServices
|
|
|
88
88
|
|
|
89
89
|
export const deviceRequestMTU = NativeBlueBreeze.deviceRequestMTU
|
|
90
90
|
|
|
91
|
+
// Device characteristic data
|
|
92
|
+
|
|
93
|
+
const _deviceCharacteristicData = new Map<string, Map<string, Map<string, StateValueEmitter<number[]>>>>()
|
|
94
|
+
|
|
95
|
+
export const deviceCharacteristicData = (
|
|
96
|
+
id: string,
|
|
97
|
+
serviceId: string,
|
|
98
|
+
characteristicId: string
|
|
99
|
+
): StateValueEmitter<number[]> => {
|
|
100
|
+
const deviceMap = mapGetOrSet(
|
|
101
|
+
_deviceCharacteristicData,
|
|
102
|
+
id,
|
|
103
|
+
() => new Map<string, Map<string, StateValueEmitter<number[]>>>()
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
const serviceMap = mapGetOrSet(
|
|
107
|
+
deviceMap,
|
|
108
|
+
serviceId,
|
|
109
|
+
() => new Map<string, StateValueEmitter<number[]>>()
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
return mapGetOrSet(
|
|
113
|
+
serviceMap,
|
|
114
|
+
characteristicId,
|
|
115
|
+
() => new StateValueEmitter<number[]>(
|
|
116
|
+
NativeBlueBreeze.deviceCharacteristicData(id, serviceId, characteristicId)
|
|
117
|
+
)
|
|
118
|
+
)
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
NativeBlueBreeze.deviceCharacteristicDataEmitter((value) => {
|
|
122
|
+
deviceCharacteristicData(value.id, value.serviceId, value.characteristicId).add(value.value)
|
|
123
|
+
})
|
|
124
|
+
|
|
91
125
|
// Device characteristic notify enabled
|
|
92
126
|
|
|
93
127
|
const _deviceCharacteristicNotifyEnabled = new Map<string, Map<string, Map<string, StateValueEmitter<boolean>>>>()
|
|
@@ -122,38 +156,36 @@ NativeBlueBreeze.deviceCharacteristicNotifyEnabledEmitter((value) => {
|
|
|
122
156
|
deviceCharacteristicNotifyEnabled(value.id, value.serviceId, value.characteristicId).add(value.value)
|
|
123
157
|
})
|
|
124
158
|
|
|
125
|
-
// Device characteristic
|
|
159
|
+
// Device characteristic notifications
|
|
126
160
|
|
|
127
|
-
const
|
|
161
|
+
const _deviceCharacteristicNotifications = new Map<string, Map<string, Map<string, ValueEmitter<number[]>>>>()
|
|
128
162
|
|
|
129
|
-
export const
|
|
163
|
+
export const deviceCharacteristicNotifications = (
|
|
130
164
|
id: string,
|
|
131
165
|
serviceId: string,
|
|
132
166
|
characteristicId: string
|
|
133
|
-
):
|
|
167
|
+
): ValueEmitter<number[]> => {
|
|
134
168
|
const deviceMap = mapGetOrSet(
|
|
135
|
-
|
|
169
|
+
_deviceCharacteristicNotifications,
|
|
136
170
|
id,
|
|
137
|
-
() => new Map<string, Map<string,
|
|
171
|
+
() => new Map<string, Map<string, ValueEmitter<number[]>>>()
|
|
138
172
|
)
|
|
139
173
|
|
|
140
174
|
const serviceMap = mapGetOrSet(
|
|
141
175
|
deviceMap,
|
|
142
176
|
serviceId,
|
|
143
|
-
() => new Map<string,
|
|
177
|
+
() => new Map<string, ValueEmitter<number[]>>()
|
|
144
178
|
)
|
|
145
179
|
|
|
146
180
|
return mapGetOrSet(
|
|
147
181
|
serviceMap,
|
|
148
182
|
characteristicId,
|
|
149
|
-
() => new
|
|
150
|
-
NativeBlueBreeze.deviceCharacteristicData(id, serviceId, characteristicId)
|
|
151
|
-
)
|
|
183
|
+
() => new ValueEmitter<number[]>()
|
|
152
184
|
)
|
|
153
185
|
}
|
|
154
186
|
|
|
155
|
-
NativeBlueBreeze.
|
|
156
|
-
|
|
187
|
+
NativeBlueBreeze.deviceCharacteristicNotificationsEmitter((value) => {
|
|
188
|
+
deviceCharacteristicNotifications(value.id, value.serviceId, value.characteristicId).add(value.value)
|
|
157
189
|
})
|
|
158
190
|
|
|
159
191
|
// Device characteristic operations
|