@connexup/react-native-xprinter 0.1.0

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.
Files changed (145) hide show
  1. package/LICENSE +20 -0
  2. package/NativeXPrinter.podspec +23 -0
  3. package/README.md +24 -0
  4. package/android/build.gradle +73 -0
  5. package/android/gradle.properties +5 -0
  6. package/android/libs/printer-lib-3.4.7.aar +0 -0
  7. package/android/src/main/AndroidManifest.xml +2 -0
  8. package/android/src/main/java/com/connexup/xprinter/Errors.kt +11 -0
  9. package/android/src/main/java/com/connexup/xprinter/Util.kt +106 -0
  10. package/android/src/main/java/com/connexup/xprinter/XPrinterPackage.kt +77 -0
  11. package/android/src/main/java/com/connexup/xprinter/esc/Convert.kt +211 -0
  12. package/android/src/main/java/com/connexup/xprinter/esc/XPrinterESCModule.kt +1995 -0
  13. package/android/src/main/java/com/connexup/xprinter/printer/Convert.kt +46 -0
  14. package/android/src/main/java/com/connexup/xprinter/printer/DeviceConnection.kt +14 -0
  15. package/android/src/main/java/com/connexup/xprinter/printer/Printers.kt +153 -0
  16. package/android/src/main/java/com/connexup/xprinter/printer/XPrinterPrinterModule.kt +295 -0
  17. package/android/src/main/java/com/connexup/xprinter/tspl/Convert.kt +151 -0
  18. package/android/src/main/java/com/connexup/xprinter/tspl/XPrinterTSPLModule.kt +1408 -0
  19. package/android/src/main/java/com/connexup/xprinter/utils/XPrinterUtilsModule.kt +54 -0
  20. package/ios/ESC/ESCConvert.swift +283 -0
  21. package/ios/ESC/Models/RCTESCPrintBarCodeRequest.swift +23 -0
  22. package/ios/ESC/Models/RCTESCPrintBitmapRequest.swift +23 -0
  23. package/ios/ESC/Models/RCTESCPrintPDF417Request.swift +27 -0
  24. package/ios/ESC/Models/RCTESCPrintQRCodeRequest.swift +19 -0
  25. package/ios/ESC/Models/RCTESCPrintTableBarcode.swift +23 -0
  26. package/ios/ESC/Models/RCTESCPrintTableRequest.swift +19 -0
  27. package/ios/ESC/Models/RCTESCPrintTableRow.swift +19 -0
  28. package/ios/ESC/Models/RCTESCPrintTextRequest.swift +21 -0
  29. package/ios/ESC/Models/RCTESCPrintTextSizeRequest.swift +17 -0
  30. package/ios/ESC/Models/RCTESCSelectBitmapModelRequest.swift +17 -0
  31. package/ios/ESC/Models/RCTESCSetNetAllRequest.swift +19 -0
  32. package/ios/ESC/Models/RCTESCSetPrintAreaRequest.swift +19 -0
  33. package/ios/ESC/Models/RCTESCSetTextStyleRequest.swift +17 -0
  34. package/ios/ESC/Models/RCTESCWifiConfigRequest.swift +23 -0
  35. package/ios/ESC/NativeXPrinterESC.swift +1339 -0
  36. package/ios/ESC/RCTNativeXPrinterESC.h +10 -0
  37. package/ios/ESC/RCTNativeXPrinterESC.mm +541 -0
  38. package/ios/Errors.swift +11 -0
  39. package/ios/NativeErrorInfo.swift +21 -0
  40. package/ios/Printer/Connecter.swift +214 -0
  41. package/ios/Printer/Models/RCTDeviceConnectStatusChangeEvent.swift +19 -0
  42. package/ios/Printer/Models/RCTNetDevice.swift +21 -0
  43. package/ios/Printer/Models/RCTUSBDevice.swift +17 -0
  44. package/ios/Printer/Models/RCTUpdateUdpNetConfigRequest.swift +21 -0
  45. package/ios/Printer/NativeXPrinterPrinter.swift +209 -0
  46. package/ios/Printer/Printers.swift +59 -0
  47. package/ios/Printer/RCTNativeXPrinterPrinter.h +12 -0
  48. package/ios/Printer/RCTNativeXPrinterPrinter.mm +123 -0
  49. package/ios/PrinterSDK/Headers/CPCLCommand.h +324 -0
  50. package/ios/PrinterSDK/Headers/KDS_Log.h +47 -0
  51. package/ios/PrinterSDK/Headers/LabelDocument.h +32 -0
  52. package/ios/PrinterSDK/Headers/LabelImageTranster.h +19 -0
  53. package/ios/PrinterSDK/Headers/POSBLEManager.h +164 -0
  54. package/ios/PrinterSDK/Headers/POSCommand.h +760 -0
  55. package/ios/PrinterSDK/Headers/POSImageTranster.h +34 -0
  56. package/ios/PrinterSDK/Headers/POSPrinter.h +47 -0
  57. package/ios/PrinterSDK/Headers/POSPrinterSDK.h +13 -0
  58. package/ios/PrinterSDK/Headers/POSWIFIManager.h +162 -0
  59. package/ios/PrinterSDK/Headers/PTable.h +50 -0
  60. package/ios/PrinterSDK/Headers/PrinterProfile.h +28 -0
  61. package/ios/PrinterSDK/Headers/TSCBLEManager.h +142 -0
  62. package/ios/PrinterSDK/Headers/TSCCommand.h +701 -0
  63. package/ios/PrinterSDK/Headers/TSCPrinterSDK.h +15 -0
  64. package/ios/PrinterSDK/Headers/TSCWIFIManager.h +99 -0
  65. package/ios/PrinterSDK/Headers/WIFIConnecter.h +131 -0
  66. package/ios/PrinterSDK/Headers/ZPLCommand.h +372 -0
  67. package/ios/PrinterSDK/libPrinterSDK.a +0 -0
  68. package/ios/TSPL/Models/RCTTSPLBarRequest.swift +19 -0
  69. package/ios/TSPL/Models/RCTTSPLBarcodeRequest.swift +29 -0
  70. package/ios/TSPL/Models/RCTTSPLBitmapCompressionRequest.swift +25 -0
  71. package/ios/TSPL/Models/RCTTSPLBitmapRequest.swift +25 -0
  72. package/ios/TSPL/Models/RCTTSPLBoxRequest.swift +21 -0
  73. package/ios/TSPL/Models/RCTTSPLEraseRequest.swift +19 -0
  74. package/ios/TSPL/Models/RCTTSPLPDFBase64Request.swift +21 -0
  75. package/ios/TSPL/Models/RCTTSPLPutBMPRequest.swift +17 -0
  76. package/ios/TSPL/Models/RCTTSPLQRCodeRequest.swift +29 -0
  77. package/ios/TSPL/Models/RCTTSPLReverseRequest.swift +19 -0
  78. package/ios/TSPL/Models/RCTTSPLTextRequest.swift +25 -0
  79. package/ios/TSPL/NativeXPrinterTSPL.swift +831 -0
  80. package/ios/TSPL/RCTNativeXPrinterTSPL.h +10 -0
  81. package/ios/TSPL/RCTNativeXPrinterTSPL.mm +445 -0
  82. package/ios/TSPL/TSPLConvert.swift +140 -0
  83. package/ios/Utils/Models/RCTCheckIsPureWhiteImageRequest.swift +16 -0
  84. package/ios/Utils/NativeXPrinterUtils.swift +17 -0
  85. package/ios/Utils/RCTNativeXPrinterUtils.h +10 -0
  86. package/ios/Utils/RCTNativeXPrinterUtils.mm +38 -0
  87. package/ios/Utils.swift +126 -0
  88. package/lib/module/esc/NativeXPrinterESC.js +218 -0
  89. package/lib/module/esc/NativeXPrinterESC.js.map +1 -0
  90. package/lib/module/esc/index.js +324 -0
  91. package/lib/module/esc/index.js.map +1 -0
  92. package/lib/module/index.js +8 -0
  93. package/lib/module/index.js.map +1 -0
  94. package/lib/module/package.json +1 -0
  95. package/lib/module/printer/NativeXPrinterPrinter.js +30 -0
  96. package/lib/module/printer/NativeXPrinterPrinter.js.map +1 -0
  97. package/lib/module/printer/index.js +110 -0
  98. package/lib/module/printer/index.js.map +1 -0
  99. package/lib/module/tspl/NativeXPrinterTSPL.js +143 -0
  100. package/lib/module/tspl/NativeXPrinterTSPL.js.map +1 -0
  101. package/lib/module/tspl/index.js +347 -0
  102. package/lib/module/tspl/index.js.map +1 -0
  103. package/lib/module/type.js +12 -0
  104. package/lib/module/type.js.map +1 -0
  105. package/lib/module/util.js +4 -0
  106. package/lib/module/util.js.map +1 -0
  107. package/lib/module/utils/NativeXPrinterUtils.js +5 -0
  108. package/lib/module/utils/NativeXPrinterUtils.js.map +1 -0
  109. package/lib/module/utils/index.js +17 -0
  110. package/lib/module/utils/index.js.map +1 -0
  111. package/lib/typescript/package.json +1 -0
  112. package/lib/typescript/src/esc/NativeXPrinterESC.d.ts +343 -0
  113. package/lib/typescript/src/esc/NativeXPrinterESC.d.ts.map +1 -0
  114. package/lib/typescript/src/esc/index.d.ts +122 -0
  115. package/lib/typescript/src/esc/index.d.ts.map +1 -0
  116. package/lib/typescript/src/index.d.ts +6 -0
  117. package/lib/typescript/src/index.d.ts.map +1 -0
  118. package/lib/typescript/src/printer/NativeXPrinterPrinter.d.ts +61 -0
  119. package/lib/typescript/src/printer/NativeXPrinterPrinter.d.ts.map +1 -0
  120. package/lib/typescript/src/printer/index.d.ts +32 -0
  121. package/lib/typescript/src/printer/index.d.ts.map +1 -0
  122. package/lib/typescript/src/tspl/NativeXPrinterTSPL.d.ts +261 -0
  123. package/lib/typescript/src/tspl/NativeXPrinterTSPL.d.ts.map +1 -0
  124. package/lib/typescript/src/tspl/index.d.ts +128 -0
  125. package/lib/typescript/src/tspl/index.d.ts.map +1 -0
  126. package/lib/typescript/src/type.d.ts +9 -0
  127. package/lib/typescript/src/type.d.ts.map +1 -0
  128. package/lib/typescript/src/util.d.ts +2 -0
  129. package/lib/typescript/src/util.d.ts.map +1 -0
  130. package/lib/typescript/src/utils/NativeXPrinterUtils.d.ts +10 -0
  131. package/lib/typescript/src/utils/NativeXPrinterUtils.d.ts.map +1 -0
  132. package/lib/typescript/src/utils/index.d.ts +9 -0
  133. package/lib/typescript/src/utils/index.d.ts.map +1 -0
  134. package/package.json +178 -0
  135. package/src/esc/NativeXPrinterESC.ts +516 -0
  136. package/src/esc/index.ts +489 -0
  137. package/src/index.ts +5 -0
  138. package/src/printer/NativeXPrinterPrinter.ts +84 -0
  139. package/src/printer/index.ts +160 -0
  140. package/src/tspl/NativeXPrinterTSPL.ts +388 -0
  141. package/src/tspl/index.ts +535 -0
  142. package/src/type.ts +11 -0
  143. package/src/util.ts +1 -0
  144. package/src/utils/NativeXPrinterUtils.ts +14 -0
  145. package/src/utils/index.ts +27 -0
@@ -0,0 +1,34 @@
1
+ //
2
+ // POSImageTranster.h
3
+ // Printer
4
+ //
5
+
6
+ #import <Foundation/Foundation.h>
7
+ #import <UIKit/UIKit.h>
8
+
9
+ @interface POSImageTranster : NSObject
10
+
11
+ typedef enum {
12
+ Dithering=0,//bitmap binary method
13
+ Threshold//bitmap dithering
14
+ } BmpType;
15
+
16
+ typedef enum {
17
+ RasterNolmorWH = 0,//print raster bitmap:normal
18
+ RasterDoubleWidth,//double width
19
+ RasterDoubleHeight,//double height
20
+ RasterDoubleWH//double width height
21
+ } PrintRasterType;
22
+
23
+ /**
24
+ * print raster bitmap
25
+ */
26
+ + (NSData *)rasterImagedata:(UIImage *) mIamge andType:(BmpType) bmptype andPrintRasterType:(PrintRasterType) type;
27
+
28
+ /**
29
+ * bitmap compression print
30
+ */
31
+ + (NSData *)compressionImagedata:(UIImage *) mIamge andType:(BmpType) bmptype andPrintRasterType:(PrintRasterType) type;
32
+
33
+
34
+ @end
@@ -0,0 +1,47 @@
1
+ //
2
+ // POSPrinter.h
3
+ // Printer
4
+ //
5
+ // Created by Apple Mac mini intel on 2022/12/7.
6
+ // Copyright © 2022 Admin. All rights reserved.
7
+ //
8
+
9
+ #import <Foundation/Foundation.h>
10
+ #import <CoreBluetooth/CoreBluetooth.h>
11
+
12
+ typedef NS_ENUM(NSInteger, POSPrinterConnectType) {
13
+ POSPrinterConnectBLE = 0, //Bluetooth
14
+ POSPrinterConnectWiFi = 1 //WiFi
15
+ };
16
+
17
+ NS_ASSUME_NONNULL_BEGIN
18
+
19
+ @interface POSPrinter : NSObject
20
+
21
+ // connect type
22
+ @property (nonatomic, assign) POSPrinterConnectType connectType;
23
+
24
+ // ble name
25
+ @property (nonatomic, copy, readwrite) NSString *name;
26
+
27
+ // mac address
28
+ @property (nonatomic, copy, readwrite) NSString *mac;
29
+
30
+ // unique identifier
31
+ @property (nonatomic, copy, readwrite) NSString *uuid;
32
+
33
+ // rssi
34
+ @property (nonatomic, copy, readwrite) NSNumber *rssi;
35
+
36
+ // peripheral
37
+ @property (nonatomic, copy, readwrite) CBPeripheral *peripheral;
38
+
39
+ // ip
40
+ @property (nonatomic, copy, readwrite) NSString *ip;
41
+
42
+ // port
43
+ @property (nonatomic, copy, readwrite) NSString *port;
44
+
45
+ @end
46
+
47
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,13 @@
1
+ //
2
+ // POSPrinterSDK.h
3
+ // Printer
4
+ //
5
+
6
+
7
+ #ifndef POSPrinterSDK_h
8
+ #define POSPrinterSDK_h
9
+
10
+ #import "POSBLEManager.h"
11
+ #import "POSWIFIManager.h"
12
+ #import "POSCommand.h"
13
+ #endif /* POSPrinterSDK_h */
@@ -0,0 +1,162 @@
1
+ //
2
+ // POSWIFIManager.h
3
+ // Printer
4
+ //
5
+
6
+ #import <Foundation/Foundation.h>
7
+ #import <UIKit/UIKit.h>
8
+ #import "PrinterProfile.h"
9
+
10
+ @class POSWIFIManager;
11
+ @protocol POSWIFIManagerDelegate <NSObject>
12
+ @optional
13
+ /**
14
+ * connect success
15
+ */
16
+ - (void)POSwifiConnectedToHost:(NSString *)host port:(UInt16)port;
17
+ /**
18
+ * disconnect error
19
+ */
20
+ - (void)POSwifiDisconnectWithError:(NSError *)error;
21
+ /**
22
+ * send data success
23
+ */
24
+ - (void)POSwifiWriteValueWithTag:(long)tag;
25
+ /**
26
+ * receive printer data
27
+ */
28
+ - (void)POSwifiReceiveValueForData:(NSData *)data;
29
+ @end
30
+
31
+ /**********************************************************************/
32
+
33
+ typedef void (^POSWIFIManagerReceiveBlock)(NSData *data);
34
+ typedef void (^POSWIFIManagerWriteBlock)(BOOL success, NSError *error);
35
+ typedef void (^POSWiFiPrinterStatusBlock)(NSData *status);
36
+ typedef void (^POSWiFiPrinterSNBlock)(NSString *sn);
37
+ typedef void (^POSWiFiPrinterCheckBlock)(NSData *check);
38
+ @class PrinterProfile;
39
+ typedef void (^POSWiFiManagerFoundPrinterBlock)(PrinterProfile *foundPrinter);
40
+
41
+ /**********************************************************************/
42
+
43
+ @interface POSWIFIManager : NSObject
44
+ // host
45
+ @property (nonatomic, copy) NSString *hostStr;
46
+ // port
47
+ @property (nonatomic, assign) UInt16 port;
48
+ // whether connect
49
+ @property (nonatomic, assign) BOOL isConnect;
50
+
51
+ @property (nonatomic, weak) id<POSWIFIManagerDelegate> delegate;
52
+
53
+ @property (nonatomic, copy) POSWIFIManagerReceiveBlock receiveBlock;
54
+ @property (nonatomic, copy) POSWIFIManagerWriteBlock writeBlock;
55
+
56
+ @property (nonatomic, copy) POSWiFiManagerFoundPrinterBlock foundPrinterBlock;
57
+ @property (nonatomic, copy) POSWiFiPrinterStatusBlock statusBlock;
58
+ @property (nonatomic, copy) POSWiFiPrinterSNBlock snBlock;
59
+ @property (nonatomic, copy) POSWiFiPrinterCheckBlock checkBlock;
60
+
61
+ @property (nonatomic, strong) PrinterProfile *connectedPrinter;
62
+
63
+ /**
64
+ * singleton
65
+ */
66
+ + (instancetype)sharedInstance;
67
+
68
+ /**
69
+ * remove a delegate
70
+ */
71
+ - (void)removeDelegate:(id<POSWIFIManagerDelegate>) delegate;
72
+
73
+ /**
74
+ * remove all delegates
75
+ */
76
+ - (void)removeAllDelegates;
77
+
78
+ /**
79
+ * connect printer address
80
+ */
81
+ - (void)connectWithHost:(NSString *)hostStr port:(UInt16)port;
82
+
83
+ /**
84
+ * disconnect
85
+ */
86
+ - (void)disconnect;
87
+
88
+ /**
89
+ * write command to printer
90
+ */
91
+ - (void)writeCommandWithData:(NSData *)data;
92
+
93
+ /**
94
+ * write command to printer with receive callback
95
+ */
96
+ - (void)writeCommandWithData:(NSData *)data receiveCallBack:(POSWIFIManagerReceiveBlock)receiveBlock;
97
+
98
+ /**
99
+ * write command to printer with write callback
100
+ */
101
+ - (void)writeCommandWithData:(NSData *)data writeCallBack:(POSWIFIManagerWriteBlock)receiveBlock;
102
+
103
+ /**
104
+ * udp socket create
105
+ */
106
+ - (BOOL)createUdpSocket;
107
+
108
+ /**
109
+ * udp socket close
110
+ */
111
+ - (void)closeUdpSocket;
112
+
113
+ /**
114
+ * search printers
115
+ */
116
+ - (void)sendFindCmd:(POSWiFiManagerFoundPrinterBlock)foundPrinterBlock;
117
+
118
+ /**
119
+ * set ip configuration
120
+ */
121
+ - (void)setIPConfigWithIP:(NSString *)ip Mask:(NSString *)mask Gateway:(NSString *)gateway DHCP:(BOOL)dhcp;
122
+
123
+ /**
124
+ * set wifi configuration
125
+ */
126
+ - (void)setWiFiConfigWithIP:(NSString *)ip mask:(NSString *)mask gateway:(NSString *)gateway ssid:(NSString *)ssid password:(NSString *)password encrypt:(NSUInteger)encrypt;
127
+
128
+ /**
129
+ * check connect status
130
+ */
131
+ - (BOOL)printerIsConnect;
132
+
133
+ /**
134
+ * printer sn code
135
+ */
136
+ - (void)printerSN:(POSWiFiPrinterSNBlock)snBlock;
137
+
138
+ /**
139
+ * connect printer address with mac address
140
+ */
141
+ - (void)connectWithMac:(NSString *)macStr;
142
+
143
+
144
+ /**
145
+ * get copyright
146
+ */
147
+ + (NSString *)GetCopyRight;
148
+
149
+ /**
150
+ * printer status
151
+ * 查询当前打印机常用状态(正常/缺纸/开盖等)
152
+ */
153
+ - (void)printerStatus:(POSWiFiPrinterStatusBlock)statusBlock;
154
+
155
+ /**
156
+ * printer check
157
+ * 这个方法用于查询打印机所有状态
158
+ * type = 1 打印机状态 type = 2 脱机状态 type = 3 错误状态 type = 4 传送纸状态
159
+ */
160
+ - (void)printerCheck:(int)type checkBlock:(POSWiFiPrinterCheckBlock)checkBlock;
161
+
162
+ @end
@@ -0,0 +1,50 @@
1
+ //
2
+ // PTable.h
3
+ // PrinterSDK
4
+ //
5
+ // Created by Apple Mac mini intel on 2023/11/27.
6
+ // Copyright © 2023 Admin. All rights reserved.
7
+ //
8
+
9
+ #import <Foundation/Foundation.h>
10
+
11
+ NS_ASSUME_NONNULL_BEGIN
12
+
13
+ typedef NS_ENUM(NSInteger, TableAlignType) {
14
+ ALL_LEFT_ALIGN, // 全部文本内容左对齐
15
+ ALL_RIGHT_ALIGN, // 全部文本内容右对齐
16
+ FIRST_LEFT_ALIGN, // 仅第一列文本内容左对齐,其余右对齐
17
+ };
18
+
19
+ typedef NS_ENUM(NSInteger, BCSBarcodeType) {
20
+ BCS_UPCA,
21
+ BCS_UPCE,
22
+ BCS_EAN13,
23
+ BCS_EAN8,
24
+ BCS_Code39,
25
+ BCS_ITF,
26
+ BCS_Codabar,
27
+ BCS_Code93,
28
+ BCS_Code128
29
+ };
30
+
31
+ typedef NS_ENUM(NSInteger, BarHriText) {
32
+ BAR_HRI_TEXT_NONE = 0,
33
+ BAR_HRI_TEXT_BELOW,
34
+ BAR_HRI_TEXT_ABOVE,
35
+ BAR_HRI_TEXT_BOTH
36
+ };
37
+
38
+
39
+
40
+ @interface PTable : NSObject
41
+
42
+ // 超过预设的字符宽度,自动换行
43
+ + (NSData *)addAutoTableH:(NSArray<NSString *> *)titles titleLength:(NSArray<NSNumber *> *)lengths align:(TableAlignType)align;
44
+
45
+ // 添加条码
46
+ + (NSData *)addBarcodeRow:(NSString *)data type:(BCSBarcodeType)type hri:(BarHriText)hri;
47
+
48
+ @end
49
+
50
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,28 @@
1
+ //
2
+ // PrinterProfile.h
3
+ // PrinterSDK
4
+ //
5
+ // Created by Apple Mac mini intel on 2023/9/5.
6
+ //
7
+
8
+ #import <Foundation/Foundation.h>
9
+
10
+ NS_ASSUME_NONNULL_BEGIN
11
+
12
+ @interface PrinterProfile : NSObject
13
+ @property (nonatomic, readonly) NSString *printerName;
14
+ @property (nonatomic, readonly) NSString *printerDesc;
15
+
16
+ - (void)setMAC:(NSData *)mac;
17
+ - (void)setIP:(NSData *)ip;
18
+ - (void)setMask:(NSData *)mask;
19
+ - (void)setGateway:(NSData *)gw;
20
+ - (void)setDHCP:(char)dhcp;
21
+ - (NSString *)getIPString;
22
+ - (NSString *)getMaskString;
23
+ - (NSString *)getGatewayString;
24
+ - (char)getDHCP;
25
+ - (Byte *)getMACArray;
26
+ @end
27
+
28
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,142 @@
1
+ //
2
+ // TSCBLEManager.h
3
+ // Printer
4
+ //
5
+
6
+ #import <Foundation/Foundation.h>
7
+ #import <CoreBluetooth/CoreBluetooth.h>
8
+
9
+ @protocol TSCBLEManagerDelegate <NSObject>
10
+ @optional
11
+ /**
12
+ * found peripheral list
13
+ */
14
+ - (void)TSCbleUpdatePeripheralList:(NSArray *)peripherals RSSIList:(NSArray *)rssiList;
15
+ /**
16
+ * connect success
17
+ */
18
+ - (void)TSCbleConnectPeripheral:(CBPeripheral *)peripheral;
19
+ /**
20
+ * connect fail
21
+ */
22
+ - (void)TSCbleFailToConnectPeripheral:(CBPeripheral *)peripheral error:(NSError *)error;
23
+ /**
24
+ * disconnect
25
+ */
26
+ - (void)TSCbleDisconnectPeripheral:(CBPeripheral *)peripheral error:(NSError *)error;
27
+ /**
28
+ * send data success
29
+ */
30
+ - (void)TSCbleWriteValueForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error;
31
+ /**
32
+ * receive printer data
33
+ */
34
+ - (void)TSCbleReceiveValueForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error;
35
+
36
+ /**
37
+ * bleCentralManager state update
38
+ */
39
+ - (void)TSCbleCentralManagerDidUpdateState:(NSInteger)state;
40
+
41
+ @end
42
+
43
+ /****************************************************************************************************/
44
+
45
+ typedef void (^TSCBLEManagerReceiveCallBackBlock)(CBCharacteristic *characteristic, NSError *error);
46
+ typedef void (^TSCBLEManagerWriteCallBackBlock) (CBCharacteristic *characteristic, NSError *error);
47
+ typedef void (^TSCBLEPrinterStatusBlock)(NSData *status);
48
+ typedef void (^TSCBLEPrinterSNBlock)(NSString *sn);
49
+
50
+
51
+ /****************************************************************************************************/
52
+
53
+ @interface TSCBLEManager : NSObject
54
+
55
+ // bt name
56
+ @property (nonatomic, copy) NSString *name;
57
+ // connect status
58
+ @property (nonatomic, assign) BOOL isConnecting;
59
+ // scan status
60
+ @property (nonatomic, assign) BOOL isScaning;
61
+ //peripheral that write
62
+ @property (nonatomic,strong) CBPeripheral *writePeripheral;
63
+ // write characteristic
64
+ @property (nonatomic, strong) CBCharacteristic *write_characteristic;
65
+ // read characteristic
66
+ @property (nonatomic, strong) CBCharacteristic *read_characteristic;
67
+ // notify characteristic
68
+ @property (nonatomic, strong) CBCharacteristic *notify_characteristic;
69
+ // search filter printer through uuid
70
+ @property (nonatomic, strong) CBUUID *searchFilterUUID;
71
+ // characteristic uuid
72
+ @property (nonatomic, strong) CBUUID *characteristicUUID;
73
+
74
+ @property (nonatomic,weak) id<TSCBLEManagerDelegate> delegate;
75
+
76
+ @property (nonatomic, copy) TSCBLEManagerReceiveCallBackBlock receiveBlock;
77
+ @property (nonatomic, copy) TSCBLEManagerWriteCallBackBlock writeBlock;
78
+ @property (nonatomic, copy) TSCBLEPrinterStatusBlock statusBlock;
79
+ @property (nonatomic, copy) TSCBLEPrinterSNBlock snBlock;
80
+ @property (nonatomic, copy) TSCBLEPrinterStatusBlock stateBlock;
81
+
82
+ /**
83
+ * singleton
84
+ */
85
+ + (instancetype)sharedInstance;
86
+
87
+ /**
88
+ * remove a delegate
89
+ */
90
+ - (void)removeDelegate:(id<TSCBLEManagerDelegate>) delegate;
91
+
92
+ /**
93
+ * remove all delegates
94
+ */
95
+ - (void)removeAllDelegates;
96
+
97
+ /**
98
+ * start scan
99
+ */
100
+ - (void)startScan;
101
+
102
+ /**
103
+ * stop scan
104
+ */
105
+ - (void)stopScan;
106
+
107
+ /**
108
+ * connect special one
109
+ */
110
+ - (void)connectDevice:(CBPeripheral *)peripheral;
111
+
112
+ /**
113
+ * disconnect manual
114
+ */
115
+ - (void)disconnectRootPeripheral;
116
+
117
+ /**
118
+ * send command
119
+ */
120
+ - (void)writeCommandWithData:(NSData *)data;
121
+
122
+ /**
123
+ * send command data with receicve callback
124
+ */
125
+ - (void)writeCommandWithData:(NSData *)data receiveCallBack:(TSCBLEManagerReceiveCallBackBlock)receiveBlock;
126
+
127
+ /**
128
+ * send command data with write callback
129
+ */
130
+ - (void)writeCommandWithData:(NSData *)data writeCallBack:(TSCBLEManagerWriteCallBackBlock)writeBlock;
131
+
132
+ /**
133
+ * get copyright
134
+ */
135
+ + (NSString *)GetCopyRight;
136
+
137
+ /**
138
+ * printer status
139
+ */
140
+ - (void)printerStatus:(TSCBLEPrinterStatusBlock)statusBlock;
141
+
142
+ @end