react-native-ble-nitro 1.0.0-beta.0 → 1.0.0-beta.10

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.
Files changed (290) hide show
  1. package/android/build.gradle +3 -0
  2. package/android/src/main/kotlin/{co → com/margelo/nitro/co}/zyke/ble/BleNitroBleManager.kt +111 -2
  3. package/app.plugin.cjs +1 -0
  4. package/ios/BleNitroBleManager.swift +66 -0
  5. package/ios/BleNitroModule.swift +2 -9
  6. package/lib/BleManagerCompatFactory.d.ts +5 -4
  7. package/lib/BleManagerCompatFactory.js +9 -6
  8. package/lib/BleManagerFactory.d.ts +21 -3
  9. package/lib/BleManagerFactory.js +53 -2
  10. package/lib/commonjs/BleManagerCompatFactory.d.ts +56 -0
  11. package/lib/commonjs/BleManagerCompatFactory.d.ts.map +1 -0
  12. package/lib/commonjs/BleManagerCompatFactory.js +201 -0
  13. package/lib/commonjs/BleManagerCompatFactory.js.map +1 -0
  14. package/lib/commonjs/BleManagerFactory.d.ts +31 -0
  15. package/lib/commonjs/BleManagerFactory.d.ts.map +1 -0
  16. package/lib/commonjs/BleManagerFactory.js +81 -0
  17. package/lib/commonjs/BleManagerFactory.js.map +1 -0
  18. package/lib/commonjs/compatibility/constants.d.ts +50 -0
  19. package/lib/commonjs/compatibility/constants.d.ts.map +1 -0
  20. package/lib/commonjs/compatibility/constants.js +58 -0
  21. package/lib/commonjs/compatibility/constants.js.map +1 -0
  22. package/lib/commonjs/compatibility/deviceWrapper.d.ts +100 -0
  23. package/lib/commonjs/compatibility/deviceWrapper.d.ts.map +1 -0
  24. package/lib/commonjs/compatibility/deviceWrapper.js +268 -0
  25. package/lib/commonjs/compatibility/deviceWrapper.js.map +1 -0
  26. package/lib/commonjs/compatibility/enums.d.ts +39 -0
  27. package/lib/commonjs/compatibility/enums.d.ts.map +1 -0
  28. package/lib/commonjs/compatibility/enums.js +179 -0
  29. package/lib/commonjs/compatibility/enums.js.map +1 -0
  30. package/lib/commonjs/compatibility/index.d.ts +13 -0
  31. package/lib/commonjs/compatibility/index.d.ts.map +1 -0
  32. package/lib/commonjs/compatibility/index.js +41 -0
  33. package/lib/commonjs/compatibility/index.js.map +1 -0
  34. package/lib/commonjs/compatibility/serviceData.d.ts +52 -0
  35. package/lib/commonjs/compatibility/serviceData.d.ts.map +1 -0
  36. package/lib/commonjs/compatibility/serviceData.js +80 -0
  37. package/lib/commonjs/compatibility/serviceData.js.map +1 -0
  38. package/lib/commonjs/errors/BleError.d.ts +60 -0
  39. package/lib/commonjs/errors/BleError.d.ts.map +1 -0
  40. package/lib/commonjs/errors/BleError.js +125 -0
  41. package/lib/commonjs/errors/BleError.js.map +1 -0
  42. package/lib/commonjs/index.d.ts +11 -0
  43. package/lib/commonjs/index.d.ts.map +1 -0
  44. package/lib/commonjs/index.js +42 -0
  45. package/lib/commonjs/index.js.map +1 -0
  46. package/lib/commonjs/specs/BleManager.nitro.d.ts +45 -0
  47. package/lib/commonjs/specs/BleManager.nitro.d.ts.map +1 -0
  48. package/lib/commonjs/specs/BleManager.nitro.js +3 -0
  49. package/lib/commonjs/specs/BleManager.nitro.js.map +1 -0
  50. package/lib/commonjs/specs/Characteristic.nitro.d.ts +27 -0
  51. package/lib/commonjs/specs/Characteristic.nitro.d.ts.map +1 -0
  52. package/lib/commonjs/specs/Characteristic.nitro.js +3 -0
  53. package/lib/commonjs/specs/Characteristic.nitro.js.map +1 -0
  54. package/lib/commonjs/specs/Descriptor.nitro.d.ts +18 -0
  55. package/lib/commonjs/specs/Descriptor.nitro.d.ts.map +1 -0
  56. package/lib/commonjs/specs/Descriptor.nitro.js +3 -0
  57. package/lib/commonjs/specs/Descriptor.nitro.js.map +1 -0
  58. package/lib/commonjs/specs/Device.nitro.d.ts +38 -0
  59. package/lib/commonjs/specs/Device.nitro.d.ts.map +1 -0
  60. package/lib/commonjs/specs/Device.nitro.js +3 -0
  61. package/lib/commonjs/specs/Device.nitro.js.map +1 -0
  62. package/lib/commonjs/specs/Service.nitro.d.ts +20 -0
  63. package/lib/commonjs/specs/Service.nitro.d.ts.map +1 -0
  64. package/lib/commonjs/specs/Service.nitro.js +3 -0
  65. package/lib/commonjs/specs/Service.nitro.js.map +1 -0
  66. package/lib/commonjs/specs/types.d.ts +229 -0
  67. package/lib/commonjs/specs/types.d.ts.map +1 -0
  68. package/lib/commonjs/specs/types.js +150 -0
  69. package/lib/commonjs/specs/types.js.map +1 -0
  70. package/lib/commonjs/utils/base64.d.ts +26 -0
  71. package/lib/commonjs/utils/base64.d.ts.map +1 -0
  72. package/lib/commonjs/utils/base64.js +88 -0
  73. package/lib/commonjs/utils/base64.js.map +1 -0
  74. package/lib/commonjs/utils/index.d.ts +3 -0
  75. package/lib/commonjs/utils/index.d.ts.map +1 -0
  76. package/lib/commonjs/utils/index.js +19 -0
  77. package/lib/commonjs/utils/index.js.map +1 -0
  78. package/lib/commonjs/utils/uuid.d.ts +10 -0
  79. package/lib/commonjs/utils/uuid.d.ts.map +1 -0
  80. package/lib/commonjs/utils/uuid.js +41 -0
  81. package/lib/commonjs/utils/uuid.js.map +1 -0
  82. package/lib/compatibility/constants.d.ts +1 -1
  83. package/lib/compatibility/constants.js +1 -1
  84. package/lib/compatibility/deviceWrapper.d.ts +2 -2
  85. package/lib/compatibility/deviceWrapper.js +2 -2
  86. package/lib/compatibility/enums.d.ts +1 -1
  87. package/lib/compatibility/enums.js +1 -1
  88. package/lib/compatibility/index.d.ts +5 -5
  89. package/lib/compatibility/index.js +4 -4
  90. package/lib/compatibility/serviceData.d.ts +1 -1
  91. package/lib/errors/BleError.d.ts +2 -2
  92. package/lib/errors/BleError.js +1 -1
  93. package/lib/index.d.ts +10 -9
  94. package/lib/index.js +9 -7
  95. package/lib/specs/BleManager.nitro.d.ts +9 -1
  96. package/lib/specs/Characteristic.nitro.d.ts +1 -1
  97. package/lib/specs/Descriptor.nitro.d.ts +1 -1
  98. package/lib/specs/Device.nitro.d.ts +1 -1
  99. package/lib/specs/Service.nitro.d.ts +1 -1
  100. package/nitro.json +6 -1
  101. package/nitrogen/generated/.gitattributes +1 -0
  102. package/nitrogen/generated/android/BleNitro+autolinking.cmake +86 -0
  103. package/nitrogen/generated/android/BleNitro+autolinking.gradle +27 -0
  104. package/nitrogen/generated/android/BleNitroOnLoad.cpp +62 -0
  105. package/nitrogen/generated/android/BleNitroOnLoad.hpp +25 -0
  106. package/nitrogen/generated/android/c++/JBleATTErrorCode.hpp +107 -0
  107. package/nitrogen/generated/android/c++/JBleAndroidErrorCode.hpp +101 -0
  108. package/nitrogen/generated/android/c++/JBleErrorCode.hpp +170 -0
  109. package/nitrogen/generated/android/c++/JBleIOSErrorCode.hpp +92 -0
  110. package/nitrogen/generated/android/c++/JBleManagerNitroOptions.hpp +54 -0
  111. package/nitrogen/generated/android/c++/JBleRestoredState.hpp +76 -0
  112. package/nitrogen/generated/android/c++/JCharacteristicSubscriptionType.hpp +59 -0
  113. package/nitrogen/generated/android/c++/JConnectionOptions.hpp +61 -0
  114. package/nitrogen/generated/android/c++/JConnectionPriority.hpp +62 -0
  115. package/nitrogen/generated/android/c++/JFunc_void.hpp +74 -0
  116. package/nitrogen/generated/android/c++/JFunc_void_State.hpp +76 -0
  117. package/nitrogen/generated/android/c++/JFunc_void_std__optional_NativeBleError__std__optional_NativeCharacteristic_.hpp +88 -0
  118. package/nitrogen/generated/android/c++/JFunc_void_std__optional_NativeBleError__std__optional_NativeDevice_.hpp +91 -0
  119. package/nitrogen/generated/android/c++/JHybridBleManagerSpec.cpp +653 -0
  120. package/nitrogen/generated/android/c++/JHybridBleManagerSpec.hpp +92 -0
  121. package/nitrogen/generated/android/c++/JHybridCharacteristicSpec.cpp +253 -0
  122. package/nitrogen/generated/android/c++/JHybridCharacteristicSpec.hpp +79 -0
  123. package/nitrogen/generated/android/c++/JHybridDescriptorSpec.cpp +115 -0
  124. package/nitrogen/generated/android/c++/JHybridDescriptorSpec.hpp +70 -0
  125. package/nitrogen/generated/android/c++/JHybridDeviceSpec.cpp +476 -0
  126. package/nitrogen/generated/android/c++/JHybridDeviceSpec.hpp +90 -0
  127. package/nitrogen/generated/android/c++/JHybridServiceSpec.cpp +232 -0
  128. package/nitrogen/generated/android/c++/JHybridServiceSpec.hpp +72 -0
  129. package/nitrogen/generated/android/c++/JLogLevel.hpp +71 -0
  130. package/nitrogen/generated/android/c++/JNativeBleError.hpp +98 -0
  131. package/nitrogen/generated/android/c++/JNativeCharacteristic.hpp +98 -0
  132. package/nitrogen/generated/android/c++/JNativeDescriptor.hpp +82 -0
  133. package/nitrogen/generated/android/c++/JNativeDevice.hpp +173 -0
  134. package/nitrogen/generated/android/c++/JNativeService.hpp +65 -0
  135. package/nitrogen/generated/android/c++/JScanCallbackType.hpp +62 -0
  136. package/nitrogen/generated/android/c++/JScanMode.hpp +65 -0
  137. package/nitrogen/generated/android/c++/JScanOptions.hpp +69 -0
  138. package/nitrogen/generated/android/c++/JServiceDataEntry.hpp +57 -0
  139. package/nitrogen/generated/android/c++/JState.hpp +71 -0
  140. package/nitrogen/generated/android/c++/JSubscription.hpp +64 -0
  141. package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/BleATTErrorCode.kt +41 -0
  142. package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/BleAndroidErrorCode.kt +39 -0
  143. package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/BleErrorCode.kt +62 -0
  144. package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/BleIOSErrorCode.kt +36 -0
  145. package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/BleManagerNitroOptions.kt +26 -0
  146. package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/BleNitroOnLoad.kt +35 -0
  147. package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/BleRestoredState.kt +26 -0
  148. package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/CharacteristicSubscriptionType.kt +25 -0
  149. package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/ConnectionOptions.kt +28 -0
  150. package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/ConnectionPriority.kt +26 -0
  151. package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/Func_void.kt +80 -0
  152. package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/Func_void_State.kt +80 -0
  153. package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/Func_void_std__optional_NativeBleError__std__optional_NativeCharacteristic_.kt +80 -0
  154. package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/Func_void_std__optional_NativeBleError__std__optional_NativeDevice_.kt +80 -0
  155. package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/HybridBleManagerSpec.kt +192 -0
  156. package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/HybridCharacteristicSpec.kt +127 -0
  157. package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/HybridDescriptorSpec.kt +86 -0
  158. package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/HybridDeviceSpec.kt +176 -0
  159. package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/HybridServiceSpec.kt +99 -0
  160. package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/LogLevel.kt +29 -0
  161. package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/NativeBleError.kt +35 -0
  162. package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/NativeCharacteristic.kt +37 -0
  163. package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/NativeDescriptor.kt +33 -0
  164. package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/NativeDevice.kt +38 -0
  165. package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/NativeService.kt +29 -0
  166. package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/ScanCallbackType.kt +26 -0
  167. package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/ScanMode.kt +27 -0
  168. package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/ScanOptions.kt +29 -0
  169. package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/ServiceDataEntry.kt +27 -0
  170. package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/State.kt +29 -0
  171. package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/Subscription.kt +30 -0
  172. package/nitrogen/generated/ios/BleNitro+autolinking.rb +60 -0
  173. package/nitrogen/generated/ios/BleNitro-Swift-Cxx-Bridge.cpp +236 -0
  174. package/nitrogen/generated/ios/BleNitro-Swift-Cxx-Bridge.hpp +1069 -0
  175. package/nitrogen/generated/ios/BleNitro-Swift-Cxx-Umbrella.hpp +131 -0
  176. package/nitrogen/generated/ios/BleNitroAutolinking.mm +33 -0
  177. package/nitrogen/generated/ios/BleNitroAutolinking.swift +25 -0
  178. package/nitrogen/generated/ios/c++/HybridBleManagerSpecSwift.cpp +11 -0
  179. package/nitrogen/generated/ios/c++/HybridBleManagerSpecSwift.hpp +377 -0
  180. package/nitrogen/generated/ios/c++/HybridCharacteristicSpecSwift.cpp +11 -0
  181. package/nitrogen/generated/ios/c++/HybridCharacteristicSpecSwift.hpp +192 -0
  182. package/nitrogen/generated/ios/c++/HybridDescriptorSpecSwift.cpp +11 -0
  183. package/nitrogen/generated/ios/c++/HybridDescriptorSpecSwift.hpp +112 -0
  184. package/nitrogen/generated/ios/c++/HybridDeviceSpecSwift.cpp +11 -0
  185. package/nitrogen/generated/ios/c++/HybridDeviceSpecSwift.hpp +294 -0
  186. package/nitrogen/generated/ios/c++/HybridServiceSpecSwift.cpp +11 -0
  187. package/nitrogen/generated/ios/c++/HybridServiceSpecSwift.hpp +170 -0
  188. package/nitrogen/generated/ios/swift/BleATTErrorCode.swift +104 -0
  189. package/nitrogen/generated/ios/swift/BleAndroidErrorCode.swift +96 -0
  190. package/nitrogen/generated/ios/swift/BleErrorCode.swift +188 -0
  191. package/nitrogen/generated/ios/swift/BleIOSErrorCode.swift +84 -0
  192. package/nitrogen/generated/ios/swift/BleManagerNitroOptions.swift +53 -0
  193. package/nitrogen/generated/ios/swift/BleRestoredState.swift +47 -0
  194. package/nitrogen/generated/ios/swift/CharacteristicSubscriptionType.swift +40 -0
  195. package/nitrogen/generated/ios/swift/ConnectionOptions.swift +57 -0
  196. package/nitrogen/generated/ios/swift/ConnectionPriority.swift +44 -0
  197. package/nitrogen/generated/ios/swift/Func_void.swift +46 -0
  198. package/nitrogen/generated/ios/swift/Func_void_LogLevel.swift +46 -0
  199. package/nitrogen/generated/ios/swift/Func_void_NativeCharacteristic.swift +46 -0
  200. package/nitrogen/generated/ios/swift/Func_void_NativeDescriptor.swift +46 -0
  201. package/nitrogen/generated/ios/swift/Func_void_NativeDevice.swift +46 -0
  202. package/nitrogen/generated/ios/swift/Func_void_State.swift +46 -0
  203. package/nitrogen/generated/ios/swift/Func_void_bool.swift +46 -0
  204. package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +46 -0
  205. package/nitrogen/generated/ios/swift/Func_void_std__optional_BleRestoredState_.swift +52 -0
  206. package/nitrogen/generated/ios/swift/Func_void_std__optional_NativeBleError__std__optional_NativeCharacteristic_.swift +58 -0
  207. package/nitrogen/generated/ios/swift/Func_void_std__optional_NativeBleError__std__optional_NativeDevice_.swift +58 -0
  208. package/nitrogen/generated/ios/swift/Func_void_std__shared_ptr_margelo__nitro__co__zyke__ble__HybridCharacteristicSpec_.swift +50 -0
  209. package/nitrogen/generated/ios/swift/Func_void_std__shared_ptr_margelo__nitro__co__zyke__ble__HybridDescriptorSpec_.swift +50 -0
  210. package/nitrogen/generated/ios/swift/Func_void_std__vector_NativeCharacteristic_.swift +46 -0
  211. package/nitrogen/generated/ios/swift/Func_void_std__vector_NativeDescriptor_.swift +46 -0
  212. package/nitrogen/generated/ios/swift/Func_void_std__vector_NativeDevice_.swift +46 -0
  213. package/nitrogen/generated/ios/swift/Func_void_std__vector_NativeService_.swift +46 -0
  214. package/nitrogen/generated/ios/swift/HybridBleManagerSpec.swift +78 -0
  215. package/nitrogen/generated/ios/swift/HybridBleManagerSpec_cxx.swift +852 -0
  216. package/nitrogen/generated/ios/swift/HybridCharacteristicSpec.swift +65 -0
  217. package/nitrogen/generated/ios/swift/HybridCharacteristicSpec_cxx.swift +384 -0
  218. package/nitrogen/generated/ios/swift/HybridDescriptorSpec.swift +56 -0
  219. package/nitrogen/generated/ios/swift/HybridDescriptorSpec_cxx.swift +218 -0
  220. package/nitrogen/generated/ios/swift/HybridDeviceSpec.swift +76 -0
  221. package/nitrogen/generated/ios/swift/HybridDeviceSpec_cxx.swift +702 -0
  222. package/nitrogen/generated/ios/swift/HybridServiceSpec.swift +58 -0
  223. package/nitrogen/generated/ios/swift/HybridServiceSpec_cxx.swift +338 -0
  224. package/nitrogen/generated/ios/swift/LogLevel.swift +56 -0
  225. package/nitrogen/generated/ios/swift/NativeBleError.swift +278 -0
  226. package/nitrogen/generated/ios/swift/NativeCharacteristic.swift +174 -0
  227. package/nitrogen/generated/ios/swift/NativeDescriptor.swift +130 -0
  228. package/nitrogen/generated/ios/swift/NativeDevice.swift +377 -0
  229. package/nitrogen/generated/ios/swift/NativeService.swift +68 -0
  230. package/nitrogen/generated/ios/swift/ScanCallbackType.swift +44 -0
  231. package/nitrogen/generated/ios/swift/ScanMode.swift +48 -0
  232. package/nitrogen/generated/ios/swift/ScanOptions.swift +116 -0
  233. package/nitrogen/generated/ios/swift/ServiceDataEntry.swift +46 -0
  234. package/nitrogen/generated/ios/swift/State.swift +56 -0
  235. package/nitrogen/generated/ios/swift/Subscription.swift +46 -0
  236. package/nitrogen/generated/shared/c++/BleATTErrorCode.hpp +80 -0
  237. package/nitrogen/generated/shared/c++/BleAndroidErrorCode.hpp +78 -0
  238. package/nitrogen/generated/shared/c++/BleErrorCode.hpp +101 -0
  239. package/nitrogen/generated/shared/c++/BleIOSErrorCode.hpp +75 -0
  240. package/nitrogen/generated/shared/c++/BleManagerNitroOptions.hpp +70 -0
  241. package/nitrogen/generated/shared/c++/BleRestoredState.hpp +71 -0
  242. package/nitrogen/generated/shared/c++/CharacteristicSubscriptionType.hpp +64 -0
  243. package/nitrogen/generated/shared/c++/ConnectionOptions.hpp +77 -0
  244. package/nitrogen/generated/shared/c++/ConnectionPriority.hpp +65 -0
  245. package/nitrogen/generated/shared/c++/HybridBleManagerSpec.cpp +51 -0
  246. package/nitrogen/generated/shared/c++/HybridBleManagerSpec.hpp +137 -0
  247. package/nitrogen/generated/shared/c++/HybridCharacteristicSpec.cpp +39 -0
  248. package/nitrogen/generated/shared/c++/HybridCharacteristicSpec.hpp +101 -0
  249. package/nitrogen/generated/shared/c++/HybridDescriptorSpec.cpp +30 -0
  250. package/nitrogen/generated/shared/c++/HybridDescriptorSpec.hpp +75 -0
  251. package/nitrogen/generated/shared/c++/HybridDeviceSpec.cpp +50 -0
  252. package/nitrogen/generated/shared/c++/HybridDeviceSpec.hpp +123 -0
  253. package/nitrogen/generated/shared/c++/HybridServiceSpec.cpp +32 -0
  254. package/nitrogen/generated/shared/c++/HybridServiceSpec.hpp +90 -0
  255. package/nitrogen/generated/shared/c++/LogLevel.hpp +68 -0
  256. package/nitrogen/generated/shared/c++/NativeBleError.hpp +117 -0
  257. package/nitrogen/generated/shared/c++/NativeCharacteristic.hpp +114 -0
  258. package/nitrogen/generated/shared/c++/NativeDescriptor.hpp +98 -0
  259. package/nitrogen/generated/shared/c++/NativeDevice.hpp +121 -0
  260. package/nitrogen/generated/shared/c++/NativeService.hpp +81 -0
  261. package/nitrogen/generated/shared/c++/ScanCallbackType.hpp +65 -0
  262. package/nitrogen/generated/shared/c++/ScanMode.hpp +66 -0
  263. package/nitrogen/generated/shared/c++/ScanOptions.hpp +86 -0
  264. package/nitrogen/generated/shared/c++/ServiceDataEntry.hpp +73 -0
  265. package/nitrogen/generated/shared/c++/State.hpp +68 -0
  266. package/nitrogen/generated/shared/c++/Subscription.hpp +69 -0
  267. package/package.json +15 -14
  268. package/plugin/build/index.d.ts +1 -1
  269. package/plugin/build/index.js +42 -4
  270. package/plugin/build/withBleNitro.d.ts +1 -1
  271. package/plugin/build/withBleNitro.js +16 -11
  272. package/react-native.config.js +2 -7
  273. package/src/BleManagerCompatFactory.ts +10 -10
  274. package/src/BleManagerFactory.ts +68 -5
  275. package/src/__tests__/BleManager.test.ts +2 -2
  276. package/src/__tests__/compatibility/enums.test.ts +0 -1
  277. package/src/compatibility/constants.ts +1 -1
  278. package/src/compatibility/deviceWrapper.ts +4 -4
  279. package/src/compatibility/enums.ts +1 -1
  280. package/src/compatibility/index.ts +5 -5
  281. package/src/compatibility/serviceData.ts +1 -1
  282. package/src/errors/BleError.ts +2 -2
  283. package/src/index.ts +12 -9
  284. package/src/specs/BleManager.nitro.ts +17 -4
  285. package/src/specs/Characteristic.nitro.ts +1 -1
  286. package/src/specs/Descriptor.nitro.ts +1 -1
  287. package/src/specs/Device.nitro.ts +1 -1
  288. package/src/specs/Service.nitro.ts +1 -1
  289. package/android/src/main/kotlin/co/zyke/ble/BleNitroPackage.kt +0 -37
  290. package/ios/BleNitro.podspec +0 -37
@@ -36,6 +36,9 @@ android {
36
36
  }
37
37
  }
38
38
 
39
+ // Apply Nitro autolinking
40
+ apply from: '../nitrogen/generated/android/BleNitro+autolinking.gradle'
41
+
39
42
  dependencies {
40
43
  implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
41
44
  implementation 'androidx.core:core-ktx:1.9.0'
@@ -4,7 +4,7 @@
4
4
  * Copyright © 2025 Zyke (https://zyke.co)
5
5
  */
6
6
 
7
- package co.zyke.ble
7
+ package com.margelo.nitro.co.zyke.ble
8
8
 
9
9
  import android.bluetooth.*
10
10
  import android.bluetooth.le.*
@@ -15,6 +15,7 @@ import android.util.Base64
15
15
  import android.util.Log
16
16
  import androidx.core.content.ContextCompat
17
17
  import com.facebook.react.bridge.ReactApplicationContext
18
+ import com.margelo.nitro.co.zyke.ble.HybridBleManagerSpec
18
19
  import com.margelo.nitro.NitroModules
19
20
  import kotlinx.coroutines.*
20
21
  import kotlinx.coroutines.channels.Channel
@@ -33,7 +34,12 @@ import com.margelo.nitro.co.zyke.ble.*
33
34
  * Core BLE Manager implementation using Android BLE APIs
34
35
  * Implements the HybridBleManagerSpec interface generated by Nitro
35
36
  */
36
- class BleNitroBleManager(private val context: ReactApplicationContext) : HybridBleManagerSpec {
37
+ class BleNitroBleManager : HybridBleManagerSpec {
38
+
39
+ // Get context from Nitro's context system
40
+ private val context: ReactApplicationContext by lazy {
41
+ NitroModules.getReactApplicationContext()
42
+ }
37
43
 
38
44
  companion object {
39
45
  private const val TAG = "BleNitroBleManager"
@@ -57,6 +63,11 @@ class BleNitroBleManager(private val context: ReactApplicationContext) : HybridB
57
63
  private var logLevel: LogLevel = LogLevel.None
58
64
  private var isScanning = false
59
65
  private var scanCallback: ScanCallback? = null
66
+
67
+ // State restoration
68
+ private var restoreIdentifier: String? = null
69
+ private var isInitialized = false
70
+ private var restoredState: BleRestoredState? = null
60
71
  private var scanListener: ((NativeBleError?, NativeDevice?) -> Unit)? = null
61
72
  private var stateChangeListener: ((State) -> Unit)? = null
62
73
 
@@ -100,6 +111,104 @@ class BleNitroBleManager(private val context: ReactApplicationContext) : HybridB
100
111
  }
101
112
  }
102
113
 
114
+ override fun initialize(options: BleManagerNitroOptions): Promise<Unit> = Promise.resolve {
115
+ options.restoreStateIdentifier?.let { restoreId ->
116
+ this.restoreIdentifier = restoreId
117
+
118
+ // Attempt to restore previous state from SharedPreferences
119
+ restoreConnectionState(restoreId)
120
+
121
+ Log.d(TAG, "BleNitro: Initialized with restore state identifier: $restoreId")
122
+ }
123
+
124
+ this.isInitialized = true
125
+ Log.d(TAG, "BleNitro: BLE Manager initialized")
126
+ Unit
127
+ }
128
+
129
+ override fun getRestoredState(): Promise<BleRestoredState?> = Promise.resolve {
130
+ restoredState
131
+ }
132
+
133
+ private fun restoreConnectionState(restoreId: String) {
134
+ try {
135
+ val sharedPrefs = context.getSharedPreferences("BleNitro_$restoreId", Context.MODE_PRIVATE)
136
+ val connectedDevicesJson = sharedPrefs.getString("connected_devices", null)
137
+
138
+ connectedDevicesJson?.let { json ->
139
+ // Parse stored device IDs and attempt to reconnect
140
+ val deviceIds = json.split(",").filter { it.isNotEmpty() }
141
+
142
+ if (deviceIds.isNotEmpty()) {
143
+ Log.d(TAG, "BleNitro: Restoring ${deviceIds.size} devices")
144
+
145
+ deviceIds.forEach { deviceId ->
146
+ // Attempt to reconnect to previously connected devices
147
+ restoreDeviceConnection(deviceId)
148
+ }
149
+
150
+ // Store restored state (initially empty, will be populated as devices reconnect)
151
+ val initialDevices = deviceIds.mapNotNull { deviceId ->
152
+ bluetoothAdapter?.getRemoteDevice(deviceId)?.let { device ->
153
+ createNativeDevice(device, null, -1) // Initial state without GATT
154
+ }
155
+ }
156
+
157
+ if (initialDevices.isNotEmpty()) {
158
+ this.restoredState = BleRestoredState(initialDevices)
159
+ Log.d(TAG, "BleNitro: Stored restored state with ${initialDevices.size} devices")
160
+ }
161
+ }
162
+ }
163
+ } catch (e: Exception) {
164
+ Log.e(TAG, "BleNitro: Error restoring connection state", e)
165
+ }
166
+ }
167
+
168
+ private fun restoreDeviceConnection(deviceId: String) {
169
+ try {
170
+ val bluetoothDevice = bluetoothAdapter?.getRemoteDevice(deviceId)
171
+ bluetoothDevice?.let { device ->
172
+ Log.d(TAG, "BleNitro: Attempting to restore connection to $deviceId")
173
+
174
+ val gatt = device.connectGatt(context, true, object : BluetoothGattCallback() {
175
+ override fun onConnectionStateChange(gatt: BluetoothGatt?, status: Int, newState: Int) {
176
+ if (newState == BluetoothProfile.STATE_CONNECTED) {
177
+ connectedDevices[deviceId] = gatt!!
178
+ Log.d(TAG, "BleNitro: Successfully restored connection to $deviceId")
179
+ } else if (newState == BluetoothProfile.STATE_DISCONNECTED) {
180
+ Log.d(TAG, "BleNitro: Failed to restore connection to $deviceId")
181
+ gatt?.close()
182
+ }
183
+ }
184
+ })
185
+
186
+ if (gatt != null) {
187
+ deviceCallbacks[deviceId] = gatt
188
+ }
189
+ }
190
+ } catch (e: Exception) {
191
+ Log.e(TAG, "BleNitro: Error restoring device connection for $deviceId", e)
192
+ }
193
+ }
194
+
195
+ private fun saveConnectionState() {
196
+ restoreIdentifier?.let { restoreId ->
197
+ try {
198
+ val sharedPrefs = context.getSharedPreferences("BleNitro_$restoreId", Context.MODE_PRIVATE)
199
+ val deviceIds = connectedDevices.keys.joinToString(",")
200
+
201
+ sharedPrefs.edit()
202
+ .putString("connected_devices", deviceIds)
203
+ .apply()
204
+
205
+ Log.d(TAG, "BleNitro: Saved connection state for ${connectedDevices.size} devices")
206
+ } catch (e: Exception) {
207
+ Log.e(TAG, "BleNitro: Error saving connection state", e)
208
+ }
209
+ }
210
+ }
211
+
103
212
  override fun setLogLevel(logLevel: LogLevel): Promise<LogLevel> = Promise.resolve {
104
213
  this.logLevel = logLevel
105
214
  logLevel
package/app.plugin.cjs ADDED
@@ -0,0 +1 @@
1
+ module.exports = require('./plugin/build/index.js').default; // eslint-disable-line @typescript-eslint/no-var-requires
@@ -26,12 +26,28 @@ public class BleNitroBleManager: HybridBleManagerSpec, CBCentralManagerDelegate
26
26
  private var characteristicMonitors: [String: ((_ error: NativeBleError?, _ characteristic: NativeCharacteristic?) -> Void)] = [:]
27
27
  private var pendingOperations: [String: Any] = [:]
28
28
 
29
+ // State restoration
30
+ private var restoreIdentifier: String?
31
+ private var isInitialized = false
32
+ private var restoredState: BleRestoredState?
33
+
29
34
  // MARK: - Initialization
30
35
  public override init() {
31
36
  super.init()
37
+ // Initialize with default options - will be reconfigured in initialize() method
32
38
  self.centralManager = CBCentralManager(delegate: self, queue: nil)
33
39
  }
34
40
 
41
+ private func reinitializeCentralManager() {
42
+ // Create CBCentralManager with state restoration if identifier is provided
43
+ var options: [String: Any] = [:]
44
+ if let restoreId = restoreIdentifier {
45
+ options[CBCentralManagerOptionRestoreIdentifierKey] = restoreId
46
+ }
47
+
48
+ self.centralManager = CBCentralManager(delegate: self, queue: nil, options: options.isEmpty ? nil : options)
49
+ }
50
+
35
51
  public override var memorySize: Int {
36
52
  return MemorySize.MemorySize_estimate(self)
37
53
  }
@@ -51,6 +67,29 @@ public class BleNitroBleManager: HybridBleManagerSpec, CBCentralManagerDelegate
51
67
  }
52
68
  }
53
69
 
70
+ public func initialize(options: BleManagerNitroOptions) throws -> Promise<Void> {
71
+ return Promise.resolve(withBlock: {
72
+ if let restoreId = options.restoreStateIdentifier {
73
+ // Store the restore identifier
74
+ self.restoreIdentifier = restoreId
75
+
76
+ // Reinitialize the central manager with state restoration
77
+ self.reinitializeCentralManager()
78
+
79
+ print("BleNitro: Initialized with restore state identifier: \(restoreId)")
80
+ }
81
+
82
+ self.isInitialized = true
83
+ print("BleNitro: BLE Manager initialized")
84
+ })
85
+ }
86
+
87
+ public func getRestoredState() throws -> Promise<BleRestoredState?> {
88
+ return Promise.resolve(withBlock: {
89
+ return self.restoredState
90
+ })
91
+ }
92
+
54
93
  public func setLogLevel(logLevel: LogLevel) throws -> Promise<LogLevel> {
55
94
  return Promise.resolve(withBlock: {
56
95
  self.logLevel = logLevel
@@ -296,6 +335,7 @@ public class BleNitroBleManager: HybridBleManagerSpec, CBCentralManagerDelegate
296
335
  public func centralManagerDidUpdateState(_ central: CBCentralManager) {
297
336
  let state = mapCBManagerState(central.state)
298
337
  stateChangeListener?(state)
338
+ print("BleNitro: Central manager state changed to: \(central.state.rawValue)")
299
339
  }
300
340
 
301
341
  public func centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: [String: Any], rssi RSSI: NSNumber) {
@@ -491,6 +531,32 @@ extension BleNitroBleManager: CBPeripheralDelegate {
491
531
  }
492
532
  }
493
533
  }
534
+
535
+ // MARK: - CBCentralManagerDelegate State Restoration
536
+
537
+ public func centralManager(_ central: CBCentralManager, willRestoreState dict: [String : Any]) {
538
+ // Handle state restoration
539
+ if let peripherals = dict[CBCentralManagerRestoredStatePeripheralsKey] as? [CBPeripheral] {
540
+ print("BleNitro: Restoring \(peripherals.count) peripherals")
541
+
542
+ // Add restored peripherals to our connected devices
543
+ for peripheral in peripherals {
544
+ let deviceId = peripheral.identifier.uuidString
545
+ connectedDevices[deviceId] = peripheral
546
+ peripheral.delegate = self
547
+
548
+ print("BleNitro: Restored peripheral: \(deviceId)")
549
+ }
550
+
551
+ // Store restored state for later retrieval
552
+ if !peripherals.isEmpty {
553
+ let restoredDevices = peripherals.map(createNativeDevice)
554
+ self.restoredState = BleRestoredState(connectedPeripherals: restoredDevices)
555
+ print("BleNitro: Stored restored state with \(restoredDevices.count) devices")
556
+ }
557
+ }
558
+ }
559
+
494
560
  }
495
561
 
496
562
  /**
@@ -19,13 +19,6 @@ public class BleNitroModule: NSObject {
19
19
  public func constantsToExport() -> [String: Any] {
20
20
  return [:]
21
21
  }
22
- }
23
-
24
- /**
25
- * Nitro module factory for creating BLE manager instances
26
- */
27
- @_cdecl("create_ble_nitro_manager")
28
- public func createBleNitroManager() -> UnsafeMutableRawPointer {
29
- let manager = BleNitroBleManager()
30
- return Unmanaged.passRetained(manager).toOpaque()
22
+
23
+ // Autolinking handles the Nitro registration automatically
31
24
  }
@@ -4,9 +4,9 @@
4
4
  * Creates BleManager instances with full react-native-ble-plx compatibility
5
5
  * by wrapping the Nitro implementation with compatibility shims
6
6
  */
7
- import type { BleManagerOptions, UUID, DeviceId, TransactionId, ConnectionPriority, ConnectionOptions, ScanOptions, NativeService, NativeCharacteristic, NativeDescriptor, LogLevel, Subscription } from './specs/types.js';
8
- import { DeviceWrapper } from './compatibility/deviceWrapper.js';
9
- import { State as PlxState, LogLevel as PlxLogLevel } from './compatibility/enums.js';
7
+ import type { BleManagerOptions, UUID, DeviceId, TransactionId, ConnectionPriority, ConnectionOptions, ScanOptions, NativeService, NativeCharacteristic, NativeDescriptor, LogLevel, Subscription } from './specs/types';
8
+ import { DeviceWrapper } from './compatibility/deviceWrapper';
9
+ import { State as PlxState, LogLevel as PlxLogLevel } from './compatibility/enums';
10
10
  /**
11
11
  * BleManager wrapper that provides react-native-ble-plx compatibility
12
12
  */
@@ -38,7 +38,8 @@ export declare class BleManagerCompat {
38
38
  readCharacteristicForDevice(deviceIdentifier: DeviceId, serviceUUID: UUID, characteristicUUID: UUID, transactionId?: TransactionId): Promise<NativeCharacteristic>;
39
39
  writeCharacteristicWithResponseForDevice(deviceIdentifier: DeviceId, serviceUUID: UUID, characteristicUUID: UUID, base64Value: string, transactionId?: TransactionId): Promise<NativeCharacteristic>;
40
40
  writeCharacteristicWithoutResponseForDevice(deviceIdentifier: DeviceId, serviceUUID: UUID, characteristicUUID: UUID, base64Value: string, transactionId?: TransactionId): Promise<NativeCharacteristic>;
41
- monitorCharacteristicForDevice(deviceIdentifier: DeviceId, serviceUUID: UUID, characteristicUUID: UUID, listener: (error: any | null, characteristic: NativeCharacteristic | null) => void, transactionId?: TransactionId, subscriptionType?: 'notification' | 'indication'): Subscription;
41
+ monitorCharacteristicForDevice(deviceIdentifier: DeviceId, serviceUUID: UUID, characteristicUUID: UUID, listener: (error: any | null, characteristic: NativeCharacteristic | null) => void, // TODO: COMPAT! use proper error type like in react-native-ble-plx
42
+ transactionId?: TransactionId, subscriptionType?: 'notification' | 'indication'): Subscription;
42
43
  descriptorsForDevice(deviceIdentifier: DeviceId, serviceUUID: UUID, characteristicUUID: UUID): Promise<NativeDescriptor[]>;
43
44
  readDescriptorForDevice(deviceIdentifier: DeviceId, serviceUUID: UUID, characteristicUUID: UUID, descriptorUUID: UUID, transactionId?: TransactionId): Promise<NativeDescriptor>;
44
45
  writeDescriptorForDevice(deviceIdentifier: DeviceId, serviceUUID: UUID, characteristicUUID: UUID, descriptorUUID: UUID, valueBase64: string, transactionId?: TransactionId): Promise<NativeDescriptor>;
@@ -4,9 +4,9 @@
4
4
  * Creates BleManager instances with full react-native-ble-plx compatibility
5
5
  * by wrapping the Nitro implementation with compatibility shims
6
6
  */
7
- import { createBleManager } from './BleManagerFactory.js';
8
- import { DeviceWrapper } from './compatibility/deviceWrapper.js';
9
- import { stateToString, logLevelToString, normalizeLogLevel, normalizeCharacteristicSubscriptionType } from './compatibility/enums.js';
7
+ import { createBleManager } from './BleManagerFactory';
8
+ import { DeviceWrapper } from './compatibility/deviceWrapper';
9
+ import { stateToString, logLevelToString, normalizeLogLevel, normalizeCharacteristicSubscriptionType } from './compatibility/enums';
10
10
  /**
11
11
  * BleManager wrapper that provides react-native-ble-plx compatibility
12
12
  */
@@ -50,7 +50,8 @@ export class BleManagerCompat {
50
50
  }, emitCurrentState);
51
51
  }
52
52
  // Device scanning with compatibility wrappers
53
- async startDeviceScan(uuids, options, listener) {
53
+ async startDeviceScan(uuids, options, listener // TODO: COMPAT! remove any and move to BleError as react-native-ble-plx uses this type as well!
54
+ ) {
54
55
  return await this.bleManager.startDeviceScan(uuids, options, (error, device) => {
55
56
  listener(error, device ? new DeviceWrapper(this.createDeviceFromNative(device)) : null);
56
57
  });
@@ -76,7 +77,8 @@ export class BleManagerCompat {
76
77
  async isDeviceConnected(deviceIdentifier) {
77
78
  return await this.bleManager.isDeviceConnected(deviceIdentifier);
78
79
  }
79
- onDeviceDisconnected(deviceIdentifier, listener) {
80
+ onDeviceDisconnected(deviceIdentifier, listener // TODO: COMPAT! use propper error type like in react-native-ble-plx!!!
81
+ ) {
80
82
  return this.bleManager.onDeviceDisconnected(deviceIdentifier, (error, device) => {
81
83
  listener(error, device ? new DeviceWrapper(this.createDeviceFromNative(device)) : null);
82
84
  });
@@ -125,7 +127,8 @@ export class BleManagerCompat {
125
127
  async writeCharacteristicWithoutResponseForDevice(deviceIdentifier, serviceUUID, characteristicUUID, base64Value, transactionId) {
126
128
  return await this.bleManager.writeCharacteristicWithoutResponseForDevice(deviceIdentifier, serviceUUID, characteristicUUID, base64Value, transactionId);
127
129
  }
128
- monitorCharacteristicForDevice(deviceIdentifier, serviceUUID, characteristicUUID, listener, transactionId, subscriptionType) {
130
+ monitorCharacteristicForDevice(deviceIdentifier, serviceUUID, characteristicUUID, listener, // TODO: COMPAT! use proper error type like in react-native-ble-plx
131
+ transactionId, subscriptionType) {
129
132
  const nitroSubscriptionType = subscriptionType
130
133
  ? normalizeCharacteristicSubscriptionType(subscriptionType)
131
134
  : undefined;
@@ -1,12 +1,30 @@
1
- import type { BleManager as BleManagerInterface } from './specs/BleManager.nitro.js';
2
- import type { BleManagerOptions } from './specs/types.js';
1
+ import type { BleManager as BleManagerInterface } from './specs/BleManager.nitro';
2
+ import type { BleManagerOptions } from './specs/types';
3
3
  /**
4
4
  * Creates a BleManager instance using Nitro Modules
5
5
  * This function maintains compatibility with react-native-ble-plx's BleManager constructor
6
6
  */
7
7
  export declare function createBleManager(options?: BleManagerOptions): BleManagerInterface;
8
+ /**
9
+ * Helper function to retrieve stored callbacks for a BleManager instance
10
+ * This is used internally when callbacks need to be invoked
11
+ */
12
+ export declare function getStoredCallbacks(manager: BleManagerInterface): {
13
+ restoreStateFunction?: (restoredState: any) => void;
14
+ errorCodesToMessagesMapping?: {
15
+ [key: number]: string;
16
+ };
17
+ } | undefined;
18
+ /**
19
+ * Helper function to get custom error message if available
20
+ * @param manager The BleManager instance
21
+ * @param errorCode The BLE error code
22
+ * @param defaultMessage Default error message
23
+ * @returns Custom message if available, otherwise default message
24
+ */
25
+ export declare function getCustomErrorMessage(manager: BleManagerInterface, errorCode: number, defaultMessage: string): string;
8
26
  /**
9
27
  * Legacy compatibility: Export a BleManager constructor function
10
28
  * This maintains compatibility with code that imports { BleManager } from 'react-native-ble-plx'
11
29
  */
12
- export declare const BleManager: any;
30
+ export declare const BleManager: (options?: BleManagerOptions) => BleManagerInterface;
@@ -1,4 +1,6 @@
1
1
  import { NitroModules } from 'react-native-nitro-modules';
2
+ // Store callbacks that can't be passed to Nitro
3
+ const storedCallbacks = new WeakMap();
2
4
  /**
3
5
  * Creates a BleManager instance using Nitro Modules
4
6
  * This function maintains compatibility with react-native-ble-plx's BleManager constructor
@@ -9,10 +11,59 @@ export function createBleManager(options) {
9
11
  throw new Error('Failed to create BleManager: Nitro module not found. ' +
10
12
  'Make sure react-native-ble-nitro is properly installed and linked.');
11
13
  }
12
- // If options are provided, we could initialize with them
13
- // For now, we return the module directly as Nitro handles the native initialization
14
+ // Initialize with options if provided
15
+ if (options) {
16
+ // Extract Nitro-compatible options
17
+ const nitroOptions = {
18
+ restoreStateIdentifier: options.restoreStateIdentifier,
19
+ };
20
+ // Store callbacks and mappings that can't be passed to Nitro
21
+ if (options.restoreStateFunction || options.errorCodesToMessagesMapping) {
22
+ storedCallbacks.set(BleManagerModule, {
23
+ restoreStateFunction: options.restoreStateFunction,
24
+ errorCodesToMessagesMapping: options.errorCodesToMessagesMapping,
25
+ });
26
+ }
27
+ // Note: initialize() is async but we need to maintain sync compatibility with react-native-ble-plx
28
+ // The initialization will happen asynchronously in the background
29
+ BleManagerModule.initialize(nitroOptions).then(async () => {
30
+ // Check for restored state and call the callback if available
31
+ if (options.restoreStateFunction) {
32
+ try {
33
+ const restoredState = await BleManagerModule.getRestoredState();
34
+ if (restoredState) {
35
+ options.restoreStateFunction(restoredState);
36
+ }
37
+ }
38
+ catch (error) {
39
+ console.warn('BleManager restore state callback failed:', error);
40
+ }
41
+ }
42
+ }).catch(error => {
43
+ console.warn('BleManager initialization failed:', error);
44
+ });
45
+ }
14
46
  return BleManagerModule;
15
47
  }
48
+ /**
49
+ * Helper function to retrieve stored callbacks for a BleManager instance
50
+ * This is used internally when callbacks need to be invoked
51
+ */
52
+ export function getStoredCallbacks(manager) {
53
+ return storedCallbacks.get(manager);
54
+ }
55
+ /**
56
+ * Helper function to get custom error message if available
57
+ * @param manager The BleManager instance
58
+ * @param errorCode The BLE error code
59
+ * @param defaultMessage Default error message
60
+ * @returns Custom message if available, otherwise default message
61
+ */
62
+ export function getCustomErrorMessage(manager, errorCode, defaultMessage) {
63
+ const callbacks = storedCallbacks.get(manager);
64
+ const customMessage = callbacks?.errorCodesToMessagesMapping?.[errorCode];
65
+ return customMessage || defaultMessage;
66
+ }
16
67
  /**
17
68
  * Legacy compatibility: Export a BleManager constructor function
18
69
  * This maintains compatibility with code that imports { BleManager } from 'react-native-ble-plx'
@@ -0,0 +1,56 @@
1
+ /**
2
+ * BleManager Compatibility Factory
3
+ *
4
+ * Creates BleManager instances with full react-native-ble-plx compatibility
5
+ * by wrapping the Nitro implementation with compatibility shims
6
+ */
7
+ import type { BleManagerOptions, UUID, DeviceId, TransactionId, ConnectionPriority, ConnectionOptions, ScanOptions, NativeService, NativeCharacteristic, NativeDescriptor, LogLevel, Subscription } from './specs/types';
8
+ import { DeviceWrapper } from './compatibility/deviceWrapper';
9
+ import { State as PlxState, LogLevel as PlxLogLevel } from './compatibility/enums';
10
+ /**
11
+ * BleManager wrapper that provides react-native-ble-plx compatibility
12
+ */
13
+ export declare class BleManagerCompat {
14
+ private bleManager;
15
+ constructor(options?: BleManagerOptions);
16
+ destroy(): Promise<void>;
17
+ setLogLevel(logLevel: LogLevel | string): Promise<PlxLogLevel>;
18
+ logLevel(): Promise<PlxLogLevel>;
19
+ cancelTransaction(transactionId: TransactionId): Promise<void>;
20
+ enable(transactionId?: TransactionId): Promise<BleManagerCompat>;
21
+ disable(transactionId?: TransactionId): Promise<BleManagerCompat>;
22
+ state(): Promise<PlxState>;
23
+ onStateChange(listener: (newState: PlxState) => void, emitCurrentState?: boolean): Subscription;
24
+ startDeviceScan(uuids: UUID[] | null, options: ScanOptions | null, listener: (error: any | null, scannedDevice: DeviceWrapper | null) => void): Promise<void>;
25
+ stopDeviceScan(): Promise<void>;
26
+ connectToDevice(deviceIdentifier: DeviceId, options?: Partial<ConnectionOptions>): Promise<DeviceWrapper>;
27
+ cancelDeviceConnection(deviceIdentifier: DeviceId): Promise<DeviceWrapper>;
28
+ isDeviceConnected(deviceIdentifier: DeviceId): Promise<boolean>;
29
+ onDeviceDisconnected(deviceIdentifier: DeviceId, listener: (error: any | null, device: DeviceWrapper | null) => void): Subscription;
30
+ devices(deviceIdentifiers: DeviceId[]): Promise<DeviceWrapper[]>;
31
+ connectedDevices(serviceUUIDs: UUID[]): Promise<DeviceWrapper[]>;
32
+ readRSSIForDevice(deviceIdentifier: DeviceId, transactionId?: TransactionId): Promise<DeviceWrapper>;
33
+ requestMTUForDevice(deviceIdentifier: DeviceId, mtu: number, transactionId?: TransactionId): Promise<DeviceWrapper>;
34
+ requestConnectionPriorityForDevice(deviceIdentifier: DeviceId, connectionPriority: ConnectionPriority, transactionId?: TransactionId): Promise<DeviceWrapper>;
35
+ discoverAllServicesAndCharacteristicsForDevice(deviceIdentifier: DeviceId, transactionId?: TransactionId): Promise<DeviceWrapper>;
36
+ servicesForDevice(deviceIdentifier: DeviceId): Promise<NativeService[]>;
37
+ characteristicsForDevice(deviceIdentifier: DeviceId, serviceUUID: UUID): Promise<NativeCharacteristic[]>;
38
+ readCharacteristicForDevice(deviceIdentifier: DeviceId, serviceUUID: UUID, characteristicUUID: UUID, transactionId?: TransactionId): Promise<NativeCharacteristic>;
39
+ writeCharacteristicWithResponseForDevice(deviceIdentifier: DeviceId, serviceUUID: UUID, characteristicUUID: UUID, base64Value: string, transactionId?: TransactionId): Promise<NativeCharacteristic>;
40
+ writeCharacteristicWithoutResponseForDevice(deviceIdentifier: DeviceId, serviceUUID: UUID, characteristicUUID: UUID, base64Value: string, transactionId?: TransactionId): Promise<NativeCharacteristic>;
41
+ monitorCharacteristicForDevice(deviceIdentifier: DeviceId, serviceUUID: UUID, characteristicUUID: UUID, listener: (error: any | null, characteristic: NativeCharacteristic | null) => void, // TODO: COMPAT! use proper error type like in react-native-ble-plx
42
+ transactionId?: TransactionId, subscriptionType?: 'notification' | 'indication'): Subscription;
43
+ descriptorsForDevice(deviceIdentifier: DeviceId, serviceUUID: UUID, characteristicUUID: UUID): Promise<NativeDescriptor[]>;
44
+ readDescriptorForDevice(deviceIdentifier: DeviceId, serviceUUID: UUID, characteristicUUID: UUID, descriptorUUID: UUID, transactionId?: TransactionId): Promise<NativeDescriptor>;
45
+ writeDescriptorForDevice(deviceIdentifier: DeviceId, serviceUUID: UUID, characteristicUUID: UUID, descriptorUUID: UUID, valueBase64: string, transactionId?: TransactionId): Promise<NativeDescriptor>;
46
+ /**
47
+ * Helper method to create a Device wrapper from NativeDevice data
48
+ * This is a temporary method until we have proper Device Nitro objects
49
+ */
50
+ private createDeviceFromNative;
51
+ }
52
+ /**
53
+ * Factory function to create a compatibility BleManager
54
+ */
55
+ export declare function createBleManagerCompat(options?: BleManagerOptions): BleManagerCompat;
56
+ //# sourceMappingURL=BleManagerCompatFactory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BleManagerCompatFactory.d.ts","sourceRoot":"","sources":["../../src/BleManagerCompatFactory.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EACV,iBAAiB,EACjB,IAAI,EACJ,QAAQ,EACR,aAAa,EACb,kBAAkB,EAClB,iBAAiB,EACjB,WAAW,EAEX,aAAa,EACb,oBAAoB,EACpB,gBAAgB,EAChB,QAAQ,EACR,YAAY,EACb,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAKL,KAAK,IAAI,QAAQ,EACjB,QAAQ,IAAI,WAAW,EACxB,MAAM,uBAAuB,CAAC;AAG/B;;GAEG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,UAAU,CAAsB;gBAE5B,OAAO,CAAC,EAAE,iBAAiB;IAKjC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAKxB,WAAW,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAM9D,QAAQ,IAAI,OAAO,CAAC,WAAW,CAAC;IAKhC,iBAAiB,CAAC,aAAa,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAK9D,MAAM,CAA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