munim-bluetooth 0.3.26 → 0.4.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.
Files changed (116) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +476 -74
  3. package/android/gradle.properties +2 -2
  4. package/android/src/main/AndroidManifest.xml +3 -1
  5. package/android/src/main/cpp/cpp-adapter.cpp +4 -1
  6. package/android/src/main/java/com/munimbluetooth/BluetoothPermissionUtils.kt +40 -0
  7. package/android/src/main/java/com/munimbluetooth/HybridMunimBluetooth.kt +2116 -217
  8. package/android/src/main/java/com/munimbluetooth/MunimBluetoothBackgroundService.kt +591 -56
  9. package/app.plugin.js +155 -0
  10. package/ios/HybridMunimBluetooth.swift +2123 -298
  11. package/ios/MunimBluetoothEventEmitter.swift +68 -8
  12. package/lib/commonjs/index.js +272 -11
  13. package/lib/commonjs/index.js.map +1 -1
  14. package/lib/module/index.js +243 -11
  15. package/lib/module/index.js.map +1 -1
  16. package/lib/typescript/src/index.d.ts +310 -7
  17. package/lib/typescript/src/index.d.ts.map +1 -1
  18. package/lib/typescript/src/specs/munim-bluetooth.nitro.d.ts +219 -5
  19. package/lib/typescript/src/specs/munim-bluetooth.nitro.d.ts.map +1 -1
  20. package/nitro.json +9 -3
  21. package/nitrogen/generated/android/c++/JAdvertisingDataTypes.hpp +96 -96
  22. package/nitrogen/generated/android/c++/JAdvertisingOptions.hpp +8 -8
  23. package/nitrogen/generated/android/c++/JBackgroundSessionOptions.hpp +8 -8
  24. package/nitrogen/generated/android/c++/JBluetoothCapabilities.hpp +105 -0
  25. package/nitrogen/generated/android/c++/JBluetoothPhy.hpp +61 -0
  26. package/nitrogen/generated/android/c++/JBluetoothPhyOption.hpp +61 -0
  27. package/nitrogen/generated/android/c++/JBondState.hpp +64 -0
  28. package/nitrogen/generated/android/c++/JDescriptorValue.hpp +69 -0
  29. package/nitrogen/generated/android/c++/JExtendedAdvertisingOptions.hpp +131 -0
  30. package/nitrogen/generated/android/c++/JGATTCharacteristic.hpp +35 -11
  31. package/nitrogen/generated/android/c++/JGATTDescriptor.hpp +85 -0
  32. package/nitrogen/generated/android/c++/JGATTService.hpp +33 -9
  33. package/nitrogen/generated/android/c++/JHybridMunimBluetoothSpec.cpp +422 -12
  34. package/nitrogen/generated/android/c++/JHybridMunimBluetoothSpec.hpp +29 -0
  35. package/nitrogen/generated/android/c++/JL2CAPChannel.hpp +66 -0
  36. package/nitrogen/generated/android/c++/JMultipeerDiscoveryInfoEntry.hpp +61 -0
  37. package/nitrogen/generated/android/c++/JMultipeerEncryptionPreference.hpp +61 -0
  38. package/nitrogen/generated/android/c++/JMultipeerPeer.hpp +93 -0
  39. package/nitrogen/generated/android/c++/JMultipeerPeerState.hpp +61 -0
  40. package/nitrogen/generated/android/c++/JMultipeerSessionOptions.hpp +105 -0
  41. package/nitrogen/generated/android/c++/JPhyStatus.hpp +62 -0
  42. package/nitrogen/generated/android/c++/JScanOptions.hpp +8 -8
  43. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/AdvertisingDataTypes.kt +47 -0
  44. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/AdvertisingOptions.kt +19 -0
  45. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/BackgroundSessionOptions.kt +27 -0
  46. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/BluetoothCapabilities.kt +111 -0
  47. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/BluetoothPhy.kt +24 -0
  48. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/BluetoothPhyOption.kt +24 -0
  49. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/BondState.kt +25 -0
  50. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/CharacteristicValue.kt +17 -0
  51. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/DescriptorValue.kt +66 -0
  52. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/ExtendedAdvertisingOptions.kt +111 -0
  53. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/GATTCharacteristic.kt +25 -3
  54. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/GATTDescriptor.kt +61 -0
  55. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/GATTService.kt +23 -3
  56. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/HybridMunimBluetoothSpec.kt +138 -22
  57. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/L2CAPChannel.kt +61 -0
  58. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/MultipeerDiscoveryInfoEntry.kt +56 -0
  59. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/MultipeerEncryptionPreference.kt +24 -0
  60. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/MultipeerPeer.kt +66 -0
  61. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/MultipeerPeerState.kt +24 -0
  62. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/MultipeerSessionOptions.kt +81 -0
  63. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/PhyStatus.kt +56 -0
  64. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/ScanOptions.kt +17 -0
  65. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/ServiceDataEntry.kt +15 -0
  66. package/nitrogen/generated/ios/MunimBluetooth+autolinking.rb +2 -0
  67. package/nitrogen/generated/ios/MunimBluetooth-Swift-Cxx-Bridge.cpp +61 -5
  68. package/nitrogen/generated/ios/MunimBluetooth-Swift-Cxx-Bridge.hpp +494 -49
  69. package/nitrogen/generated/ios/MunimBluetooth-Swift-Cxx-Umbrella.hpp +42 -0
  70. package/nitrogen/generated/ios/c++/HybridMunimBluetoothSpecSwift.hpp +254 -0
  71. package/nitrogen/generated/ios/swift/BluetoothCapabilities.swift +89 -0
  72. package/nitrogen/generated/ios/swift/BluetoothPhy.swift +44 -0
  73. package/nitrogen/generated/ios/swift/BluetoothPhyOption.swift +44 -0
  74. package/nitrogen/generated/ios/swift/BondState.swift +48 -0
  75. package/nitrogen/generated/ios/swift/DescriptorValue.swift +44 -0
  76. package/nitrogen/generated/ios/swift/ExtendedAdvertisingOptions.swift +243 -0
  77. package/nitrogen/generated/ios/swift/Func_void_BluetoothCapabilities.swift +46 -0
  78. package/nitrogen/generated/ios/swift/Func_void_BondState.swift +46 -0
  79. package/nitrogen/generated/ios/swift/Func_void_DescriptorValue.swift +46 -0
  80. package/nitrogen/generated/ios/swift/Func_void_L2CAPChannel.swift +46 -0
  81. package/nitrogen/generated/ios/swift/Func_void_PhyStatus.swift +46 -0
  82. package/nitrogen/generated/ios/swift/Func_void_std__string.swift +46 -0
  83. package/nitrogen/generated/ios/swift/Func_void_std__vector_MultipeerPeer_.swift +46 -0
  84. package/nitrogen/generated/ios/swift/GATTCharacteristic.swift +25 -1
  85. package/nitrogen/generated/ios/swift/GATTDescriptor.swift +71 -0
  86. package/nitrogen/generated/ios/swift/GATTService.swift +25 -1
  87. package/nitrogen/generated/ios/swift/HybridMunimBluetoothSpec.swift +29 -0
  88. package/nitrogen/generated/ios/swift/HybridMunimBluetoothSpec_cxx.swift +556 -23
  89. package/nitrogen/generated/ios/swift/L2CAPChannel.swift +52 -0
  90. package/nitrogen/generated/ios/swift/MultipeerDiscoveryInfoEntry.swift +34 -0
  91. package/nitrogen/generated/ios/swift/MultipeerEncryptionPreference.swift +44 -0
  92. package/nitrogen/generated/ios/swift/MultipeerPeer.swift +63 -0
  93. package/nitrogen/generated/ios/swift/MultipeerPeerState.swift +44 -0
  94. package/nitrogen/generated/ios/swift/MultipeerSessionOptions.swift +136 -0
  95. package/nitrogen/generated/ios/swift/PhyStatus.swift +34 -0
  96. package/nitrogen/generated/shared/c++/BluetoothCapabilities.hpp +131 -0
  97. package/nitrogen/generated/shared/c++/BluetoothPhy.hpp +80 -0
  98. package/nitrogen/generated/shared/c++/BluetoothPhyOption.hpp +80 -0
  99. package/nitrogen/generated/shared/c++/BondState.hpp +84 -0
  100. package/nitrogen/generated/shared/c++/DescriptorValue.hpp +95 -0
  101. package/nitrogen/generated/shared/c++/ExtendedAdvertisingOptions.hpp +138 -0
  102. package/nitrogen/generated/shared/c++/GATTCharacteristic.hpp +9 -3
  103. package/nitrogen/generated/shared/c++/GATTDescriptor.hpp +93 -0
  104. package/nitrogen/generated/shared/c++/GATTService.hpp +7 -2
  105. package/nitrogen/generated/shared/c++/HybridMunimBluetoothSpec.cpp +29 -0
  106. package/nitrogen/generated/shared/c++/HybridMunimBluetoothSpec.hpp +61 -2
  107. package/nitrogen/generated/shared/c++/L2CAPChannel.hpp +92 -0
  108. package/nitrogen/generated/shared/c++/MultipeerDiscoveryInfoEntry.hpp +87 -0
  109. package/nitrogen/generated/shared/c++/MultipeerEncryptionPreference.hpp +80 -0
  110. package/nitrogen/generated/shared/c++/MultipeerPeer.hpp +102 -0
  111. package/nitrogen/generated/shared/c++/MultipeerPeerState.hpp +80 -0
  112. package/nitrogen/generated/shared/c++/MultipeerSessionOptions.hpp +114 -0
  113. package/nitrogen/generated/shared/c++/PhyStatus.hpp +88 -0
  114. package/package.json +22 -11
  115. package/src/index.ts +416 -31
  116. package/src/specs/munim-bluetooth.nitro.ts +298 -14
@@ -18,13 +18,25 @@ public extension GATTService {
18
18
  /**
19
19
  * Create a new instance of `GATTService`.
20
20
  */
21
- init(uuid: String, characteristics: [GATTCharacteristic]) {
21
+ init(uuid: String, characteristics: [GATTCharacteristic], includedServices: [String]?) {
22
22
  self.init(std.string(uuid), { () -> bridge.std__vector_GATTCharacteristic_ in
23
23
  var __vector = bridge.create_std__vector_GATTCharacteristic_(characteristics.count)
24
24
  for __item in characteristics {
25
25
  __vector.push_back(__item)
26
26
  }
27
27
  return __vector
28
+ }(), { () -> bridge.std__optional_std__vector_std__string__ in
29
+ if let __unwrappedValue = includedServices {
30
+ return bridge.create_std__optional_std__vector_std__string__({ () -> bridge.std__vector_std__string_ in
31
+ var __vector = bridge.create_std__vector_std__string_(__unwrappedValue.count)
32
+ for __item in __unwrappedValue {
33
+ __vector.push_back(std.string(__item))
34
+ }
35
+ return __vector
36
+ }())
37
+ } else {
38
+ return .init()
39
+ }
28
40
  }())
29
41
  }
30
42
 
@@ -37,4 +49,16 @@ public extension GATTService {
37
49
  var characteristics: [GATTCharacteristic] {
38
50
  return self.__characteristics.map({ __item in __item })
39
51
  }
52
+
53
+ @inline(__always)
54
+ var includedServices: [String]? {
55
+ return { () -> [String]? in
56
+ if bridge.has_value_std__optional_std__vector_std__string__(self.__includedServices) {
57
+ let __unwrapped = bridge.get_std__optional_std__vector_std__string__(self.__includedServices)
58
+ return __unwrapped.map({ __item in String(__item) })
59
+ } else {
60
+ return nil
61
+ }
62
+ }()
63
+ }
40
64
  }
@@ -18,21 +18,50 @@ public protocol HybridMunimBluetoothSpec_protocol: HybridObject {
18
18
  func getAdvertisingData() throws -> Promise<AdvertisingDataTypes>
19
19
  func stopAdvertising() throws -> Void
20
20
  func setServices(services: [GATTService]) throws -> Void
21
+ func updateCharacteristicValue(serviceUUID: String, characteristicUUID: String, value: String, notify: Bool?) throws -> Promise<Void>
21
22
  func isBluetoothEnabled() throws -> Promise<Bool>
22
23
  func requestBluetoothPermission() throws -> Promise<Bool>
24
+ func getCapabilities() throws -> Promise<BluetoothCapabilities>
23
25
  func startScan(options: ScanOptions?) throws -> Void
24
26
  func stopScan() throws -> Void
25
27
  func connect(deviceId: String) throws -> Promise<Void>
26
28
  func disconnect(deviceId: String) throws -> Void
27
29
  func discoverServices(deviceId: String) throws -> Promise<[GATTService]>
28
30
  func readCharacteristic(deviceId: String, serviceUUID: String, characteristicUUID: String) throws -> Promise<CharacteristicValue>
31
+ func readDescriptor(deviceId: String, serviceUUID: String, characteristicUUID: String, descriptorUUID: String) throws -> Promise<DescriptorValue>
29
32
  func writeCharacteristic(deviceId: String, serviceUUID: String, characteristicUUID: String, value: String, writeType: WriteType?) throws -> Promise<Void>
33
+ func writeDescriptor(deviceId: String, serviceUUID: String, characteristicUUID: String, descriptorUUID: String, value: String) throws -> Promise<Void>
30
34
  func subscribeToCharacteristic(deviceId: String, serviceUUID: String, characteristicUUID: String) throws -> Void
31
35
  func unsubscribeFromCharacteristic(deviceId: String, serviceUUID: String, characteristicUUID: String) throws -> Void
32
36
  func getConnectedDevices() throws -> Promise<[String]>
33
37
  func readRSSI(deviceId: String) throws -> Promise<Double>
38
+ func requestMTU(deviceId: String, mtu: Double) throws -> Promise<Double>
39
+ func setPreferredPhy(deviceId: String, txPhy: BluetoothPhy, rxPhy: BluetoothPhy, phyOption: BluetoothPhyOption?) throws -> Promise<Void>
40
+ func readPhy(deviceId: String) throws -> Promise<PhyStatus>
41
+ func getBondState(deviceId: String) throws -> Promise<BondState>
42
+ func createBond(deviceId: String) throws -> Promise<BondState>
43
+ func removeBond(deviceId: String) throws -> Promise<BondState>
44
+ func startExtendedAdvertising(options: ExtendedAdvertisingOptions) throws -> Promise<String>
45
+ func stopExtendedAdvertising(advertisingId: String) throws -> Void
46
+ func publishL2CAPChannel(encryptionRequired: Bool?) throws -> Promise<L2CAPChannel>
47
+ func unpublishL2CAPChannel(psm: Double) throws -> Void
48
+ func openL2CAPChannel(deviceId: String, psm: Double) throws -> Promise<L2CAPChannel>
49
+ func closeL2CAPChannel(channelId: String) throws -> Void
50
+ func sendL2CAPData(channelId: String, value: String) throws -> Promise<Void>
51
+ func startClassicScan() throws -> Void
52
+ func stopClassicScan() throws -> Void
53
+ func connectClassic(deviceId: String, serviceUUID: String?) throws -> Promise<Void>
54
+ func startClassicServer(serviceUUID: String?, serviceName: String?) throws -> Promise<Void>
55
+ func stopClassicServer(serviceUUID: String?) throws -> Void
56
+ func disconnectClassic(deviceId: String) throws -> Void
57
+ func writeClassic(deviceId: String, value: String) throws -> Promise<Void>
34
58
  func startBackgroundSession(options: BackgroundSessionOptions) throws -> Void
35
59
  func stopBackgroundSession() throws -> Void
60
+ func startMultipeerSession(options: MultipeerSessionOptions) throws -> Void
61
+ func stopMultipeerSession() throws -> Void
62
+ func inviteMultipeerPeer(peerId: String) throws -> Void
63
+ func getMultipeerPeers() throws -> Promise<[MultipeerPeer]>
64
+ func sendMultipeerMessage(value: String, peerIds: [String]?, reliable: Bool?) throws -> Promise<Void>
36
65
  func addListener(eventName: String) throws -> Void
37
66
  func removeListeners(count: Double) throws -> Void
38
67
  }