GeekyAnts / react-native-zebra-bluetooth-printer

MIT License
23 stars 15 forks source link

Unable to connect device #13

Open CorentinHeroux opened 2 years ago

CorentinHeroux commented 2 years ago

This code always returns "Unable to connect device" no matter what device is used (Android 5, 8, 10). The address sent is the correct one (returned by pairedDevices()). Zebra ZD421 printer

let deviceAddress = '00:07:4D:BD:27:2E';
RNZebraBluetoothPrinter.connectDevice(deviceAddress)
    .then((res) => { 
        console.log(res);
    })
    .catch((error) => console.log(error.message));

Has anyone experienced this problem or seen how to solve it ? Thanks

anmoljain10 commented 2 years ago

@CorentinHeroux , is it happening in both Android and iOS?

CorentinHeroux commented 2 years ago

Yes

timnode commented 2 years ago

I think I have the same problem. My device is ZD420.

I can find the address from paired list, but receive "Unable to connect device" when calling connectDevice.

The error logs in java are below

java.io.IOException: read failed, socket might closed or timeout, read ret: -1 at android.bluetooth.BluetoothSocket.readAll(BluetoothSocket.java:762) at android.bluetooth.BluetoothSocket.waitSocketSignal(BluetoothSocket.java:715) at android.bluetooth.BluetoothSocket.connect(BluetoothSocket.java:404) at com.zebrabluetoothprinter.BluetoothService$ConnectedThread.run(BluetoothService.java:184)

timnode commented 2 years ago

I found the reason of my problem, it was because connectDevice seemed to not support ZD420 Bluetooth LE. Finally, I solved it by using import com.zebra.sdk.btleComm.BluetoothLeConnection to make connection.

I think I have the same problem. My device is ZD420.

I can find the address from paired list, but receive "Unable to connect device" when calling connectDevice.

The error logs in java are below

java.io.IOException: read failed, socket might closed or timeout, read ret: -1 at android.bluetooth.BluetoothSocket.readAll(BluetoothSocket.java:762) at android.bluetooth.BluetoothSocket.waitSocketSignal(BluetoothSocket.java:715) at android.bluetooth.BluetoothSocket.connect(BluetoothSocket.java:404) at com.zebrabluetoothprinter.BluetoothService$ConnectedThread.run(BluetoothService.java:184)

shivamb-private commented 2 years ago

@timnode Hey I am trying to connect with the same printer. Can you elaborate on how you went about it? Would really appreciate.

timnode commented 2 years ago

@timnode Hey I am trying to connect with the same printer. Can you elaborate on how you went about it? Would really appreciate.

You may refer to https://github.com/ararog/react-native-zebra-printer/blob/master/android/src/main/java/com/cyclelution/RCTZebraBTPrinter/RCTZebraBTPrinterModule.java