Giter Site home page Giter Site logo

No callback to listen for turn on of bluetooth after calling BluetoothManager.enableBluetooth() about react-native-bluetooth-escpos-printer HOT 11 CLOSED

januslo avatar januslo commented on September 16, 2024
No callback to listen for turn on of bluetooth after calling BluetoothManager.enableBluetooth()

from react-native-bluetooth-escpos-printer.

Comments (11)

januslo avatar januslo commented on September 16, 2024

from react-native-bluetooth-escpos-printer.

shubhamdeol avatar shubhamdeol commented on September 16, 2024

okay, just the way you are checking Bluetooth status, can you also check connected status, whether a pos device is connected to Bluetooth or not. I am having command not found warning lot of times.

and regarding this issue, You should have some callback, which can be executed from the app once user turns Bluetooth on

from react-native-bluetooth-escpos-printer.

shubhamdeol avatar shubhamdeol commented on September 16, 2024

@januslo If I am running scanDevices function, more than one time, it falls in catch block, How did you handled connectivity issues can you please provide me some example

from react-native-bluetooth-escpos-printer.

januslo avatar januslo commented on September 16, 2024

from react-native-bluetooth-escpos-printer.

shubhamdeol avatar shubhamdeol commented on September 16, 2024

@januslo can you please let me know how to connect to printer using this package. I am facing problems. Sometimes it doesn't show my device in paired devices array even if the device is paired. then I need to restart the app and turn bluetooth on/off it sharts showing

from react-native-bluetooth-escpos-printer.

januslo avatar januslo commented on September 16, 2024

marry Eve, plz try more about the bluetoothManager, the relates operations should be included in it.
You may try to listen the event rather then using the method returns, I am sorry I need to do more testing about the method returns later.

 DeviceEventEmitter.addListener(
            BluetoothManager.EVENT_DEVICE_ALREADY_PAIRED, (rsp)=> {
                this._deviceAlreadPaired(rsp) // rsp.devices would returns the paired devices array in JSON string.
            });
        DeviceEventEmitter.addListener(
            BluetoothManager.EVENT_DEVICE_FOUND, (rsp)=> {
                this._deviceFoundEvent(rsp) // rsp.devices would returns the found device object in JSON string
            });

from react-native-bluetooth-escpos-printer.

shubhamdeol avatar shubhamdeol commented on September 16, 2024

okay, thanks. This thing can be solved now. Can I connect to device more than once. I mean if a device is connected can I connect to it again.

or to avoid this, how can I know which device is connected to the printer at the current moment.

sometimes I am getting this error Error: Unable connect device, when I try to reconnect to the paired device

from react-native-bluetooth-escpos-printer.

januslo avatar januslo commented on September 16, 2024

Actually, we suffer the same thing, In the last commit, I update the android connect mechanism that would check the current connect and return the connected device name directly. In one word, plz update the repo to the last one (with git url directly current, will publish a new version after this mechanism is applied and tested in IOS as well) and you can just call connect() once again.

from react-native-bluetooth-escpos-printer.

shubhamdeol avatar shubhamdeol commented on September 16, 2024

I tried adding these methods also, but getting these functions as undefined :(
can you fix this: here is the code

`

@ReactMethod
public void isDeviceConnected(Callback booleanCallback) {

    Boolean isConnected = true;

    if (mService != null) {
        switch (mService.getState()) {
            case 0:
                isConnected = false;
                break;

            case 2:
                isConnected = false;
                break;

            case 3:
                isConnected = true;
                break;

            default:
                isConnected = false;
                break;
        }
    }
    booleanCallback.invoke(isConnected);
}



/* Return the address of the currently connected device */
@ReactMethod
public void getConnectedDeviceAddress(final Promise promise) {
    if (mService!=null){
        promise.resolve(mService.getLastConnectedDeviceAddress());
    }

}`

from react-native-bluetooth-escpos-printer.

januslo avatar januslo commented on September 16, 2024

plz make sure your code was installed into node_module folder.

from react-native-bluetooth-escpos-printer.

shubhamdeol avatar shubhamdeol commented on September 16, 2024

Now, I finally I am able to connect to pos printer flawlessly, Thanks for your help. Will give you a pull request soon, I have added both of these methods, which makes the connection with pos easier.

from react-native-bluetooth-escpos-printer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.