capacitor-hugin-gmp3 0.2.1 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -72
- package/android/build.gradle +8 -0
- package/android/src/main/AndroidManifest.xml +7 -0
- package/android/src/main/aidl/com/kerzz/hugin/gmp3/IPrinterService.aidl +19 -0
- package/android/src/main/java/com/kerzz/hugin/gmp3/CapacitorHuginGMP3Plugin.java +91 -49
- package/android/src/main/java/com/kerzz/hugin/gmp3/PrinterCoverService.java +257 -0
- package/dist/docs.json +2 -246
- package/dist/esm/definitions.d.ts +22 -6
- package/dist/esm/definitions.js +34 -1
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/web.d.ts +4 -1
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +37 -0
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +37 -0
- package/dist/plugin.js.map +1 -1
- package/package.json +1 -1
- package/android/src/main/java/com/kerzz/hugin/gmp3/CapacitorHuginGMP3.java +0 -122
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
package com.kerzz.hugin.gmp3;
|
|
2
|
-
|
|
3
|
-
import android.util.Log;
|
|
4
|
-
|
|
5
|
-
import com.getcapacitor.JSObject;
|
|
6
|
-
|
|
7
|
-
import gmp3.droid.printer.DeviceInfo;
|
|
8
|
-
import gmp3.droid.printer.HuginPrinter;
|
|
9
|
-
import gmp3.droid.printer.Utility;
|
|
10
|
-
|
|
11
|
-
public class CapacitorHuginGMP3 {
|
|
12
|
-
protected final HuginPrinter huginPrinter = new HuginPrinter();
|
|
13
|
-
private final String TAG = "CapacitorHuginGMP3Plugin";
|
|
14
|
-
protected boolean tcpConnected = false;
|
|
15
|
-
private int tcpRetry = 0;
|
|
16
|
-
private boolean tcpConnect(String ip, Integer port) {
|
|
17
|
-
try {
|
|
18
|
-
if(tcpConnected) return true;
|
|
19
|
-
if (port == null) {
|
|
20
|
-
Log.w(TAG,"Port parametresi eksik.");
|
|
21
|
-
return false;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
return huginPrinter.TCPConnect(ip, port);
|
|
25
|
-
} catch (RuntimeException e) {
|
|
26
|
-
return false;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
protected boolean connect(String ip, int port, String terminalNo) {
|
|
31
|
-
try {
|
|
32
|
-
tcpConnected = tcpConnect(ip,port);
|
|
33
|
-
if(!tcpConnected) {
|
|
34
|
-
tcpRetry += 1;
|
|
35
|
-
Log.w(TAG,"TCP Bağlantısı sağlanamadı. Tekrar deneniyor: " + tcpRetry);
|
|
36
|
-
return false;
|
|
37
|
-
}
|
|
38
|
-
DeviceInfo serverInfo = new DeviceInfo();
|
|
39
|
-
serverInfo.Brand = "HUGIN";
|
|
40
|
-
serverInfo.IP = ip;
|
|
41
|
-
serverInfo.Model = "HUGIN COMPACT";
|
|
42
|
-
serverInfo.Port = port;
|
|
43
|
-
serverInfo.TerminalNo = terminalNo;// "FP11004397";
|
|
44
|
-
serverInfo.Version = "";
|
|
45
|
-
serverInfo.SerialNum = "";
|
|
46
|
-
Log.i(TAG, serverInfo.IP);
|
|
47
|
-
return huginPrinter.Connect(serverInfo, serverInfo.TerminalNo, "");
|
|
48
|
-
} catch (Exception e) {
|
|
49
|
-
return false;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
protected String libraryVersion() {
|
|
54
|
-
return huginPrinter.LibraryVersion();
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
protected boolean printZReport() {
|
|
58
|
-
try {
|
|
59
|
-
String[] response = printResponse(huginPrinter.PrintZReport());
|
|
60
|
-
int errorCode = Integer.parseInt(response[0]);
|
|
61
|
-
if(errorCode != 0) {
|
|
62
|
-
System.out.println("Error Code : " + Utility.GetErrorMessage(errorCode));
|
|
63
|
-
return false;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return true;
|
|
67
|
-
} catch (Exception e) {
|
|
68
|
-
return false;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
protected boolean printXReport(int type) {
|
|
73
|
-
try {
|
|
74
|
-
String[] response = printResponse(huginPrinter.PrintXReport(type));
|
|
75
|
-
int errorCode = Integer.parseInt(response[0]);
|
|
76
|
-
if(errorCode != 0) {
|
|
77
|
-
System.out.println("Error Code : " + Utility.GetErrorMessage(errorCode));
|
|
78
|
-
return false;
|
|
79
|
-
}
|
|
80
|
-
return true;
|
|
81
|
-
} catch (Exception e) {
|
|
82
|
-
return false;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
protected static String[] printResponse(String response) {
|
|
88
|
-
int res = 6;
|
|
89
|
-
String[] splitted = response.split("\\|", 0);
|
|
90
|
-
if (splitted.length >= 2) {
|
|
91
|
-
res = Integer.parseInt(splitted[0]);
|
|
92
|
-
System.out.println("Error Code : " + Utility.GetErrorMessage(res));
|
|
93
|
-
System.out.println("State : " + Utility.GetStateMessage(Integer.parseInt(splitted[1])));
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
System.out.println("Full Response : " + response);
|
|
97
|
-
return splitted;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
protected String sale(JSObject saleItem) {
|
|
101
|
-
String res = huginPrinter.CheckPrinterStatus();
|
|
102
|
-
Log.i(TAG, res);
|
|
103
|
-
String result = huginPrinter.PrintDocumentHeader();
|
|
104
|
-
Log.i(TAG, result);
|
|
105
|
-
String str = huginPrinter.PrintJSONDocumentDeptOnly(saleItem.toString());
|
|
106
|
-
Log.i(TAG, str);
|
|
107
|
-
String[] response = printResponse(str);
|
|
108
|
-
if(response.length > 2) {
|
|
109
|
-
return printResponse(str)[2];
|
|
110
|
-
}
|
|
111
|
-
return "-1";
|
|
112
|
-
// String result = huginPrinter.PrintDocumentHeader();
|
|
113
|
-
// String item1 = huginPrinter.PrintItem(1, 15, 3.00, "Capacitor Ürün", "", 1, 1);
|
|
114
|
-
// String item2 = huginPrinter.PrintItem(1, 30, 3.00, "Capacitor Ürün 2", "", 1, 1);
|
|
115
|
-
// String payment = huginPrinter.PrintPayment(0 , -1 , 300);
|
|
116
|
-
//
|
|
117
|
-
// huginPrinter.CloseReceipt(false);
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}
|