Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 IOS 17.7 and IOS 18.0.1 not able to read ble device characteristics. #1248

Open
2 tasks done
sumitsharma7667 opened this issue Nov 12, 2024 · 2 comments
Open
2 tasks done
Labels

Comments

@sumitsharma7667
Copy link

sumitsharma7667 commented Nov 12, 2024

Prerequisites

  • I checked the documentation and FAQ without finding a solution
  • I checked to make sure that this issue has not already been filed

Expected Behavior

It should show device characterstics

Current Behavior

It not showing device characterstics

Library version

3.2.1

Device

iphone 14

Environment info

System:
    OS: macOS 14.6.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 89.20 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.11.0 - ~/.nvm/versions/node/v20.11.0/bin/node
    Yarn: 1.22.22 - ~/.nvm/versions/node/v20.11.0/bin/yarn
    npm: 10.2.4 - ~/.nvm/versions/node/v20.11.0/bin/npm
    Watchman: 2024.10.21.00 - /opt/homebrew/bin/watchman
  Managers:
    CocoaPods: 1.15.2 - /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
 IDEs:
    Android Studio: 2024.2 AI-242.23339.11.2421.12483815
    Xcode: 15.4/15F31d - /usr/bin/xcodebuild
  Languages:
    Java: 17.0.13 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 18.2.0 => 18.2.0 
    react-native: 0.71.11 => 0.71.11 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Steps to reproduce

1 - start device scan.
2 - read characteristics.
3- decode characteristics

Formatted code sample or link to a repository

async function scanBlePlxDevices(UUID: string) {
    setUuid(UUID);

    return new Promise(async (resolve, reject) => {
        let device: Device | null = null;

        // Start scanning for devices
        const scanSubscription = await bleManager.startDeviceScan(null, null, async (error, bleDevice) => {
            if (error) {
                await bleManager.stopDeviceScan();
                return reject(new Error("Device scan failed"));
            }

            // Check if a device with the desired prefix is found
            if (bleDevice?.name) {
                bleManager.stopDeviceScan();
                device = bleDevice;

                try {
                    // Connect to the device and discover services/characteristics
                    await device.connect();
                    await device.discoverAllServicesAndCharacteristics();
                    const services = await device.services();
                    const characteristics = await services[0].characteristics();

                    // Decode and display characteristics
                    const values = await Promise.all(characteristics.map(async (c) => {
                        try {
                            return c.value ? base64.decode(c.value).toString('utf8') : '';
                        } catch (err) {
                            console.warn(`Error decoding characteristic: ${err.message}`);
                            return null;
                        }
                    }));

                    setCaps(values.filter(Boolean)); // Store non-empty values
                    resolve(device);
                } catch (err) {
                    return reject(new Error("Failed to connect or retrieve characteristics"));
                } finally {
                    await bleManager.destroy();
                }
            }
        });

        // Stop scanning if no device is found within the timeout
        setTimeout(async () => {
            await bleManager.stopDeviceScan();
            if (!device) reject(new Error("No device found within timeout period"));
        }, 10000); // Adjust timeout duration as needed
    });
}

Relevant log output

Additional information

IMG_2906
IMG_2907
IMG_2926
I am trying to decode from base64

@RohitDeshwal
Copy link

i'm facing same issue

@GBR-422777
Copy link

Any fix yet?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants