react-native-ble-plx icon indicating copy to clipboard operation
react-native-ble-plx copied to clipboard

🐛 BLE writeCharacteristicWithResponseForService not working on Android while functioning on iOS

Open Mochamad-Rizky opened this issue 11 months ago • 3 comments

Prerequisites

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

Expected Behavior

  1. The receipt printing function should work consistently across both iOS and Android platforms
  2. The BLE write characteristic operation should complete successfully
  3. A success message should be displayed upon successful printing

Current Behavior

iOS: Works as expected, successfully prints receipts

Android:

  1. No response from the write characteristic method
  2. No error messages are thrown
  3. The success/error callbacks are not triggered

Library version

3.4.0

Device

Android 13

Environment info

expo-env-info 1.2.2 environment info:
    System:
      OS: macOS 15.2
      Shell: 5.9 - /bin/zsh
    Binaries:
      Node: 20.10.0 - ~/.nvm/versions/node/v20.10.0/bin/node
      Yarn: 1.22.21 - ~/.nvm/versions/node/v20.10.0/bin/yarn
      npm: 10.2.3 - ~/.nvm/versions/node/v20.10.0/bin/npm
      Watchman: 2024.09.16.00 - /opt/homebrew/bin/watchman
    Managers:
      CocoaPods: 1.15.2 - /opt/homebrew/bin/pod
    SDKs:
      iOS SDK:
        Platforms: DriverKit 24.2, iOS 18.2, macOS 15.2, tvOS 18.2, visionOS 2.2, watchOS 11.2
      Android SDK:
        API Levels: 30, 34, 35
        Build Tools: 30.0.3, 34.0.0, 35.0.0
    IDEs:
      Xcode: 16.2/16C5032a - /usr/bin/xcodebuild
    npmPackages:
      expo: ^52.0.27 => 52.0.27 
      expo-router: ~3.5.24 => 3.5.24 
      react: 18.3.1 => 18.3.1 
      react-dom: 18.3.1 => 18.3.1 
      react-native: 0.76.6 => 0.76.6 
      react-native-web: ~0.19.10 => 0.19.13 
    npmGlobalPackages:
      eas-cli: 12.6.2
    Expo Workflow: bare

Steps to reproduce

  1. Connect to BLE device
  2. Attempt to print receipt using the provided code
  3. Observe that iOS successfully prints while Android fails silently

Formatted code sample or link to a repository

const printReceipt = async () => {
    if (!device || !serviceUUID || !characteristicUUID) {
        toast.error('Belum terhubung dengan perangkat');
        return;
    }

    try {
        const printCommand = await getPrintCommand();
        const bufferPrint = Buffer.from(printCommand).toString('base64');
        console.log(serviceUUID, characteristicUUID, device);
        
        await device.writeCharacteristicWithoutResponseForService(
            serviceUUID,
            characteristicUUID,
            bufferPrint
        );
        
        toast.success('Print berhasil');
    } catch (error) {
        toast.error(`Print gagal: ${error}`);
    }
};

Relevant log output

when console log output (console.log(serviceUUID, characteristicUUID, device));

 LOG  00001800-0000-1000-8000-00805f9b34fb 00002a00-0000-1000-8000-00805f9b34fb {"id": "02:15:12:29:8C:D7", "isConnectable": null, "localName": null, "manufacturerData": null, "mtu": 23, "name": "RPP02", "overflowServiceUUIDs": null, "rssi": null, "serviceData": null, "serviceUUIDs": null, "solicitedServiceUUIDs": null, "txPowerLevel": null}

Additional information

When attempting to print receipts using BLE communication, the writeCharacteristicWithResponseForService method works as expected on iOS devices but fails silently on Android devices. The method call does not trigger any response or error on Android, preventing the receipt printing functionality.

Mochamad-Rizky avatar Jan 29 '25 06:01 Mochamad-Rizky

getting same issue when writing command on characterstic

Image

manoj-mehra-spraxa avatar Mar 05 '25 11:03 manoj-mehra-spraxa

Hello @Mochamad-Rizky. Thank you for bringing this up! We've added the issue to our backlog and will work on a fix soon.

aliberski avatar May 26 '25 21:05 aliberski

"react-native-ble-plx": "3.2.1", - it is working with this version

manoj-mehra-spraxa avatar May 27 '25 04:05 manoj-mehra-spraxa