Bluetooth printer just prints once, stops printing, and then prints duplicates
See original GitHub issuePrerequisites
- [X ] I am running the latest version
- [X ] I checked the documentation and found no answer
- [X ] I checked to make sure that this issue has not already been filed
Expected Behavior
Print each time the button is pressed
Current Behavior
The first time app sends print command, it prints. The second time (without any change), doesn’t do anything. The next time, it prints duplicates (from the second and third time).
Steps to Reproduce
- Just call the method multiple times.
Context
- Library version: 1.1.0
- Platform: Android.
As you can see, after scanning and connecting to the device, the print command is sent. After printing, I cancel the connection and then destroy the manager object in order to restart the object and be able to print again.
But this doesn’t happen until the third time, when it prints duplicates. It does not show errors.
Maybe I got something wrong and I can’t see it. Some help will be appreciated.
export default class BluetoothSerial extends Component {
constructor() {
super()
this.state = {info: "", values: {}}
}
info(message) {
this.setState({info: message})
}
error(message) {
this.setState({info: "ERROR: " + message})
}
async scanAndConnect() {
this.manager = new BleManager()
this.manager.startDeviceScan(["000018f0-0000-1000-8000-00805f9b34fb"],
null, async (error, device) => {
this.info("Scanning...");
console.log(device.name); //printer name
if (error) {
this.error(error.message);
return
}
if (device.name === 'RG-MDP58B') {
this.info("Connected to printer");
this.manager.stopDeviceScan();
await this.manager.connectToDevice(device.id)
.then(async (device) => {
await this.manager.discoverAllServicesAndCharacteristicsForDevice(device.id)
console.log('device id ', device.id)
await this.manager.writeCharacteristicWithoutResponseForDevice(
device.id,
"000018f0-0000-1000-8000-00805f9b34fb",
'00002af1-0000-1000-8000-00805f9b34fb',
'cHJpbnRlciBjb25uZWN0ZWQ=')
.then((characteristic) => {
console.log('print value', characteristic.value)
this.info(characteristic.value);
this.manager.cancelDeviceConnection(device.id).then( () => {
this.manager.destroy()
});
}).catch(err => console.log(err))
})
.catch((error) => {
this.error(error.message)
})
}
});
}
render() {
return (
<View>
<Button title="Print" onPress={() => this.scanAndConnect()} />
<Text>{this.state.info}</Text>
</View>
)
}
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:9
Top Results From Across the Web
Bluetooth printer just prints once, stops printing, and then ...
Bluetooth printer just prints once, stops printing, and then ... The next time, it prints duplicates (from the second and third time).
Read more >13 Common Printer Problems and How to Fix Them
Turn on your printer using the power button, then turn on your computer again. Restart the print spooler service. Print your document.
Read more >Fix printer connection and printing problems in Windows
Fix printer connection and printing problems in Windows · Step 1. Unplug and restart your printer · Step 2. Check cables or wireless...
Read more >Epson Printer Not Printing [SOLVED] - Driver Easy
Their Epson printer isn't responding to their command when they're trying to print something with it. This is a frustrating issue.
Read more >Printer stops halfway through job and then an error message
Try printing the document - just that one "problem" page (if you know the page number). Convert to PDF > Open in Adobe...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@mayniii This is how I made it. I provide the text that I want to print in an array, where each line I wish to print its an array item.
@pdlm95 can you guide me about receipt printing?