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,280 @@
|
|
|
1
|
+
#import "BlueBreeze.h"
|
|
2
|
+
#import "react_native_bluebreeze-Swift.h"
|
|
3
|
+
|
|
4
|
+
@implementation BlueBreeze {
|
|
5
|
+
BlueBreezeImpl* impl;
|
|
6
|
+
NSMutableArray<NSString*>* trackedDeviceServices;
|
|
7
|
+
NSMutableArray<NSString*>* trackedDeviceConnectionStatus;
|
|
8
|
+
NSMutableArray<NSString*>* trackedDeviceMTU;
|
|
9
|
+
NSMutableArray<NSString*>* trackedDeviceCharacteristicData;
|
|
10
|
+
NSMutableArray<NSString*>* trackedDeviceCharacteristicNotifyEnabled;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
- (instancetype) init {
|
|
14
|
+
self = [super init];
|
|
15
|
+
if (self) {
|
|
16
|
+
impl = [BlueBreezeImpl new];
|
|
17
|
+
|
|
18
|
+
trackedDeviceConnectionStatus = [NSMutableArray new];
|
|
19
|
+
trackedDeviceServices = [NSMutableArray new];
|
|
20
|
+
trackedDeviceMTU = [NSMutableArray new];
|
|
21
|
+
|
|
22
|
+
trackedDeviceCharacteristicData = [NSMutableArray new];
|
|
23
|
+
trackedDeviceCharacteristicNotifyEnabled = [NSMutableArray new];
|
|
24
|
+
|
|
25
|
+
[impl authorizationStatusObserveOnChanged:^(NSString * _Nonnull status) {
|
|
26
|
+
if (self->_eventEmitterCallback != nil) {
|
|
27
|
+
[self emitAuthorizationStatusEmitter:status];
|
|
28
|
+
}
|
|
29
|
+
}];
|
|
30
|
+
[impl stateObserveOnChanged:^(NSString * _Nonnull status) {
|
|
31
|
+
if (self->_eventEmitterCallback != nil) {
|
|
32
|
+
[self emitStateEmitter:status];
|
|
33
|
+
}
|
|
34
|
+
}];
|
|
35
|
+
[impl scanningEnabledObserveOnChanged:^(BOOL status) {
|
|
36
|
+
if (self->_eventEmitterCallback != nil) {
|
|
37
|
+
[self emitScanningEnabledEmitter:status];
|
|
38
|
+
}
|
|
39
|
+
}];
|
|
40
|
+
[impl devicesObserveOnChanged:^(NSArray<id<NSObject>> *devices) {
|
|
41
|
+
for (id device in devices) {
|
|
42
|
+
NSString* deviceId = device[@"id"];
|
|
43
|
+
|
|
44
|
+
if ([self->trackedDeviceServices indexOfObject:deviceId] == NSNotFound) {
|
|
45
|
+
[self->trackedDeviceServices addObject:deviceId];
|
|
46
|
+
[self->impl deviceServicesObserveWithId:deviceId onChanged:^(NSArray<id<NSObject>> * _Nonnull value) {
|
|
47
|
+
[self emitDeviceServicesEmitter:@{
|
|
48
|
+
@"id": deviceId,
|
|
49
|
+
@"value": value
|
|
50
|
+
}];
|
|
51
|
+
|
|
52
|
+
for (id service in value) {
|
|
53
|
+
NSString* serviceId = service[@"id"];
|
|
54
|
+
for (id characteristic in service[@"characteristics"]) {
|
|
55
|
+
NSString* characteristicId = characteristic[@"id"];
|
|
56
|
+
NSString* trackingKey = [NSString stringWithFormat:@"%@:%@:%@", deviceId, serviceId, characteristicId];
|
|
57
|
+
|
|
58
|
+
if ([self->trackedDeviceCharacteristicData indexOfObject:trackingKey] == NSNotFound) {
|
|
59
|
+
[self->trackedDeviceConnectionStatus addObject:trackingKey];
|
|
60
|
+
[self->impl deviceCharacteristicDataObserveWithId:deviceId serviceId:serviceId characteristicId:characteristicId onChanged:^(NSArray<NSNumber *> * _Nonnull value) {
|
|
61
|
+
[self emitDeviceCharacteristicDataEmitter:@{
|
|
62
|
+
@"id": deviceId,
|
|
63
|
+
@"serviceId": serviceId,
|
|
64
|
+
@"characteristicId": characteristicId,
|
|
65
|
+
@"value": value
|
|
66
|
+
}];
|
|
67
|
+
}];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if ([self->trackedDeviceCharacteristicNotifyEnabled indexOfObject:trackingKey] == NSNotFound) {
|
|
71
|
+
[self->trackedDeviceCharacteristicNotifyEnabled addObject:trackingKey];
|
|
72
|
+
[self->impl deviceCharacteristicNotifyEnabledObserveWithId:deviceId serviceId:serviceId characteristicId:characteristicId onChanged:^(BOOL value) {
|
|
73
|
+
[self emitDeviceCharacteristicNotifyEnabledEmitter:@{
|
|
74
|
+
@"id": deviceId,
|
|
75
|
+
@"serviceId": serviceId,
|
|
76
|
+
@"characteristicId": characteristicId,
|
|
77
|
+
@"value": [NSNumber numberWithBool:value]
|
|
78
|
+
}];
|
|
79
|
+
}];
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}];
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if ([self->trackedDeviceConnectionStatus indexOfObject:deviceId] == NSNotFound) {
|
|
87
|
+
[self->trackedDeviceConnectionStatus addObject:deviceId];
|
|
88
|
+
[self->impl deviceConnectionStatusObserveWithId:deviceId onChanged:^(NSString * _Nonnull value) {
|
|
89
|
+
[self emitDeviceConnectionStatusEmitter:@{
|
|
90
|
+
@"id": deviceId,
|
|
91
|
+
@"value": value
|
|
92
|
+
}];
|
|
93
|
+
}];
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if ([self->trackedDeviceMTU indexOfObject:deviceId] == NSNotFound) {
|
|
97
|
+
[self->trackedDeviceMTU addObject:deviceId];
|
|
98
|
+
[self->impl deviceMTUObserveWithId:deviceId onChanged:^(NSInteger value) {
|
|
99
|
+
[self emitDeviceMTUEmitter:@{
|
|
100
|
+
@"id": deviceId,
|
|
101
|
+
@"value": [NSNumber numberWithInt:value]
|
|
102
|
+
}];
|
|
103
|
+
}];
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (self->_eventEmitterCallback != nil) {
|
|
108
|
+
[self emitDevicesEmitter:devices];
|
|
109
|
+
}
|
|
110
|
+
}];
|
|
111
|
+
}
|
|
112
|
+
return self;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
RCT_EXPORT_MODULE()
|
|
116
|
+
|
|
117
|
+
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
|
|
118
|
+
(const facebook::react::ObjCTurboModule::InitParams &)params
|
|
119
|
+
{
|
|
120
|
+
return std::make_shared<facebook::react::NativeBlueBreezeSpecJSI>(params);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
- (NSString *)authorizationStatus {
|
|
124
|
+
return [impl authorizationStatus];
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
- (void)authorizationRequest {
|
|
128
|
+
[impl authorizationRequest];
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
- (NSString *)state {
|
|
132
|
+
return [impl state];
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
- (NSNumber *)scanningEnabled {
|
|
136
|
+
return [NSNumber numberWithBool:[impl scanningEnabled]];
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
- (void)scanningStart {
|
|
140
|
+
[impl scanningStart];
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
- (void)scanningStop {
|
|
144
|
+
[impl scanningStop];
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
- (NSArray<id<NSObject>> *)devices {
|
|
148
|
+
return [impl devices];
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
- (NSArray<id<NSObject>> *)deviceServices:(NSString *)id {
|
|
152
|
+
return [impl deviceServicesWithId:id];
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
- (NSString*)deviceConnectionStatus:(NSString *)id {
|
|
156
|
+
return [impl deviceConnectionStatusWithId:id];
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
- (NSNumber *)deviceMTU:(NSString *)id {
|
|
160
|
+
return [NSNumber numberWithInt:[impl deviceMTUWithId:id]];
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
- (void)deviceConnect:(NSString *)id resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
|
|
164
|
+
[impl deviceConnectWithId:id completionHandler:^(NSError * _Nullable error) {
|
|
165
|
+
if (error != nil) {
|
|
166
|
+
reject([@([error code]) stringValue], [error description], error);
|
|
167
|
+
} else {
|
|
168
|
+
resolve(nil);
|
|
169
|
+
}
|
|
170
|
+
}];
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
- (void)deviceDisconnect:(NSString *)id resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
|
|
175
|
+
[impl deviceDisconnectWithId:id completionHandler:^(NSError * _Nullable error) {
|
|
176
|
+
if (error != nil) {
|
|
177
|
+
reject([@([error code]) stringValue], [error description], error);
|
|
178
|
+
} else {
|
|
179
|
+
resolve(nil);
|
|
180
|
+
}
|
|
181
|
+
}];
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
- (void)deviceDiscoverServices:(NSString *)id resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
|
|
186
|
+
[impl deviceDiscoverServicesWithId:id completionHandler:^(NSError * _Nullable error) {
|
|
187
|
+
if (error != nil) {
|
|
188
|
+
reject([@([error code]) stringValue], [error description], error);
|
|
189
|
+
} else {
|
|
190
|
+
resolve(nil);
|
|
191
|
+
}
|
|
192
|
+
}];
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
- (void)deviceRequestMTU:(NSString *)id mtu:(double)mtu resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
|
|
197
|
+
[impl deviceRequestMTUWithId:id mtu:mtu completionHandler:^(NSError * _Nullable error) {
|
|
198
|
+
if (error != nil) {
|
|
199
|
+
reject([@([error code]) stringValue], [error description], error);
|
|
200
|
+
} else {
|
|
201
|
+
resolve(nil);
|
|
202
|
+
}
|
|
203
|
+
}];
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
- (NSArray<NSNumber *> *)deviceCharacteristicData:(NSString *)id serviceId:(NSString *)serviceId characteristicId:(NSString *)characteristicId {
|
|
207
|
+
return [impl deviceCharacteristicDataWithId:id
|
|
208
|
+
serviceId:serviceId
|
|
209
|
+
characteristicId:characteristicId
|
|
210
|
+
];
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
- (NSNumber *)deviceCharacteristicNotifyEnabled:(NSString *)id serviceId:(NSString *)serviceId characteristicId:(NSString *)characteristicId {
|
|
214
|
+
return [NSNumber numberWithBool:[impl deviceCharacteristicNotifyEnabledWithId:id
|
|
215
|
+
serviceId:serviceId
|
|
216
|
+
characteristicId:characteristicId
|
|
217
|
+
]];
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
- (void)deviceCharacteristicRead:(NSString *)id serviceId:(NSString *)serviceId characteristicId:(NSString *)characteristicId resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
|
|
222
|
+
[impl deviceCharacteristicReadWithId:id
|
|
223
|
+
serviceId:serviceId
|
|
224
|
+
characteristicId:characteristicId
|
|
225
|
+
completionHandler:^(NSArray<NSNumber *> * _Nullable value, NSError * _Nullable error) {
|
|
226
|
+
if (error != nil) {
|
|
227
|
+
reject([@([error code]) stringValue], [error description], error);
|
|
228
|
+
} else {
|
|
229
|
+
resolve(value);
|
|
230
|
+
}
|
|
231
|
+
}];
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
- (void)deviceCharacteristicWrite:(NSString *)id serviceId:(NSString *)serviceId characteristicId:(NSString *)characteristicId data:(NSArray *)data withResponse:(BOOL)withResponse resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
|
|
236
|
+
[impl deviceCharacteristicWriteWithId:id
|
|
237
|
+
serviceId:serviceId
|
|
238
|
+
characteristicId:characteristicId
|
|
239
|
+
data:data
|
|
240
|
+
withResponse:withResponse
|
|
241
|
+
completionHandler:^(NSError * _Nullable error) {
|
|
242
|
+
if (error != nil) {
|
|
243
|
+
reject([@([error code]) stringValue], [error description], error);
|
|
244
|
+
} else {
|
|
245
|
+
resolve(nil);
|
|
246
|
+
}
|
|
247
|
+
}];
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
- (void)deviceCharacteristicSubscribe:(NSString *)id serviceId:(NSString *)serviceId characteristicId:(NSString *)characteristicId resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
|
|
252
|
+
[impl deviceCharacteristicSubscribeWithId:id
|
|
253
|
+
serviceId:serviceId
|
|
254
|
+
characteristicId:characteristicId
|
|
255
|
+
completionHandler:^(NSError * _Nullable error) {
|
|
256
|
+
if (error != nil) {
|
|
257
|
+
reject([@([error code]) stringValue], [error description], error);
|
|
258
|
+
} else {
|
|
259
|
+
resolve(nil);
|
|
260
|
+
}
|
|
261
|
+
}];
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
- (void)deviceCharacteristicUnsubscribe:(NSString *)id serviceId:(NSString *)serviceId characteristicId:(NSString *)characteristicId resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
|
|
266
|
+
[impl deviceCharacteristicUnsubscribeWithId:id
|
|
267
|
+
serviceId:serviceId
|
|
268
|
+
characteristicId:characteristicId
|
|
269
|
+
completionHandler:^(NSError * _Nullable error) {
|
|
270
|
+
if (error != nil) {
|
|
271
|
+
reject([@([error code]) stringValue], [error description], error);
|
|
272
|
+
} else {
|
|
273
|
+
resolve(nil);
|
|
274
|
+
}
|
|
275
|
+
}];
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
@end
|
|
280
|
+
|
|
@@ -0,0 +1,219 @@
|
|
|
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: GenerateModuleObjCpp
|
|
8
|
+
*
|
|
9
|
+
* We create an umbrella header (and corresponding implementation) here since
|
|
10
|
+
* Cxx compilation in BUCK has a limitation: source-code producing genrule()s
|
|
11
|
+
* must have a single output. More files => more genrule()s => slower builds.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
#import "RNBlueBreezeSpec.h"
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@implementation NativeBlueBreezeSpecBase
|
|
18
|
+
- (void)emitAuthorizationStatusEmitter:(NSString *_Nonnull)value
|
|
19
|
+
{
|
|
20
|
+
_eventEmitterCallback("authorizationStatusEmitter", value);
|
|
21
|
+
}
|
|
22
|
+
- (void)emitStateEmitter:(NSString *_Nonnull)value
|
|
23
|
+
{
|
|
24
|
+
_eventEmitterCallback("stateEmitter", value);
|
|
25
|
+
}
|
|
26
|
+
- (void)emitScanningEnabledEmitter:(BOOL)value
|
|
27
|
+
{
|
|
28
|
+
_eventEmitterCallback("scanningEnabledEmitter", [NSNumber numberWithBool:value]);
|
|
29
|
+
}
|
|
30
|
+
- (void)emitDevicesEmitter:(NSArray<id<NSObject>> *)value
|
|
31
|
+
{
|
|
32
|
+
_eventEmitterCallback("devicesEmitter", value);
|
|
33
|
+
}
|
|
34
|
+
- (void)emitDeviceServicesEmitter:(NSDictionary *)value
|
|
35
|
+
{
|
|
36
|
+
_eventEmitterCallback("deviceServicesEmitter", value);
|
|
37
|
+
}
|
|
38
|
+
- (void)emitDeviceConnectionStatusEmitter:(NSDictionary *)value
|
|
39
|
+
{
|
|
40
|
+
_eventEmitterCallback("deviceConnectionStatusEmitter", value);
|
|
41
|
+
}
|
|
42
|
+
- (void)emitDeviceMTUEmitter:(NSDictionary *)value
|
|
43
|
+
{
|
|
44
|
+
_eventEmitterCallback("deviceMTUEmitter", value);
|
|
45
|
+
}
|
|
46
|
+
- (void)emitDeviceCharacteristicDataEmitter:(NSDictionary *)value
|
|
47
|
+
{
|
|
48
|
+
_eventEmitterCallback("deviceCharacteristicDataEmitter", value);
|
|
49
|
+
}
|
|
50
|
+
- (void)emitDeviceCharacteristicNotifyEnabledEmitter:(NSDictionary *)value
|
|
51
|
+
{
|
|
52
|
+
_eventEmitterCallback("deviceCharacteristicNotifyEnabledEmitter", value);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
- (void)setEventEmitterCallback:(EventEmitterCallbackWrapper *)eventEmitterCallbackWrapper
|
|
56
|
+
{
|
|
57
|
+
_eventEmitterCallback = std::move(eventEmitterCallbackWrapper->_eventEmitterCallback);
|
|
58
|
+
}
|
|
59
|
+
@end
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
namespace facebook::react {
|
|
63
|
+
|
|
64
|
+
static facebook::jsi::Value __hostFunction_NativeBlueBreezeSpecJSI_authorizationStatus(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
65
|
+
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, StringKind, "authorizationStatus", @selector(authorizationStatus), args, count);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
static facebook::jsi::Value __hostFunction_NativeBlueBreezeSpecJSI_authorizationRequest(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
69
|
+
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, VoidKind, "authorizationRequest", @selector(authorizationRequest), args, count);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
static facebook::jsi::Value __hostFunction_NativeBlueBreezeSpecJSI_state(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
73
|
+
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, StringKind, "state", @selector(state), args, count);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
static facebook::jsi::Value __hostFunction_NativeBlueBreezeSpecJSI_scanningEnabled(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
77
|
+
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, BooleanKind, "scanningEnabled", @selector(scanningEnabled), args, count);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
static facebook::jsi::Value __hostFunction_NativeBlueBreezeSpecJSI_scanningStart(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
81
|
+
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, VoidKind, "scanningStart", @selector(scanningStart), args, count);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
static facebook::jsi::Value __hostFunction_NativeBlueBreezeSpecJSI_scanningStop(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
85
|
+
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, VoidKind, "scanningStop", @selector(scanningStop), args, count);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
static facebook::jsi::Value __hostFunction_NativeBlueBreezeSpecJSI_devices(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
89
|
+
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, ArrayKind, "devices", @selector(devices), args, count);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
static facebook::jsi::Value __hostFunction_NativeBlueBreezeSpecJSI_deviceServices(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
93
|
+
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, ArrayKind, "deviceServices", @selector(deviceServices:), args, count);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
static facebook::jsi::Value __hostFunction_NativeBlueBreezeSpecJSI_deviceConnectionStatus(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
97
|
+
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, StringKind, "deviceConnectionStatus", @selector(deviceConnectionStatus:), args, count);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
static facebook::jsi::Value __hostFunction_NativeBlueBreezeSpecJSI_deviceMTU(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
101
|
+
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, NumberKind, "deviceMTU", @selector(deviceMTU:), args, count);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
static facebook::jsi::Value __hostFunction_NativeBlueBreezeSpecJSI_deviceConnect(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
105
|
+
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, PromiseKind, "deviceConnect", @selector(deviceConnect:resolve:reject:), args, count);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
static facebook::jsi::Value __hostFunction_NativeBlueBreezeSpecJSI_deviceDisconnect(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
109
|
+
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, PromiseKind, "deviceDisconnect", @selector(deviceDisconnect:resolve:reject:), args, count);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
static facebook::jsi::Value __hostFunction_NativeBlueBreezeSpecJSI_deviceDiscoverServices(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
113
|
+
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, PromiseKind, "deviceDiscoverServices", @selector(deviceDiscoverServices:resolve:reject:), args, count);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
static facebook::jsi::Value __hostFunction_NativeBlueBreezeSpecJSI_deviceRequestMTU(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
117
|
+
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, PromiseKind, "deviceRequestMTU", @selector(deviceRequestMTU:mtu:resolve:reject:), args, count);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
static facebook::jsi::Value __hostFunction_NativeBlueBreezeSpecJSI_deviceCharacteristicData(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
121
|
+
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, ArrayKind, "deviceCharacteristicData", @selector(deviceCharacteristicData:serviceId:characteristicId:), args, count);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
static facebook::jsi::Value __hostFunction_NativeBlueBreezeSpecJSI_deviceCharacteristicNotifyEnabled(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
125
|
+
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, BooleanKind, "deviceCharacteristicNotifyEnabled", @selector(deviceCharacteristicNotifyEnabled:serviceId:characteristicId:), args, count);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
static facebook::jsi::Value __hostFunction_NativeBlueBreezeSpecJSI_deviceCharacteristicRead(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
129
|
+
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, PromiseKind, "deviceCharacteristicRead", @selector(deviceCharacteristicRead:serviceId:characteristicId:resolve:reject:), args, count);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
static facebook::jsi::Value __hostFunction_NativeBlueBreezeSpecJSI_deviceCharacteristicWrite(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
133
|
+
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, PromiseKind, "deviceCharacteristicWrite", @selector(deviceCharacteristicWrite:serviceId:characteristicId:data:withResponse:resolve:reject:), args, count);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
static facebook::jsi::Value __hostFunction_NativeBlueBreezeSpecJSI_deviceCharacteristicSubscribe(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
137
|
+
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, PromiseKind, "deviceCharacteristicSubscribe", @selector(deviceCharacteristicSubscribe:serviceId:characteristicId:resolve:reject:), args, count);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
static facebook::jsi::Value __hostFunction_NativeBlueBreezeSpecJSI_deviceCharacteristicUnsubscribe(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
141
|
+
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, PromiseKind, "deviceCharacteristicUnsubscribe", @selector(deviceCharacteristicUnsubscribe:serviceId:characteristicId:resolve:reject:), args, count);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
NativeBlueBreezeSpecJSI::NativeBlueBreezeSpecJSI(const ObjCTurboModule::InitParams ¶ms)
|
|
145
|
+
: ObjCTurboModule(params) {
|
|
146
|
+
|
|
147
|
+
methodMap_["authorizationStatus"] = MethodMetadata {0, __hostFunction_NativeBlueBreezeSpecJSI_authorizationStatus};
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
methodMap_["authorizationRequest"] = MethodMetadata {0, __hostFunction_NativeBlueBreezeSpecJSI_authorizationRequest};
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
methodMap_["state"] = MethodMetadata {0, __hostFunction_NativeBlueBreezeSpecJSI_state};
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
methodMap_["scanningEnabled"] = MethodMetadata {0, __hostFunction_NativeBlueBreezeSpecJSI_scanningEnabled};
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
methodMap_["scanningStart"] = MethodMetadata {0, __hostFunction_NativeBlueBreezeSpecJSI_scanningStart};
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
methodMap_["scanningStop"] = MethodMetadata {0, __hostFunction_NativeBlueBreezeSpecJSI_scanningStop};
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
methodMap_["devices"] = MethodMetadata {0, __hostFunction_NativeBlueBreezeSpecJSI_devices};
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
methodMap_["deviceServices"] = MethodMetadata {1, __hostFunction_NativeBlueBreezeSpecJSI_deviceServices};
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
methodMap_["deviceConnectionStatus"] = MethodMetadata {1, __hostFunction_NativeBlueBreezeSpecJSI_deviceConnectionStatus};
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
methodMap_["deviceMTU"] = MethodMetadata {1, __hostFunction_NativeBlueBreezeSpecJSI_deviceMTU};
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
methodMap_["deviceConnect"] = MethodMetadata {1, __hostFunction_NativeBlueBreezeSpecJSI_deviceConnect};
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
methodMap_["deviceDisconnect"] = MethodMetadata {1, __hostFunction_NativeBlueBreezeSpecJSI_deviceDisconnect};
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
methodMap_["deviceDiscoverServices"] = MethodMetadata {1, __hostFunction_NativeBlueBreezeSpecJSI_deviceDiscoverServices};
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
methodMap_["deviceRequestMTU"] = MethodMetadata {2, __hostFunction_NativeBlueBreezeSpecJSI_deviceRequestMTU};
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
methodMap_["deviceCharacteristicData"] = MethodMetadata {3, __hostFunction_NativeBlueBreezeSpecJSI_deviceCharacteristicData};
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
methodMap_["deviceCharacteristicNotifyEnabled"] = MethodMetadata {3, __hostFunction_NativeBlueBreezeSpecJSI_deviceCharacteristicNotifyEnabled};
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
methodMap_["deviceCharacteristicRead"] = MethodMetadata {3, __hostFunction_NativeBlueBreezeSpecJSI_deviceCharacteristicRead};
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
methodMap_["deviceCharacteristicWrite"] = MethodMetadata {5, __hostFunction_NativeBlueBreezeSpecJSI_deviceCharacteristicWrite};
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
methodMap_["deviceCharacteristicSubscribe"] = MethodMetadata {3, __hostFunction_NativeBlueBreezeSpecJSI_deviceCharacteristicSubscribe};
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
methodMap_["deviceCharacteristicUnsubscribe"] = MethodMetadata {3, __hostFunction_NativeBlueBreezeSpecJSI_deviceCharacteristicUnsubscribe};
|
|
205
|
+
|
|
206
|
+
eventEmitterMap_["authorizationStatusEmitter"] = std::make_shared<AsyncEventEmitter<id>>();
|
|
207
|
+
eventEmitterMap_["stateEmitter"] = std::make_shared<AsyncEventEmitter<id>>();
|
|
208
|
+
eventEmitterMap_["scanningEnabledEmitter"] = std::make_shared<AsyncEventEmitter<id>>();
|
|
209
|
+
eventEmitterMap_["devicesEmitter"] = std::make_shared<AsyncEventEmitter<id>>();
|
|
210
|
+
eventEmitterMap_["deviceServicesEmitter"] = std::make_shared<AsyncEventEmitter<id>>();
|
|
211
|
+
eventEmitterMap_["deviceConnectionStatusEmitter"] = std::make_shared<AsyncEventEmitter<id>>();
|
|
212
|
+
eventEmitterMap_["deviceMTUEmitter"] = std::make_shared<AsyncEventEmitter<id>>();
|
|
213
|
+
eventEmitterMap_["deviceCharacteristicDataEmitter"] = std::make_shared<AsyncEventEmitter<id>>();
|
|
214
|
+
eventEmitterMap_["deviceCharacteristicNotifyEnabledEmitter"] = std::make_shared<AsyncEventEmitter<id>>();
|
|
215
|
+
setEventEmitterCallback([&](const std::string &name, id value) {
|
|
216
|
+
static_cast<AsyncEventEmitter<id> &>(*eventEmitterMap_[name]).emit(value);
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,117 @@
|
|
|
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: GenerateModuleObjCpp
|
|
8
|
+
*
|
|
9
|
+
* We create an umbrella header (and corresponding implementation) here since
|
|
10
|
+
* Cxx compilation in BUCK has a limitation: source-code producing genrule()s
|
|
11
|
+
* must have a single output. More files => more genrule()s => slower builds.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
#ifndef __cplusplus
|
|
15
|
+
#error This file must be compiled as Obj-C++. If you are importing it, you must change your file extension to .mm.
|
|
16
|
+
#endif
|
|
17
|
+
|
|
18
|
+
// Avoid multiple includes of RNBlueBreezeSpec symbols
|
|
19
|
+
#ifndef RNBlueBreezeSpec_H
|
|
20
|
+
#define RNBlueBreezeSpec_H
|
|
21
|
+
|
|
22
|
+
#import <Foundation/Foundation.h>
|
|
23
|
+
#import <RCTRequired/RCTRequired.h>
|
|
24
|
+
#import <RCTTypeSafety/RCTConvertHelpers.h>
|
|
25
|
+
#import <RCTTypeSafety/RCTTypedModuleConstants.h>
|
|
26
|
+
#import <React/RCTBridgeModule.h>
|
|
27
|
+
#import <React/RCTCxxConvert.h>
|
|
28
|
+
#import <React/RCTManagedPointer.h>
|
|
29
|
+
#import <ReactCommon/RCTTurboModule.h>
|
|
30
|
+
#import <optional>
|
|
31
|
+
#import <vector>
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
@protocol NativeBlueBreezeSpec <RCTBridgeModule, RCTTurboModule>
|
|
35
|
+
|
|
36
|
+
- (NSString *)authorizationStatus;
|
|
37
|
+
- (void)authorizationRequest;
|
|
38
|
+
- (NSString *)state;
|
|
39
|
+
- (NSNumber *)scanningEnabled;
|
|
40
|
+
- (void)scanningStart;
|
|
41
|
+
- (void)scanningStop;
|
|
42
|
+
- (NSArray<id<NSObject>> *)devices;
|
|
43
|
+
- (NSArray<NSDictionary *> *)deviceServices:(NSString *)id;
|
|
44
|
+
- (NSString *)deviceConnectionStatus:(NSString *)id;
|
|
45
|
+
- (NSNumber *)deviceMTU:(NSString *)id;
|
|
46
|
+
- (void)deviceConnect:(NSString *)id
|
|
47
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
48
|
+
reject:(RCTPromiseRejectBlock)reject;
|
|
49
|
+
- (void)deviceDisconnect:(NSString *)id
|
|
50
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
51
|
+
reject:(RCTPromiseRejectBlock)reject;
|
|
52
|
+
- (void)deviceDiscoverServices:(NSString *)id
|
|
53
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
54
|
+
reject:(RCTPromiseRejectBlock)reject;
|
|
55
|
+
- (void)deviceRequestMTU:(NSString *)id
|
|
56
|
+
mtu:(double)mtu
|
|
57
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
58
|
+
reject:(RCTPromiseRejectBlock)reject;
|
|
59
|
+
- (NSArray<NSNumber *> *)deviceCharacteristicData:(NSString *)id
|
|
60
|
+
serviceId:(NSString *)serviceId
|
|
61
|
+
characteristicId:(NSString *)characteristicId;
|
|
62
|
+
- (NSNumber *)deviceCharacteristicNotifyEnabled:(NSString *)id
|
|
63
|
+
serviceId:(NSString *)serviceId
|
|
64
|
+
characteristicId:(NSString *)characteristicId;
|
|
65
|
+
- (void)deviceCharacteristicRead:(NSString *)id
|
|
66
|
+
serviceId:(NSString *)serviceId
|
|
67
|
+
characteristicId:(NSString *)characteristicId
|
|
68
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
69
|
+
reject:(RCTPromiseRejectBlock)reject;
|
|
70
|
+
- (void)deviceCharacteristicWrite:(NSString *)id
|
|
71
|
+
serviceId:(NSString *)serviceId
|
|
72
|
+
characteristicId:(NSString *)characteristicId
|
|
73
|
+
data:(NSArray *)data
|
|
74
|
+
withResponse:(BOOL)withResponse
|
|
75
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
76
|
+
reject:(RCTPromiseRejectBlock)reject;
|
|
77
|
+
- (void)deviceCharacteristicSubscribe:(NSString *)id
|
|
78
|
+
serviceId:(NSString *)serviceId
|
|
79
|
+
characteristicId:(NSString *)characteristicId
|
|
80
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
81
|
+
reject:(RCTPromiseRejectBlock)reject;
|
|
82
|
+
- (void)deviceCharacteristicUnsubscribe:(NSString *)id
|
|
83
|
+
serviceId:(NSString *)serviceId
|
|
84
|
+
characteristicId:(NSString *)characteristicId
|
|
85
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
86
|
+
reject:(RCTPromiseRejectBlock)reject;
|
|
87
|
+
|
|
88
|
+
@end
|
|
89
|
+
|
|
90
|
+
@interface NativeBlueBreezeSpecBase : NSObject {
|
|
91
|
+
@protected
|
|
92
|
+
facebook::react::EventEmitterCallback _eventEmitterCallback;
|
|
93
|
+
}
|
|
94
|
+
- (void)setEventEmitterCallback:(EventEmitterCallbackWrapper *)eventEmitterCallbackWrapper;
|
|
95
|
+
|
|
96
|
+
- (void)emitAuthorizationStatusEmitter:(NSString *_Nonnull)value;
|
|
97
|
+
- (void)emitStateEmitter:(NSString *_Nonnull)value;
|
|
98
|
+
- (void)emitScanningEnabledEmitter:(BOOL)value;
|
|
99
|
+
- (void)emitDevicesEmitter:(NSArray<id<NSObject>> *)value;
|
|
100
|
+
- (void)emitDeviceServicesEmitter:(NSDictionary *)value;
|
|
101
|
+
- (void)emitDeviceConnectionStatusEmitter:(NSDictionary *)value;
|
|
102
|
+
- (void)emitDeviceMTUEmitter:(NSDictionary *)value;
|
|
103
|
+
- (void)emitDeviceCharacteristicDataEmitter:(NSDictionary *)value;
|
|
104
|
+
- (void)emitDeviceCharacteristicNotifyEnabledEmitter:(NSDictionary *)value;
|
|
105
|
+
@end
|
|
106
|
+
|
|
107
|
+
namespace facebook::react {
|
|
108
|
+
/**
|
|
109
|
+
* ObjC++ class for module 'NativeBlueBreeze'
|
|
110
|
+
*/
|
|
111
|
+
class JSI_EXPORT NativeBlueBreezeSpecJSI : public ObjCTurboModule {
|
|
112
|
+
public:
|
|
113
|
+
NativeBlueBreezeSpecJSI(const ObjCTurboModule::InitParams ¶ms);
|
|
114
|
+
};
|
|
115
|
+
} // namespace facebook::react
|
|
116
|
+
|
|
117
|
+
#endif // RNBlueBreezeSpec_H
|