Closed aupareal closed 7 years ago
Not enough info. Be more specific, it is working for you in another versions? What did you try to?
window.DatecsPrinter.listBluetoothDevices(
function(devices) {
var impresora = 0;
var bt = 0;
for (var i = 0; i < devices.length; i++) {
if ( devices[i].name.includes("DPP-") ) {
bt = i;
impresora = 1;
break;
} else if ( devices[i].name.includes("Printer") ) {
bt = i;
impresora = 1;
break;
}
}
if ( impresora == 0 ) {
app.showNotification('Impresora no reconocida');
}
app.showNotification(devices[bt].name);
window.DatecsPrinter.connect(devices[bt].address,
function() {
window.DatecsPrinter.printText('Hola mundo', 'ISO-8859-1');
window.DatecsPrinter.disconnect();
},
function() {
alert(JSON.stringify(error));
}
);
window.DatecsPrinter.disconnect();
},
function(error) {
alert('error');
alert(JSON.stringify(error));
}
);
Lets break this into baby steps to easily find what's going wrong. I guess it's some implementation issue, cuz I can confirm it's working well on Android 4.1.2. First of all, be sure to only have the printer paired to the device. Then try the example, I'll paste here:
window.DatecsPrinter.listBluetoothDevices(
function (devices) {
window.DatecsPrinter.connect(devices[0].address,
function() {
alert("connected!");
printSomeTestText();
},
function() {
alert(JSON.stringify(error));
}
);
},
function (error) {
alert(JSON.stringify(error));
}
);
function printSomeTestText() {
window.DatecsPrinter.printText("Print Test!", 'ISO-8859-1',
function() {
alert("finished!");
}
);
}
I'm very sorry, but not working. If the bluetooth is down, it show the error correctly. However, if the bluetooth is up does nothing. Thank you.
what is the return of listBluetoothDevices
?
Nothing, no error too. Tomorrow I will prove with other mobile.
Closing due to long time without activity. If necessary I'll reopen.
Hello, The plugin not working on Android 4.1.2. Any suggestion ? Thank you.