react-native-ble-nitro 1.0.0-beta.9 → 1.1.0
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/BleNitro.podspec +39 -0
- package/LICENSE +1 -1
- package/README.md +277 -77
- package/ios/BleNitroBleManager.swift +457 -455
- package/ios/BlePeripheralDelegate.swift +174 -0
- package/lib/commonjs/index.d.ts +176 -10
- package/lib/commonjs/index.d.ts.map +1 -1
- package/lib/commonjs/index.js +398 -38
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/specs/NativeBleNitro.d.ts +5 -0
- package/lib/commonjs/specs/NativeBleNitro.d.ts.map +1 -0
- package/lib/commonjs/{utils/index.js → specs/NativeBleNitro.js} +6 -3
- package/lib/commonjs/specs/NativeBleNitro.js.map +1 -0
- package/lib/commonjs/specs/NativeBleNitro.nitro.d.ts +72 -0
- package/lib/commonjs/specs/NativeBleNitro.nitro.d.ts.map +1 -0
- package/lib/commonjs/specs/NativeBleNitro.nitro.js +14 -0
- package/lib/commonjs/specs/NativeBleNitro.nitro.js.map +1 -0
- package/lib/index.d.ts +176 -10
- package/lib/index.js +393 -16
- package/lib/specs/NativeBleNitro.d.ts +4 -0
- package/lib/specs/NativeBleNitro.js +5 -0
- package/lib/specs/NativeBleNitro.nitro.d.ts +71 -0
- package/lib/specs/NativeBleNitro.nitro.js +10 -0
- package/nitro.json +1 -1
- package/nitrogen/generated/android/BleNitro+autolinking.cmake +2 -10
- package/nitrogen/generated/android/BleNitroOnLoad.cpp +19 -22
- package/nitrogen/generated/android/c++/JBLEDevice.hpp +95 -0
- package/nitrogen/generated/android/c++/{JState.hpp → JBLEState.hpp} +22 -22
- package/nitrogen/generated/android/c++/JFunc_void_BLEDevice.hpp +82 -0
- package/nitrogen/generated/android/c++/JFunc_void_BLEState.hpp +76 -0
- package/nitrogen/generated/android/c++/JFunc_void_bool_std__string.hpp +75 -0
- package/nitrogen/generated/android/c++/JFunc_void_bool_std__string_std__string.hpp +75 -0
- package/nitrogen/generated/android/c++/JFunc_void_bool_std__vector_double__std__string.hpp +86 -0
- package/nitrogen/generated/android/c++/JFunc_void_std__string_bool_std__string.hpp +75 -0
- package/nitrogen/generated/android/c++/JFunc_void_std__string_std__vector_double_.hpp +86 -0
- package/nitrogen/generated/android/c++/JHybridNativeBleNitroSpec.cpp +212 -0
- package/nitrogen/generated/android/c++/JHybridNativeBleNitroSpec.hpp +82 -0
- package/nitrogen/generated/android/c++/JManufacturerData.hpp +73 -0
- package/nitrogen/generated/android/c++/JManufacturerDataEntry.hpp +68 -0
- package/nitrogen/generated/android/c++/JOperationResult.hpp +58 -0
- package/nitrogen/generated/android/c++/JScanFilter.hpp +79 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/BLEDevice.kt +44 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/{LogLevel.kt → BLEState.kt} +9 -13
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/{Func_void_State.kt → Func_void_BLEDevice.kt} +15 -14
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/{Func_void.kt → Func_void_BLEState.kt} +15 -14
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/{Func_void_std__optional_NativeBleError__std__optional_NativeDevice_.kt → Func_void_bool_std__string.kt} +15 -14
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/{Func_void_std__optional_NativeBleError__std__optional_NativeCharacteristic_.kt → Func_void_bool_std__string_std__string.kt} +15 -14
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/Func_void_bool_std__vector_double__std__string.kt +81 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/Func_void_std__string_bool_std__string.kt +81 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/Func_void_std__string_std__vector_double_.kt +81 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/HybridNativeBleNitroSpec.kt +174 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/{ServiceDataEntry.kt → ManufacturerData.kt} +7 -5
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/{NativeService.kt → ManufacturerDataEntry.kt} +10 -7
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/{ConnectionOptions.kt → OperationResult.kt} +10 -6
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/{BleRestoredState.kt → ScanFilter.kt} +13 -4
- package/nitrogen/generated/ios/BleNitro-Swift-Cxx-Bridge.cpp +56 -188
- package/nitrogen/generated/ios/BleNitro-Swift-Cxx-Bridge.hpp +210 -881
- package/nitrogen/generated/ios/BleNitro-Swift-Cxx-Umbrella.hpp +23 -88
- package/nitrogen/generated/ios/BleNitroAutolinking.mm +3 -3
- package/nitrogen/generated/ios/BleNitroAutolinking.swift +4 -4
- package/nitrogen/generated/ios/c++/{HybridCharacteristicSpecSwift.cpp → HybridNativeBleNitroSpecSwift.cpp} +2 -2
- package/nitrogen/generated/ios/c++/HybridNativeBleNitroSpecSwift.hpp +220 -0
- package/nitrogen/generated/ios/swift/BLEDevice.swift +102 -0
- package/nitrogen/generated/ios/swift/{State.swift → BLEState.swift} +6 -6
- package/nitrogen/generated/ios/swift/Func_void.swift +1 -0
- package/nitrogen/generated/ios/swift/{Func_void_bool.swift → Func_void_BLEDevice.swift} +12 -11
- package/nitrogen/generated/ios/swift/{Func_void_LogLevel.swift → Func_void_BLEState.swift} +12 -11
- package/nitrogen/generated/ios/swift/{Func_void_NativeDescriptor.swift → Func_void_bool_std__string.swift} +12 -11
- package/nitrogen/generated/ios/swift/{Func_void_std__vector_NativeCharacteristic_.swift → Func_void_bool_std__string_std__string.swift} +12 -11
- package/nitrogen/generated/ios/swift/Func_void_bool_std__vector_double__std__string.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +1 -0
- package/nitrogen/generated/ios/swift/{Func_void_std__vector_NativeDevice_.swift → Func_void_std__string_bool_std__string.swift} +12 -11
- package/nitrogen/generated/ios/swift/{Func_void_std__optional_BleRestoredState_.swift → Func_void_std__string_std__vector_double_.swift} +12 -17
- package/nitrogen/generated/ios/swift/HybridNativeBleNitroSpec.swift +67 -0
- package/nitrogen/generated/ios/swift/HybridNativeBleNitroSpec_cxx.swift +433 -0
- package/nitrogen/generated/ios/swift/ManufacturerData.swift +47 -0
- package/nitrogen/generated/ios/swift/ManufacturerDataEntry.swift +58 -0
- package/nitrogen/generated/ios/swift/{BleManagerNitroOptions.swift → OperationResult.swift} +22 -11
- package/nitrogen/generated/ios/swift/ScanFilter.swift +69 -0
- package/nitrogen/generated/shared/c++/BLEDevice.hpp +90 -0
- package/nitrogen/generated/shared/c++/{State.hpp → BLEState.hpp} +13 -15
- package/nitrogen/generated/shared/c++/HybridNativeBleNitroSpec.cpp +39 -0
- package/nitrogen/generated/shared/c++/HybridNativeBleNitroSpec.hpp +95 -0
- package/nitrogen/generated/shared/c++/ManufacturerData.hpp +69 -0
- package/nitrogen/generated/shared/c++/{ServiceDataEntry.hpp → ManufacturerDataEntry.hpp} +19 -20
- package/nitrogen/generated/shared/c++/{BleManagerNitroOptions.hpp → OperationResult.hpp} +19 -17
- package/nitrogen/generated/shared/c++/ScanFilter.hpp +76 -0
- package/package.json +9 -11
- package/react-native.config.js +2 -7
- package/src/__tests__/index.test.ts +185 -0
- package/src/index.ts +548 -45
- package/src/specs/NativeBleNitro.nitro.ts +88 -0
- package/src/specs/NativeBleNitro.ts +8 -0
- package/android/build.gradle +0 -58
- package/android/src/main/AndroidManifest.xml +0 -23
- package/android/src/main/kotlin/com/margelo/nitro/co/zyke/ble/BleNitroBleManager.kt +0 -760
- package/ios/BleNitro.podspec +0 -44
- package/ios/BleNitroModule.swift +0 -24
- package/lib/BleManagerCompatFactory.d.ts +0 -55
- package/lib/BleManagerCompatFactory.js +0 -194
- package/lib/BleManagerFactory.d.ts +0 -30
- package/lib/BleManagerFactory.js +0 -73
- package/lib/commonjs/BleManagerCompatFactory.d.ts +0 -56
- package/lib/commonjs/BleManagerCompatFactory.d.ts.map +0 -1
- package/lib/commonjs/BleManagerCompatFactory.js +0 -201
- package/lib/commonjs/BleManagerCompatFactory.js.map +0 -1
- package/lib/commonjs/BleManagerFactory.d.ts +0 -31
- package/lib/commonjs/BleManagerFactory.d.ts.map +0 -1
- package/lib/commonjs/BleManagerFactory.js +0 -81
- package/lib/commonjs/BleManagerFactory.js.map +0 -1
- package/lib/commonjs/compatibility/constants.d.ts +0 -50
- package/lib/commonjs/compatibility/constants.d.ts.map +0 -1
- package/lib/commonjs/compatibility/constants.js +0 -58
- package/lib/commonjs/compatibility/constants.js.map +0 -1
- package/lib/commonjs/compatibility/deviceWrapper.d.ts +0 -100
- package/lib/commonjs/compatibility/deviceWrapper.d.ts.map +0 -1
- package/lib/commonjs/compatibility/deviceWrapper.js +0 -268
- package/lib/commonjs/compatibility/deviceWrapper.js.map +0 -1
- package/lib/commonjs/compatibility/enums.d.ts +0 -39
- package/lib/commonjs/compatibility/enums.d.ts.map +0 -1
- package/lib/commonjs/compatibility/enums.js +0 -179
- package/lib/commonjs/compatibility/enums.js.map +0 -1
- package/lib/commonjs/compatibility/index.d.ts +0 -13
- package/lib/commonjs/compatibility/index.d.ts.map +0 -1
- package/lib/commonjs/compatibility/index.js +0 -41
- package/lib/commonjs/compatibility/index.js.map +0 -1
- package/lib/commonjs/compatibility/serviceData.d.ts +0 -52
- package/lib/commonjs/compatibility/serviceData.d.ts.map +0 -1
- package/lib/commonjs/compatibility/serviceData.js +0 -80
- package/lib/commonjs/compatibility/serviceData.js.map +0 -1
- package/lib/commonjs/errors/BleError.d.ts +0 -60
- package/lib/commonjs/errors/BleError.d.ts.map +0 -1
- package/lib/commonjs/errors/BleError.js +0 -125
- package/lib/commonjs/errors/BleError.js.map +0 -1
- package/lib/commonjs/specs/BleManager.nitro.d.ts +0 -45
- package/lib/commonjs/specs/BleManager.nitro.d.ts.map +0 -1
- package/lib/commonjs/specs/BleManager.nitro.js +0 -3
- package/lib/commonjs/specs/BleManager.nitro.js.map +0 -1
- package/lib/commonjs/specs/Characteristic.nitro.d.ts +0 -27
- package/lib/commonjs/specs/Characteristic.nitro.d.ts.map +0 -1
- package/lib/commonjs/specs/Characteristic.nitro.js +0 -3
- package/lib/commonjs/specs/Characteristic.nitro.js.map +0 -1
- package/lib/commonjs/specs/Descriptor.nitro.d.ts +0 -18
- package/lib/commonjs/specs/Descriptor.nitro.d.ts.map +0 -1
- package/lib/commonjs/specs/Descriptor.nitro.js +0 -3
- package/lib/commonjs/specs/Descriptor.nitro.js.map +0 -1
- package/lib/commonjs/specs/Device.nitro.d.ts +0 -38
- package/lib/commonjs/specs/Device.nitro.d.ts.map +0 -1
- package/lib/commonjs/specs/Device.nitro.js +0 -3
- package/lib/commonjs/specs/Device.nitro.js.map +0 -1
- package/lib/commonjs/specs/Service.nitro.d.ts +0 -20
- package/lib/commonjs/specs/Service.nitro.d.ts.map +0 -1
- package/lib/commonjs/specs/Service.nitro.js +0 -3
- package/lib/commonjs/specs/Service.nitro.js.map +0 -1
- package/lib/commonjs/specs/types.d.ts +0 -229
- package/lib/commonjs/specs/types.d.ts.map +0 -1
- package/lib/commonjs/specs/types.js +0 -150
- package/lib/commonjs/specs/types.js.map +0 -1
- package/lib/commonjs/utils/base64.d.ts +0 -26
- package/lib/commonjs/utils/base64.d.ts.map +0 -1
- package/lib/commonjs/utils/base64.js +0 -88
- package/lib/commonjs/utils/base64.js.map +0 -1
- package/lib/commonjs/utils/index.d.ts +0 -3
- package/lib/commonjs/utils/index.d.ts.map +0 -1
- package/lib/commonjs/utils/index.js.map +0 -1
- package/lib/commonjs/utils/uuid.d.ts +0 -10
- package/lib/commonjs/utils/uuid.d.ts.map +0 -1
- package/lib/commonjs/utils/uuid.js +0 -41
- package/lib/commonjs/utils/uuid.js.map +0 -1
- package/lib/compatibility/constants.d.ts +0 -49
- package/lib/compatibility/constants.js +0 -50
- package/lib/compatibility/deviceWrapper.d.ts +0 -99
- package/lib/compatibility/deviceWrapper.js +0 -259
- package/lib/compatibility/enums.d.ts +0 -38
- package/lib/compatibility/enums.js +0 -159
- package/lib/compatibility/index.d.ts +0 -12
- package/lib/compatibility/index.js +0 -12
- package/lib/compatibility/serviceData.d.ts +0 -51
- package/lib/compatibility/serviceData.js +0 -70
- package/lib/errors/BleError.d.ts +0 -59
- package/lib/errors/BleError.js +0 -120
- package/lib/specs/BleManager.nitro.d.ts +0 -44
- package/lib/specs/BleManager.nitro.js +0 -1
- package/lib/specs/Characteristic.nitro.d.ts +0 -26
- package/lib/specs/Characteristic.nitro.js +0 -1
- package/lib/specs/Descriptor.nitro.d.ts +0 -17
- package/lib/specs/Descriptor.nitro.js +0 -1
- package/lib/specs/Device.nitro.d.ts +0 -37
- package/lib/specs/Device.nitro.js +0 -1
- package/lib/specs/Service.nitro.d.ts +0 -19
- package/lib/specs/Service.nitro.js +0 -1
- package/lib/specs/types.d.ts +0 -228
- package/lib/specs/types.js +0 -146
- package/lib/utils/base64.d.ts +0 -25
- package/lib/utils/base64.js +0 -80
- package/lib/utils/index.d.ts +0 -2
- package/lib/utils/index.js +0 -2
- package/lib/utils/uuid.d.ts +0 -9
- package/lib/utils/uuid.js +0 -37
- package/nitrogen/generated/android/c++/JBleATTErrorCode.hpp +0 -107
- package/nitrogen/generated/android/c++/JBleAndroidErrorCode.hpp +0 -101
- package/nitrogen/generated/android/c++/JBleErrorCode.hpp +0 -170
- package/nitrogen/generated/android/c++/JBleIOSErrorCode.hpp +0 -92
- package/nitrogen/generated/android/c++/JBleManagerNitroOptions.hpp +0 -54
- package/nitrogen/generated/android/c++/JBleRestoredState.hpp +0 -76
- package/nitrogen/generated/android/c++/JCharacteristicSubscriptionType.hpp +0 -59
- package/nitrogen/generated/android/c++/JConnectionOptions.hpp +0 -61
- package/nitrogen/generated/android/c++/JConnectionPriority.hpp +0 -62
- package/nitrogen/generated/android/c++/JFunc_void.hpp +0 -74
- package/nitrogen/generated/android/c++/JFunc_void_State.hpp +0 -76
- package/nitrogen/generated/android/c++/JFunc_void_std__optional_NativeBleError__std__optional_NativeCharacteristic_.hpp +0 -88
- package/nitrogen/generated/android/c++/JFunc_void_std__optional_NativeBleError__std__optional_NativeDevice_.hpp +0 -91
- package/nitrogen/generated/android/c++/JHybridBleManagerSpec.cpp +0 -653
- package/nitrogen/generated/android/c++/JHybridBleManagerSpec.hpp +0 -92
- package/nitrogen/generated/android/c++/JHybridCharacteristicSpec.cpp +0 -253
- package/nitrogen/generated/android/c++/JHybridCharacteristicSpec.hpp +0 -79
- package/nitrogen/generated/android/c++/JHybridDescriptorSpec.cpp +0 -115
- package/nitrogen/generated/android/c++/JHybridDescriptorSpec.hpp +0 -70
- package/nitrogen/generated/android/c++/JHybridDeviceSpec.cpp +0 -476
- package/nitrogen/generated/android/c++/JHybridDeviceSpec.hpp +0 -90
- package/nitrogen/generated/android/c++/JHybridServiceSpec.cpp +0 -232
- package/nitrogen/generated/android/c++/JHybridServiceSpec.hpp +0 -72
- package/nitrogen/generated/android/c++/JLogLevel.hpp +0 -71
- package/nitrogen/generated/android/c++/JNativeBleError.hpp +0 -98
- package/nitrogen/generated/android/c++/JNativeCharacteristic.hpp +0 -98
- package/nitrogen/generated/android/c++/JNativeDescriptor.hpp +0 -82
- package/nitrogen/generated/android/c++/JNativeDevice.hpp +0 -173
- package/nitrogen/generated/android/c++/JNativeService.hpp +0 -65
- package/nitrogen/generated/android/c++/JScanCallbackType.hpp +0 -62
- package/nitrogen/generated/android/c++/JScanMode.hpp +0 -65
- package/nitrogen/generated/android/c++/JScanOptions.hpp +0 -69
- package/nitrogen/generated/android/c++/JServiceDataEntry.hpp +0 -57
- package/nitrogen/generated/android/c++/JSubscription.hpp +0 -64
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/BleATTErrorCode.kt +0 -41
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/BleAndroidErrorCode.kt +0 -39
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/BleErrorCode.kt +0 -62
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/BleIOSErrorCode.kt +0 -36
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/BleManagerNitroOptions.kt +0 -26
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/CharacteristicSubscriptionType.kt +0 -25
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/ConnectionPriority.kt +0 -26
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/HybridBleManagerSpec.kt +0 -192
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/HybridCharacteristicSpec.kt +0 -127
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/HybridDescriptorSpec.kt +0 -86
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/HybridDeviceSpec.kt +0 -176
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/HybridServiceSpec.kt +0 -99
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/NativeBleError.kt +0 -35
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/NativeCharacteristic.kt +0 -37
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/NativeDescriptor.kt +0 -33
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/NativeDevice.kt +0 -38
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/ScanCallbackType.kt +0 -26
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/ScanMode.kt +0 -27
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/ScanOptions.kt +0 -29
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/State.kt +0 -29
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/Subscription.kt +0 -30
- package/nitrogen/generated/ios/c++/HybridBleManagerSpecSwift.cpp +0 -11
- package/nitrogen/generated/ios/c++/HybridBleManagerSpecSwift.hpp +0 -377
- package/nitrogen/generated/ios/c++/HybridCharacteristicSpecSwift.hpp +0 -192
- package/nitrogen/generated/ios/c++/HybridDescriptorSpecSwift.cpp +0 -11
- package/nitrogen/generated/ios/c++/HybridDescriptorSpecSwift.hpp +0 -112
- package/nitrogen/generated/ios/c++/HybridDeviceSpecSwift.cpp +0 -11
- package/nitrogen/generated/ios/c++/HybridDeviceSpecSwift.hpp +0 -294
- package/nitrogen/generated/ios/c++/HybridServiceSpecSwift.cpp +0 -11
- package/nitrogen/generated/ios/c++/HybridServiceSpecSwift.hpp +0 -170
- package/nitrogen/generated/ios/swift/BleATTErrorCode.swift +0 -104
- package/nitrogen/generated/ios/swift/BleAndroidErrorCode.swift +0 -96
- package/nitrogen/generated/ios/swift/BleErrorCode.swift +0 -188
- package/nitrogen/generated/ios/swift/BleIOSErrorCode.swift +0 -84
- package/nitrogen/generated/ios/swift/BleRestoredState.swift +0 -47
- package/nitrogen/generated/ios/swift/CharacteristicSubscriptionType.swift +0 -40
- package/nitrogen/generated/ios/swift/ConnectionOptions.swift +0 -57
- package/nitrogen/generated/ios/swift/ConnectionPriority.swift +0 -44
- package/nitrogen/generated/ios/swift/Func_void_NativeCharacteristic.swift +0 -46
- package/nitrogen/generated/ios/swift/Func_void_NativeDevice.swift +0 -46
- package/nitrogen/generated/ios/swift/Func_void_State.swift +0 -46
- package/nitrogen/generated/ios/swift/Func_void_std__optional_NativeBleError__std__optional_NativeCharacteristic_.swift +0 -58
- package/nitrogen/generated/ios/swift/Func_void_std__optional_NativeBleError__std__optional_NativeDevice_.swift +0 -58
- package/nitrogen/generated/ios/swift/Func_void_std__shared_ptr_margelo__nitro__co__zyke__ble__HybridCharacteristicSpec_.swift +0 -50
- package/nitrogen/generated/ios/swift/Func_void_std__shared_ptr_margelo__nitro__co__zyke__ble__HybridDescriptorSpec_.swift +0 -50
- package/nitrogen/generated/ios/swift/Func_void_std__vector_NativeDescriptor_.swift +0 -46
- package/nitrogen/generated/ios/swift/Func_void_std__vector_NativeService_.swift +0 -46
- package/nitrogen/generated/ios/swift/HybridBleManagerSpec.swift +0 -78
- package/nitrogen/generated/ios/swift/HybridBleManagerSpec_cxx.swift +0 -852
- package/nitrogen/generated/ios/swift/HybridCharacteristicSpec.swift +0 -65
- package/nitrogen/generated/ios/swift/HybridCharacteristicSpec_cxx.swift +0 -384
- package/nitrogen/generated/ios/swift/HybridDescriptorSpec.swift +0 -56
- package/nitrogen/generated/ios/swift/HybridDescriptorSpec_cxx.swift +0 -218
- package/nitrogen/generated/ios/swift/HybridDeviceSpec.swift +0 -76
- package/nitrogen/generated/ios/swift/HybridDeviceSpec_cxx.swift +0 -702
- package/nitrogen/generated/ios/swift/HybridServiceSpec.swift +0 -58
- package/nitrogen/generated/ios/swift/HybridServiceSpec_cxx.swift +0 -338
- package/nitrogen/generated/ios/swift/LogLevel.swift +0 -56
- package/nitrogen/generated/ios/swift/NativeBleError.swift +0 -278
- package/nitrogen/generated/ios/swift/NativeCharacteristic.swift +0 -174
- package/nitrogen/generated/ios/swift/NativeDescriptor.swift +0 -130
- package/nitrogen/generated/ios/swift/NativeDevice.swift +0 -377
- package/nitrogen/generated/ios/swift/NativeService.swift +0 -68
- package/nitrogen/generated/ios/swift/ScanCallbackType.swift +0 -44
- package/nitrogen/generated/ios/swift/ScanMode.swift +0 -48
- package/nitrogen/generated/ios/swift/ScanOptions.swift +0 -116
- package/nitrogen/generated/ios/swift/ServiceDataEntry.swift +0 -46
- package/nitrogen/generated/ios/swift/Subscription.swift +0 -46
- package/nitrogen/generated/shared/c++/BleATTErrorCode.hpp +0 -80
- package/nitrogen/generated/shared/c++/BleAndroidErrorCode.hpp +0 -78
- package/nitrogen/generated/shared/c++/BleErrorCode.hpp +0 -101
- package/nitrogen/generated/shared/c++/BleIOSErrorCode.hpp +0 -75
- package/nitrogen/generated/shared/c++/BleRestoredState.hpp +0 -71
- package/nitrogen/generated/shared/c++/CharacteristicSubscriptionType.hpp +0 -64
- package/nitrogen/generated/shared/c++/ConnectionOptions.hpp +0 -77
- package/nitrogen/generated/shared/c++/ConnectionPriority.hpp +0 -65
- package/nitrogen/generated/shared/c++/HybridBleManagerSpec.cpp +0 -51
- package/nitrogen/generated/shared/c++/HybridBleManagerSpec.hpp +0 -137
- package/nitrogen/generated/shared/c++/HybridCharacteristicSpec.cpp +0 -39
- package/nitrogen/generated/shared/c++/HybridCharacteristicSpec.hpp +0 -101
- package/nitrogen/generated/shared/c++/HybridDescriptorSpec.cpp +0 -30
- package/nitrogen/generated/shared/c++/HybridDescriptorSpec.hpp +0 -75
- package/nitrogen/generated/shared/c++/HybridDeviceSpec.cpp +0 -50
- package/nitrogen/generated/shared/c++/HybridDeviceSpec.hpp +0 -123
- package/nitrogen/generated/shared/c++/HybridServiceSpec.cpp +0 -32
- package/nitrogen/generated/shared/c++/HybridServiceSpec.hpp +0 -90
- package/nitrogen/generated/shared/c++/LogLevel.hpp +0 -68
- package/nitrogen/generated/shared/c++/NativeBleError.hpp +0 -117
- package/nitrogen/generated/shared/c++/NativeCharacteristic.hpp +0 -114
- package/nitrogen/generated/shared/c++/NativeDescriptor.hpp +0 -98
- package/nitrogen/generated/shared/c++/NativeDevice.hpp +0 -121
- package/nitrogen/generated/shared/c++/NativeService.hpp +0 -81
- package/nitrogen/generated/shared/c++/ScanCallbackType.hpp +0 -65
- package/nitrogen/generated/shared/c++/ScanMode.hpp +0 -66
- package/nitrogen/generated/shared/c++/ScanOptions.hpp +0 -86
- package/nitrogen/generated/shared/c++/Subscription.hpp +0 -69
- package/src/BleManagerCompatFactory.ts +0 -371
- package/src/BleManagerFactory.ts +0 -93
- package/src/__tests__/BleManager.test.ts +0 -327
- package/src/__tests__/compatibility/deviceWrapper.test.ts +0 -563
- package/src/__tests__/compatibility/enums.test.ts +0 -264
- package/src/compatibility/constants.ts +0 -71
- package/src/compatibility/deviceWrapper.ts +0 -427
- package/src/compatibility/enums.ts +0 -190
- package/src/compatibility/index.ts +0 -32
- package/src/compatibility/serviceData.ts +0 -85
- package/src/errors/BleError.ts +0 -193
- package/src/specs/BleManager.nitro.ts +0 -165
- package/src/specs/Characteristic.nitro.ts +0 -61
- package/src/specs/Descriptor.nitro.ts +0 -28
- package/src/specs/Device.nitro.ts +0 -104
- package/src/specs/Service.nitro.ts +0 -64
- package/src/specs/types.ts +0 -259
- package/src/utils/base64.ts +0 -80
- package/src/utils/index.ts +0 -2
- package/src/utils/uuid.ts +0 -45
package/BleNitro.podspec
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
require "json"
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
4
|
+
|
|
5
|
+
Pod::Spec.new do |s|
|
|
6
|
+
s.name = "BleNitro"
|
|
7
|
+
s.version = package["version"]
|
|
8
|
+
s.summary = package["description"]
|
|
9
|
+
s.homepage = package["homepage"]
|
|
10
|
+
s.license = package["license"]
|
|
11
|
+
s.authors = package["author"]
|
|
12
|
+
|
|
13
|
+
s.platforms = { :ios => min_ios_version_supported, :visionos => 1.0 }
|
|
14
|
+
s.source = { :git => "https://github.com/zykeco/react-native-ble-nitro.git", :tag => "#{s.version}" }
|
|
15
|
+
|
|
16
|
+
s.source_files = [
|
|
17
|
+
# Implementation (Swift)
|
|
18
|
+
"ios/**/*.{swift}",
|
|
19
|
+
# Autolinking/Registration (Objective-C++)
|
|
20
|
+
"ios/**/*.{m,mm}",
|
|
21
|
+
# Implementation (C++ objects)
|
|
22
|
+
"cpp/**/*.{hpp,cpp}",
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
# iOS frameworks
|
|
26
|
+
s.frameworks = "CoreBluetooth"
|
|
27
|
+
|
|
28
|
+
s.user_target_xcconfig = {
|
|
29
|
+
'OTHER_LDFLAGS' => '-lc++'
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
# Apply Nitro autolinking
|
|
33
|
+
load 'nitrogen/generated/ios/BleNitro+autolinking.rb'
|
|
34
|
+
add_nitrogen_files(s)
|
|
35
|
+
|
|
36
|
+
s.dependency 'React-jsi'
|
|
37
|
+
s.dependency 'React-callinvoker'
|
|
38
|
+
install_modules_dependencies(s)
|
|
39
|
+
end
|
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2025 Zyke (https://zyke.co)
|
|
3
|
+
Copyright (c) 2025 Zyke (https://zyke.co) presented by Phil Schaffarzyk
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.md
CHANGED
|
@@ -3,20 +3,20 @@
|
|
|
3
3
|
[](https://badge.fury.io/js/react-native-ble-nitro)
|
|
4
4
|
[](https://opensource.org/licenses/MIT)
|
|
5
5
|
|
|
6
|
-
A high-performance React Native BLE library built on [Nitro Modules](https://nitro.margelo.com/)
|
|
6
|
+
A high-performance React Native BLE library built on [Nitro Modules](https://nitro.margelo.com/).
|
|
7
7
|
|
|
8
8
|
Originally developed for [Zyke Band](https://zykeband.com) - a fitness and health tracker created by a small team.
|
|
9
9
|
|
|
10
10
|
## ✨ Features
|
|
11
11
|
|
|
12
12
|
- 🚀 **High Performance**: Built on Nitro Modules with JSI for zero-overhead native communication
|
|
13
|
-
-
|
|
14
|
-
-
|
|
13
|
+
- 📱 **iOS Support**: Complete iOS implementation with Swift and Core Bluetooth
|
|
14
|
+
- 🤖 **Android Support**: Currently in development - iOS fully functional
|
|
15
15
|
- 🎯 **Type-Safe**: Full TypeScript support with comprehensive type definitions
|
|
16
16
|
- 🔧 **Expo Ready**: Built-in Expo config plugin for easy setup
|
|
17
17
|
- 🏗️ **New Architecture**: Full support for React Native's new architecture
|
|
18
18
|
- ⚡ **Zero Bridge**: Direct JSI communication eliminates bridge bottlenecks
|
|
19
|
-
- 🛡️ **Reliable**: Swift
|
|
19
|
+
- 🛡️ **Reliable**: Swift native implementation for maximum stability
|
|
20
20
|
|
|
21
21
|
## 🚀 Quick Start
|
|
22
22
|
|
|
@@ -66,55 +66,289 @@ npx pod-install # iOS only
|
|
|
66
66
|
|
|
67
67
|
## 📖 Usage
|
|
68
68
|
|
|
69
|
-
|
|
69
|
+
> **📱 Platform Support**: Currently iOS only. Android implementation is in development.
|
|
70
|
+
|
|
71
|
+
### Basic Setup
|
|
70
72
|
|
|
71
73
|
```typescript
|
|
72
|
-
import {
|
|
74
|
+
import { BleNitro, BLEState, type BLEDevice } from 'react-native-ble-nitro';
|
|
73
75
|
|
|
74
|
-
|
|
76
|
+
// Get the singleton instance
|
|
77
|
+
const ble = BleNitro.instance();
|
|
78
|
+
```
|
|
75
79
|
|
|
76
|
-
|
|
77
|
-
const state = await manager.state();
|
|
78
|
-
if (state === State.PoweredOn) {
|
|
79
|
-
console.log('Bluetooth is ready!');
|
|
80
|
-
}
|
|
80
|
+
### Complete API Reference
|
|
81
81
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
82
|
+
#### 🔌 Bluetooth State Management
|
|
83
|
+
|
|
84
|
+
```typescript
|
|
85
|
+
// Check if Bluetooth is enabled
|
|
86
|
+
const isEnabled = ble.isBluetoothEnabled();
|
|
87
|
+
|
|
88
|
+
// Get current Bluetooth state
|
|
89
|
+
const state = ble.state();
|
|
90
|
+
// Returns: BLEState.PoweredOn, BLEState.PoweredOff, etc.
|
|
91
|
+
|
|
92
|
+
// Request to enable Bluetooth (Android only)
|
|
93
|
+
await ble.requestBluetoothEnable();
|
|
94
|
+
|
|
95
|
+
// Subscribe to state changes
|
|
96
|
+
const subscription = ble.subscribeToStateChange((state) => {
|
|
97
|
+
console.log('Bluetooth state changed:', state);
|
|
98
|
+
}, true); // true = emit initial state
|
|
99
|
+
|
|
100
|
+
// Unsubscribe from state changes
|
|
101
|
+
subscription.remove();
|
|
102
|
+
|
|
103
|
+
// Open Bluetooth settings
|
|
104
|
+
await ble.openSettings();
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
#### 🔍 Device Scanning
|
|
108
|
+
|
|
109
|
+
```typescript
|
|
110
|
+
// Start scanning for devices
|
|
111
|
+
ble.startScan({
|
|
112
|
+
serviceUUIDs: ['180d'], // Optional: filter by service UUIDs
|
|
113
|
+
rssiThreshold: -80, // Optional: minimum signal strength
|
|
114
|
+
allowDuplicates: false // Optional: allow duplicate discoveries
|
|
115
|
+
}, (device) => {
|
|
116
|
+
console.log('Found device:', device.name, device.id);
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
// Stop scanning
|
|
120
|
+
ble.stopScan();
|
|
121
|
+
|
|
122
|
+
// Check if currently scanning
|
|
123
|
+
const isScanning = ble.isScanning();
|
|
124
|
+
|
|
125
|
+
// Get already connected devices
|
|
126
|
+
const connectedDevices = ble.getConnectedDevices(['180d']); // Optional: filter by service UUIDs
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
#### 🔗 Device Connection
|
|
130
|
+
|
|
131
|
+
```typescript
|
|
132
|
+
// Connect to a device with disconnect event handling
|
|
133
|
+
const deviceId = await ble.connect(deviceId, (deviceId, interrupted, error) => {
|
|
134
|
+
if (interrupted) {
|
|
135
|
+
console.log('Connection interrupted:', error);
|
|
136
|
+
// Handle unexpected disconnection (out of range, etc.)
|
|
137
|
+
} else {
|
|
138
|
+
console.log('Disconnected intentionally');
|
|
139
|
+
// Handle normal disconnection
|
|
102
140
|
}
|
|
103
141
|
});
|
|
142
|
+
|
|
143
|
+
// Connect without disconnect callback
|
|
144
|
+
const deviceId = await ble.connect(deviceId);
|
|
145
|
+
|
|
146
|
+
// Disconnect from a device
|
|
147
|
+
await ble.disconnect(deviceId);
|
|
148
|
+
|
|
149
|
+
// Check connection status
|
|
150
|
+
const isConnected = ble.isConnected(deviceId);
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
#### 🔧 Service Discovery
|
|
154
|
+
|
|
155
|
+
```typescript
|
|
156
|
+
// Discover all services for a device
|
|
157
|
+
await ble.discoverServices(deviceId);
|
|
158
|
+
|
|
159
|
+
// Get discovered services
|
|
160
|
+
const services = await ble.getServices(deviceId);
|
|
161
|
+
// Returns: ['0000180d-0000-1000-8000-00805f9b34fb', '0000180f-0000-1000-8000-00805f9b34fb', ...]
|
|
162
|
+
// Always returns full 128-bit UUIDs
|
|
163
|
+
|
|
164
|
+
// Get characteristics for a service
|
|
165
|
+
const characteristics = ble.getCharacteristics(deviceId, serviceUUID);
|
|
166
|
+
// Returns: ['00002a37-0000-1000-8000-00805f9b34fb', '00002a38-0000-1000-8000-00805f9b34fb', ...]
|
|
167
|
+
// Always returns full 128-bit UUIDs
|
|
168
|
+
|
|
169
|
+
// Note: You can use either short or long form UUIDs as input:
|
|
170
|
+
const characteristics1 = ble.getCharacteristics(deviceId, '180d'); // Short form
|
|
171
|
+
const characteristics2 = ble.getCharacteristics(deviceId, '0000180d-0000-1000-8000-00805f9b34fb'); // Long form
|
|
172
|
+
// Both work identically - conversion handled automatically
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
#### 📖 Reading Characteristics
|
|
176
|
+
|
|
177
|
+
```typescript
|
|
178
|
+
// Read a characteristic value
|
|
179
|
+
const data = await ble.readCharacteristic(deviceId, serviceUUID, characteristicUUID);
|
|
180
|
+
// Returns: number[] - array of bytes
|
|
181
|
+
|
|
182
|
+
// Example: Reading battery level
|
|
183
|
+
const batteryData = await ble.readCharacteristic(deviceId, '180f', '2a19');
|
|
184
|
+
const batteryLevel = batteryData[0]; // First byte is battery percentage
|
|
185
|
+
console.log('Battery level:', batteryLevel + '%');
|
|
104
186
|
```
|
|
105
187
|
|
|
106
|
-
|
|
188
|
+
#### ✍️ Writing Characteristics
|
|
189
|
+
|
|
190
|
+
```typescript
|
|
191
|
+
// Write to a characteristic with response
|
|
192
|
+
await ble.writeCharacteristic(
|
|
193
|
+
deviceId,
|
|
194
|
+
serviceUUID,
|
|
195
|
+
characteristicUUID,
|
|
196
|
+
[0x01, 0x02, 0x03], // Data as byte array
|
|
197
|
+
true // withResponse = true (default)
|
|
198
|
+
);
|
|
199
|
+
|
|
200
|
+
// Write without response (faster, no confirmation)
|
|
201
|
+
await ble.writeCharacteristic(
|
|
202
|
+
deviceId,
|
|
203
|
+
serviceUUID,
|
|
204
|
+
characteristicUUID,
|
|
205
|
+
[0x01, 0x02, 0x03],
|
|
206
|
+
false // withResponse = false
|
|
207
|
+
);
|
|
208
|
+
```
|
|
107
209
|
|
|
108
|
-
|
|
210
|
+
#### 📡 Characteristic Notifications
|
|
109
211
|
|
|
110
212
|
```typescript
|
|
111
|
-
//
|
|
112
|
-
|
|
213
|
+
// Subscribe to characteristic notifications
|
|
214
|
+
const subscription = ble.subscribeToCharacteristic(
|
|
215
|
+
deviceId,
|
|
216
|
+
serviceUUID,
|
|
217
|
+
characteristicUUID,
|
|
218
|
+
(characteristicId, data) => {
|
|
219
|
+
console.log('Received notification:', data);
|
|
220
|
+
// Handle incoming data
|
|
221
|
+
}
|
|
222
|
+
);
|
|
113
223
|
|
|
114
|
-
//
|
|
115
|
-
|
|
224
|
+
// Unsubscribe from notifications
|
|
225
|
+
subscription.remove();
|
|
116
226
|
|
|
117
|
-
//
|
|
227
|
+
// Or unsubscribe directly
|
|
228
|
+
await ble.unsubscribeFromCharacteristic(deviceId, serviceUUID, characteristicUUID);
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
### Real-World Examples
|
|
232
|
+
|
|
233
|
+
#### Heart Rate Monitor
|
|
234
|
+
|
|
235
|
+
```typescript
|
|
236
|
+
const HEART_RATE_SERVICE = '180d';
|
|
237
|
+
const HEART_RATE_MEASUREMENT = '2a37';
|
|
238
|
+
|
|
239
|
+
// Connect and subscribe to heart rate
|
|
240
|
+
const deviceId = await ble.connect(heartRateDeviceId);
|
|
241
|
+
await ble.discoverServices(deviceId);
|
|
242
|
+
|
|
243
|
+
const subscription = ble.subscribeToCharacteristic(
|
|
244
|
+
deviceId,
|
|
245
|
+
HEART_RATE_SERVICE,
|
|
246
|
+
HEART_RATE_MEASUREMENT,
|
|
247
|
+
(_, data) => {
|
|
248
|
+
const heartRate = data[1]; // Second byte contains BPM
|
|
249
|
+
console.log('Heart rate:', heartRate, 'BPM');
|
|
250
|
+
}
|
|
251
|
+
);
|
|
252
|
+
|
|
253
|
+
// Unsubscribe when done
|
|
254
|
+
subscription.remove();
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
#### Battery Level Reading
|
|
258
|
+
|
|
259
|
+
```typescript
|
|
260
|
+
const BATTERY_SERVICE = '180f';
|
|
261
|
+
const BATTERY_LEVEL_CHARACTERISTIC = '2a19';
|
|
262
|
+
|
|
263
|
+
const batteryData = await ble.readCharacteristic(
|
|
264
|
+
deviceId,
|
|
265
|
+
BATTERY_SERVICE,
|
|
266
|
+
BATTERY_LEVEL_CHARACTERISTIC
|
|
267
|
+
);
|
|
268
|
+
const batteryPercentage = batteryData[0];
|
|
269
|
+
console.log('Battery:', batteryPercentage + '%');
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
#### Custom Device Control
|
|
273
|
+
|
|
274
|
+
```typescript
|
|
275
|
+
const CUSTOM_SERVICE = 'your-custom-service-uuid';
|
|
276
|
+
const COMMAND_CHARACTERISTIC = 'your-command-characteristic-uuid';
|
|
277
|
+
|
|
278
|
+
// Send a custom command
|
|
279
|
+
const enableLedCommand = [0x01, 0x1f, 0x01]; // Your protocol
|
|
280
|
+
await ble.writeCharacteristic(
|
|
281
|
+
deviceId,
|
|
282
|
+
CUSTOM_SERVICE,
|
|
283
|
+
COMMAND_CHARACTERISTIC,
|
|
284
|
+
enableLedCommand
|
|
285
|
+
);
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
### UUID Handling
|
|
289
|
+
|
|
290
|
+
**🔧 Automatic UUID Conversion**
|
|
291
|
+
|
|
292
|
+
This library automatically handles UUID conversion between 16-bit, 32-bit, and 128-bit formats:
|
|
293
|
+
|
|
294
|
+
```typescript
|
|
295
|
+
// All input methods accept both short and long form UUIDs:
|
|
296
|
+
await ble.readCharacteristic(deviceId, '180d', '2a19'); // Short form ✅
|
|
297
|
+
await ble.readCharacteristic(deviceId, '0000180d-0000-1000-8000-00805f9b34fb', '00002a19-0000-1000-8000-00805f9b34fb'); // Long form ✅
|
|
298
|
+
|
|
299
|
+
// All output methods return full 128-bit UUIDs:
|
|
300
|
+
const services = await ble.getServices(deviceId);
|
|
301
|
+
// Always returns: ['0000180d-0000-1000-8000-00805f9b34fb', ...]
|
|
302
|
+
|
|
303
|
+
// Conversion happens automatically on the native side for maximum performance
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
### Utility Functions
|
|
307
|
+
|
|
308
|
+
```typescript
|
|
309
|
+
// Manually normalize UUIDs to full 128-bit format (rarely needed)
|
|
310
|
+
const fullUUID = BleNitro.normalizeGattUUID('180d');
|
|
311
|
+
// Returns: '0000180d-0000-1000-8000-00805f9b34fb'
|
|
312
|
+
|
|
313
|
+
// Normalize multiple UUIDs
|
|
314
|
+
const fullUUIDs = BleNitro.normalizeGattUUIDs(['180d', '180f']);
|
|
315
|
+
// Returns: ['0000180d-0000-1000-8000-00805f9b34fb', '0000180f-0000-1000-8000-00805f9b34fb']
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
### TypeScript Types
|
|
319
|
+
|
|
320
|
+
```typescript
|
|
321
|
+
interface BLEDevice {
|
|
322
|
+
id: string;
|
|
323
|
+
name: string;
|
|
324
|
+
rssi: number;
|
|
325
|
+
manufacturerData: ManufacturerData;
|
|
326
|
+
serviceUUIDs: string[];
|
|
327
|
+
isConnectable: boolean;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
interface ScanFilter {
|
|
331
|
+
serviceUUIDs?: string[];
|
|
332
|
+
rssiThreshold?: number;
|
|
333
|
+
allowDuplicates?: boolean;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
interface Subscription {
|
|
337
|
+
remove: () => Promise<void>;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
enum BLEState {
|
|
341
|
+
Unknown = 'Unknown',
|
|
342
|
+
Resetting = 'Resetting',
|
|
343
|
+
Unsupported = 'Unsupported',
|
|
344
|
+
Unauthorized = 'Unauthorized',
|
|
345
|
+
PoweredOff = 'PoweredOff',
|
|
346
|
+
PoweredOn = 'PoweredOn'
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
// Callback types
|
|
350
|
+
type DisconnectEventCallback = (deviceId: string, interrupted: boolean, error: string) => void;
|
|
351
|
+
type CharacteristicUpdateCallback = (characteristicId: string, data: number[]) => void;
|
|
118
352
|
```
|
|
119
353
|
|
|
120
354
|
## 🏗️ Architecture
|
|
@@ -130,9 +364,9 @@ Built on [Nitro Modules](https://nitro.margelo.com/) for:
|
|
|
130
364
|
|
|
131
365
|
### Platform Implementation
|
|
132
366
|
|
|
133
|
-
- **iOS**:
|
|
134
|
-
- **Android**:
|
|
135
|
-
- **Shared C++**: Common logic and type definitions
|
|
367
|
+
- **iOS**: ✅ Complete Swift implementation using Core Bluetooth
|
|
368
|
+
- **Android**: 🚧 Kotlin implementation in development using Android BLE APIs
|
|
369
|
+
- **Shared C++**: Common logic and type definitions via Nitro Modules
|
|
136
370
|
|
|
137
371
|
### Compatibility Layer
|
|
138
372
|
|
|
@@ -144,29 +378,6 @@ While maintaining 100% API compatibility, some internal changes were needed for
|
|
|
144
378
|
|
|
145
379
|
See [API_DIFFERENCES.md](./API_DIFFERENCES.md) for technical details.
|
|
146
380
|
|
|
147
|
-
## 📋 API Reference
|
|
148
|
-
|
|
149
|
-
The API is identical to `react-native-ble-plx`. Key classes and methods:
|
|
150
|
-
|
|
151
|
-
### BleManager
|
|
152
|
-
|
|
153
|
-
- `new BleManager(options?)`: Create manager instance
|
|
154
|
-
- `state()`: Get current Bluetooth state
|
|
155
|
-
- `startDeviceScan()`: Start scanning for devices
|
|
156
|
-
- `connectToDevice()`: Connect to a BLE device
|
|
157
|
-
- `readCharacteristicForDevice()`: Read characteristic value
|
|
158
|
-
- `writeCharacteristicWithResponseForDevice()`: Write with response
|
|
159
|
-
- `monitorCharacteristicForDevice()`: Monitor value changes
|
|
160
|
-
|
|
161
|
-
### Device
|
|
162
|
-
|
|
163
|
-
- `connect()`: Connect to this device
|
|
164
|
-
- `discoverAllServicesAndCharacteristics()`: Discover GATT structure
|
|
165
|
-
- `readCharacteristicForService()`: Read characteristic
|
|
166
|
-
- `monitorCharacteristicForService()`: Monitor characteristic
|
|
167
|
-
|
|
168
|
-
For complete API documentation, see the [react-native-ble-plx docs](https://github.com/dotintent/react-native-ble-plx) - everything applies to this library too!
|
|
169
|
-
|
|
170
381
|
## ⚙️ Configuration
|
|
171
382
|
|
|
172
383
|
### Expo Plugin Options
|
|
@@ -241,7 +452,6 @@ npm run lint
|
|
|
241
452
|
react-native-ble-nitro/
|
|
242
453
|
├── src/
|
|
243
454
|
│ ├── specs/ # Nitro module TypeScript specs
|
|
244
|
-
│ ├── compatibility/ # react-native-ble-plx compatibility layer
|
|
245
455
|
│ ├── utils/ # Utility functions (UUID, Base64)
|
|
246
456
|
│ └── errors/ # BLE error handling
|
|
247
457
|
├── nitrogen/generated/ # Generated native code (Nitro)
|
|
@@ -269,23 +479,13 @@ We welcome contributions! Please see [CONTRIBUTING.md](./CONTRIBUTING.md) for gu
|
|
|
269
479
|
|
|
270
480
|
MIT License - see [LICENSE](./LICENSE) file.
|
|
271
481
|
|
|
272
|
-
## Comparison with react-native-ble-plx
|
|
273
|
-
|
|
274
|
-
| Feature | react-native-ble-plx | react-native-ble-nitro |
|
|
275
|
-
|---------|---------------------|------------------------|
|
|
276
|
-
| **Performance** | React Native Bridge | Direct JSI ⚡ |
|
|
277
|
-
| **Type Safety** | TypeScript definitions | Compile-time validation ✅ |
|
|
278
|
-
| **Memory Usage** | Higher overhead | Optimized 🎯 |
|
|
279
|
-
| **New Architecture** | Limited support | Full support ✅ |
|
|
280
|
-
| **API Compatibility** | Original | 100% Compatible ✅ |
|
|
281
|
-
|
|
282
482
|
## 🙏 Acknowledgments
|
|
283
483
|
|
|
284
484
|
- [Zyke Band](https://zykeband.com) - The fitness tracker project that inspired this library
|
|
285
|
-
- [react-native-ble-plx](https://github.com/dotintent/react-native-ble-plx) - Original library and API design
|
|
286
485
|
- [Marc Rousavy](https://github.com/mrousavy) - Creator of Nitro Modules and CEO of Margelo
|
|
287
486
|
- [Nitro Modules](https://nitro.margelo.com/) - High-performance native module framework
|
|
288
487
|
- [Margelo](https://margelo.com/) - Nitro Modules creators
|
|
488
|
+
- [Alvinotuya84](https://github.com/Alvinotuya84) - For the API inspiration I took from his repo [react-native-bluetooth-nitro-nexus](https://github.com/Alvinotuya84/react-native-bluetooth-nitro-nexus)
|
|
289
489
|
|
|
290
490
|
## 📞 Support
|
|
291
491
|
|