@react-native-ohos/react-native-ble-plx 3.2.1 → 3.5.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/README.OpenSource +2 -2
- package/README.md +1 -1
- package/harmony/rn_bleplx/BuildProfile.ets +9 -0
- package/harmony/rn_bleplx/hvigorfile.ts +5 -1
- package/harmony/rn_bleplx/index.ets +5 -27
- package/harmony/rn_bleplx/oh-package.json5 +1 -1
- package/harmony/rn_bleplx/src/main/cpp/CMakeLists.txt +2 -2
- package/harmony/rn_bleplx/src/main/cpp/generated/{RNOH/generated/turbo_modules/BlePlx.cpp → BlePlx.cpp} +9 -4
- package/harmony/rn_bleplx/src/main/cpp/generated/{RNOH/generated/turbo_modules/BlePlx.h → BlePlx.h} +6 -1
- package/harmony/rn_bleplx/src/main/cpp/generated/{RNOH/generated/BaseReactNativeBlePlxPackage.h → BlePlxRNOHGeneratedPackage.h} +21 -10
- package/harmony/rn_bleplx/src/main/ets/BleDevice.ts +4 -24
- package/harmony/rn_bleplx/src/main/ets/BleModule.ts +26 -37
- package/harmony/rn_bleplx/src/main/ets/BlePlxInterface.ts +4 -24
- package/harmony/rn_bleplx/src/main/ets/BlePlxModule.ts +9 -29
- package/harmony/rn_bleplx/src/main/ets/BlePlxPackage.ts +26 -0
- package/harmony/rn_bleplx/src/main/ets/Characteristic.ts +3 -23
- package/harmony/rn_bleplx/src/main/ets/CommonConstants.ts +4 -24
- package/harmony/rn_bleplx/src/main/ets/Descriptor.ts +3 -23
- package/harmony/rn_bleplx/src/main/ets/Service.ts +3 -23
- package/harmony/rn_bleplx/src/main/ets/common/BleError.ts +3 -23
- package/harmony/rn_bleplx/src/main/ets/common/BleErrorToJsObjectConverter.ts +4 -24
- package/harmony/rn_bleplx/src/main/ets/common/BleEvent.ts +4 -24
- package/harmony/rn_bleplx/src/main/ets/common/BleUtils.ts +3 -23
- package/harmony/rn_bleplx/src/main/ets/common/IdGenerator.ts +3 -23
- package/harmony/rn_bleplx/src/main/ets/common/IdGeneratorKey.ts +3 -23
- package/harmony/rn_bleplx/src/main/ets/common/InstanceIdGenerator.ts +4 -24
- package/harmony/rn_bleplx/src/main/ets/common/Logger.ts +1 -1
- package/harmony/rn_bleplx/src/main/ets/common/PermissionHandler.ts +3 -23
- package/harmony/rn_bleplx/src/main/ets/common/ServiceFactory.ts +3 -23
- package/harmony/rn_bleplx/src/main/ets/generated/components/ts.ts +4 -1
- package/harmony/rn_bleplx/src/main/ets/generated/index.ets +4 -1
- package/harmony/rn_bleplx/src/main/ets/generated/ts.ts +4 -1
- package/harmony/rn_bleplx/src/main/ets/generated/turboModules/BlePlx.ts +9 -4
- package/harmony/rn_bleplx/src/main/ets/generated/turboModules/ts.ts +4 -1
- package/harmony/rn_bleplx/ts.ts +6 -0
- package/harmony/rn_bleplx.har +0 -0
- package/package.json +11 -20
- package/src/BleManager.js +55 -18
- package/src/BleModule.js +14 -4
- package/src/Characteristic.js +18 -4
- package/src/Descriptor.js +2 -1
- package/src/Device.js +19 -11
- package/src/NativeBlePlx.ts +6 -26
- package/src/Service.js +20 -4
- package/src/TypeDefinition.js +5 -0
- package/src/Utils.js +3 -0
- package/src/index.d.ts +17 -4
- package/harmony/rn_bleplx/src/main/cpp/BlePlxPackage.h +0 -36
- package/harmony/rn_bleplx/src/main/cpp/generated/react/renderer/components/react_native_ble_plx/ComponentDescriptors.h +0 -22
- package/harmony/rn_bleplx/src/main/cpp/generated/react/renderer/components/react_native_ble_plx/EventEmitters.cpp +0 -18
- package/harmony/rn_bleplx/src/main/cpp/generated/react/renderer/components/react_native_ble_plx/EventEmitters.h +0 -19
- package/harmony/rn_bleplx/src/main/cpp/generated/react/renderer/components/react_native_ble_plx/Props.cpp +0 -21
- package/harmony/rn_bleplx/src/main/cpp/generated/react/renderer/components/react_native_ble_plx/Props.h +0 -20
- package/harmony/rn_bleplx/src/main/cpp/generated/react/renderer/components/react_native_ble_plx/ShadowNodes.cpp +0 -19
- package/harmony/rn_bleplx/src/main/cpp/generated/react/renderer/components/react_native_ble_plx/ShadowNodes.h +0 -25
- package/harmony/rn_bleplx/src/main/cpp/generated/react/renderer/components/react_native_ble_plx/States.cpp +0 -18
- package/harmony/rn_bleplx/src/main/cpp/generated/react/renderer/components/react_native_ble_plx/States.h +0 -23
- package/harmony/rn_bleplx/src/main/ets/BlePlxPackage.ets +0 -47
- package/harmony/rn_bleplx/ts.ets +0 -26
package/src/BleModule.js
CHANGED
|
@@ -8,6 +8,7 @@ import type {
|
|
|
8
8
|
Identifier,
|
|
9
9
|
UUID,
|
|
10
10
|
TransactionId,
|
|
11
|
+
CharacteristicSubscriptionType,
|
|
11
12
|
Base64,
|
|
12
13
|
ScanOptions,
|
|
13
14
|
ConnectionOptions
|
|
@@ -56,7 +57,7 @@ export interface NativeDevice {
|
|
|
56
57
|
rawScanRecord: Base64;
|
|
57
58
|
|
|
58
59
|
/**
|
|
59
|
-
* Map
|
|
60
|
+
* Map of service UUIDs with associated data.
|
|
60
61
|
* @private
|
|
61
62
|
*/
|
|
62
63
|
serviceData: ?{ [uuid: UUID]: Base64 };
|
|
@@ -607,6 +608,7 @@ export interface BleModuleInterface {
|
|
|
607
608
|
* @param {UUID} serviceUUID Service UUID
|
|
608
609
|
* @param {UUID} characteristicUUID Characteristic UUID
|
|
609
610
|
* @param {TransactionId} transactionId Transaction handle used to cancel operation
|
|
611
|
+
* @param {?CharacteristicSubscriptionType} subscriptionType subscription type of the characteristic
|
|
610
612
|
* @returns {Promise<void>} Value which is returned when monitoring was cancelled or resulted in error
|
|
611
613
|
* @private
|
|
612
614
|
*/
|
|
@@ -614,7 +616,8 @@ export interface BleModuleInterface {
|
|
|
614
616
|
deviceIdentifier: DeviceId,
|
|
615
617
|
serviceUUID: UUID,
|
|
616
618
|
characteristicUUID: UUID,
|
|
617
|
-
transactionId: TransactionId
|
|
619
|
+
transactionId: TransactionId,
|
|
620
|
+
subscriptionType: ?CharacteristicSubscriptionType
|
|
618
621
|
): Promise<void>;
|
|
619
622
|
|
|
620
623
|
/**
|
|
@@ -623,13 +626,15 @@ export interface BleModuleInterface {
|
|
|
623
626
|
* @param {Identifier} serviceIdentifier Service ID
|
|
624
627
|
* @param {UUID} characteristicUUID Characteristic UUID
|
|
625
628
|
* @param {TransactionId} transactionId Transaction handle used to cancel operation
|
|
629
|
+
* @param {?CharacteristicSubscriptionType} subscriptionType subscription type of the characteristic
|
|
626
630
|
* @returns {Promise<void>} Value which is returned when monitoring was cancelled or resulted in error
|
|
627
631
|
* @private
|
|
628
632
|
*/
|
|
629
633
|
monitorCharacteristicForService(
|
|
630
634
|
serviceIdentifier: Identifier,
|
|
631
635
|
characteristicUUID: UUID,
|
|
632
|
-
transactionId: TransactionId
|
|
636
|
+
transactionId: TransactionId,
|
|
637
|
+
subscriptionType: ?CharacteristicSubscriptionType
|
|
633
638
|
): Promise<void>;
|
|
634
639
|
|
|
635
640
|
/**
|
|
@@ -637,10 +642,15 @@ export interface BleModuleInterface {
|
|
|
637
642
|
*
|
|
638
643
|
* @param {Identifier} characteristicIdentifier Characteristic ID
|
|
639
644
|
* @param {TransactionId} transactionId Transaction handle used to cancel operation
|
|
645
|
+
* @param {?CharacteristicSubscriptionType} subscriptionType subscription type of the characteristic
|
|
640
646
|
* @returns {Promise<void>} Value which is returned when monitoring was cancelled or resulted in error
|
|
641
647
|
* @private
|
|
642
648
|
*/
|
|
643
|
-
monitorCharacteristic(
|
|
649
|
+
monitorCharacteristic(
|
|
650
|
+
characteristicIdentifier: Identifier,
|
|
651
|
+
transactionId: TransactionId,
|
|
652
|
+
subscriptionType: ?CharacteristicSubscriptionType
|
|
653
|
+
): Promise<void>;
|
|
644
654
|
|
|
645
655
|
// Descriptor operations
|
|
646
656
|
|
package/src/Characteristic.js
CHANGED
|
@@ -5,7 +5,16 @@ import type { BleManager } from './BleManager'
|
|
|
5
5
|
import type { BleError } from './BleError'
|
|
6
6
|
import { Descriptor } from './Descriptor'
|
|
7
7
|
import type { NativeCharacteristic } from './BleModule'
|
|
8
|
-
import type {
|
|
8
|
+
import type {
|
|
9
|
+
DeviceId,
|
|
10
|
+
Identifier,
|
|
11
|
+
UUID,
|
|
12
|
+
TransactionId,
|
|
13
|
+
CharacteristicSubscriptionType,
|
|
14
|
+
Base64,
|
|
15
|
+
Subscription
|
|
16
|
+
} from './TypeDefinition'
|
|
17
|
+
import { isIOS } from './Utils'
|
|
9
18
|
|
|
10
19
|
/**
|
|
11
20
|
* Characteristic object.
|
|
@@ -72,7 +81,8 @@ export class Characteristic implements NativeCharacteristic {
|
|
|
72
81
|
* @private
|
|
73
82
|
*/
|
|
74
83
|
constructor(nativeCharacteristic: NativeCharacteristic, manager: BleManager) {
|
|
75
|
-
Object.assign(this, nativeCharacteristic
|
|
84
|
+
Object.assign(this, nativeCharacteristic)
|
|
85
|
+
Object.defineProperty(this, '_manager', { value: manager, enumerable: false })
|
|
76
86
|
}
|
|
77
87
|
|
|
78
88
|
/**
|
|
@@ -129,14 +139,18 @@ export class Characteristic implements NativeCharacteristic {
|
|
|
129
139
|
* @param {function(error: ?BleError, characteristic: ?Characteristic)} listener callback which emits
|
|
130
140
|
* this {@link Characteristic} with modified value for each notification.
|
|
131
141
|
* @param {?TransactionId} transactionId optional `transactionId` which can be used in
|
|
142
|
+
* @param {?CharacteristicSubscriptionType} subscriptionType subscription type of the characteristic
|
|
132
143
|
* {@link #blemanagercanceltransaction|bleManager.cancelTransaction()} function.
|
|
133
144
|
* @returns {Subscription} Subscription on which `remove()` function can be called to unsubscribe.
|
|
134
145
|
*/
|
|
135
146
|
monitor(
|
|
136
147
|
listener: (error: ?BleError, characteristic: ?Characteristic) => void,
|
|
137
|
-
transactionId: ?TransactionId
|
|
148
|
+
transactionId: ?TransactionId,
|
|
149
|
+
subscriptionType: ?CharacteristicSubscriptionType
|
|
138
150
|
): Subscription {
|
|
139
|
-
|
|
151
|
+
const commonArgs = [this.id, listener, transactionId]
|
|
152
|
+
const args = isIOS ? commonArgs : [...commonArgs, subscriptionType]
|
|
153
|
+
return this._manager._monitorCharacteristic(...args)
|
|
140
154
|
}
|
|
141
155
|
|
|
142
156
|
/**
|
package/src/Descriptor.js
CHANGED
|
@@ -54,7 +54,8 @@ export class Descriptor implements NativeDescriptor {
|
|
|
54
54
|
* @private
|
|
55
55
|
*/
|
|
56
56
|
constructor(nativeDescriptor: NativeDescriptor, manager: BleManager) {
|
|
57
|
-
Object.assign(this, nativeDescriptor
|
|
57
|
+
Object.assign(this, nativeDescriptor)
|
|
58
|
+
Object.defineProperty(this, '_manager', { value: manager, enumerable: false })
|
|
58
59
|
}
|
|
59
60
|
|
|
60
61
|
/**
|
package/src/Device.js
CHANGED
|
@@ -8,8 +8,16 @@ import type { Service } from './Service'
|
|
|
8
8
|
import type { Descriptor } from './Descriptor'
|
|
9
9
|
import { ConnectionPriority } from './TypeDefinition'
|
|
10
10
|
import type { NativeDevice } from './BleModule'
|
|
11
|
-
import type {
|
|
12
|
-
|
|
11
|
+
import type {
|
|
12
|
+
DeviceId,
|
|
13
|
+
Base64,
|
|
14
|
+
UUID,
|
|
15
|
+
Subscription,
|
|
16
|
+
TransactionId,
|
|
17
|
+
CharacteristicSubscriptionType,
|
|
18
|
+
ConnectionOptions
|
|
19
|
+
} from './TypeDefinition'
|
|
20
|
+
import { isIOS } from './Utils'
|
|
13
21
|
/**
|
|
14
22
|
* Device instance which can be retrieved only by calling
|
|
15
23
|
* {@link #blemanagerstartdevicescan|bleManager.startDeviceScan()}.
|
|
@@ -98,7 +106,8 @@ export class Device implements NativeDevice {
|
|
|
98
106
|
* @private
|
|
99
107
|
*/
|
|
100
108
|
constructor(nativeDevice: NativeDevice, manager: BleManager) {
|
|
101
|
-
Object.assign(this, nativeDevice
|
|
109
|
+
Object.assign(this, nativeDevice)
|
|
110
|
+
Object.defineProperty(this, '_manager', { value: manager, enumerable: false })
|
|
102
111
|
}
|
|
103
112
|
|
|
104
113
|
/**
|
|
@@ -297,6 +306,7 @@ export class Device implements NativeDevice {
|
|
|
297
306
|
* @param {function(error: ?BleError, characteristic: ?Characteristic)} listener - callback which emits
|
|
298
307
|
* {@link Characteristic} objects with modified value for each notification.
|
|
299
308
|
* @param {?TransactionId} transactionId optional `transactionId` which can be used in
|
|
309
|
+
* @param {?CharacteristicSubscriptionType} subscriptionType subscription type of the characteristic
|
|
300
310
|
* {@link #blemanagercanceltransaction|bleManager.cancelTransaction()} function.
|
|
301
311
|
* @returns {Subscription} Subscription on which `remove()` function can be called to unsubscribe.
|
|
302
312
|
*/
|
|
@@ -304,15 +314,13 @@ export class Device implements NativeDevice {
|
|
|
304
314
|
serviceUUID: UUID,
|
|
305
315
|
characteristicUUID: UUID,
|
|
306
316
|
listener: (error: ?BleError, characteristic: ?Characteristic) => void,
|
|
307
|
-
transactionId: ?TransactionId
|
|
317
|
+
transactionId: ?TransactionId,
|
|
318
|
+
subscriptionType?: CharacteristicSubscriptionType
|
|
308
319
|
): Subscription {
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
listener,
|
|
314
|
-
transactionId
|
|
315
|
-
)
|
|
320
|
+
const commonArgs = [this.id, serviceUUID, characteristicUUID, listener, transactionId]
|
|
321
|
+
const args = isIOS ? commonArgs : [...commonArgs, subscriptionType]
|
|
322
|
+
|
|
323
|
+
return this._manager.monitorCharacteristicForDevice(...args)
|
|
316
324
|
}
|
|
317
325
|
|
|
318
326
|
/**
|
package/src/NativeBlePlx.ts
CHANGED
|
@@ -1,26 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* Copyright (C) 2023 Huawei Device Co., Ltd.
|
|
5
|
-
*
|
|
6
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
-
* in the Software without restriction, including without limitation the rights
|
|
9
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
-
* furnished to do so, subject to the following conditions:
|
|
12
|
-
*
|
|
13
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
-
* copies or substantial portions of the Software.
|
|
15
|
-
*
|
|
16
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
-
* SOFTWARE.
|
|
23
|
-
*/
|
|
1
|
+
// Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved
|
|
2
|
+
// Use of this source code is governed by a Apache-2.0 license that can be
|
|
3
|
+
// found in the LICENSE file.
|
|
24
4
|
|
|
25
5
|
import type { TurboModule } from 'react-native/Libraries/TurboModule/RCTExport';
|
|
26
6
|
import { TurboModuleRegistry } from 'react-native';
|
|
@@ -95,11 +75,11 @@ export interface Spec extends TurboModule {
|
|
|
95
75
|
|
|
96
76
|
writeCharacteristic(characteristicIdentifier: number, valueBase64: string, response: boolean, transactionId: string): Promise<Object>; //Object-->NativeCharacteristic
|
|
97
77
|
|
|
98
|
-
monitorCharacteristicForDevice(deviceId: string, serviceUUID: string, characteristicUUID: string, transactionId: string): Promise<void>;
|
|
78
|
+
monitorCharacteristicForDevice(deviceId: string, serviceUUID: string, characteristicUUID: string, transactionId: string, subscriptionType?: string): Promise<void>;
|
|
99
79
|
|
|
100
|
-
monitorCharacteristicForService(serviceIdentifier: number, characteristicUUID: string, transactionId: string): Promise<void>;
|
|
80
|
+
monitorCharacteristicForService(serviceIdentifier: number, characteristicUUID: string, transactionId: string, subscriptionType?: string): Promise<void>;
|
|
101
81
|
|
|
102
|
-
monitorCharacteristic(characteristicIdentifier: number, transactionId: string): Promise<void>;
|
|
82
|
+
monitorCharacteristic(characteristicIdentifier: number, transactionId: string, subscriptionType?: string): Promise<void>;
|
|
103
83
|
|
|
104
84
|
readDescriptorForDevice(deviceId: string, serviceUUID: string, characteristicUUID: string, descriptorUUID: string, transactionId: string): Promise<Object>; //Object-->NativeDescriptor
|
|
105
85
|
|
package/src/Service.js
CHANGED
|
@@ -6,7 +6,17 @@ import type { BleError } from './BleError'
|
|
|
6
6
|
import type { Characteristic } from './Characteristic'
|
|
7
7
|
import type { Descriptor } from './Descriptor'
|
|
8
8
|
import type { NativeService } from './BleModule'
|
|
9
|
-
import type {
|
|
9
|
+
import type {
|
|
10
|
+
DeviceId,
|
|
11
|
+
Identifier,
|
|
12
|
+
Base64,
|
|
13
|
+
UUID,
|
|
14
|
+
Subscription,
|
|
15
|
+
TransactionId,
|
|
16
|
+
CharacteristicSubscriptionType
|
|
17
|
+
} from './TypeDefinition'
|
|
18
|
+
import { isIOS } from './Utils'
|
|
19
|
+
|
|
10
20
|
|
|
11
21
|
/**
|
|
12
22
|
* Service object.
|
|
@@ -43,7 +53,8 @@ export class Service implements NativeService {
|
|
|
43
53
|
* @ignore
|
|
44
54
|
*/
|
|
45
55
|
constructor(nativeService: NativeService, manager: BleManager) {
|
|
46
|
-
Object.assign(this, nativeService
|
|
56
|
+
Object.assign(this, nativeService)
|
|
57
|
+
Object.defineProperty(this, '_manager', { value: manager, enumerable: false })
|
|
47
58
|
}
|
|
48
59
|
|
|
49
60
|
/**
|
|
@@ -133,15 +144,20 @@ export class Service implements NativeService {
|
|
|
133
144
|
* @param {function(error: ?BleError, characteristic: ?Characteristic)} listener callback which emits
|
|
134
145
|
* {@link Characteristic} objects with modified value for each notification.
|
|
135
146
|
* @param {?TransactionId} transactionId optional `transactionId` which can be used in
|
|
147
|
+
* @param {?CharacteristicSubscriptionType} subscriptionType subscription type of the characteristic
|
|
136
148
|
* {@link #blemanagercanceltransaction|bleManager.cancelTransaction()} function.
|
|
137
149
|
* @returns {Subscription} Subscription on which `remove()` function can be called to unsubscribe.
|
|
138
150
|
*/
|
|
139
151
|
monitorCharacteristic(
|
|
140
152
|
characteristicUUID: UUID,
|
|
141
153
|
listener: (error: ?BleError, characteristic: ?Characteristic) => void,
|
|
142
|
-
transactionId: ?TransactionId
|
|
154
|
+
transactionId: ?TransactionId,
|
|
155
|
+
subscriptionType: ?CharacteristicSubscriptionType
|
|
143
156
|
): Subscription {
|
|
144
|
-
|
|
157
|
+
const commonArgs = [this.id, characteristicUUID, listener, transactionId]
|
|
158
|
+
const args = isIOS ? commonArgs : [...commonArgs, subscriptionType]
|
|
159
|
+
|
|
160
|
+
return this._manager._monitorCharacteristicForService(...args)
|
|
145
161
|
}
|
|
146
162
|
|
|
147
163
|
/**
|
package/src/TypeDefinition.js
CHANGED
|
@@ -29,6 +29,11 @@ export type Base64 = string
|
|
|
29
29
|
*/
|
|
30
30
|
export type TransactionId = string
|
|
31
31
|
|
|
32
|
+
/**
|
|
33
|
+
* Characteritic subscription type.
|
|
34
|
+
*/
|
|
35
|
+
export type CharacteristicSubscriptionType = 'notification' | 'indication'
|
|
36
|
+
|
|
32
37
|
/**
|
|
33
38
|
* [Android only] ConnectionOptions parameter to describe when to call BluetoothGatt.refresh()
|
|
34
39
|
*/
|
package/src/Utils.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// @flow
|
|
2
2
|
'use strict'
|
|
3
3
|
|
|
4
|
+
import { Platform } from 'react-native'
|
|
4
5
|
import type { UUID } from './TypeDefinition'
|
|
5
6
|
|
|
6
7
|
/**
|
|
@@ -24,3 +25,5 @@ export function fillStringWithArguments(value: string, object: Object): string {
|
|
|
24
25
|
return object[arg] || '?'
|
|
25
26
|
})
|
|
26
27
|
}
|
|
28
|
+
|
|
29
|
+
export const isIOS = Platform.OS === 'ios'
|
package/src/index.d.ts
CHANGED
|
@@ -25,6 +25,11 @@ declare module 'react-native-ble-plx' {
|
|
|
25
25
|
* Transaction identifier. All transaction identifiers in numeric form are reserved for internal use.
|
|
26
26
|
*/
|
|
27
27
|
export type TransactionId = string
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Characteritic subscription type.
|
|
31
|
+
*/
|
|
32
|
+
export type CharacteristicSubscriptionType = 'notification' | 'indication'
|
|
28
33
|
|
|
29
34
|
/**
|
|
30
35
|
* Subscription
|
|
@@ -1397,6 +1402,7 @@ declare module 'react-native-ble-plx' {
|
|
|
1397
1402
|
* @param {function(error?: BleError, characteristic?: Characteristic)} listener - callback which emits
|
|
1398
1403
|
* {@link Characteristic} objects with modified value for each notification.
|
|
1399
1404
|
* @param {?TransactionId} transactionId optional `transactionId` which can be used in
|
|
1405
|
+
* @param {?CharacteristicSubscriptionType} subscriptionType subscription type of the characteristic
|
|
1400
1406
|
* {@link #blemanagercanceltransaction|cancelTransaction()} function.
|
|
1401
1407
|
* @returns {Subscription} Subscription on which `remove()` function can be called to unsubscribe.
|
|
1402
1408
|
*/
|
|
@@ -1405,7 +1411,8 @@ declare module 'react-native-ble-plx' {
|
|
|
1405
1411
|
serviceUUID: UUID,
|
|
1406
1412
|
characteristicUUID: UUID,
|
|
1407
1413
|
listener: (error: BleError | null, characteristic: Characteristic | null) => void,
|
|
1408
|
-
transactionId?: TransactionId
|
|
1414
|
+
transactionId?: TransactionId,
|
|
1415
|
+
subscriptionType?: CharacteristicSubscriptionType
|
|
1409
1416
|
): Subscription
|
|
1410
1417
|
|
|
1411
1418
|
// Mark: Descriptors operations ----------------------------------------------------------------------------------
|
|
@@ -1689,6 +1696,7 @@ declare module 'react-native-ble-plx' {
|
|
|
1689
1696
|
* @param {function(error: ?BleError, characteristic: ?Characteristic)} listener - callback which emits
|
|
1690
1697
|
* {@link Characteristic} objects with modified value for each notification.
|
|
1691
1698
|
* @param {?TransactionId} transactionId optional `transactionId` which can be used in
|
|
1699
|
+
* @param {?CharacteristicSubscriptionType} subscriptionType subscription type of the characteristic
|
|
1692
1700
|
* {@link #blemanagercanceltransaction|bleManager.cancelTransaction()} function.
|
|
1693
1701
|
* @returns {Subscription} Subscription on which `remove()` function can be called to unsubscribe.
|
|
1694
1702
|
*/
|
|
@@ -1696,7 +1704,8 @@ declare module 'react-native-ble-plx' {
|
|
|
1696
1704
|
serviceUUID: UUID,
|
|
1697
1705
|
characteristicUUID: UUID,
|
|
1698
1706
|
listener: (error: BleError | null, characteristic: Characteristic | null) => void,
|
|
1699
|
-
transactionId?: TransactionId
|
|
1707
|
+
transactionId?: TransactionId,
|
|
1708
|
+
subscriptionType?: CharacteristicSubscriptionType
|
|
1700
1709
|
): Subscription
|
|
1701
1710
|
|
|
1702
1711
|
/**
|
|
@@ -1839,13 +1848,15 @@ declare module 'react-native-ble-plx' {
|
|
|
1839
1848
|
* @param {function(error?: BleError, characteristic?: Characteristic)} listener callback which emits
|
|
1840
1849
|
* {@link Characteristic} objects with modified value for each notification.
|
|
1841
1850
|
* @param {?TransactionId} transactionId optional `transactionId` which can be used in
|
|
1851
|
+
* @param {?CharacteristicSubscriptionType} subscriptionType subscription type of the characteristic
|
|
1842
1852
|
* {@link #blemanagercanceltransaction|bleManager.cancelTransaction()} function.
|
|
1843
1853
|
* @returns {Subscription} Subscription on which `remove()` function can be called to unsubscribe.
|
|
1844
1854
|
*/
|
|
1845
1855
|
monitorCharacteristic(
|
|
1846
1856
|
characteristicUUID: UUID,
|
|
1847
1857
|
listener: (error: BleError | null, characteristic: Characteristic | null) => void,
|
|
1848
|
-
transactionId?: string
|
|
1858
|
+
transactionId?: string,
|
|
1859
|
+
subscriptionType?: CharacteristicSubscriptionType
|
|
1849
1860
|
): Subscription
|
|
1850
1861
|
|
|
1851
1862
|
/**
|
|
@@ -2001,12 +2012,14 @@ declare module 'react-native-ble-plx' {
|
|
|
2001
2012
|
* @param {function(error?: BleError, characteristic?: Characteristic)} listener callback which emits
|
|
2002
2013
|
* this {@link Characteristic} with modified value for each notification.
|
|
2003
2014
|
* @param {?TransactionId} transactionId optional `transactionId` which can be used in
|
|
2015
|
+
* @param {?CharacteristicSubscriptionType} subscriptionType [android only] subscription type of the characteristic
|
|
2004
2016
|
* {@link #blemanagercanceltransaction|bleManager.cancelTransaction()} function.
|
|
2005
2017
|
* @returns {Subscription} Subscription on which `remove()` function can be called to unsubscribe.
|
|
2006
2018
|
*/
|
|
2007
2019
|
monitor(
|
|
2008
2020
|
listener: (error: BleError | null, characteristic: Characteristic | null) => void,
|
|
2009
|
-
transactionId?: string
|
|
2021
|
+
transactionId?: string,
|
|
2022
|
+
subscriptionType?: CharacteristicSubscriptionType
|
|
2010
2023
|
): Subscription
|
|
2011
2024
|
|
|
2012
2025
|
/**
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MIT License
|
|
3
|
-
*
|
|
4
|
-
* Copyright (C) 2024 Huawei Device Co., Ltd.
|
|
5
|
-
*
|
|
6
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
-
* in the Software without restriction, including without limitation the rights
|
|
9
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
-
* furnished to do so, subject to the following conditions:
|
|
12
|
-
*
|
|
13
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
-
* copies or substantial portions of the Software.
|
|
15
|
-
*
|
|
16
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
-
* SOFTWARE.
|
|
23
|
-
*/
|
|
24
|
-
#ifndef BLEPLXPACKAGE_H
|
|
25
|
-
#define BLEPLXPACKAGE_H
|
|
26
|
-
|
|
27
|
-
#include "generated/RNOH/generated/BaseReactNativeBlePlxPackage.h"
|
|
28
|
-
#pragma once
|
|
29
|
-
|
|
30
|
-
namespace rnoh {
|
|
31
|
-
class BlePlxPackage : public BaseReactNativeBlePlxPackage {
|
|
32
|
-
using Super = BaseReactNativeBlePlxPackage;
|
|
33
|
-
using Super::Super;
|
|
34
|
-
};
|
|
35
|
-
} // namespace rnoh
|
|
36
|
-
#endif // BLEPLXPACKAGE_H
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
-
*
|
|
5
|
-
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
-
* once the code is regenerated.
|
|
7
|
-
*
|
|
8
|
-
* @generated by codegen project: GenerateComponentDescriptorH.js
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
#pragma once
|
|
12
|
-
|
|
13
|
-
#include <react/renderer/components/react_native_ble_plx/ShadowNodes.h>
|
|
14
|
-
#include <react/renderer/core/ConcreteComponentDescriptor.h>
|
|
15
|
-
|
|
16
|
-
namespace facebook {
|
|
17
|
-
namespace react {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
} // namespace react
|
|
22
|
-
} // namespace facebook
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
-
*
|
|
5
|
-
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
-
* once the code is regenerated.
|
|
7
|
-
*
|
|
8
|
-
* @generated by codegen project: GenerateEventEmitterCpp.js
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
#include <react/renderer/components/react_native_ble_plx/EventEmitters.h>
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
namespace facebook {
|
|
15
|
-
namespace react {
|
|
16
|
-
|
|
17
|
-
} // namespace react
|
|
18
|
-
} // namespace facebook
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
-
*
|
|
5
|
-
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
-
* once the code is regenerated.
|
|
7
|
-
*
|
|
8
|
-
* @generated by codegen project: GenerateEventEmitterH.js
|
|
9
|
-
*/
|
|
10
|
-
#pragma once
|
|
11
|
-
|
|
12
|
-
#include <react/renderer/components/view/ViewEventEmitter.h>
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
namespace facebook {
|
|
16
|
-
namespace react {
|
|
17
|
-
|
|
18
|
-
} // namespace react
|
|
19
|
-
} // namespace facebook
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
-
*
|
|
5
|
-
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
-
* once the code is regenerated.
|
|
7
|
-
*
|
|
8
|
-
* @generated by codegen project: GeneratePropsCpp.js
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
#include <react/renderer/components/react_native_ble_plx/Props.h>
|
|
12
|
-
#include <react/renderer/core/PropsParserContext.h>
|
|
13
|
-
#include <react/renderer/core/propsConversions.h>
|
|
14
|
-
|
|
15
|
-
namespace facebook {
|
|
16
|
-
namespace react {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
} // namespace react
|
|
21
|
-
} // namespace facebook
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
-
*
|
|
5
|
-
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
-
* once the code is regenerated.
|
|
7
|
-
*
|
|
8
|
-
* @generated by codegen project: GeneratePropsH.js
|
|
9
|
-
*/
|
|
10
|
-
#pragma once
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
namespace facebook {
|
|
15
|
-
namespace react {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
} // namespace react
|
|
20
|
-
} // namespace facebook
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
-
*
|
|
5
|
-
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
-
* once the code is regenerated.
|
|
7
|
-
*
|
|
8
|
-
* @generated by codegen project: GenerateShadowNodeCpp.js
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
#include <react/renderer/components/react_native_ble_plx/ShadowNodes.h>
|
|
12
|
-
|
|
13
|
-
namespace facebook {
|
|
14
|
-
namespace react {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
} // namespace react
|
|
19
|
-
} // namespace facebook
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
-
*
|
|
5
|
-
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
-
* once the code is regenerated.
|
|
7
|
-
*
|
|
8
|
-
* @generated by codegen project: GenerateShadowNodeH.js
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
#pragma once
|
|
12
|
-
|
|
13
|
-
#include <react/renderer/components/react_native_ble_plx/EventEmitters.h>
|
|
14
|
-
#include <react/renderer/components/react_native_ble_plx/Props.h>
|
|
15
|
-
#include <react/renderer/components/react_native_ble_plx/States.h>
|
|
16
|
-
#include <react/renderer/components/view/ConcreteViewShadowNode.h>
|
|
17
|
-
#include <jsi/jsi.h>
|
|
18
|
-
|
|
19
|
-
namespace facebook {
|
|
20
|
-
namespace react {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
} // namespace react
|
|
25
|
-
} // namespace facebook
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
-
*
|
|
5
|
-
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
-
* once the code is regenerated.
|
|
7
|
-
*
|
|
8
|
-
* @generated by codegen project: GenerateStateCpp.js
|
|
9
|
-
*/
|
|
10
|
-
#include <react/renderer/components/react_native_ble_plx/States.h>
|
|
11
|
-
|
|
12
|
-
namespace facebook {
|
|
13
|
-
namespace react {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
} // namespace react
|
|
18
|
-
} // namespace facebook
|
|
@@ -1,23 +0,0 @@
|
|
|
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: GenerateStateH.js
|
|
8
|
-
*/
|
|
9
|
-
#pragma once
|
|
10
|
-
|
|
11
|
-
#ifdef ANDROID
|
|
12
|
-
#include <folly/dynamic.h>
|
|
13
|
-
#include <react/renderer/mapbuffer/MapBuffer.h>
|
|
14
|
-
#include <react/renderer/mapbuffer/MapBufferBuilder.h>
|
|
15
|
-
#endif
|
|
16
|
-
|
|
17
|
-
namespace facebook {
|
|
18
|
-
namespace react {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
} // namespace react
|
|
23
|
-
} // namespace facebook
|