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

🐛 BLE writeCharacteristicWithResponseForService not working on Android while functioning on iOS #1272

Open
2 tasks done
Mochamad-Rizky opened this issue Jan 29, 2025 · 0 comments
Labels

Comments

@Mochamad-Rizky
Copy link

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

  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 Mochamad-Rizky changed the title 🐛 writeCharacteristicWithResponseForService not working on android device, but in ios is work 🐛 BLE writeCharacteristicWithResponseForService not working on Android while functioning on iOS Jan 29, 2025
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

1 participant