@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
|
@@ -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 { BleError } from './BleError';
|
|
26
6
|
|
|
@@ -60,4 +40,4 @@ export class BleErrorToJsObjectConverter {
|
|
|
60
40
|
obj[key] = null;
|
|
61
41
|
}
|
|
62
42
|
}
|
|
63
|
-
}
|
|
43
|
+
}
|
|
@@ -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
|
export const BleEvent = {
|
|
26
6
|
scanEvent: 'ScanEvent',
|
|
@@ -30,4 +10,4 @@ export const BleEvent = {
|
|
|
30
10
|
disconnectionEvent: 'DisconnectionEvent',
|
|
31
11
|
connectingEvent: 'ConnectingEvent',
|
|
32
12
|
connectedEvent: 'ConnectedEvent'
|
|
33
|
-
}
|
|
13
|
+
}
|
|
@@ -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 { ValuesBucket } from '@kit.ArkData';
|
|
26
6
|
import { ble } from '@kit.ConnectivityKit';
|
|
@@ -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 { IdGeneratorKey } from './IdGeneratorKey';
|
|
26
6
|
|
|
@@ -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
|
export class IdGeneratorKey {
|
|
26
6
|
readonly deviceAddress: string;
|
|
@@ -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
|
export class InstanceIdGenerator {
|
|
26
6
|
static instanceMap: Map<string, number> = new Map();
|
|
@@ -34,4 +14,4 @@ export class InstanceIdGenerator {
|
|
|
34
14
|
}
|
|
35
15
|
return value;
|
|
36
16
|
}
|
|
37
|
-
}
|
|
17
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* MIT License
|
|
3
3
|
*
|
|
4
|
-
* Copyright (C)
|
|
4
|
+
* Copyright (C) 2025 Huawei Device Co., Ltd.
|
|
5
5
|
*
|
|
6
6
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
7
|
* of this software and associated documentation files (the "Software"), to deal
|
|
@@ -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 bundleManager from '@ohos.bundle.bundleManager';
|
|
26
6
|
import abilityAccessCtrl, { Permissions } from '@ohos.abilityAccessCtrl';
|
|
@@ -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 ble from '@ohos.bluetooth.ble';
|
|
26
6
|
import { InstanceIdGenerator } from './InstanceIdGenerator';
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* This code was generated by "react-native codegen-
|
|
2
|
+
* This code was generated by "react-native codegen-harmony"
|
|
3
|
+
*
|
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be
|
|
5
|
+
* lost once the code is regenerated.
|
|
3
6
|
*/
|
|
4
7
|
|
|
5
8
|
export * from "./ts"
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* This code was generated by "react-native codegen-
|
|
2
|
+
* This code was generated by "react-native codegen-harmony"
|
|
3
|
+
*
|
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be
|
|
5
|
+
* lost once the code is regenerated.
|
|
3
6
|
*/
|
|
4
7
|
|
|
5
8
|
export * as RNC from "./components/ts"
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* This code was generated by "react-native codegen-
|
|
2
|
+
* This code was generated by "react-native codegen-harmony"
|
|
3
|
+
*
|
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be
|
|
5
|
+
* lost once the code is regenerated.
|
|
6
|
+
*
|
|
7
|
+
* @generatorVersion: 1
|
|
3
8
|
*/
|
|
4
9
|
|
|
5
10
|
import { Tag } from "@rnoh/react-native-openharmony/ts"
|
|
@@ -74,11 +79,11 @@ export namespace BlePlx {
|
|
|
74
79
|
|
|
75
80
|
writeCharacteristic(characteristicIdentifier: number, valueBase64: string, response: boolean, transactionId: string): Promise<Object>;
|
|
76
81
|
|
|
77
|
-
monitorCharacteristicForDevice(deviceId: string, serviceUUID: string, characteristicUUID: string, transactionId: string): Promise<void>;
|
|
82
|
+
monitorCharacteristicForDevice(deviceId: string, serviceUUID: string, characteristicUUID: string, transactionId: string, subscriptionType: string): Promise<void>;
|
|
78
83
|
|
|
79
|
-
monitorCharacteristicForService(serviceIdentifier: number, characteristicUUID: string, transactionId: string): Promise<void>;
|
|
84
|
+
monitorCharacteristicForService(serviceIdentifier: number, characteristicUUID: string, transactionId: string, subscriptionType: string): Promise<void>;
|
|
80
85
|
|
|
81
|
-
monitorCharacteristic(characteristicIdentifier: number, transactionId: string): Promise<void>;
|
|
86
|
+
monitorCharacteristic(characteristicIdentifier: number, transactionId: string, subscriptionType: string): Promise<void>;
|
|
82
87
|
|
|
83
88
|
readDescriptorForDevice(deviceId: string, serviceUUID: string, characteristicUUID: string, descriptorUUID: string, transactionId: string): Promise<Object>;
|
|
84
89
|
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* This code was generated by "react-native codegen-
|
|
2
|
+
* This code was generated by "react-native codegen-harmony"
|
|
3
|
+
*
|
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be
|
|
5
|
+
* lost once the code is regenerated.
|
|
3
6
|
*/
|
|
4
7
|
|
|
5
8
|
export * from "./BlePlx"
|
package/harmony/rn_bleplx.har
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-native-ohos/react-native-ble-plx",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.5.1",
|
|
4
4
|
"description": "React Native Bluetooth Low Energy library",
|
|
5
5
|
"main": "src/index",
|
|
6
6
|
"module": "src/index",
|
|
@@ -11,19 +11,11 @@
|
|
|
11
11
|
"@react-native/codegen": "0.74.0"
|
|
12
12
|
},
|
|
13
13
|
"harmony": {
|
|
14
|
-
"alias": "react-native-ble-plx"
|
|
15
|
-
"autolinking": {
|
|
16
|
-
"etsPackageClassName":"BlePlxPackage",
|
|
17
|
-
"cppPackageClassName":"BlePlxPackage",
|
|
18
|
-
"cmakeLibraryTargetName": "rnoh_ble_plx",
|
|
19
|
-
"ohPackageName": "@react-native-ohos/react-native-ble-plx"
|
|
20
|
-
}
|
|
14
|
+
"alias": "react-native-ble-plx"
|
|
21
15
|
},
|
|
22
16
|
"files": [
|
|
23
17
|
"src",
|
|
24
18
|
"lib",
|
|
25
|
-
"android",
|
|
26
|
-
"ios",
|
|
27
19
|
"cpp",
|
|
28
20
|
"harmony",
|
|
29
21
|
"plugin/build",
|
|
@@ -58,12 +50,10 @@
|
|
|
58
50
|
"clean:plugin": "expo-module clean plugin",
|
|
59
51
|
"test:plugin": "jest --config plugin/jest.config.js",
|
|
60
52
|
"lint:plugin": "eslint plugin/src/*",
|
|
61
|
-
"codegen-lib": "react-native codegen-lib-harmony --no-safety-check --npm-package-name
|
|
53
|
+
"codegen-lib": "react-native codegen-lib-harmony --no-safety-check --npm-package-name rn_bleplx --cpp-output-path ../harmony/rn_bleplx/src/main/cpp/generated --ets-output-path ../harmony/rn_bleplx/src/main/ets/generated --turbo-modules-spec-paths ./src"
|
|
62
54
|
},
|
|
63
55
|
"keywords": [
|
|
64
56
|
"react-native",
|
|
65
|
-
"ios",
|
|
66
|
-
"android",
|
|
67
57
|
"React",
|
|
68
58
|
"Native",
|
|
69
59
|
"Bluetooth",
|
|
@@ -73,9 +63,8 @@
|
|
|
73
63
|
],
|
|
74
64
|
"repository": {
|
|
75
65
|
"type": "git",
|
|
76
|
-
"url": "https://gitcode.com/openharmony-sig/rntpc_react-native-ble-plx"
|
|
66
|
+
"url": "git+https://gitcode.com/openharmony-sig/rntpc_react-native-ble-plx.git"
|
|
77
67
|
},
|
|
78
|
-
"author": "dotintent (https://withintent.com/)",
|
|
79
68
|
"license": "MIT",
|
|
80
69
|
"bugs": {
|
|
81
70
|
"url": "https://gitcode.com/openharmony-sig/rntpc_react-native-ble-plx/issues"
|
|
@@ -90,6 +79,7 @@
|
|
|
90
79
|
"@babel/preset-flow": "^7.22.15",
|
|
91
80
|
"@commitlint/config-conventional": "^17.0.2",
|
|
92
81
|
"@evilmartians/lefthook": "^1.5.0",
|
|
82
|
+
"@react-native-community/cli": "^15.0.1",
|
|
93
83
|
"@react-native-community/eslint-config": "^3.0.2",
|
|
94
84
|
"@react-native/eslint-config": "^0.73.1",
|
|
95
85
|
"@release-it/conventional-changelog": "^5.0.0",
|
|
@@ -117,19 +107,20 @@
|
|
|
117
107
|
"jest": "^29.7.0",
|
|
118
108
|
"pod-install": "^0.1.0",
|
|
119
109
|
"prettier": "^3.0.3",
|
|
120
|
-
"react": "18.
|
|
121
|
-
"react-native": "0.
|
|
110
|
+
"react": "18.3.1",
|
|
111
|
+
"react-native": "0.77.1",
|
|
122
112
|
"react-native-builder-bob": "^0.20.0",
|
|
123
113
|
"release-it": "^17.3.0",
|
|
124
114
|
"turbo": "^1.10.7",
|
|
125
|
-
"typescript": "^5.2.2"
|
|
115
|
+
"typescript": "^5.2.2",
|
|
116
|
+
"@react-native-oh/react-native-harmony-cli": "file:packages/rnoh-react-native-harmony-cli-0.77.10.tgz"
|
|
126
117
|
},
|
|
127
118
|
"resolutions": {
|
|
128
119
|
"@types/react": "^18.2.44"
|
|
129
120
|
},
|
|
130
121
|
"dependencies": {
|
|
131
122
|
"@expo/config-plugins": "^7.2.5 || ^8.0.0",
|
|
132
|
-
"react-native-ble-plx": "3.
|
|
123
|
+
"react-native-ble-plx": "3.5.0"
|
|
133
124
|
},
|
|
134
125
|
"peerDependencies": {
|
|
135
126
|
"react": "*",
|
|
@@ -182,4 +173,4 @@
|
|
|
182
173
|
]
|
|
183
174
|
]
|
|
184
175
|
}
|
|
185
|
-
}
|
|
176
|
+
}
|
package/src/BleManager.js
CHANGED
|
@@ -5,7 +5,7 @@ import { Device } from './Device'
|
|
|
5
5
|
import { Service } from './Service'
|
|
6
6
|
import { Characteristic } from './Characteristic'
|
|
7
7
|
import { Descriptor } from './Descriptor'
|
|
8
|
-
import { State, LogLevel,
|
|
8
|
+
import { State, LogLevel, ConnectionPriority } from './TypeDefinition'
|
|
9
9
|
// import { BleModule, EventEmitter } from './BleModule'
|
|
10
10
|
import { EventEmitter } from './BleModule'
|
|
11
11
|
import BleModule from './NativeBlePlx'
|
|
@@ -20,16 +20,19 @@ import {
|
|
|
20
20
|
} from './BleError'
|
|
21
21
|
import type { NativeDevice, NativeCharacteristic, NativeDescriptor, NativeBleRestoredState } from './BleModule'
|
|
22
22
|
import type {
|
|
23
|
+
BleErrorCodeMessageMapping,
|
|
23
24
|
Subscription,
|
|
24
25
|
DeviceId,
|
|
25
26
|
Identifier,
|
|
26
27
|
UUID,
|
|
27
28
|
TransactionId,
|
|
29
|
+
CharacteristicSubscriptionType,
|
|
28
30
|
Base64,
|
|
29
31
|
ScanOptions,
|
|
30
32
|
ConnectionOptions,
|
|
31
33
|
BleManagerOptions
|
|
32
34
|
} from './TypeDefinition'
|
|
35
|
+
import { isIOS } from './Utils'
|
|
33
36
|
import { Platform } from 'react-native'
|
|
34
37
|
|
|
35
38
|
const enableDisableDeprecatedMessage =
|
|
@@ -65,11 +68,20 @@ export class BleManager {
|
|
|
65
68
|
|
|
66
69
|
// Map of error codes to error messages
|
|
67
70
|
_errorCodesToMessagesMapping: BleErrorCodeMessageMapping
|
|
71
|
+
|
|
72
|
+
static sharedInstance: BleManager | null = null
|
|
68
73
|
|
|
69
74
|
/**
|
|
70
75
|
* Creates an instance of {@link BleManager}.
|
|
76
|
+
* It will return already created instance if it was created before.
|
|
77
|
+
* If you want to create a new instance to for example use different options, you have to call {@link #blemanagerdestroy|destroy()} on the previous one.
|
|
71
78
|
*/
|
|
72
79
|
constructor(options: BleManagerOptions = {}) {
|
|
80
|
+
if (BleManager.sharedInstance !== null) {
|
|
81
|
+
// $FlowFixMe - Constructor returns shared instance for singleton pattern
|
|
82
|
+
return BleManager.sharedInstance
|
|
83
|
+
}
|
|
84
|
+
|
|
73
85
|
this._eventEmitter = new EventEmitter(BleModule)
|
|
74
86
|
this._uniqueId = 0
|
|
75
87
|
this._activePromises = {}
|
|
@@ -99,6 +111,7 @@ export class BleManager {
|
|
|
99
111
|
: BleErrorCodeMessage
|
|
100
112
|
|
|
101
113
|
BleModule.createClient(options.restoreStateIdentifier || null)
|
|
114
|
+
BleManager.sharedInstance = this
|
|
102
115
|
}
|
|
103
116
|
|
|
104
117
|
/**
|
|
@@ -137,7 +150,7 @@ export class BleManager {
|
|
|
137
150
|
* @returns {Promise<void>} Promise may return an error when the function cannot be called.
|
|
138
151
|
* {@link #bleerrorcodebluetoothmanagerdestroyed|BluetoothManagerDestroyed} error code.
|
|
139
152
|
*/
|
|
140
|
-
|
|
153
|
+
async destroy(): Promise<void> {
|
|
141
154
|
const response = await this._callPromise(BleModule.destroyClient())
|
|
142
155
|
|
|
143
156
|
// Unsubscribe from any subscriptions
|
|
@@ -146,6 +159,10 @@ export class BleManager {
|
|
|
146
159
|
this._scanEventSubscription = null
|
|
147
160
|
}
|
|
148
161
|
this._destroySubscriptions()
|
|
162
|
+
|
|
163
|
+
if (BleManager.sharedInstance) {
|
|
164
|
+
BleManager.sharedInstance = null
|
|
165
|
+
}
|
|
149
166
|
|
|
150
167
|
// Destroy all promises
|
|
151
168
|
this._destroyPromises()
|
|
@@ -231,7 +248,7 @@ export class BleManager {
|
|
|
231
248
|
* @param {TransactionId} transactionId Id of pending transactions.
|
|
232
249
|
* @returns {Promise<void>}
|
|
233
250
|
*/
|
|
234
|
-
cancelTransaction(transactionId: TransactionId) {
|
|
251
|
+
cancelTransaction(transactionId: TransactionId): Promise<void> {
|
|
235
252
|
return this._callPromise(BleModule.cancelTransaction(transactionId))
|
|
236
253
|
}
|
|
237
254
|
|
|
@@ -273,7 +290,7 @@ export class BleManager {
|
|
|
273
290
|
*
|
|
274
291
|
* @returns {Promise<State>} Promise which emits current state of BleManager.
|
|
275
292
|
*/
|
|
276
|
-
state
|
|
293
|
+
state(): Promise<$Keys<typeof State>> {
|
|
277
294
|
return this._callPromise(BleModule.state())
|
|
278
295
|
}
|
|
279
296
|
|
|
@@ -294,10 +311,10 @@ export class BleManager {
|
|
|
294
311
|
*
|
|
295
312
|
* @returns {Subscription} Subscription on which `remove()` function can be called to unsubscribe.
|
|
296
313
|
*/
|
|
297
|
-
onStateChange
|
|
314
|
+
onStateChange(
|
|
298
315
|
listener: (newState: $Keys<typeof State>) => void,
|
|
299
316
|
emitCurrentState: boolean = false
|
|
300
|
-
): Subscription
|
|
317
|
+
): Subscription {
|
|
301
318
|
const subscription: Subscription = this._eventEmitter.addListener(Platform.OS === 'harmony' ? 'StateChangeEvent' : BleModule.StateChangeEvent, listener)
|
|
302
319
|
const id = this._nextUniqueID()
|
|
303
320
|
var wrappedSubscription: Subscription
|
|
@@ -305,7 +322,6 @@ export class BleManager {
|
|
|
305
322
|
if (emitCurrentState) {
|
|
306
323
|
var cancelled = false
|
|
307
324
|
this._callPromise(this.state()).then(currentState => {
|
|
308
|
-
console.log(currentState)
|
|
309
325
|
if (!cancelled) {
|
|
310
326
|
listener(currentState)
|
|
311
327
|
}
|
|
@@ -354,7 +370,7 @@ export class BleManager {
|
|
|
354
370
|
UUIDs: ?Array<UUID>,
|
|
355
371
|
options: ?ScanOptions,
|
|
356
372
|
listener: (error: ?BleError, scannedDevice: ?Device) => Promise<void>
|
|
357
|
-
) {
|
|
373
|
+
): Promise<void> {
|
|
358
374
|
const scanListener = ([error, nativeDevice]: [?string, ?NativeDevice]) => {
|
|
359
375
|
listener(
|
|
360
376
|
error ? parseBleError(error, this._errorCodesToMessagesMapping) : null,
|
|
@@ -371,7 +387,7 @@ export class BleManager {
|
|
|
371
387
|
* Stops {@link Device} scan if in progress.
|
|
372
388
|
* @returns {Promise<void>} the promise may be rejected if the operation is impossible to perform.
|
|
373
389
|
*/
|
|
374
|
-
stopDeviceScan
|
|
390
|
+
stopDeviceScan (): Promise<void> {
|
|
375
391
|
if (this._scanEventSubscription != null) {
|
|
376
392
|
this._scanEventSubscription.remove()
|
|
377
393
|
this._scanEventSubscription = null
|
|
@@ -400,7 +416,15 @@ export class BleManager {
|
|
|
400
416
|
const nativeDevice = await this._callPromise(
|
|
401
417
|
BleModule.requestConnectionPriorityForDevice(deviceIdentifier, connectionPriority, transactionId)
|
|
402
418
|
)
|
|
403
|
-
|
|
419
|
+
const services = await this._callPromise(BleModule.servicesForDevice(deviceIdentifier))
|
|
420
|
+
const serviceUUIDs = (services || []).map(service => service.uuid)
|
|
421
|
+
|
|
422
|
+
// $FlowFixMe
|
|
423
|
+
const device = {
|
|
424
|
+
...nativeDevice,
|
|
425
|
+
serviceUUIDs
|
|
426
|
+
}
|
|
427
|
+
return new Device(device, this)
|
|
404
428
|
}
|
|
405
429
|
|
|
406
430
|
/**
|
|
@@ -941,11 +965,15 @@ export class BleManager {
|
|
|
941
965
|
serviceUUID: UUID,
|
|
942
966
|
characteristicUUID: UUID,
|
|
943
967
|
listener: (error: ?BleError, characteristic: ?Characteristic) => void,
|
|
944
|
-
transactionId: ?TransactionId
|
|
968
|
+
transactionId: ?TransactionId,
|
|
969
|
+
subscriptionType: ?CharacteristicSubscriptionType
|
|
945
970
|
): Subscription {
|
|
946
971
|
const filledTransactionId = transactionId || this._nextUniqueID()
|
|
972
|
+
const commonArgs = [deviceIdentifier, serviceUUID, characteristicUUID, filledTransactionId]
|
|
973
|
+
const args = isIOS ? commonArgs : [...commonArgs, subscriptionType]
|
|
974
|
+
|
|
947
975
|
return this._handleMonitorCharacteristic(
|
|
948
|
-
BleModule.monitorCharacteristicForDevice(
|
|
976
|
+
BleModule.monitorCharacteristicForDevice(...args),
|
|
949
977
|
filledTransactionId,
|
|
950
978
|
listener
|
|
951
979
|
)
|
|
@@ -968,11 +996,15 @@ export class BleManager {
|
|
|
968
996
|
serviceIdentifier: Identifier,
|
|
969
997
|
characteristicUUID: UUID,
|
|
970
998
|
listener: (error: ?BleError, characteristic: ?Characteristic) => void,
|
|
971
|
-
transactionId: ?TransactionId
|
|
999
|
+
transactionId: ?TransactionId,
|
|
1000
|
+
subscriptionType: ?CharacteristicSubscriptionType
|
|
972
1001
|
): Subscription {
|
|
973
1002
|
const filledTransactionId = transactionId || this._nextUniqueID()
|
|
1003
|
+
const commonArgs = [serviceIdentifier, characteristicUUID, filledTransactionId]
|
|
1004
|
+
const args = isIOS ? commonArgs : [...commonArgs, subscriptionType]
|
|
1005
|
+
|
|
974
1006
|
return this._handleMonitorCharacteristic(
|
|
975
|
-
BleModule.monitorCharacteristicForService(
|
|
1007
|
+
BleModule.monitorCharacteristicForService(...args),
|
|
976
1008
|
filledTransactionId,
|
|
977
1009
|
listener
|
|
978
1010
|
)
|
|
@@ -986,6 +1018,7 @@ export class BleManager {
|
|
|
986
1018
|
* @param {function(error: ?BleError, characteristic: ?Characteristic)} listener - callback which emits
|
|
987
1019
|
* {@link Characteristic} objects with modified value for each notification.
|
|
988
1020
|
* @param {?TransactionId} transactionId optional `transactionId` which can be used in
|
|
1021
|
+
* @param {?CharacteristicSubscriptionType} subscriptionType subscription type of the characteristic
|
|
989
1022
|
* {@link #blemanagercanceltransaction|cancelTransaction()} function.
|
|
990
1023
|
* @returns {Subscription} Subscription on which `remove()` function can be called to unsubscribe.
|
|
991
1024
|
* @private
|
|
@@ -993,13 +1026,17 @@ export class BleManager {
|
|
|
993
1026
|
_monitorCharacteristic(
|
|
994
1027
|
characteristicIdentifier: Identifier,
|
|
995
1028
|
listener: (error: ?BleError, characteristic: ?Characteristic) => void,
|
|
996
|
-
transactionId: ?TransactionId
|
|
1029
|
+
transactionId: ?TransactionId,
|
|
1030
|
+
subscriptionType: ?CharacteristicSubscriptionType
|
|
997
1031
|
): Subscription {
|
|
998
1032
|
const filledTransactionId = transactionId || this._nextUniqueID()
|
|
1033
|
+
const commonArgs = [characteristicIdentifier, filledTransactionId]
|
|
1034
|
+
const args = isIOS ? commonArgs : [...commonArgs, subscriptionType]
|
|
1035
|
+
|
|
999
1036
|
return this._handleMonitorCharacteristic(
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1037
|
+
BleModule.monitorCharacteristic(...args),
|
|
1038
|
+
filledTransactionId,
|
|
1039
|
+
listener
|
|
1003
1040
|
)
|
|
1004
1041
|
}
|
|
1005
1042
|
|