Open michaelVictoriaDev opened 4 years ago
I got the same error, its occurring when the scan button is pressed and console.log(er) gives "[Error: NOT_STARTED]". I have it running on an actual physical device. Let me know if you are able to solve it.
same with me, please if there is update. I am in really desperate need of this printer, because my boss so demanding to have bluetooth printer in our project.
same to me
Also having this problem.
But since In my project i dont really need to scan through the app, it works to get only the already paired devices. If u need to scan, maybe u can try https://github.com/innoveit/react-native-ble-manager for the scan, than show the list and connect with escpos-printer
Add this to your AndroidManifset.xml
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
Apparently you use a android emulator and this library is not compatible with android emulators try use a cellphone with usb and run npx react-native run-android
I changed the SDK version from 29 to 28 and then this error disappeared. But with SDK 28, you cannot download apk file on google play.
I had the same issue when I updated my targetSdkVersion from 28 to 29. Replacing the android permission ACCESS_COARSE_LOCATION with ACCESS_FINE_LOCATION in _nodemodule/react-native-bluetooth-escpos-printer/android/src/main/java/cn/jystudio/bluetooth/RNBluetoothManagerModule.java Hope this helps.
I had same issue when I use tablet Samsung Tab A but working on my android devices.
you must pay attention to this method
init pairing the printer in the android settings menu
first install package version 0.0.6 "react-native-bluetooth-escpos-printer": "git+https://github.com/januslo/react-native-bluetooth-escpos-printer.git",
call and ignore response
async scan() {
await BluetoothManager.scanDevices().then(
(s) => {
log({scanDevices: s});
},
(er) => {
log({er: er});
IGNORE THIS ERROR
},
);
}
3.response scanDevices you can focus to listener
DeviceEventEmitter.addListener(
BluetoothManager.EVENT_DEVICE_ALREADY_PAIRED,
(rsp) => {
log({resp: rsp});
this._deviceAlreadPaired(rsp);
},
),
please try example https://github.com/januslo/react-native-bluetooth-escpos-printer/blob/master/examples/
You need to add uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" and turn on location (GPS ) before scanning for new peripherals.
I had the same issue when I updated my targetSdkVersion from 28 to 29. Replacing the android permission ACCESS_COARSE_LOCATION with ACCESS_FINE_LOCATION in _nodemodule/react-native-bluetooth-escpos-printer/android/src/main/java/cn/jystudio/bluetooth/RNBluetoothManagerModule.java Hope this helps.
I had same issue and this solution worked for me
In Android API 29 >= you need to use "ACCESS_FINE_LOCATION" instead of "ACCESS_COARSE_LOCATION".
Replacing the android permission ACCESS_COARSE_LOCATION with ACCESS_FINE_LOCATION in node_module/react-native-bluetooth-escpos-printer/android/src/main/java/cn/jystudio/bluetooth/RNBluetoothManagerModule.java
Still not working for me after using your fix. I'm trying on Redmi 7A - Android 10. Any suggestion ? targetSdkVersion 28 but also tried with 29
Make sure to turn on location in your device. And also need to give proper permissions in Android manifest. I added following to manifest.
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
Then cleaned the gradle and built and ran the app. Worked fine for me!
This scanning works fine with mobile devices but does not work with samsung tablet.It gives out error message NOT_STARTED. What can be the reason?
you must pay attention to this method
init pairing the printer in the android settings menu
- first install package version 0.0.6 "react-native-bluetooth-escpos-printer": "git+https://github.com/januslo/react-native-bluetooth-escpos-printer.git",
- call and ignore response
async scan() { await BluetoothManager.scanDevices().then( (s) => { log({scanDevices: s}); }, (er) => { log({er: er}); IGNORE THIS ERROR }, ); }
3.response scanDevices you can focus to listener
DeviceEventEmitter.addListener( BluetoothManager.EVENT_DEVICE_ALREADY_PAIRED, (rsp) => { log({resp: rsp}); this._deviceAlreadPaired(rsp); }, ),
please try example https://github.com/januslo/react-native-bluetooth-escpos-printer/blob/master/examples/
Hey I'm also trying to connect with a MTP-III or MTP-3, I'm having issues, would like to share a repository with this example that is on this image?
You need to add these permissions in the AndroidManifset.xml
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
And you need to replace the android permission ACCESS_COARSE_LOCATION with ACCESS_FINE_LOCATION in node_module/react-native-bluetooth-escpos-printer/android/src/main/java/cn/jystudio/bluetooth/RNBluetoothManagerModule.java (Which is the Library native code itself).
Finally, open your location (GPS) on your device and then try again it will work fine :)))
@Mahmoud-S97 you saved my day :) thanks Brother
@Mahmoud-S97 you saved my day :) thanks Brother
It's my pleasure dear🌷
error{"nativeStackAndroid":[],"userInfo":null,"message":"NOT_STARTED","code":"DISCOVER"}
Do you have any Idea? its a fresh project