tr3v3r / react-native-esc-pos-printer

An unofficial React Native library for printing on an EPSON TM printer with the Epson ePOS SDK for iOS and Epson ePOS SDK for Android
MIT License
164 stars 71 forks source link

Discover method returns empty array for a bluetooth thermal printer #122

Closed sakshambhatt closed 11 months ago

sakshambhatt commented 11 months ago

JS log:

JSlog

App info:

1. RN version: 0.72.5
2. Android manifest
<uses-permission android:name="android.permission.INTERNET" />

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

<uses-permission android:name="android.permission.BLUETOOTH_SCAN" android:usesPermissionFlags="neverForLocation"/>

<uses-permission android:name="android.permission.BLUETOOTH_CONNECT"/>     
3. build.gradle -> targetSdkVersion = 33
4. Discover method usage:
const discoverPrinterPress = async () => {
    try {
        const printers = await EscPosPrinter.discover();
        console.log({printers});
        if (printers[0]) {
            setPrinter(printers[0]);
        }
    } catch (e) {
        console.log('error while discovering printer', JSON.stringify(e));
    }
};
5. logcat for discover method: 

logcat

  1. GitHub Link for further info

Android Phone info:

1. Name: SM-M315F/DS
2. Android version: 12

Printer info:

1. [Amazon link](https://www.amazon.in/Shreyans-Thermal-Receipt-Printer-Bluetooth/dp/B08NXTFY52)     
2. Processor architecture: I could not find
sakshambhatt commented 11 months ago

Possibly related issues:

  1. Issue #50
  2. Issue #78

Process I am following:

  1. Switching on printer
  2. Switching on bluetooth and location on the Android phone mentioned in the description above
  3. Pairing the printer with phone with the 4 digit PIN
  4. Opening the App and pressing on Discover printer button which triggers the discoverPrinterPress function mentioned in the description above.

Additionally, I have tried to print with this play store application and it is working. So, it is not that the printer is faulty. Perhaps I am missing something or there might be an issue with the library. It seems that the application mentioned above is using this library

sakshambhatt commented 11 months ago

Perhaps the issue might be that the printer is simply incompatible with this library.

I was able to print with react-native-thermal-printer which is an RN bridge of ESCPOS-ThermalPrinter-Android.

Unfortunately it won't work for iOS.