react-native-bluebreeze 0.0.1
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/LICENSE +20 -0
- package/README.md +33 -0
- package/android/build.gradle +122 -0
- package/android/generated/java/com/bluebreeze/NativeBlueBreezeSpec.java +153 -0
- package/android/generated/jni/CMakeLists.txt +36 -0
- package/android/generated/jni/RNBlueBreezeSpec-generated.cpp +156 -0
- package/android/generated/jni/RNBlueBreezeSpec.h +31 -0
- package/android/generated/jni/react/renderer/components/RNBlueBreezeSpec/RNBlueBreezeSpecJSI-generated.cpp +171 -0
- package/android/generated/jni/react/renderer/components/RNBlueBreezeSpec/RNBlueBreezeSpecJSI.h +632 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/AndroidManifestNew.xml +2 -0
- package/android/src/main/java/com/bluebreeze/BlueBreezeModule.kt +23 -0
- package/android/src/main/java/com/bluebreeze/BlueBreezePackage.kt +34 -0
- package/ios/BlueBreezeImpl.swift +477 -0
- package/ios/Bluebreeze.h +6 -0
- package/ios/Bluebreeze.mm +280 -0
- package/ios/generated/RNBlueBreezeSpec/RNBlueBreezeSpec-generated.mm +219 -0
- package/ios/generated/RNBlueBreezeSpec/RNBlueBreezeSpec.h +117 -0
- package/ios/generated/RNBlueBreezeSpecJSI-generated.cpp +171 -0
- package/ios/generated/RNBlueBreezeSpecJSI.h +632 -0
- package/package.json +203 -0
- package/react-native-bluebreeze.podspec +44 -0
- package/react-native.config.js +12 -0
- package/src/NativeBlueBreeze.ts +142 -0
- package/src/index.tsx +99 -0
|
@@ -0,0 +1,632 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
3
|
+
*
|
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
5
|
+
* once the code is regenerated.
|
|
6
|
+
*
|
|
7
|
+
* @generated by codegen project: GenerateModuleH.js
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
#pragma once
|
|
11
|
+
|
|
12
|
+
#include <ReactCommon/TurboModule.h>
|
|
13
|
+
#include <react/bridging/Bridging.h>
|
|
14
|
+
|
|
15
|
+
namespace facebook::react {
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
#pragma mark - NativeBlueBreezeBBDeviceCharacteristicDataEvent
|
|
20
|
+
|
|
21
|
+
template <typename P0, typename P1, typename P2, typename P3>
|
|
22
|
+
struct NativeBlueBreezeBBDeviceCharacteristicDataEvent {
|
|
23
|
+
P0 id;
|
|
24
|
+
P1 serviceId;
|
|
25
|
+
P2 characteristicId;
|
|
26
|
+
P3 value;
|
|
27
|
+
bool operator==(const NativeBlueBreezeBBDeviceCharacteristicDataEvent &other) const {
|
|
28
|
+
return id == other.id && serviceId == other.serviceId && characteristicId == other.characteristicId && value == other.value;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
template <typename T>
|
|
33
|
+
struct NativeBlueBreezeBBDeviceCharacteristicDataEventBridging {
|
|
34
|
+
static T types;
|
|
35
|
+
|
|
36
|
+
static T fromJs(
|
|
37
|
+
jsi::Runtime &rt,
|
|
38
|
+
const jsi::Object &value,
|
|
39
|
+
const std::shared_ptr<CallInvoker> &jsInvoker) {
|
|
40
|
+
T result{
|
|
41
|
+
bridging::fromJs<decltype(types.id)>(rt, value.getProperty(rt, "id"), jsInvoker),
|
|
42
|
+
bridging::fromJs<decltype(types.serviceId)>(rt, value.getProperty(rt, "serviceId"), jsInvoker),
|
|
43
|
+
bridging::fromJs<decltype(types.characteristicId)>(rt, value.getProperty(rt, "characteristicId"), jsInvoker),
|
|
44
|
+
bridging::fromJs<decltype(types.value)>(rt, value.getProperty(rt, "value"), jsInvoker)};
|
|
45
|
+
return result;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
#ifdef DEBUG
|
|
49
|
+
static jsi::String idToJs(jsi::Runtime &rt, decltype(types.id) value) {
|
|
50
|
+
return bridging::toJs(rt, value);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
static jsi::String serviceIdToJs(jsi::Runtime &rt, decltype(types.serviceId) value) {
|
|
54
|
+
return bridging::toJs(rt, value);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
static jsi::String characteristicIdToJs(jsi::Runtime &rt, decltype(types.characteristicId) value) {
|
|
58
|
+
return bridging::toJs(rt, value);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
static jsi::Array valueToJs(jsi::Runtime &rt, decltype(types.value) value) {
|
|
62
|
+
return bridging::toJs(rt, value);
|
|
63
|
+
}
|
|
64
|
+
#endif
|
|
65
|
+
|
|
66
|
+
static jsi::Object toJs(
|
|
67
|
+
jsi::Runtime &rt,
|
|
68
|
+
const T &value,
|
|
69
|
+
const std::shared_ptr<CallInvoker> &jsInvoker) {
|
|
70
|
+
auto result = facebook::jsi::Object(rt);
|
|
71
|
+
result.setProperty(rt, "id", bridging::toJs(rt, value.id, jsInvoker));
|
|
72
|
+
result.setProperty(rt, "serviceId", bridging::toJs(rt, value.serviceId, jsInvoker));
|
|
73
|
+
result.setProperty(rt, "characteristicId", bridging::toJs(rt, value.characteristicId, jsInvoker));
|
|
74
|
+
result.setProperty(rt, "value", bridging::toJs(rt, value.value, jsInvoker));
|
|
75
|
+
return result;
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
#pragma mark - NativeBlueBreezeBBDeviceCharacteristicNotifyEnabledEvent
|
|
82
|
+
|
|
83
|
+
template <typename P0, typename P1, typename P2, typename P3>
|
|
84
|
+
struct NativeBlueBreezeBBDeviceCharacteristicNotifyEnabledEvent {
|
|
85
|
+
P0 id;
|
|
86
|
+
P1 serviceId;
|
|
87
|
+
P2 characteristicId;
|
|
88
|
+
P3 value;
|
|
89
|
+
bool operator==(const NativeBlueBreezeBBDeviceCharacteristicNotifyEnabledEvent &other) const {
|
|
90
|
+
return id == other.id && serviceId == other.serviceId && characteristicId == other.characteristicId && value == other.value;
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
template <typename T>
|
|
95
|
+
struct NativeBlueBreezeBBDeviceCharacteristicNotifyEnabledEventBridging {
|
|
96
|
+
static T types;
|
|
97
|
+
|
|
98
|
+
static T fromJs(
|
|
99
|
+
jsi::Runtime &rt,
|
|
100
|
+
const jsi::Object &value,
|
|
101
|
+
const std::shared_ptr<CallInvoker> &jsInvoker) {
|
|
102
|
+
T result{
|
|
103
|
+
bridging::fromJs<decltype(types.id)>(rt, value.getProperty(rt, "id"), jsInvoker),
|
|
104
|
+
bridging::fromJs<decltype(types.serviceId)>(rt, value.getProperty(rt, "serviceId"), jsInvoker),
|
|
105
|
+
bridging::fromJs<decltype(types.characteristicId)>(rt, value.getProperty(rt, "characteristicId"), jsInvoker),
|
|
106
|
+
bridging::fromJs<decltype(types.value)>(rt, value.getProperty(rt, "value"), jsInvoker)};
|
|
107
|
+
return result;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
#ifdef DEBUG
|
|
111
|
+
static jsi::String idToJs(jsi::Runtime &rt, decltype(types.id) value) {
|
|
112
|
+
return bridging::toJs(rt, value);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
static jsi::String serviceIdToJs(jsi::Runtime &rt, decltype(types.serviceId) value) {
|
|
116
|
+
return bridging::toJs(rt, value);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
static jsi::String characteristicIdToJs(jsi::Runtime &rt, decltype(types.characteristicId) value) {
|
|
120
|
+
return bridging::toJs(rt, value);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
static bool valueToJs(jsi::Runtime &rt, decltype(types.value) value) {
|
|
124
|
+
return bridging::toJs(rt, value);
|
|
125
|
+
}
|
|
126
|
+
#endif
|
|
127
|
+
|
|
128
|
+
static jsi::Object toJs(
|
|
129
|
+
jsi::Runtime &rt,
|
|
130
|
+
const T &value,
|
|
131
|
+
const std::shared_ptr<CallInvoker> &jsInvoker) {
|
|
132
|
+
auto result = facebook::jsi::Object(rt);
|
|
133
|
+
result.setProperty(rt, "id", bridging::toJs(rt, value.id, jsInvoker));
|
|
134
|
+
result.setProperty(rt, "serviceId", bridging::toJs(rt, value.serviceId, jsInvoker));
|
|
135
|
+
result.setProperty(rt, "characteristicId", bridging::toJs(rt, value.characteristicId, jsInvoker));
|
|
136
|
+
result.setProperty(rt, "value", bridging::toJs(rt, value.value, jsInvoker));
|
|
137
|
+
return result;
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
#pragma mark - NativeBlueBreezeBBDeviceConnectionStatusEvent
|
|
144
|
+
|
|
145
|
+
template <typename P0, typename P1>
|
|
146
|
+
struct NativeBlueBreezeBBDeviceConnectionStatusEvent {
|
|
147
|
+
P0 id;
|
|
148
|
+
P1 value;
|
|
149
|
+
bool operator==(const NativeBlueBreezeBBDeviceConnectionStatusEvent &other) const {
|
|
150
|
+
return id == other.id && value == other.value;
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
template <typename T>
|
|
155
|
+
struct NativeBlueBreezeBBDeviceConnectionStatusEventBridging {
|
|
156
|
+
static T types;
|
|
157
|
+
|
|
158
|
+
static T fromJs(
|
|
159
|
+
jsi::Runtime &rt,
|
|
160
|
+
const jsi::Object &value,
|
|
161
|
+
const std::shared_ptr<CallInvoker> &jsInvoker) {
|
|
162
|
+
T result{
|
|
163
|
+
bridging::fromJs<decltype(types.id)>(rt, value.getProperty(rt, "id"), jsInvoker),
|
|
164
|
+
bridging::fromJs<decltype(types.value)>(rt, value.getProperty(rt, "value"), jsInvoker)};
|
|
165
|
+
return result;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
#ifdef DEBUG
|
|
169
|
+
static jsi::String idToJs(jsi::Runtime &rt, decltype(types.id) value) {
|
|
170
|
+
return bridging::toJs(rt, value);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
static jsi::String valueToJs(jsi::Runtime &rt, decltype(types.value) value) {
|
|
174
|
+
return bridging::toJs(rt, value);
|
|
175
|
+
}
|
|
176
|
+
#endif
|
|
177
|
+
|
|
178
|
+
static jsi::Object toJs(
|
|
179
|
+
jsi::Runtime &rt,
|
|
180
|
+
const T &value,
|
|
181
|
+
const std::shared_ptr<CallInvoker> &jsInvoker) {
|
|
182
|
+
auto result = facebook::jsi::Object(rt);
|
|
183
|
+
result.setProperty(rt, "id", bridging::toJs(rt, value.id, jsInvoker));
|
|
184
|
+
result.setProperty(rt, "value", bridging::toJs(rt, value.value, jsInvoker));
|
|
185
|
+
return result;
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
#pragma mark - NativeBlueBreezeBBDeviceMTUEvent
|
|
192
|
+
|
|
193
|
+
template <typename P0, typename P1>
|
|
194
|
+
struct NativeBlueBreezeBBDeviceMTUEvent {
|
|
195
|
+
P0 id;
|
|
196
|
+
P1 value;
|
|
197
|
+
bool operator==(const NativeBlueBreezeBBDeviceMTUEvent &other) const {
|
|
198
|
+
return id == other.id && value == other.value;
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
template <typename T>
|
|
203
|
+
struct NativeBlueBreezeBBDeviceMTUEventBridging {
|
|
204
|
+
static T types;
|
|
205
|
+
|
|
206
|
+
static T fromJs(
|
|
207
|
+
jsi::Runtime &rt,
|
|
208
|
+
const jsi::Object &value,
|
|
209
|
+
const std::shared_ptr<CallInvoker> &jsInvoker) {
|
|
210
|
+
T result{
|
|
211
|
+
bridging::fromJs<decltype(types.id)>(rt, value.getProperty(rt, "id"), jsInvoker),
|
|
212
|
+
bridging::fromJs<decltype(types.value)>(rt, value.getProperty(rt, "value"), jsInvoker)};
|
|
213
|
+
return result;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
#ifdef DEBUG
|
|
217
|
+
static jsi::String idToJs(jsi::Runtime &rt, decltype(types.id) value) {
|
|
218
|
+
return bridging::toJs(rt, value);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
static double valueToJs(jsi::Runtime &rt, decltype(types.value) value) {
|
|
222
|
+
return bridging::toJs(rt, value);
|
|
223
|
+
}
|
|
224
|
+
#endif
|
|
225
|
+
|
|
226
|
+
static jsi::Object toJs(
|
|
227
|
+
jsi::Runtime &rt,
|
|
228
|
+
const T &value,
|
|
229
|
+
const std::shared_ptr<CallInvoker> &jsInvoker) {
|
|
230
|
+
auto result = facebook::jsi::Object(rt);
|
|
231
|
+
result.setProperty(rt, "id", bridging::toJs(rt, value.id, jsInvoker));
|
|
232
|
+
result.setProperty(rt, "value", bridging::toJs(rt, value.value, jsInvoker));
|
|
233
|
+
return result;
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
#pragma mark - NativeBlueBreezeBBDeviceServicesEvent
|
|
240
|
+
|
|
241
|
+
template <typename P0, typename P1>
|
|
242
|
+
struct NativeBlueBreezeBBDeviceServicesEvent {
|
|
243
|
+
P0 id;
|
|
244
|
+
P1 value;
|
|
245
|
+
bool operator==(const NativeBlueBreezeBBDeviceServicesEvent &other) const {
|
|
246
|
+
return id == other.id && value == other.value;
|
|
247
|
+
}
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
template <typename T>
|
|
251
|
+
struct NativeBlueBreezeBBDeviceServicesEventBridging {
|
|
252
|
+
static T types;
|
|
253
|
+
|
|
254
|
+
static T fromJs(
|
|
255
|
+
jsi::Runtime &rt,
|
|
256
|
+
const jsi::Object &value,
|
|
257
|
+
const std::shared_ptr<CallInvoker> &jsInvoker) {
|
|
258
|
+
T result{
|
|
259
|
+
bridging::fromJs<decltype(types.id)>(rt, value.getProperty(rt, "id"), jsInvoker),
|
|
260
|
+
bridging::fromJs<decltype(types.value)>(rt, value.getProperty(rt, "value"), jsInvoker)};
|
|
261
|
+
return result;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
#ifdef DEBUG
|
|
265
|
+
static jsi::String idToJs(jsi::Runtime &rt, decltype(types.id) value) {
|
|
266
|
+
return bridging::toJs(rt, value);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
static jsi::Array valueToJs(jsi::Runtime &rt, decltype(types.value) value) {
|
|
270
|
+
return bridging::toJs(rt, value);
|
|
271
|
+
}
|
|
272
|
+
#endif
|
|
273
|
+
|
|
274
|
+
static jsi::Object toJs(
|
|
275
|
+
jsi::Runtime &rt,
|
|
276
|
+
const T &value,
|
|
277
|
+
const std::shared_ptr<CallInvoker> &jsInvoker) {
|
|
278
|
+
auto result = facebook::jsi::Object(rt);
|
|
279
|
+
result.setProperty(rt, "id", bridging::toJs(rt, value.id, jsInvoker));
|
|
280
|
+
result.setProperty(rt, "value", bridging::toJs(rt, value.value, jsInvoker));
|
|
281
|
+
return result;
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
#pragma mark - NativeBlueBreezeBBService
|
|
288
|
+
|
|
289
|
+
template <typename P0, typename P1, typename P2>
|
|
290
|
+
struct NativeBlueBreezeBBService {
|
|
291
|
+
P0 id;
|
|
292
|
+
P1 name;
|
|
293
|
+
P2 characteristics;
|
|
294
|
+
bool operator==(const NativeBlueBreezeBBService &other) const {
|
|
295
|
+
return id == other.id && name == other.name && characteristics == other.characteristics;
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
template <typename T>
|
|
300
|
+
struct NativeBlueBreezeBBServiceBridging {
|
|
301
|
+
static T types;
|
|
302
|
+
|
|
303
|
+
static T fromJs(
|
|
304
|
+
jsi::Runtime &rt,
|
|
305
|
+
const jsi::Object &value,
|
|
306
|
+
const std::shared_ptr<CallInvoker> &jsInvoker) {
|
|
307
|
+
T result{
|
|
308
|
+
bridging::fromJs<decltype(types.id)>(rt, value.getProperty(rt, "id"), jsInvoker),
|
|
309
|
+
bridging::fromJs<decltype(types.name)>(rt, value.getProperty(rt, "name"), jsInvoker),
|
|
310
|
+
bridging::fromJs<decltype(types.characteristics)>(rt, value.getProperty(rt, "characteristics"), jsInvoker)};
|
|
311
|
+
return result;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
#ifdef DEBUG
|
|
315
|
+
static jsi::String idToJs(jsi::Runtime &rt, decltype(types.id) value) {
|
|
316
|
+
return bridging::toJs(rt, value);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
static jsi::String nameToJs(jsi::Runtime &rt, decltype(types.name) value) {
|
|
320
|
+
return bridging::toJs(rt, value);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
static jsi::Array characteristicsToJs(jsi::Runtime &rt, decltype(types.characteristics) value) {
|
|
324
|
+
return bridging::toJs(rt, value);
|
|
325
|
+
}
|
|
326
|
+
#endif
|
|
327
|
+
|
|
328
|
+
static jsi::Object toJs(
|
|
329
|
+
jsi::Runtime &rt,
|
|
330
|
+
const T &value,
|
|
331
|
+
const std::shared_ptr<CallInvoker> &jsInvoker) {
|
|
332
|
+
auto result = facebook::jsi::Object(rt);
|
|
333
|
+
result.setProperty(rt, "id", bridging::toJs(rt, value.id, jsInvoker));
|
|
334
|
+
if (value.name) {
|
|
335
|
+
result.setProperty(rt, "name", bridging::toJs(rt, value.name.value(), jsInvoker));
|
|
336
|
+
}
|
|
337
|
+
result.setProperty(rt, "characteristics", bridging::toJs(rt, value.characteristics, jsInvoker));
|
|
338
|
+
return result;
|
|
339
|
+
}
|
|
340
|
+
};
|
|
341
|
+
|
|
342
|
+
class JSI_EXPORT NativeBlueBreezeCxxSpecJSI : public TurboModule {
|
|
343
|
+
protected:
|
|
344
|
+
NativeBlueBreezeCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker);
|
|
345
|
+
|
|
346
|
+
public:
|
|
347
|
+
virtual jsi::String authorizationStatus(jsi::Runtime &rt) = 0;
|
|
348
|
+
virtual void authorizationRequest(jsi::Runtime &rt) = 0;
|
|
349
|
+
virtual jsi::String state(jsi::Runtime &rt) = 0;
|
|
350
|
+
virtual bool scanningEnabled(jsi::Runtime &rt) = 0;
|
|
351
|
+
virtual void scanningStart(jsi::Runtime &rt) = 0;
|
|
352
|
+
virtual void scanningStop(jsi::Runtime &rt) = 0;
|
|
353
|
+
virtual jsi::Array devices(jsi::Runtime &rt) = 0;
|
|
354
|
+
virtual jsi::Array deviceServices(jsi::Runtime &rt, jsi::String id) = 0;
|
|
355
|
+
virtual jsi::String deviceConnectionStatus(jsi::Runtime &rt, jsi::String id) = 0;
|
|
356
|
+
virtual double deviceMTU(jsi::Runtime &rt, jsi::String id) = 0;
|
|
357
|
+
virtual jsi::Value deviceConnect(jsi::Runtime &rt, jsi::String id) = 0;
|
|
358
|
+
virtual jsi::Value deviceDisconnect(jsi::Runtime &rt, jsi::String id) = 0;
|
|
359
|
+
virtual jsi::Value deviceDiscoverServices(jsi::Runtime &rt, jsi::String id) = 0;
|
|
360
|
+
virtual jsi::Value deviceRequestMTU(jsi::Runtime &rt, jsi::String id, double mtu) = 0;
|
|
361
|
+
virtual jsi::Array deviceCharacteristicData(jsi::Runtime &rt, jsi::String id, jsi::String serviceId, jsi::String characteristicId) = 0;
|
|
362
|
+
virtual bool deviceCharacteristicNotifyEnabled(jsi::Runtime &rt, jsi::String id, jsi::String serviceId, jsi::String characteristicId) = 0;
|
|
363
|
+
virtual jsi::Value deviceCharacteristicRead(jsi::Runtime &rt, jsi::String id, jsi::String serviceId, jsi::String characteristicId) = 0;
|
|
364
|
+
virtual jsi::Value deviceCharacteristicWrite(jsi::Runtime &rt, jsi::String id, jsi::String serviceId, jsi::String characteristicId, jsi::Array data, bool withResponse) = 0;
|
|
365
|
+
virtual jsi::Value deviceCharacteristicSubscribe(jsi::Runtime &rt, jsi::String id, jsi::String serviceId, jsi::String characteristicId) = 0;
|
|
366
|
+
virtual jsi::Value deviceCharacteristicUnsubscribe(jsi::Runtime &rt, jsi::String id, jsi::String serviceId, jsi::String characteristicId) = 0;
|
|
367
|
+
|
|
368
|
+
};
|
|
369
|
+
|
|
370
|
+
template <typename T>
|
|
371
|
+
class JSI_EXPORT NativeBlueBreezeCxxSpec : public TurboModule {
|
|
372
|
+
public:
|
|
373
|
+
jsi::Value get(jsi::Runtime &rt, const jsi::PropNameID &propName) override {
|
|
374
|
+
return delegate_.get(rt, propName);
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
static constexpr std::string_view kModuleName = "BlueBreeze";
|
|
378
|
+
|
|
379
|
+
protected:
|
|
380
|
+
NativeBlueBreezeCxxSpec(std::shared_ptr<CallInvoker> jsInvoker)
|
|
381
|
+
: TurboModule(std::string{NativeBlueBreezeCxxSpec::kModuleName}, jsInvoker),
|
|
382
|
+
delegate_(reinterpret_cast<T*>(this), jsInvoker) {}
|
|
383
|
+
|
|
384
|
+
template <typename AuthorizationStatusEmitterType> void emitAuthorizationStatusEmitter(AuthorizationStatusEmitterType value) {
|
|
385
|
+
static_assert(bridging::supportsFromJs<AuthorizationStatusEmitterType, jsi::String>, "value cannnot be converted to jsi::String");
|
|
386
|
+
static_cast<AsyncEventEmitter<jsi::Value>&>(*delegate_.eventEmitterMap_["authorizationStatusEmitter"]).emit([jsInvoker = jsInvoker_, eventValue = value](jsi::Runtime& rt) -> jsi::Value {
|
|
387
|
+
return bridging::toJs(rt, eventValue, jsInvoker);
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
template <typename StateEmitterType> void emitStateEmitter(StateEmitterType value) {
|
|
392
|
+
static_assert(bridging::supportsFromJs<StateEmitterType, jsi::String>, "value cannnot be converted to jsi::String");
|
|
393
|
+
static_cast<AsyncEventEmitter<jsi::Value>&>(*delegate_.eventEmitterMap_["stateEmitter"]).emit([jsInvoker = jsInvoker_, eventValue = value](jsi::Runtime& rt) -> jsi::Value {
|
|
394
|
+
return bridging::toJs(rt, eventValue, jsInvoker);
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
template <typename ScanningEnabledEmitterType> void emitScanningEnabledEmitter(ScanningEnabledEmitterType value) {
|
|
399
|
+
static_assert(bridging::supportsFromJs<ScanningEnabledEmitterType, bool>, "value cannnot be converted to bool");
|
|
400
|
+
static_cast<AsyncEventEmitter<jsi::Value>&>(*delegate_.eventEmitterMap_["scanningEnabledEmitter"]).emit([jsInvoker = jsInvoker_, eventValue = value](jsi::Runtime& rt) -> jsi::Value {
|
|
401
|
+
return bridging::toJs(rt, eventValue, jsInvoker);
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
template <typename DevicesEmitterType> void emitDevicesEmitter(std::vector<DevicesEmitterType> value) {
|
|
406
|
+
static_assert(bridging::supportsFromJs<std::vector<DevicesEmitterType>, jsi::Array>, "value cannnot be converted to jsi::Array");
|
|
407
|
+
static_cast<AsyncEventEmitter<jsi::Value>&>(*delegate_.eventEmitterMap_["devicesEmitter"]).emit([jsInvoker = jsInvoker_, eventValue = value](jsi::Runtime& rt) -> jsi::Value {
|
|
408
|
+
return bridging::toJs(rt, eventValue, jsInvoker);
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
template <typename DeviceServicesEmitterType> void emitDeviceServicesEmitter(DeviceServicesEmitterType value) {
|
|
413
|
+
static_assert(bridging::supportsFromJs<DeviceServicesEmitterType, jsi::Object>, "value cannnot be converted to jsi::Object");
|
|
414
|
+
static_cast<AsyncEventEmitter<jsi::Value>&>(*delegate_.eventEmitterMap_["deviceServicesEmitter"]).emit([jsInvoker = jsInvoker_, eventValue = value](jsi::Runtime& rt) -> jsi::Value {
|
|
415
|
+
return bridging::toJs(rt, eventValue, jsInvoker);
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
template <typename DeviceConnectionStatusEmitterType> void emitDeviceConnectionStatusEmitter(DeviceConnectionStatusEmitterType value) {
|
|
420
|
+
static_assert(bridging::supportsFromJs<DeviceConnectionStatusEmitterType, jsi::Object>, "value cannnot be converted to jsi::Object");
|
|
421
|
+
static_cast<AsyncEventEmitter<jsi::Value>&>(*delegate_.eventEmitterMap_["deviceConnectionStatusEmitter"]).emit([jsInvoker = jsInvoker_, eventValue = value](jsi::Runtime& rt) -> jsi::Value {
|
|
422
|
+
return bridging::toJs(rt, eventValue, jsInvoker);
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
template <typename DeviceMTUEmitterType> void emitDeviceMTUEmitter(DeviceMTUEmitterType value) {
|
|
427
|
+
static_assert(bridging::supportsFromJs<DeviceMTUEmitterType, jsi::Object>, "value cannnot be converted to jsi::Object");
|
|
428
|
+
static_cast<AsyncEventEmitter<jsi::Value>&>(*delegate_.eventEmitterMap_["deviceMTUEmitter"]).emit([jsInvoker = jsInvoker_, eventValue = value](jsi::Runtime& rt) -> jsi::Value {
|
|
429
|
+
return bridging::toJs(rt, eventValue, jsInvoker);
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
template <typename DeviceCharacteristicDataEmitterType> void emitDeviceCharacteristicDataEmitter(DeviceCharacteristicDataEmitterType value) {
|
|
434
|
+
static_assert(bridging::supportsFromJs<DeviceCharacteristicDataEmitterType, jsi::Object>, "value cannnot be converted to jsi::Object");
|
|
435
|
+
static_cast<AsyncEventEmitter<jsi::Value>&>(*delegate_.eventEmitterMap_["deviceCharacteristicDataEmitter"]).emit([jsInvoker = jsInvoker_, eventValue = value](jsi::Runtime& rt) -> jsi::Value {
|
|
436
|
+
return bridging::toJs(rt, eventValue, jsInvoker);
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
template <typename DeviceCharacteristicNotifyEnabledEmitterType> void emitDeviceCharacteristicNotifyEnabledEmitter(DeviceCharacteristicNotifyEnabledEmitterType value) {
|
|
441
|
+
static_assert(bridging::supportsFromJs<DeviceCharacteristicNotifyEnabledEmitterType, jsi::Object>, "value cannnot be converted to jsi::Object");
|
|
442
|
+
static_cast<AsyncEventEmitter<jsi::Value>&>(*delegate_.eventEmitterMap_["deviceCharacteristicNotifyEnabledEmitter"]).emit([jsInvoker = jsInvoker_, eventValue = value](jsi::Runtime& rt) -> jsi::Value {
|
|
443
|
+
return bridging::toJs(rt, eventValue, jsInvoker);
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
private:
|
|
448
|
+
class Delegate : public NativeBlueBreezeCxxSpecJSI {
|
|
449
|
+
public:
|
|
450
|
+
Delegate(T *instance, std::shared_ptr<CallInvoker> jsInvoker) :
|
|
451
|
+
NativeBlueBreezeCxxSpecJSI(std::move(jsInvoker)), instance_(instance) {
|
|
452
|
+
eventEmitterMap_["authorizationStatusEmitter"] = std::make_shared<AsyncEventEmitter<jsi::Value>>();
|
|
453
|
+
eventEmitterMap_["stateEmitter"] = std::make_shared<AsyncEventEmitter<jsi::Value>>();
|
|
454
|
+
eventEmitterMap_["scanningEnabledEmitter"] = std::make_shared<AsyncEventEmitter<jsi::Value>>();
|
|
455
|
+
eventEmitterMap_["devicesEmitter"] = std::make_shared<AsyncEventEmitter<jsi::Value>>();
|
|
456
|
+
eventEmitterMap_["deviceServicesEmitter"] = std::make_shared<AsyncEventEmitter<jsi::Value>>();
|
|
457
|
+
eventEmitterMap_["deviceConnectionStatusEmitter"] = std::make_shared<AsyncEventEmitter<jsi::Value>>();
|
|
458
|
+
eventEmitterMap_["deviceMTUEmitter"] = std::make_shared<AsyncEventEmitter<jsi::Value>>();
|
|
459
|
+
eventEmitterMap_["deviceCharacteristicDataEmitter"] = std::make_shared<AsyncEventEmitter<jsi::Value>>();
|
|
460
|
+
eventEmitterMap_["deviceCharacteristicNotifyEnabledEmitter"] = std::make_shared<AsyncEventEmitter<jsi::Value>>();
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
jsi::String authorizationStatus(jsi::Runtime &rt) override {
|
|
464
|
+
static_assert(
|
|
465
|
+
bridging::getParameterCount(&T::authorizationStatus) == 1,
|
|
466
|
+
"Expected authorizationStatus(...) to have 1 parameters");
|
|
467
|
+
|
|
468
|
+
return bridging::callFromJs<jsi::String>(
|
|
469
|
+
rt, &T::authorizationStatus, jsInvoker_, instance_);
|
|
470
|
+
}
|
|
471
|
+
void authorizationRequest(jsi::Runtime &rt) override {
|
|
472
|
+
static_assert(
|
|
473
|
+
bridging::getParameterCount(&T::authorizationRequest) == 1,
|
|
474
|
+
"Expected authorizationRequest(...) to have 1 parameters");
|
|
475
|
+
|
|
476
|
+
return bridging::callFromJs<void>(
|
|
477
|
+
rt, &T::authorizationRequest, jsInvoker_, instance_);
|
|
478
|
+
}
|
|
479
|
+
jsi::String state(jsi::Runtime &rt) override {
|
|
480
|
+
static_assert(
|
|
481
|
+
bridging::getParameterCount(&T::state) == 1,
|
|
482
|
+
"Expected state(...) to have 1 parameters");
|
|
483
|
+
|
|
484
|
+
return bridging::callFromJs<jsi::String>(
|
|
485
|
+
rt, &T::state, jsInvoker_, instance_);
|
|
486
|
+
}
|
|
487
|
+
bool scanningEnabled(jsi::Runtime &rt) override {
|
|
488
|
+
static_assert(
|
|
489
|
+
bridging::getParameterCount(&T::scanningEnabled) == 1,
|
|
490
|
+
"Expected scanningEnabled(...) to have 1 parameters");
|
|
491
|
+
|
|
492
|
+
return bridging::callFromJs<bool>(
|
|
493
|
+
rt, &T::scanningEnabled, jsInvoker_, instance_);
|
|
494
|
+
}
|
|
495
|
+
void scanningStart(jsi::Runtime &rt) override {
|
|
496
|
+
static_assert(
|
|
497
|
+
bridging::getParameterCount(&T::scanningStart) == 1,
|
|
498
|
+
"Expected scanningStart(...) to have 1 parameters");
|
|
499
|
+
|
|
500
|
+
return bridging::callFromJs<void>(
|
|
501
|
+
rt, &T::scanningStart, jsInvoker_, instance_);
|
|
502
|
+
}
|
|
503
|
+
void scanningStop(jsi::Runtime &rt) override {
|
|
504
|
+
static_assert(
|
|
505
|
+
bridging::getParameterCount(&T::scanningStop) == 1,
|
|
506
|
+
"Expected scanningStop(...) to have 1 parameters");
|
|
507
|
+
|
|
508
|
+
return bridging::callFromJs<void>(
|
|
509
|
+
rt, &T::scanningStop, jsInvoker_, instance_);
|
|
510
|
+
}
|
|
511
|
+
jsi::Array devices(jsi::Runtime &rt) override {
|
|
512
|
+
static_assert(
|
|
513
|
+
bridging::getParameterCount(&T::devices) == 1,
|
|
514
|
+
"Expected devices(...) to have 1 parameters");
|
|
515
|
+
|
|
516
|
+
return bridging::callFromJs<jsi::Array>(
|
|
517
|
+
rt, &T::devices, jsInvoker_, instance_);
|
|
518
|
+
}
|
|
519
|
+
jsi::Array deviceServices(jsi::Runtime &rt, jsi::String id) override {
|
|
520
|
+
static_assert(
|
|
521
|
+
bridging::getParameterCount(&T::deviceServices) == 2,
|
|
522
|
+
"Expected deviceServices(...) to have 2 parameters");
|
|
523
|
+
|
|
524
|
+
return bridging::callFromJs<jsi::Array>(
|
|
525
|
+
rt, &T::deviceServices, jsInvoker_, instance_, std::move(id));
|
|
526
|
+
}
|
|
527
|
+
jsi::String deviceConnectionStatus(jsi::Runtime &rt, jsi::String id) override {
|
|
528
|
+
static_assert(
|
|
529
|
+
bridging::getParameterCount(&T::deviceConnectionStatus) == 2,
|
|
530
|
+
"Expected deviceConnectionStatus(...) to have 2 parameters");
|
|
531
|
+
|
|
532
|
+
return bridging::callFromJs<jsi::String>(
|
|
533
|
+
rt, &T::deviceConnectionStatus, jsInvoker_, instance_, std::move(id));
|
|
534
|
+
}
|
|
535
|
+
double deviceMTU(jsi::Runtime &rt, jsi::String id) override {
|
|
536
|
+
static_assert(
|
|
537
|
+
bridging::getParameterCount(&T::deviceMTU) == 2,
|
|
538
|
+
"Expected deviceMTU(...) to have 2 parameters");
|
|
539
|
+
|
|
540
|
+
return bridging::callFromJs<double>(
|
|
541
|
+
rt, &T::deviceMTU, jsInvoker_, instance_, std::move(id));
|
|
542
|
+
}
|
|
543
|
+
jsi::Value deviceConnect(jsi::Runtime &rt, jsi::String id) override {
|
|
544
|
+
static_assert(
|
|
545
|
+
bridging::getParameterCount(&T::deviceConnect) == 2,
|
|
546
|
+
"Expected deviceConnect(...) to have 2 parameters");
|
|
547
|
+
|
|
548
|
+
return bridging::callFromJs<jsi::Value>(
|
|
549
|
+
rt, &T::deviceConnect, jsInvoker_, instance_, std::move(id));
|
|
550
|
+
}
|
|
551
|
+
jsi::Value deviceDisconnect(jsi::Runtime &rt, jsi::String id) override {
|
|
552
|
+
static_assert(
|
|
553
|
+
bridging::getParameterCount(&T::deviceDisconnect) == 2,
|
|
554
|
+
"Expected deviceDisconnect(...) to have 2 parameters");
|
|
555
|
+
|
|
556
|
+
return bridging::callFromJs<jsi::Value>(
|
|
557
|
+
rt, &T::deviceDisconnect, jsInvoker_, instance_, std::move(id));
|
|
558
|
+
}
|
|
559
|
+
jsi::Value deviceDiscoverServices(jsi::Runtime &rt, jsi::String id) override {
|
|
560
|
+
static_assert(
|
|
561
|
+
bridging::getParameterCount(&T::deviceDiscoverServices) == 2,
|
|
562
|
+
"Expected deviceDiscoverServices(...) to have 2 parameters");
|
|
563
|
+
|
|
564
|
+
return bridging::callFromJs<jsi::Value>(
|
|
565
|
+
rt, &T::deviceDiscoverServices, jsInvoker_, instance_, std::move(id));
|
|
566
|
+
}
|
|
567
|
+
jsi::Value deviceRequestMTU(jsi::Runtime &rt, jsi::String id, double mtu) override {
|
|
568
|
+
static_assert(
|
|
569
|
+
bridging::getParameterCount(&T::deviceRequestMTU) == 3,
|
|
570
|
+
"Expected deviceRequestMTU(...) to have 3 parameters");
|
|
571
|
+
|
|
572
|
+
return bridging::callFromJs<jsi::Value>(
|
|
573
|
+
rt, &T::deviceRequestMTU, jsInvoker_, instance_, std::move(id), std::move(mtu));
|
|
574
|
+
}
|
|
575
|
+
jsi::Array deviceCharacteristicData(jsi::Runtime &rt, jsi::String id, jsi::String serviceId, jsi::String characteristicId) override {
|
|
576
|
+
static_assert(
|
|
577
|
+
bridging::getParameterCount(&T::deviceCharacteristicData) == 4,
|
|
578
|
+
"Expected deviceCharacteristicData(...) to have 4 parameters");
|
|
579
|
+
|
|
580
|
+
return bridging::callFromJs<jsi::Array>(
|
|
581
|
+
rt, &T::deviceCharacteristicData, jsInvoker_, instance_, std::move(id), std::move(serviceId), std::move(characteristicId));
|
|
582
|
+
}
|
|
583
|
+
bool deviceCharacteristicNotifyEnabled(jsi::Runtime &rt, jsi::String id, jsi::String serviceId, jsi::String characteristicId) override {
|
|
584
|
+
static_assert(
|
|
585
|
+
bridging::getParameterCount(&T::deviceCharacteristicNotifyEnabled) == 4,
|
|
586
|
+
"Expected deviceCharacteristicNotifyEnabled(...) to have 4 parameters");
|
|
587
|
+
|
|
588
|
+
return bridging::callFromJs<bool>(
|
|
589
|
+
rt, &T::deviceCharacteristicNotifyEnabled, jsInvoker_, instance_, std::move(id), std::move(serviceId), std::move(characteristicId));
|
|
590
|
+
}
|
|
591
|
+
jsi::Value deviceCharacteristicRead(jsi::Runtime &rt, jsi::String id, jsi::String serviceId, jsi::String characteristicId) override {
|
|
592
|
+
static_assert(
|
|
593
|
+
bridging::getParameterCount(&T::deviceCharacteristicRead) == 4,
|
|
594
|
+
"Expected deviceCharacteristicRead(...) to have 4 parameters");
|
|
595
|
+
|
|
596
|
+
return bridging::callFromJs<jsi::Value>(
|
|
597
|
+
rt, &T::deviceCharacteristicRead, jsInvoker_, instance_, std::move(id), std::move(serviceId), std::move(characteristicId));
|
|
598
|
+
}
|
|
599
|
+
jsi::Value deviceCharacteristicWrite(jsi::Runtime &rt, jsi::String id, jsi::String serviceId, jsi::String characteristicId, jsi::Array data, bool withResponse) override {
|
|
600
|
+
static_assert(
|
|
601
|
+
bridging::getParameterCount(&T::deviceCharacteristicWrite) == 6,
|
|
602
|
+
"Expected deviceCharacteristicWrite(...) to have 6 parameters");
|
|
603
|
+
|
|
604
|
+
return bridging::callFromJs<jsi::Value>(
|
|
605
|
+
rt, &T::deviceCharacteristicWrite, jsInvoker_, instance_, std::move(id), std::move(serviceId), std::move(characteristicId), std::move(data), std::move(withResponse));
|
|
606
|
+
}
|
|
607
|
+
jsi::Value deviceCharacteristicSubscribe(jsi::Runtime &rt, jsi::String id, jsi::String serviceId, jsi::String characteristicId) override {
|
|
608
|
+
static_assert(
|
|
609
|
+
bridging::getParameterCount(&T::deviceCharacteristicSubscribe) == 4,
|
|
610
|
+
"Expected deviceCharacteristicSubscribe(...) to have 4 parameters");
|
|
611
|
+
|
|
612
|
+
return bridging::callFromJs<jsi::Value>(
|
|
613
|
+
rt, &T::deviceCharacteristicSubscribe, jsInvoker_, instance_, std::move(id), std::move(serviceId), std::move(characteristicId));
|
|
614
|
+
}
|
|
615
|
+
jsi::Value deviceCharacteristicUnsubscribe(jsi::Runtime &rt, jsi::String id, jsi::String serviceId, jsi::String characteristicId) override {
|
|
616
|
+
static_assert(
|
|
617
|
+
bridging::getParameterCount(&T::deviceCharacteristicUnsubscribe) == 4,
|
|
618
|
+
"Expected deviceCharacteristicUnsubscribe(...) to have 4 parameters");
|
|
619
|
+
|
|
620
|
+
return bridging::callFromJs<jsi::Value>(
|
|
621
|
+
rt, &T::deviceCharacteristicUnsubscribe, jsInvoker_, instance_, std::move(id), std::move(serviceId), std::move(characteristicId));
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
private:
|
|
625
|
+
friend class NativeBlueBreezeCxxSpec;
|
|
626
|
+
T *instance_;
|
|
627
|
+
};
|
|
628
|
+
|
|
629
|
+
Delegate delegate_;
|
|
630
|
+
};
|
|
631
|
+
|
|
632
|
+
} // namespace facebook::react
|