munim-bluetooth 0.3.18 → 0.3.20

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.
@@ -95,34 +95,47 @@ class HybridMunimBluetooth: HybridMunimBluetoothSpec {
95
95
 
96
96
  var advertisingData: [String: Any] = [:]
97
97
 
98
- // Service UUIDs
98
+ // Service UUIDs - ALLOWED
99
99
  if !options.serviceUUIDs.isEmpty {
100
100
  let uuids = options.serviceUUIDs.compactMap { CBUUID(string: $0) }
101
101
  advertisingData[CBAdvertisementDataServiceUUIDsKey] = uuids
102
102
  NSLog("[MunimBluetooth] Advertising service UUIDs: %@", options.serviceUUIDs)
103
103
  }
104
104
 
105
- // Local name
105
+ // Local name - ALLOWED
106
106
  if let localName = options.localName {
107
107
  advertisingData[CBAdvertisementDataLocalNameKey] = localName
108
108
  NSLog("[MunimBluetooth] Advertising local name: %@", localName)
109
109
  }
110
110
 
111
- // Manufacturer data
112
- if let manufacturerData = options.manufacturerData,
113
- let data = hexStringToData(manufacturerData) {
114
- advertisingData[CBAdvertisementDataManufacturerDataKey] = data
115
- NSLog("[MunimBluetooth] Advertising manufacturer data: %@ bytes", String(data.count))
111
+ // Manufacturer data - NOT ALLOWED by iOS for peripheral advertising
112
+ // This can only be included when you're a central scanning for peripherals
113
+ if options.manufacturerData != nil {
114
+ NSLog("[MunimBluetooth] ⚠️ WARNING: Manufacturer data cannot be advertised on iOS")
115
+ NSLog("[MunimBluetooth] iOS only allows localName and serviceUUIDs in peripheral advertisements")
116
+ // Don't add it to advertisingData - it will cause a warning/error
116
117
  }
117
118
 
118
- // Advertising data
119
+ // Advertising data types - Most are NOT ALLOWED
119
120
  if let advertisingDataTypes = options.advertisingData {
120
- processAdvertisingData(advertisingDataTypes, into: &advertisingData)
121
+ // Only process allowed fields
122
+ if let completeLocalName = advertisingDataTypes.completeLocalName {
123
+ advertisingData[CBAdvertisementDataLocalNameKey] = completeLocalName
124
+ NSLog("[MunimBluetooth] Using complete local name from advertising data: %@", completeLocalName)
125
+ }
126
+
127
+ // Warn about unsupported fields
128
+ if advertisingDataTypes.txPowerLevel != nil {
129
+ NSLog("[MunimBluetooth] ⚠️ WARNING: txPowerLevel cannot be set in peripheral advertisements on iOS")
130
+ }
131
+ if advertisingDataTypes.flags != nil {
132
+ NSLog("[MunimBluetooth] ⚠️ WARNING: flags cannot be set in peripheral advertisements on iOS")
133
+ }
121
134
  }
122
135
 
123
136
  currentAdvertisingData = options.advertisingData
124
137
 
125
- NSLog("[MunimBluetooth] Starting advertising with data: %@", advertisingData)
138
+ NSLog("[MunimBluetooth] Starting advertising with allowed data: %@", advertisingData)
126
139
  peripheralManager.startAdvertising(advertisingData)
127
140
  }
128
141
 
@@ -25,25 +25,8 @@ import com.margelo.nitro.core.HybridObject
25
25
  "LocalVariableName", "PropertyName", "PrivatePropertyName", "FunctionName"
26
26
  )
27
27
  abstract class HybridMunimBluetoothSpec: HybridObject() {
28
- @DoNotStrip
29
- private var mHybridData: HybridData = initHybrid()
30
-
31
- init {
32
- super.updateNative(mHybridData)
33
- }
34
-
35
- override fun updateNative(hybridData: HybridData) {
36
- mHybridData = hybridData
37
- super.updateNative(hybridData)
38
- }
39
-
40
- // Default implementation of `HybridObject.toString()`
41
- override fun toString(): String {
42
- return "[HybridObject MunimBluetooth]"
43
- }
44
-
45
28
  // Properties
46
-
29
+
47
30
 
48
31
  // Methods
49
32
  @DoNotStrip
@@ -126,7 +109,21 @@ abstract class HybridMunimBluetoothSpec: HybridObject() {
126
109
  @Keep
127
110
  abstract fun removeListeners(count: Double): Unit
128
111
 
129
- private external fun initHybrid(): HybridData
112
+ // Default implementation of `HybridObject.toString()`
113
+ override fun toString(): String {
114
+ return "[HybridObject MunimBluetooth]"
115
+ }
116
+
117
+ // C++ backing class
118
+ @DoNotStrip
119
+ @Keep
120
+ protected open class CxxPart(javaPart: HybridMunimBluetoothSpec): HybridObject.CxxPart(javaPart) {
121
+ // C++ JHybridMunimBluetoothSpec::CxxPart::initHybrid(...)
122
+ external override fun initHybrid(): HybridData
123
+ }
124
+ override fun createCxxPart(): CxxPart {
125
+ return CxxPart(this)
126
+ }
130
127
 
131
128
  companion object {
132
129
  protected const val TAG = "HybridMunimBluetoothSpec"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "munim-bluetooth",
3
- "version": "0.3.18",
3
+ "version": "0.3.20",
4
4
  "description": "A comprehensive React Native library for all your Bluetooth Low Energy (BLE) needs, supporting both peripheral and central roles with Expo support",
5
5
  "main": "./lib/commonjs/index.js",
6
6
  "module": "./lib/module/index.js",
@@ -85,11 +85,11 @@
85
85
  "@semantic-release/git": "^10.0.1",
86
86
  "@types/jest": "^29.5.14",
87
87
  "@types/react": "19.2.8",
88
- "nitrogen": "0.33.1",
88
+ "nitrogen": "0.35.2",
89
89
  "react": "19.2.3",
90
90
  "react-native": "0.83.1",
91
91
  "react-native-builder-bob": "^0.40.17",
92
- "react-native-nitro-modules": "0.33.1",
92
+ "react-native-nitro-modules": "0.35.2",
93
93
  "conventional-changelog-conventionalcommits": "^9.1.0",
94
94
  "semantic-release": "^25.0.2",
95
95
  "typescript": "^5.8.3"