dotintent / react-native-ble-plx

React Native BLE library
Apache License 2.0
3.06k stars 512 forks source link

🐛ManufacturerData on iOS returning null, in Android is correctly setted #1229

Open Mattefarax opened 3 months ago

Mattefarax commented 3 months ago

Prerequisites

Expected Behavior

I need to reed the manufacturerData of my device, on Android I can read it normally, on iOS manufacturerData return null.

Current Behavior

I need to reed the manufacturerData of my device, on Android I can read it normally, on iOS manufacturerData return null.

Library version

3.2.1

Device

iPhone 15

Environment info

System:
  OS: macOS 14.5
  CPU: (8) arm64 Apple M1 Pro
  Memory: 150.28 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 21.7.3
    path: /opt/homebrew/bin/node
  Yarn: Not Found
  npm:
    version: 10.5.0
    path: /opt/homebrew/bin/npm
  Watchman:
    version: 2024.04.15.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.15.2
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.5
      - iOS 17.5
      - macOS 14.5
      - tvOS 17.5
      - visionOS 1.2
      - watchOS 10.5
  Android SDK: Not Found
IDEs:
  Android Studio: 2023.2 AI-232.10300.40.2321.11567975
  Xcode:
    version: 15.4/15F31d
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 19.0.1
    path: /usr/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.73.6
    wanted: 0.73.6
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false

Steps to reproduce

Only installing library and add the Multiplatform adapter, then after setting all the permission and add this code line.

Formatted code sample or link to a repository

bleManager.startDeviceScan(null, null, (error, device) => {
      if (error) {
        console.error('Error scanning for devices:', error);
        return;
      }
console.log(device.manufacturerData)

Relevant log output

{ manufacturerData: null,
  isConnectable: false,
  serviceUUIDs: null,
  overflowServiceUUIDs: null,
  txPowerLevel: null,
  solicitedServiceUUIDs: null,
}

Additional information

No response

GioIacca9 commented 3 months ago

Same problem here, any solution?

luca-tomasetti commented 3 months ago

Isn't it the same problem as here: #1149 ? @Mattefarax What version of MultiPlatformBleAdapter you have?

Mattefarax commented 3 months ago

@luca-tomasetti I installed the 0.2.0 using the pods file, and doesn't work. Then I tried to change various version of the library, like the documentation said, but doesn't work. Are there any other method to install it?

luca-tomasetti commented 3 months ago

@luca-tomasetti I installed the 0.2.0 using the pods file, and doesn't work. Then I tried to change various version of the library, like the documentation said, but doesn't work. Are there any other method to install it?

@Mattefarax not that I know... Can you share your podfile where you set the MultiPlatformBleAdapter ?

Mattefarax commented 3 months ago

@luca-tomasetti pod 'MultiplatformBleAdapter', :git => 'https://github.com/dotintent/MultiPlatformBleAdapter', :tag => '0.2.0'

this is the line on my pod file, then I launch the pod update command and successfully installed the library, but doesn't work. Im using the react-native-ble-plx library version "3.2.1"

luca-tomasetti commented 3 months ago

I'm using the same...

What OS version you have for your iPhone? I can try to check if I have some hardware with the same version and test it...

mircotom commented 2 months ago

I encountered the same issue. Not all devices return null for ManufactureData. Out of 200 devices, I was able to retrieve ManufactureData from only 40, whereas on Android, all 200 devices provided ManufactureData.

luca-tomasetti commented 2 months ago

I encountered the same issue. Not all devices return null for ManufactureData. Out of 200 devices, I was able to retrieve ManufactureData from only 40, whereas on Android, all 200 devices provided ManufactureData.

Weird... Is there any consistency with the devices ? Like OS Version, model, year, ...

mircotom commented 2 months ago

After decoding the manufacturer data and converting the first two bytes to the actual company names using the information from "https://bitbucket.org/bluetooth-SIG/public/raw/HEAD/assigned_numbers/company_identifiers/company_identifiers.yaml". I found that the additional devices detected by Android are mostly Apple devices. This suggests that the iOS SDK cannot capture Apple devices, whereas Android can.

GioIacca9 commented 2 months ago

Did some tests with a third-party app (eBeacon) and there the beacon's manufacturer data is visible, may it be not related to the SDK? Strangely enough on that app only beacons from Apple (0x004C) are detected. Don't know if that's a setting or something else.

IMG_0037

mircotom commented 2 months ago

@GioIacca9 I couldn't find the Manufacturer Data in your snapshot. In iOS,there are two frameworks used for communicating with Bluetooth devices: CoreBluetooth and CoreLocation. CoreLocation is used to detect nearby beacon devices, so it can discover Bluetooth devices, but it cannot retrieve Manufacturer Data from them. The CLBeacon class only provides uuid, major, minor, proximity, accuracy, and rssi attributes. You can find more details here:https://developer.apple.com/documentation/corelocation/clbeacon.

On the other hand, CoreBluetooth allows you to directly process Bluetooth data packets, including Manufacturer Data.

GioIacca9 commented 2 months ago

@mircotom thank you for the explanation. I thought that Major and Minor values were included in the manufacturer data, my goal is to get those numbers. On android I semply base64-decode the manufacturer data and get the 25-26 bytes for the major value and 27-28 bytes for the minor value, but if there's another way to obtain those two vlaues I'm ok with that.

luca-tomasetti commented 2 months ago

When you use the startDeviceScan() function, what are you setting in the allowDuplicates option field?

Mattefarax commented 2 months ago

This is my startDeviceScan function:

bleManager.startDeviceScan(null, null, (error, device)

luca-tomasetti commented 2 months ago

Can you check what happen if you set the option allowDuplicates=true?

bleManager.startDeviceScan(null, {allowDuplicates: true}, (error, device)

Mattefarax commented 2 months ago

Didn't change. Manufacturer Data is null.

tom501 commented 2 months ago

Didn't change. Manufacturer Data is null.

I'm assuming manufacturedData is null even if you set allowDuplicates to false...

Mattefarax commented 2 months ago

Exactly, I changed to false and manufacturedData is already null

Mattefarax commented 2 months ago

Hi @tom501, do I need to change some configuration modes on Xcode application to let the library works correctly?

Screenshot 2024-09-02 alle 09 25 02
tom501 commented 2 months ago

@Mattefarax I have a similar configuration...