seven365-zyprinter 0.0.1

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 (53) hide show
  1. package/Package.swift +43 -0
  2. package/README.md +186 -0
  3. package/Seven365Zyprinter.podspec +27 -0
  4. package/android/build.gradle +58 -0
  5. package/android/src/main/AndroidManifest.xml +2 -0
  6. package/android/src/main/java/com/mycompany/plugins/example/Example.java +342 -0
  7. package/android/src/main/java/com/mycompany/plugins/example/ExamplePlugin.java +161 -0
  8. package/android/src/main/res/.gitkeep +0 -0
  9. package/dist/docs.json +229 -0
  10. package/dist/esm/definitions.d.ts +56 -0
  11. package/dist/esm/definitions.js +2 -0
  12. package/dist/esm/definitions.js.map +1 -0
  13. package/dist/esm/index.d.ts +4 -0
  14. package/dist/esm/index.js +7 -0
  15. package/dist/esm/index.js.map +1 -0
  16. package/dist/esm/web.d.ts +49 -0
  17. package/dist/esm/web.js +40 -0
  18. package/dist/esm/web.js.map +1 -0
  19. package/dist/plugin.cjs.js +54 -0
  20. package/dist/plugin.cjs.js.map +1 -0
  21. package/dist/plugin.js +57 -0
  22. package/dist/plugin.js.map +1 -0
  23. package/ios/Seven365Zyprinter.podspec +28 -0
  24. package/ios/Sources/Plugin/ZyprintPlugin.swift +161 -0
  25. package/ios/Sources/Plugin/ZywellSDK.swift +358 -0
  26. package/ios/Sources/Seven365Zyprinter-Umbrella.h +16 -0
  27. package/ios/Sources/module.modulemap +12 -0
  28. package/ios/Sources/sources/BLEManager.h +658 -0
  29. package/ios/Sources/sources/BLEManager.m +2842 -0
  30. package/ios/Sources/sources/GCD/Documentation.html +47 -0
  31. package/ios/Sources/sources/GCD/GCDAsyncSocket.h +1226 -0
  32. package/ios/Sources/sources/GCD/GCDAsyncSocket.m +8560 -0
  33. package/ios/Sources/sources/GCD/GCDAsyncUdpSocket.h +1036 -0
  34. package/ios/Sources/sources/GCD/GCDAsyncUdpSocket.m +5632 -0
  35. package/ios/Sources/sources/GCD/PrinterManager.h +91 -0
  36. package/ios/Sources/sources/GCD/PrinterManager.m +513 -0
  37. package/ios/Sources/sources/GCD/WifiManager.h +91 -0
  38. package/ios/Sources/sources/GCD/WifiManager.m +510 -0
  39. package/ios/Sources/sources/ImageTranster.h +38 -0
  40. package/ios/Sources/sources/ImageTranster.m +389 -0
  41. package/ios/Sources/sources/POSBLEManager.h +759 -0
  42. package/ios/Sources/sources/POSBLEManager.m +834 -0
  43. package/ios/Sources/sources/POSSDK.h +93 -0
  44. package/ios/Sources/sources/POSWIFIManager.h +116 -0
  45. package/ios/Sources/sources/POSWIFIManager.m +260 -0
  46. package/ios/Sources/sources/POSWIFIManagerAsync.h +745 -0
  47. package/ios/Sources/sources/POSWIFIManagerAsync.m +1847 -0
  48. package/ios/Sources/sources/PosCommand.h +633 -0
  49. package/ios/Sources/sources/PosCommand.m +1019 -0
  50. package/ios/Sources/sources/TscCommand.h +723 -0
  51. package/ios/Sources/sources/TscCommand.m +566 -0
  52. package/ios/Tests/ExamplePluginTests/ExamplePluginTests.swift +15 -0
  53. package/package.json +339 -0
@@ -0,0 +1,93 @@
1
+ //
2
+ // PosSDK.h
3
+ // Printer
4
+ //
5
+ // Created by apple on 16/4/6.
6
+ // Copyright © 2016年 Admin. All rights reserved.
7
+ //
8
+
9
+
10
+ /*
11
+ 简介:使用SDK需要添加系统依赖库
12
+ SystemConfiguration.framework
13
+ CFNetwork.framework
14
+ CoreBluetooth.framework
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
+ 在PosPrinterIosSdk的usr文件中,可见的头文件(.h文件)分别有:PosBLEManager.h,PosWIFIManager.h,TscCommand.h,PosCommand.h,ImageTranster.h和PosSDK.h.
25
+ 这几.h文件包含了蓝牙和wifi的连接:PosBLEMananger.h和PosWIFIManager,发送,接收数据的方法和需要遵循的代理,还有指令封装的工具类:TscCommand,PosCommand,图像处理类:ImageTranster;
26
+ 说明文档PosSDK.h
27
+ PosBLEManager.h 是蓝牙管理类,处理蓝牙的连接相关和POS指令的发送。
28
+ 使用 [PosBLEManager sharedInstance] 单例方法创建管理对象,创建的同时遵循代理,实现代理方法. 调用 PosstartScan 方法开始扫描,并在代理方法 PosdidUpdatePeripheralList 中拿到扫描结果。 PosconnectDevice: 是蓝牙连接方法,连接指定的外设。PosBLEManager中有个 writePeripheral 属性,用来指定向哪个外设写数据,不指定默认位最后连接的那个外设。
29
+ PosWIFIManager.h 是wifi管理类,处理wifi的连接和条码指令的发送。单个连接可使用单例方法 [PosWIFIManager shareWifiManager] 创建连接对象,并遵循代理,PosConnectWithHost:port:completion:是连接的方法,指定IP 和端口号,有 block 回调是否成功。多个连接时用 [[PosWIFIManager alloc] init] 方法初始化多个管理对象,并保存,使用相应的对象来发送指令。
30
+ TscCommand.h条码指令封装工具类,所有返回值均为NSData类型;
31
+ PosCommand.h,pos指令封装工具类,返回都是NSData类型。
32
+ 这俩个指令工具类里的方法均为类方法,直接用类名调用,返回值都是NSData类型,可用于数据直接发送
33
+ 蓝牙和WiFi的连接实现,都需要遵循代理,详细请参考示例代码.
34
+ 具体的发送数据的方法,在PosBLEManager.h和PosWIFIManager.h,都为-(void)PosWriteCommandWithData:(NSData *)data;以及带回调的方法
35
+ -(void)PosWriteCommandWithData:(NSData *)data callBack:(PosTSCCompletionBlock)block;
36
+
37
+
38
+ 蓝牙管理类的使用说明:
39
+ 首先:使用[PosBLEManager sharedInstance] 单例方法创建管理对象,设置代理,并实现代理方法。注意:当创建了PosBLEManager的对象后,蓝牙已经开启了扫描,扫描结果也进行了保存。此时,在实现的代理方法 - (void)PosdidUpdatePeripheralList:(NSArray *)peripherals RSSIList:(NSArray *)rssiList;中,可以拿到扫描结果,通过扫描的设备,可以进行连接, PosconnectDevice: ;连接结成功或失败会分别调用代理方法- (void)PosdidConnectPeripheral:(CBPeripheral *)peripheral;和- (void)PosdidFailToConnectPeripheral:(CBPeripheral *)peripheral error:(NSError *)error;方法。
40
+ 连接成功后,获得写数据的特征,就可以调用发送数据的方法了,推荐使用PosWriteCommandWithData:方法发送。在数据发送后,会回调代理方法PosdidWriteValueForCharacteristic:(CBCharacteristic *)character error:(NSError *)error;可以通过error来判断发送数据是否成功,再做相应的操作。也可用PosWriteCommandWithData:callblock:方法发送,用block回调是否成功。
41
+
42
+ @protocol PosBLEManagerDelegate <NSObject>
43
+ // 发现的蓝牙设备后执行
44
+ - (void)PosdidUpdatePeripheralList:(NSArray *)peripherals RSSIList:(NSArray *)rssiList;
45
+ // 连接成功后执行
46
+ - (void)PosdidConnectPeripheral:(CBPeripheral *)peripheral;
47
+ // 连接失败后执行
48
+ - (void)PosdidFailToConnectPeripheral:(CBPeripheral *)peripheral error:(NSError *)error;
49
+ // 断开连接后执行
50
+ - (void)PosdidDisconnectPeripheral:(CBPeripheral *)peripheral isAutoDisconnect:(BOOL)isAutoDisconnect;
51
+ // 发送数据后执行
52
+ - (void)PosdidWriteValueForCharacteristic:(CBCharacteristic *)character error:(NSError *)error;
53
+
54
+ @end
55
+
56
+
57
+ wifi管理类的使用说明:
58
+ 单个连接可使用单例方法 [PosWIFIManager shareWifiManager] 创建连接对象,设置代理,并实现代理方法。
59
+ PosConnectWithHost:port:completion:是连接的方法,指定IP 和端口号,有 block 回调是否成功。也可以实现代理方法- (void)PosWIFIManager:(PosWIFIManager *)manager didConnectedToHost:(NSString *)host port:(UInt16)port;来处理连接成功或失败后的操作.
60
+
61
+ 连接成功后,发送数据推荐使用-(void)PosWriteCommandWithData:(NSData *)data;和
62
+
63
+ -(void)PosWriteCommandWithData:(NSData *)data withResponse:(PosWIFICallBackBlock)block;
64
+ 来发送数据,对发送数据的结果可以用block回调,也可以在PosWIFIManager:(PosWIFIManager *)manager didWriteDataWithTag:(long)tag代理方法中执行判断后的操作。
65
+
66
+
67
+ @protocol PosWIFIManagerDelegate <NSObject>
68
+
69
+ // 成功连接主机后执行
70
+ - (void)PosWIFIManager:(PosWIFIManager *)manager didConnectedToHost:(NSString *)host port:(UInt16)port;
71
+ // 断开连接
72
+ - (void)PosWIFIManager:(PosWIFIManager *)manager willDisconnectWithError:(NSError *)error;
73
+ // 写入数据后执行
74
+ - (void)PosWIFIManager:(PosWIFIManager *)manager didWriteDataWithTag:(long)tag;
75
+ // 接收数据方法执行后执行的方法
76
+ - (void)PosWIFIManager:(PosWIFIManager *)manager didReadData:(NSData *)data tag:(long)tag;
77
+ // 断开连接后执行的方法
78
+ - (void)PosWIFIManagerDidDisconnected:(PosWIFIManager *)manager;
79
+ @end
80
+
81
+
82
+
83
+ */
84
+
85
+
86
+ #ifndef POSSDK_h
87
+ #define POSSDK_h
88
+
89
+ #import "POSBLEManager.h"
90
+ #import "POSWIFIManager.h"
91
+ #endif /* PosSDK_h */
92
+
93
+
@@ -0,0 +1,116 @@
1
+ //
2
+ // PosWIFIManager.h
3
+ // Printer
4
+ //
5
+ // Created by ding on 2022/12/23
6
+ //
7
+
8
+ #import <Foundation/Foundation.h>
9
+ #import <UIKit/UIKit.h>
10
+ @class POSWIFIManager;
11
+ typedef void(^POSWIFIBlock)(BOOL isConnect);
12
+ typedef void(^POSWIFICallBackBlock)(NSData *data);
13
+ enum {
14
+ SocketOfflineByServer,// 服务器掉线,默认为0
15
+ SocketOfflineByUser, // 用户主动cut
16
+ };
17
+
18
+ /**
19
+ *Connect multiple devices.
20
+ *Use POSWIFIManager *manager = [[POSWIFIManager alloc] init] to instantiate the object,
21
+ *Save the manager and specify the corresponding manager when sending the command to send the command
22
+ */
23
+ @protocol POSWIFIManagerDelegate <NSObject>
24
+
25
+ /// Successfully connected to the host
26
+ /// @param managerWiFi connection object management
27
+ /// @param host ip address
28
+ /// @param port The port number
29
+ - (void)POSWIFIManager:(POSWIFIManager *)manager didConnectedToHost:(NSString *)host port:(UInt16)port;
30
+ /// Disconnect
31
+ /// @param manager WiFi connection object management
32
+ /// @param error error
33
+ - (void)POSWIFIManager:(POSWIFIManager *)manager willDisconnectWithError:(NSError *)error;
34
+ // Data written successfully
35
+ - (void)POSWIFIManager:(POSWIFIManager *)manager didWriteDataWithTag:(long)tag;
36
+ /// Receive the data returned by the printer
37
+ /// @param manager Management object
38
+ /// @param data Returned data
39
+ /// @param tag tag
40
+ - (void)POSWIFIManager:(POSWIFIManager *)manager didReadData:(NSData *)data tag:(long)tag;
41
+ // 断开连接
42
+ - (void)POSWIFIManagerDidDisconnected:(POSWIFIManager *)manager;
43
+ @end
44
+
45
+ @interface POSWIFIManager : NSObject
46
+ {
47
+ int commandSendMode; //命令发送模式 0:立即发送 1:批量发送
48
+ }
49
+ #pragma mark - 基本属性
50
+ // 主机地址
51
+ @property (nonatomic,copy) NSString *hostStr;
52
+ // 端口
53
+ @property (nonatomic,assign) UInt16 port;
54
+ // 是否连接成功
55
+ @property (nonatomic,assign) BOOL connectOK;
56
+ // 是自动断开连接 还是 手动断开
57
+ @property (nonatomic,assign) BOOL isAutoDisconnect;
58
+
59
+ @property (nonatomic,weak) id<POSWIFIManagerDelegate> delegate;
60
+ // 连接回调
61
+ @property (nonatomic,copy) POSWIFIBlock callBack;
62
+ // 接收服务端返回的数据
63
+ @property (nonatomic,copy) POSWIFICallBackBlock callBackBlock;
64
+ @property (nonatomic,strong) NSMutableArray *commandBuffer;
65
+ //是否连接成功
66
+ @property (nonatomic,assign) BOOL isConnected;
67
+ //接收到的数据
68
+ @property(nonatomic,copy)NSData* receivedData;
69
+ //是否成功监控打印机的状态
70
+ @property (nonatomic,assign) BOOL isReceivedData;
71
+ //打印机类型
72
+ @property(nonatomic,assign)NSUInteger printerType;
73
+ @property(strong,nonatomic) NSTimer *timer;
74
+ @property(nonatomic,assign)bool isFirstRece;
75
+ //发送队列数组
76
+ #pragma mark - 基本方法
77
+ + (instancetype)shareWifiManager;
78
+ //连接主机
79
+ -(void)POSConnectWithHost:(NSString *)hostStr port:(UInt16)port completion:(POSWIFIBlock)block;
80
+ // 断开主机
81
+ - (void)POSDisConnect;
82
+
83
+ //修改版本的推荐使用发送数据的两个方法
84
+ -(void)POSWriteCommandWithData:(NSData *)data;
85
+
86
+ -(void)POSWriteCommandWithData:(NSData *)data withResponse:(POSWIFICallBackBlock)block;
87
+
88
+ // 发送TSC完整指令
89
+ - (void)POSSendMSGWith:(NSString *)str;
90
+
91
+ - (void)POSSetCommandMode:(BOOL)Mode;
92
+
93
+ /*
94
+ * 74.设置打印机发送命令模式
95
+ * 范围:0,1
96
+ * 0:立即发送
97
+ * 1:批量发送
98
+ */
99
+
100
+ -(NSArray*)POSGetBuffer;
101
+ /*
102
+ * 75.返回等待发送指令队列
103
+ */
104
+
105
+ -(void)POSClearBuffer;
106
+ /*
107
+ * 76.清空等待发送指令队列
108
+ */
109
+
110
+ -(void)POSSendCommandBuffer;
111
+ /*
112
+ * 77.发送指令队列
113
+ */
114
+
115
+
116
+ @end
@@ -0,0 +1,260 @@
1
+ //
2
+ // PosWIFIManager.m
3
+ // Printer
4
+ //
5
+ // Created by ding on 2022/12/23
6
+ //
7
+
8
+ #import "POSWIFIManager.h"
9
+ #import "GCD/GCDAsyncSocket.h"
10
+ #import <SystemConfiguration/CaptiveNetwork.h>
11
+
12
+ static POSWIFIManager *shareManager = nil;
13
+
14
+ @interface POSWIFIManager ()<GCDAsyncSocketDelegate>
15
+ // 连接的socket对象
16
+ @property (nonatomic,strong) GCDAsyncSocket *sendSocket;
17
+ @property (nonatomic,strong) NSTimer *connectTimer;
18
+ @end
19
+
20
+ @implementation POSWIFIManager
21
+
22
+ /// Create WiFi management object
23
+ + (instancetype)shareWifiManager {
24
+ static dispatch_once_t onceToken;
25
+ dispatch_once(&onceToken, ^{
26
+ shareManager = [[POSWIFIManager alloc] init];
27
+ });
28
+ return shareManager;
29
+ }
30
+
31
+ - (instancetype)init {
32
+ if (self = [super init]) {
33
+ dispatch_queue_t queue = dispatch_queue_create([@"com.label.print" UTF8String], DISPATCH_QUEUE_SERIAL);
34
+ _sendSocket=[[GCDAsyncSocket alloc] initWithDelegate:self delegateQueue:queue];
35
+ _sendSocket.userData = SocketOfflineByServer;
36
+ _commandBuffer=[[NSMutableArray alloc]init];
37
+ }
38
+ return self;
39
+ }
40
+ //连接wifi打印机
41
+ -(bool)ConnectWifiPrinter:(NSString *)ip port:(UInt16)port{
42
+ if(!_isConnected){
43
+ NSError *err = nil;
44
+ _isFirstRece=true;
45
+ _isReceivedData=false;
46
+ _isConnected=false;
47
+ _isConnected=[_sendSocket connectToHost:ip onPort:port withTimeout:-1 error:&err];
48
+ if(!_isConnected){
49
+ _isConnected=false;
50
+ NSLog(@"connect failed\n");
51
+ }else{
52
+ _isConnected=true;
53
+ //NSLog(@"connect success\n");
54
+ }
55
+ NSDate* tmpStartData = [NSDate date];
56
+ while(_isFirstRece){
57
+ double timeout = [[NSDate date] timeIntervalSinceDate:tmpStartData];
58
+ if(timeout>2){//连接超时
59
+ _isConnected=false;
60
+ NSLog(@"connect timeout,connect failed\n");
61
+ break;
62
+ }
63
+ }
64
+ if(!_isFirstRece){
65
+ _isConnected=true;
66
+ NSLog(@"didconnect,connect success\n");
67
+ }
68
+ }
69
+ return _isConnected;
70
+ }
71
+ /**
72
+ Disconnect manually
73
+ */
74
+ - (void)POSDisConnect {
75
+
76
+ if (_sendSocket) {
77
+ _isAutoDisconnect = NO;
78
+ [self.connectTimer invalidate];
79
+ [_sendSocket disconnect];
80
+ }
81
+ }
82
+
83
+
84
+ /// send data
85
+ /// @param data data
86
+ -(void)POSWriteCommandWithData:(NSData *)data{
87
+ if (_connectOK) {
88
+ //NSLog(@"----%@",data);
89
+ if (commandSendMode==0){
90
+ [_sendSocket writeData:data withTimeout:-1 tag:0];
91
+
92
+ }
93
+ else{
94
+ [_commandBuffer addObject: data];
95
+ // [_sendSocket writeData:data withTimeout:-1 tag:0];
96
+ }
97
+ }
98
+
99
+
100
+ }
101
+
102
+ /// Send data and call back
103
+ /// @param data data
104
+ /// @param block callback
105
+ -(void)POSWriteCommandWithData:(NSData *)data withResponse:(POSWIFICallBackBlock)block{
106
+
107
+ if (_connectOK) {
108
+ self.callBackBlock = block;
109
+ if (commandSendMode==0)
110
+ [_sendSocket writeData:data withTimeout:-1 tag:0];
111
+ else
112
+ [_commandBuffer addObject: data];
113
+ //[_sendSocket writeData:data withTimeout:-1 tag:0];
114
+ }
115
+
116
+ }
117
+
118
+ /**
119
+ send messages
120
+ @param str data
121
+ */
122
+ - (void)POSSendMSGWith:(NSString *)str {
123
+ if (_connectOK) {
124
+ str = [str stringByAppendingString:@"\r\n"];
125
+ NSData *data = [str dataUsingEncoding:NSASCIIStringEncoding];
126
+ NSLog(@"%@==%@",str,data);
127
+ if (commandSendMode==0)
128
+ [_sendSocket writeData:data withTimeout:-1 tag:0];
129
+ else
130
+ [_commandBuffer addObject: data];
131
+
132
+ }
133
+ }
134
+ //
135
+ ///**
136
+ // 发送POS指令
137
+ // */
138
+ //- (void)PosWritePOSCommandWithData:(NSData *)data withResponse:(PosWIFICallBackBlock)block {
139
+ // if (_connectOK) {
140
+ // self.callBackBlock = block;
141
+ // if (commandSendMode==0)
142
+ // [_sendSocket writeData:data withTimeout:-1 tag:0];
143
+ // else
144
+ // [_commandBuffer addObject: data];
145
+ // //[_sendSocket writeData:data withTimeout:-1 tag:0];
146
+ // }
147
+ //}
148
+
149
+ /// Connect the printer
150
+ /// @param hostStr Printer ip address
151
+ /// @param port port of printer
152
+ /// @param block callback
153
+ -(void)POSConnectWithHost:(NSString *)hostStr port:(UInt16)port completion:(POSWIFIBlock)block
154
+ {
155
+ _connectOK = NO;
156
+ _hostStr = hostStr;
157
+ _port = port;
158
+
159
+ NSError *error=nil;
160
+ _isConnected=false;
161
+ _connectOK=[self ConnectWifiPrinter:hostStr port:port];
162
+ block(_connectOK);
163
+ }
164
+
165
+ /// Connection established
166
+ /// @param sock sock object
167
+ /// @param host Host address
168
+ /// @param port The port number
169
+ - (void)socket:(GCDAsyncSocket *)sock didConnectToHost:(NSString *)host port:(uint16_t)port{
170
+ if(sock.isConnected){
171
+ NSLog(@"didconnect to host");
172
+ _isConnected=true;
173
+ _isFirstRece=false;
174
+ }
175
+ if ([self.delegate respondsToSelector:@selector(POSWIFIManager:didConnectedToHost:port:)]) {
176
+ [self.delegate POSWIFIManager:self didConnectedToHost:host port:port];
177
+ }
178
+ [_sendSocket readDataWithTimeout: -1 tag: 0];
179
+ }
180
+ - (void)socket:(GCDAsyncSocket *)sock didWriteDataWithTag:(long)tag{
181
+ if(sock.isDisconnected){
182
+ _isConnected=false;
183
+ }
184
+ NSLog(@"%s %d, tag = %ld", __FUNCTION__, __LINE__, tag);
185
+ if ([self.delegate respondsToSelector:@selector(POSWIFIManager:didWriteDataWithTag:)]) {
186
+ [self.delegate POSWIFIManager:self didWriteDataWithTag:tag];
187
+ }
188
+ [_sendSocket readDataWithTimeout: -1 tag: 0];
189
+ }
190
+ - (void)socket:(GCDAsyncSocket *)sock willDisconnectWithError:(NSError *)err
191
+ {
192
+ _isAutoDisconnect = YES;
193
+ if ([self.delegate respondsToSelector:@selector(POSWIFIManager:willDisconnectWithError:)]) {
194
+ [self.delegate POSWIFIManager:self willDisconnectWithError:err];
195
+ }
196
+ NSLog(@"%s %d, tag = %@", __FUNCTION__, __LINE__, err);
197
+ }
198
+
199
+ - (void)socket:(GCDAsyncSocket *)sock didReadData:(NSData *)data withTag:(long)tag
200
+ {
201
+
202
+ NSString *msg = [[NSString alloc] initWithData: data encoding:NSUTF8StringEncoding];
203
+
204
+ if ([self.delegate respondsToSelector:@selector(POSWIFIManager:didReadData:tag:)]) {
205
+ [self.delegate POSWIFIManager:self didReadData:data tag:tag];
206
+ }
207
+ NSLog(@"%@", data);
208
+ [_sendSocket readDataWithTimeout: -1 tag: 0];
209
+ }
210
+ - (void)socketDidDisconnect:(GCDAsyncSocket *)sock withError:(nullable NSError *)err{
211
+ if(sock.isDisconnected){
212
+ _isConnected=false;
213
+ // NSLog(@"printer disconnected");
214
+ }
215
+ _connectOK = NO;
216
+ if ([self.delegate respondsToSelector:@selector(POSWIFIManagerDidDisconnected:)]) {
217
+ [self.delegate POSWIFIManagerDidDisconnected:self];
218
+ }
219
+ }
220
+ - (void)showAlert:(NSString *)str {
221
+ UIAlertView *alter = [[UIAlertView alloc] initWithTitle:@"提示" message:str delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
222
+ [alter show];
223
+ }
224
+
225
+
226
+
227
+ -(NSArray*)POSGetBuffer
228
+ {
229
+ return [_commandBuffer copy];
230
+ }
231
+
232
+ -(void)POSClearBuffer
233
+ {
234
+ [_commandBuffer removeAllObjects];
235
+ }
236
+
237
+ -(void)sendCommand:(NSData *)data
238
+ {
239
+ [_sendSocket writeData:data withTimeout:-1 tag:0];
240
+ }
241
+
242
+ -(void)POSSendCommandBuffer
243
+ {
244
+ float timeInterver=0.5;
245
+
246
+ for (int t=0;t<[_commandBuffer count];t++)
247
+ {
248
+ //[self performSelectorOnMainThread:@selector(sendCommand:) withObject:_commandBuffer[t] waitUntilDone:NO ];
249
+ [self performSelector:@selector(sendCommand:) withObject:_commandBuffer[t] afterDelay:timeInterver];
250
+ timeInterver=timeInterver+0.2;
251
+ }
252
+ [_commandBuffer removeAllObjects];
253
+ }
254
+
255
+ - (void)POSSetCommandMode:(BOOL)Mode{
256
+ commandSendMode=Mode;
257
+ }
258
+
259
+
260
+ @end