Phonegap plugin for Star Micronics bluetooth/LAN printers. It works with Android and iOS
How to use :
-
Integrate the SDK into your project. Visit the Star Micronics developer section and follow the appropriate documentation.
-
Install the plugin:
cordova plugin add https://github.com/InteractiveObject/StarIOPlugin.git
window.plugins.starPrinter.portDiscovery('All', function(error, printerList){
if (error) {
console.error(error);
} else {
console.log(printerList[0].name);
console.log(printerList[0].macAddress);
}
});
Port types are: 'All', 'Bluetooth', 'USB', 'LAN'
window.plugins.starPrinter.checkStatus(portName, function(error, result){
if (error) {
console.error(error);
} else {
console.log(result.offline ? "printer is offline : "printer is online);
}
});
var myReceipt = "Title \n\n -- Price\r\r\r 20$\n\n ---\n";
window.plugins.starPrinter.printReceipt(portName, myReceipt, function(error, result){
if (error) {
console.error(error);
} else {
console.log("printReceipt finished");
}
});
window.plugins.starPrinter.connect(portName, function(error, result){
if (error) {
console.error(error);
} else {
console.log("connect finished");
}
});
window.addEventListener('starIOPluginData', function (e) {
switch (e.dataType) {
case 'printerCoverOpen':
break;
case 'printerCoverClose':
break;
case 'printerImpossible':
break;
case 'printerOnline':
break;
case 'printerOffline':
break;
case 'printerPaperEmpty':
break;
case 'printerPaperNearEmpty':
break;
case 'printerPaperReady':
break;
case 'barcodeReaderConnect':
break;
case 'barcodeDataReceive':
break;
case 'barcodeReaderImpossible':
break;
case 'cashDrawerOpen':
break;
case 'cashDrawerClose':
break;
}
});
window.plugins.starPrinter.openCashDrawer(name, function(error, result){
if (error) {
console.error(error);
} else {
console.log("openCashDrawer finished");
}
});
Copyright (c) 2016 Interactive Object . Licensed under the MIT license.