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.
- package/Package.swift +43 -0
- package/README.md +186 -0
- package/Seven365Zyprinter.podspec +27 -0
- package/android/build.gradle +58 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/com/mycompany/plugins/example/Example.java +342 -0
- package/android/src/main/java/com/mycompany/plugins/example/ExamplePlugin.java +161 -0
- package/android/src/main/res/.gitkeep +0 -0
- package/dist/docs.json +229 -0
- package/dist/esm/definitions.d.ts +56 -0
- package/dist/esm/definitions.js +2 -0
- package/dist/esm/definitions.js.map +1 -0
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/web.d.ts +49 -0
- package/dist/esm/web.js +40 -0
- package/dist/esm/web.js.map +1 -0
- package/dist/plugin.cjs.js +54 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.js +57 -0
- package/dist/plugin.js.map +1 -0
- package/ios/Seven365Zyprinter.podspec +28 -0
- package/ios/Sources/Plugin/ZyprintPlugin.swift +161 -0
- package/ios/Sources/Plugin/ZywellSDK.swift +358 -0
- package/ios/Sources/Seven365Zyprinter-Umbrella.h +16 -0
- package/ios/Sources/module.modulemap +12 -0
- package/ios/Sources/sources/BLEManager.h +658 -0
- package/ios/Sources/sources/BLEManager.m +2842 -0
- package/ios/Sources/sources/GCD/Documentation.html +47 -0
- package/ios/Sources/sources/GCD/GCDAsyncSocket.h +1226 -0
- package/ios/Sources/sources/GCD/GCDAsyncSocket.m +8560 -0
- package/ios/Sources/sources/GCD/GCDAsyncUdpSocket.h +1036 -0
- package/ios/Sources/sources/GCD/GCDAsyncUdpSocket.m +5632 -0
- package/ios/Sources/sources/GCD/PrinterManager.h +91 -0
- package/ios/Sources/sources/GCD/PrinterManager.m +513 -0
- package/ios/Sources/sources/GCD/WifiManager.h +91 -0
- package/ios/Sources/sources/GCD/WifiManager.m +510 -0
- package/ios/Sources/sources/ImageTranster.h +38 -0
- package/ios/Sources/sources/ImageTranster.m +389 -0
- package/ios/Sources/sources/POSBLEManager.h +759 -0
- package/ios/Sources/sources/POSBLEManager.m +834 -0
- package/ios/Sources/sources/POSSDK.h +93 -0
- package/ios/Sources/sources/POSWIFIManager.h +116 -0
- package/ios/Sources/sources/POSWIFIManager.m +260 -0
- package/ios/Sources/sources/POSWIFIManagerAsync.h +745 -0
- package/ios/Sources/sources/POSWIFIManagerAsync.m +1847 -0
- package/ios/Sources/sources/PosCommand.h +633 -0
- package/ios/Sources/sources/PosCommand.m +1019 -0
- package/ios/Sources/sources/TscCommand.h +723 -0
- package/ios/Sources/sources/TscCommand.m +566 -0
- package/ios/Tests/ExamplePluginTests/ExamplePluginTests.swift +15 -0
- package/package.json +339 -0
|
@@ -0,0 +1,2842 @@
|
|
|
1
|
+
//
|
|
2
|
+
// BLEManage.m
|
|
3
|
+
//
|
|
4
|
+
//
|
|
5
|
+
// Created by ding on 16/7/19.
|
|
6
|
+
// Copyright © 2019年 ding. All rights reserved.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
#import "BLEManager.h"
|
|
10
|
+
#import <UIKit/UIKit.h>
|
|
11
|
+
|
|
12
|
+
static BLEManager *shareManager = nil;
|
|
13
|
+
|
|
14
|
+
@implementation BLEManager
|
|
15
|
+
|
|
16
|
+
#pragma mark -
|
|
17
|
+
#pragma mark 基本方法
|
|
18
|
+
/**
|
|
19
|
+
* 单例方法
|
|
20
|
+
*
|
|
21
|
+
* @return self
|
|
22
|
+
*/
|
|
23
|
+
+ (instancetype)sharedBLEManager {
|
|
24
|
+
if (shareManager == nil) {
|
|
25
|
+
shareManager = [[super allocWithZone:NULL] init];
|
|
26
|
+
}
|
|
27
|
+
return shareManager;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// 初始化连接
|
|
31
|
+
- (instancetype)init {
|
|
32
|
+
self = [super init];
|
|
33
|
+
_manager = [[CBCentralManager alloc] initWithDelegate:self queue:nil];
|
|
34
|
+
_manager.delegate = self;
|
|
35
|
+
_dataArray = [NSMutableArray array];
|
|
36
|
+
_isAutoDisconnect = YES;
|
|
37
|
+
_commandBuffer=[[NSMutableArray alloc]init];
|
|
38
|
+
return self;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
#pragma mark 获取手机蓝牙状态
|
|
42
|
+
- (BOOL)isLECapableHardware {
|
|
43
|
+
NSString * state = nil;
|
|
44
|
+
|
|
45
|
+
// int iState = (int)[_manager state];
|
|
46
|
+
|
|
47
|
+
// NSLog(@"Central manager state: %i", iState);
|
|
48
|
+
|
|
49
|
+
switch ([_manager state]) {
|
|
50
|
+
case CBManagerStateUnsupported://不支持
|
|
51
|
+
state = @"The platform/hardware doesn't support Bluetooth Low Energy.";
|
|
52
|
+
break;
|
|
53
|
+
case CBManagerStateUnauthorized://未授权
|
|
54
|
+
state = @"The app is not authorized to use Bluetooth Low Energy.";
|
|
55
|
+
break;
|
|
56
|
+
case CBManagerStatePoweredOff://蓝牙关闭
|
|
57
|
+
state = @"Bluetooth is currently powered off.";
|
|
58
|
+
break;
|
|
59
|
+
case CBManagerStatePoweredOn://蓝牙打开
|
|
60
|
+
return TRUE;
|
|
61
|
+
case CBManagerStateUnknown://未知状态
|
|
62
|
+
default:
|
|
63
|
+
return FALSE;
|
|
64
|
+
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// NSLog(@"Central manager state: %@", state);
|
|
68
|
+
|
|
69
|
+
return FALSE;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
#pragma mark 开启蓝牙扫描-(可针对性扫描)
|
|
73
|
+
- (void)startScan {
|
|
74
|
+
if ([self isLECapableHardware]) {
|
|
75
|
+
if (_peripherals) {
|
|
76
|
+
[_peripherals removeAllObjects];
|
|
77
|
+
[_RSSIArray removeAllObjects];
|
|
78
|
+
} else {
|
|
79
|
+
_peripherals = [NSMutableArray array];
|
|
80
|
+
_RSSIArray = [NSMutableArray array];
|
|
81
|
+
}
|
|
82
|
+
_isScaning = YES;
|
|
83
|
+
|
|
84
|
+
BOOL result = [self checkConnectedPeripherals];
|
|
85
|
+
|
|
86
|
+
if (result) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
[_manager scanForPeripheralsWithServices:nil options:nil];
|
|
91
|
+
|
|
92
|
+
// 针对性扫描 serviceUUIDs = [NSArray arrayWithObject:[CBUUID UUIDWithString:@"180D"]]
|
|
93
|
+
// 其中 180D 就是对外公开的 1 级 服务UUID
|
|
94
|
+
// [_manager scanForPeripheralsWithServices:[NSArray arrayWithObject:[CBUUID UUIDWithString:@"6E40FFA0-B5A3-F393-E0A9-E50E24DCCA9E"]] options:nil];
|
|
95
|
+
|
|
96
|
+
} else {
|
|
97
|
+
|
|
98
|
+
if (self.scanBlock) {
|
|
99
|
+
self.scanBlock(_peripherals);
|
|
100
|
+
self.scanBlock(nil);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
#pragma mark - 检查已与手机连接的设备
|
|
105
|
+
-(BOOL)checkConnectedPeripherals
|
|
106
|
+
{
|
|
107
|
+
NSArray *arr = [_manager retrieveConnectedPeripheralsWithServices:@[[CBUUID UUIDWithString:@"18F0"]]];
|
|
108
|
+
for (CBPeripheral *per in arr) {
|
|
109
|
+
// if ([per.name isEqualToString:@"Printer001"]) {
|
|
110
|
+
[self connectPeripheral:per];
|
|
111
|
+
return YES;
|
|
112
|
+
// }
|
|
113
|
+
|
|
114
|
+
}
|
|
115
|
+
arr = [_manager retrieveConnectedPeripheralsWithServices:@[[CBUUID UUIDWithString:@"FFF0"]]];
|
|
116
|
+
for (CBPeripheral *per in arr) {
|
|
117
|
+
// if ([per.name isEqualToString:@"Printer001"]) {
|
|
118
|
+
[self connectPeripheral:per];
|
|
119
|
+
return YES;
|
|
120
|
+
// }
|
|
121
|
+
}
|
|
122
|
+
return NO;
|
|
123
|
+
}
|
|
124
|
+
#pragma mark 开始扫描并在scanInterval秒后停止
|
|
125
|
+
- (void)startScanWithInterval:(NSInteger)scanInterval completion:(BleManagerDiscoverPeripheralCallBack)callBack {
|
|
126
|
+
self.scanBlock = callBack;
|
|
127
|
+
[self startScan];
|
|
128
|
+
[self performSelector:@selector(stopScan) withObject:nil afterDelay:scanInterval];
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
#pragma mark 停止扫描
|
|
132
|
+
- (void)stopScan {
|
|
133
|
+
_isScaning = NO;
|
|
134
|
+
[_manager stopScan];
|
|
135
|
+
if (self.scanBlock) {
|
|
136
|
+
self.scanBlock(_peripherals);
|
|
137
|
+
self.scanBlock(nil);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
#pragma mark 连接到指定设备
|
|
142
|
+
- (void)connectPeripheral:(CBPeripheral *)peripheral {
|
|
143
|
+
[_manager connectPeripheral:peripheral options:[NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES] forKey:CBConnectPeripheralOptionNotifyOnDisconnectionKey]];
|
|
144
|
+
_peripheral = peripheral;
|
|
145
|
+
if (_writePeripheral == nil) {
|
|
146
|
+
_writePeripheral = peripheral;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
#pragma mark 连接蓝牙设备
|
|
151
|
+
- (void)connectPeripheral:(CBPeripheral *)peripheral completion:(BleManagerConnectPeripheralCallBack)callBack {
|
|
152
|
+
self.connectBlock = callBack;
|
|
153
|
+
[self connectPeripheral:peripheral];
|
|
154
|
+
[self performSelector:@selector(connectTimeOutAction) withObject:nil afterDelay:5.0];
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
#pragma mark 尝试重新连接
|
|
158
|
+
- (void)reConnectPeripheral:(CBPeripheral *)peripheral {
|
|
159
|
+
[_manager connectPeripheral:peripheral options:[NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES] forKey:CBConnectPeripheralOptionNotifyOnDisconnectionKey]];
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
#pragma mark 断开连接
|
|
163
|
+
- (void)disconnectPeripheral:(CBPeripheral *)peripheral {
|
|
164
|
+
_isConnected = NO;
|
|
165
|
+
_isAutoDisconnect = NO;
|
|
166
|
+
[_manager cancelPeripheralConnection:peripheral];
|
|
167
|
+
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
#pragma mark -
|
|
171
|
+
#pragma mark BLE 管理中心的代理方法
|
|
172
|
+
#pragma mark -
|
|
173
|
+
/*
|
|
174
|
+
*Invoked whenever the central manager's state is updated.
|
|
175
|
+
*设备蓝牙状态发生改变
|
|
176
|
+
*/
|
|
177
|
+
#pragma mark 设备蓝牙状态发生改变
|
|
178
|
+
- (void)centralManagerDidUpdateState:(CBCentralManager *)central
|
|
179
|
+
{
|
|
180
|
+
if ([self isLECapableHardware]) {
|
|
181
|
+
if (_peripheral) {
|
|
182
|
+
// [self reConnectPeripheral:_peripheral];
|
|
183
|
+
} else {
|
|
184
|
+
[self startScan];
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
} else {
|
|
188
|
+
NSLog(@"Bluetooth turned off");
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/*
|
|
194
|
+
*Invoked when the central discovers heart rate peripheral while scanning.
|
|
195
|
+
*发现蓝牙设备
|
|
196
|
+
*/
|
|
197
|
+
#pragma mark 发现蓝牙设备
|
|
198
|
+
- (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)aPeripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI {
|
|
199
|
+
|
|
200
|
+
NSArray *serviceUUIDs = [advertisementData objectForKey:CBAdvertisementDataServiceUUIDsKey];
|
|
201
|
+
// NSLog(@"aPeripheral========%@",aPeripheral.identifier.UUIDString);
|
|
202
|
+
// NSLog(@"APeripheralName==========%@",serviceUUIDs);
|
|
203
|
+
// NSLog(@"advertisementData ======= %@",advertisementData);
|
|
204
|
+
// NSLog(@">>> %@",aPeripheral.services);
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
// 针对性的发现设备
|
|
209
|
+
BOOL isExist = NO;
|
|
210
|
+
for (int i = 0; i < serviceUUIDs.count; i++) {
|
|
211
|
+
NSString *uuid = [serviceUUIDs[i] UUIDString];
|
|
212
|
+
if ([uuid isEqualToString:@"18F0"]||[uuid isEqualToString:@"FFF0"]) {//便携打印机为FFF0
|
|
213
|
+
if(![_peripherals containsObject:aPeripheral])
|
|
214
|
+
isExist = YES;
|
|
215
|
+
break;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
// if ([aPeripheral.identifier.UUIDString isEqualToString:@"49535343-FE7D-4AE5-8FA9-9FAFD205E455"]) {//@"49535343-FE7D-4AE5-8FA9-9FAFD205E455"
|
|
219
|
+
// NSLog(@"进入此方法");
|
|
220
|
+
// isExist = YES;
|
|
221
|
+
// }
|
|
222
|
+
if (isExist) {
|
|
223
|
+
|
|
224
|
+
//添加蓝牙对象到peripherals
|
|
225
|
+
[_peripherals addObject:aPeripheral];
|
|
226
|
+
[_RSSIArray addObject:RSSI];
|
|
227
|
+
if ([self.delegate respondsToSelector:@selector(BLEManagerDelegate:updatePeripheralList:RSSIList:)]) {
|
|
228
|
+
[self.delegate BLEManagerDelegate:self updatePeripheralList:_peripherals RSSIList:_RSSIArray];
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
//添加蓝牙对象到peripherals
|
|
234
|
+
|
|
235
|
+
// [_peripherals addObject:aPeripheral];
|
|
236
|
+
// [_RSSIArray addObject:RSSI];
|
|
237
|
+
// if ([self.delegate respondsToSelector:@selector(BLEManagerDelegate:updatePeripheralList:RSSIList:)]) {
|
|
238
|
+
// [self.delegate BLEManagerDelegate:self updatePeripheralList:_peripherals RSSIList:_RSSIArray];
|
|
239
|
+
// }
|
|
240
|
+
// //-------------------------------------------------------
|
|
241
|
+
// //发现所有的设备---打开注释就好
|
|
242
|
+
// [_peripherals addObject:aPeripheral];
|
|
243
|
+
// [_RSSIArray addObject:RSSI];
|
|
244
|
+
//
|
|
245
|
+
// self.scanBlock(_peripherals);
|
|
246
|
+
// [[NSNotificationCenter defaultCenter] postNotificationName:kBlueToothDisCoverPeripheral object:nil];
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/*
|
|
250
|
+
Invoked when the central manager retrieves the list of known peripherals.
|
|
251
|
+
Automatically connect to first known peripheral
|
|
252
|
+
*/
|
|
253
|
+
#pragma mark 当中央管理器调用检索列表中已知的外围设备。自动连接到第一个已知的外围
|
|
254
|
+
- (void)centralManager:(CBCentralManager *)central didRetrievePeripherals:(NSArray *)peripherals {
|
|
255
|
+
//
|
|
256
|
+
// if([_peripherals count] >= 1) {
|
|
257
|
+
// _peripheral = [peripherals objectAtIndex:0];
|
|
258
|
+
//// NSLog(@"当中央管理器调用检索列表中已知的外围设备。自动连接到第一个已知的外围........此设备名为==%@",_peripheral.name);
|
|
259
|
+
// [_manager connectPeripheral:_peripheral options:[NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES] forKey:CBConnectPeripheralOptionNotifyOnDisconnectionKey]];
|
|
260
|
+
// }
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/*
|
|
264
|
+
*Invoked whenever a connection is succesfully created with the peripheral.
|
|
265
|
+
*Discover available services on the peripheral
|
|
266
|
+
*已连接到设备
|
|
267
|
+
*/
|
|
268
|
+
#pragma mark 已连接到设备-----每当调用是成功创建连接外围。外围发现可用的服务
|
|
269
|
+
- (void)centralManager:(CBCentralManager *)central didConnectPeripheral:(CBPeripheral *)aPeripheral {
|
|
270
|
+
NSLog(@"蓝牙连接成功%@",aPeripheral.name);
|
|
271
|
+
[aPeripheral setDelegate:self];
|
|
272
|
+
//查找mac地址
|
|
273
|
+
// [aPeripheral discoverServices:@[[CBUUID UUIDWithString:@"180A"]]];
|
|
274
|
+
[aPeripheral discoverServices:nil];
|
|
275
|
+
_isConnected = YES;
|
|
276
|
+
|
|
277
|
+
if (self.connectBlock) {
|
|
278
|
+
self.connectBlock(YES);
|
|
279
|
+
self.connectBlock = nil;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
/*
|
|
283
|
+
*Invoked whenever an existing connection with the peripheral is torn down.
|
|
284
|
+
*Reset local variables
|
|
285
|
+
*设备已经断开
|
|
286
|
+
*/
|
|
287
|
+
#pragma mark 设备已经断开
|
|
288
|
+
- (void)centralManager:(CBCentralManager *)central didDisconnectPeripheral:(CBPeripheral *)aPeripheral error:(NSError *)error
|
|
289
|
+
{
|
|
290
|
+
if(_peripheral )
|
|
291
|
+
{
|
|
292
|
+
[_peripheral setDelegate:nil];
|
|
293
|
+
_peripheral = nil;
|
|
294
|
+
|
|
295
|
+
}else {
|
|
296
|
+
|
|
297
|
+
}
|
|
298
|
+
_isConnected = NO;
|
|
299
|
+
// if (_isAutoDisconnect == NO) {
|
|
300
|
+
// //断开n秒计时
|
|
301
|
+
//// [self performSelector:@selector(disconnectTimerAction) withObject:nil afterDelay:0.0];
|
|
302
|
+
// } else {
|
|
303
|
+
//// [self connectPeripheral:aPeripheral];
|
|
304
|
+
// [[[UIAlertView alloc] initWithTitle:@"device disconnect" message:nil delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil] show];
|
|
305
|
+
// }
|
|
306
|
+
|
|
307
|
+
if (self.connectBlock) {
|
|
308
|
+
self.connectBlock(NO);
|
|
309
|
+
self.connectBlock = nil;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
if ([self.delegate respondsToSelector:@selector(BLEManagerDelegate:disconnectPeripheral:isAutoDisconnect:)]) {
|
|
313
|
+
[self.delegate BLEManagerDelegate:self disconnectPeripheral:aPeripheral isAutoDisconnect:_isAutoDisconnect];
|
|
314
|
+
}
|
|
315
|
+
_isAutoDisconnect = NO;
|
|
316
|
+
// [[NSNotificationCenter defaultCenter] postNotificationName:kBlueToothDisConnect object:aPeripheral];
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/*
|
|
320
|
+
*Invoked whenever the central manager fails to create a connection with the peripheral.
|
|
321
|
+
*连接设备失败
|
|
322
|
+
*/
|
|
323
|
+
#pragma mark 连接设备失败
|
|
324
|
+
- (void)centralManager:(CBCentralManager *)central didFailToConnectPeripheral:(CBPeripheral *)aPeripheral error:(NSError *)error {
|
|
325
|
+
|
|
326
|
+
NSLog(@"Fail to connect to peripheral: %@ with error = %@", aPeripheral, [error localizedDescription]);
|
|
327
|
+
if(_peripheral) {
|
|
328
|
+
[_peripheral setDelegate:nil];
|
|
329
|
+
_peripheral = nil;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
// -- 可以做其他处理
|
|
333
|
+
if ([self.delegate respondsToSelector:@selector(BLEManagerDelegate:didFailToConnectPeripheral:error:)]) {
|
|
334
|
+
[self.delegate BLEManagerDelegate:self didFailToConnectPeripheral:aPeripheral error:error];
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
#pragma mark -
|
|
339
|
+
#pragma mark -外设 的代理方法
|
|
340
|
+
#pragma mark -
|
|
341
|
+
/*
|
|
342
|
+
*Invoked upon completion of a -[discoverServices:] request.
|
|
343
|
+
*Discover available characteristics on interested services
|
|
344
|
+
*发现服务
|
|
345
|
+
*/
|
|
346
|
+
#pragma mark 发现服务
|
|
347
|
+
- (void) peripheral:(CBPeripheral *)aPeripheral didDiscoverServices:(NSError *)error {
|
|
348
|
+
// CBService *service = aPeripheral.services.firstObject;
|
|
349
|
+
// [aPeripheral discoverCharacteristics:@[[CBUUID UUIDWithString:@"2A23"]] forService:service];
|
|
350
|
+
for (CBService *aService in aPeripheral.services) {
|
|
351
|
+
// NSLog(@"Service found with UUID : %@", aService.UUID);
|
|
352
|
+
[aPeripheral discoverCharacteristics:nil forService:aService];
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
/*
|
|
357
|
+
*Invoked upon completion of a -[discoverCharacteristics:forService:] request.
|
|
358
|
+
*Perform appropriate operations on interested characteristics
|
|
359
|
+
*发现服务特征值
|
|
360
|
+
*/
|
|
361
|
+
#pragma mark 发现服务特征值
|
|
362
|
+
- (void) peripheral:(CBPeripheral *)aPeripheral didDiscoverCharacteristicsForService:(CBService *)service error:(NSError *)error {
|
|
363
|
+
if (error) {
|
|
364
|
+
NSLog(@"Error discovering characteristics: %@", [error localizedDescription]);
|
|
365
|
+
return;
|
|
366
|
+
}
|
|
367
|
+
// NSLog(@"Service : %@", service.UUID);
|
|
368
|
+
// NSLog(@"includedServices :%@",service.includedServices);
|
|
369
|
+
// NSLog(@"characteristics :%@",service.characteristics);
|
|
370
|
+
// if (service.isPrimary) {
|
|
371
|
+
//// NSLog(@"service.isPrimary : %@", service.UUID);
|
|
372
|
+
// }
|
|
373
|
+
|
|
374
|
+
//-------------------------------------------------------
|
|
375
|
+
//此处对服务UUID 进行 一对一 匹配,然后再遍历 其特征值,再对需要用到的特征UUID 进行一对一匹配
|
|
376
|
+
//
|
|
377
|
+
// NSLog(@"%s%@",__func__,service.UUID);
|
|
378
|
+
if ([service.UUID isEqual: [CBUUID UUIDWithString:@"18F0"]]||[service.UUID isEqual: [CBUUID UUIDWithString:@"FFF0"]])//便携打印机使用这个uuid:49535343-FE7D-4AE5-8FA9-9FAFD205E455
|
|
379
|
+
{
|
|
380
|
+
write_characteristic = nil;
|
|
381
|
+
read_characteristic = nil;
|
|
382
|
+
NSLog(@"获取特征值");
|
|
383
|
+
for (CBCharacteristic *aChar in service.characteristics)
|
|
384
|
+
{
|
|
385
|
+
|
|
386
|
+
const CBCharacteristicProperties properties = [aChar properties];
|
|
387
|
+
|
|
388
|
+
// 消息通知类型的特征值
|
|
389
|
+
if (CBCharacteristicPropertyNotify && properties) {
|
|
390
|
+
[aPeripheral setNotifyValue:YES forCharacteristic:aChar];
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
// write 特征值
|
|
394
|
+
if ((CBCharacteristicPropertyWrite && properties) || (CBCharacteristicPropertyWriteWithoutResponse && properties)) {
|
|
395
|
+
write_characteristic = aChar;
|
|
396
|
+
[aPeripheral readValueForCharacteristic:aChar];
|
|
397
|
+
NSLog(@"write Power Characteristic : %@", aChar.UUID);
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
// read 特征值
|
|
401
|
+
if (CBCharacteristicPropertyRead && properties) {
|
|
402
|
+
read_characteristic = aChar;
|
|
403
|
+
// [aPeripheral readValueForCharacteristic:aChar];
|
|
404
|
+
// NSLog(@"read Power Characteristic : %@", aChar.UUID);
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
// NSLog(@"aChar.UUID==:%@",aChar.UUID);
|
|
408
|
+
// if ([aChar.UUID isEqual:[CBUUID UUIDWithString:@"49535343-8841-43F4-A8D4-ECBE34729BB3"]]) {
|
|
409
|
+
// // 匹配成功后:
|
|
410
|
+
// //广播
|
|
411
|
+
// [_peripheral setNotifyValue:YES forCharacteristic:aChar];
|
|
412
|
+
// write_characteristic = aChar;
|
|
413
|
+
// [aPeripheral readValueForCharacteristic:aChar];
|
|
414
|
+
// NSLog(@"Power Characteristic : %@", aChar.UUID);
|
|
415
|
+
// //-------------------------------------------------------
|
|
416
|
+
// //此处可以对特征值进行保存
|
|
417
|
+
// }
|
|
418
|
+
// if ([aChar.UUID isEqual:[CBUUID UUIDWithString:@"49535343-1E4D-4BD9-BA61-23C647249616"]]) {
|
|
419
|
+
// // 匹配成功后:
|
|
420
|
+
// //广播
|
|
421
|
+
// [_peripheral setNotifyValue:YES forCharacteristic:aChar];
|
|
422
|
+
// read_characteristic = aChar;
|
|
423
|
+
// [aPeripheral readValueForCharacteristic:aChar];
|
|
424
|
+
//
|
|
425
|
+
// NSLog(@"Power Characteristic : %@", aChar.UUID);
|
|
426
|
+
// //-------------------------------------------------------
|
|
427
|
+
// //此处可以对特征值进行保存
|
|
428
|
+
// }
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
/**
|
|
435
|
+
* -->描述:获取蓝牙的信号强度
|
|
436
|
+
*/
|
|
437
|
+
#pragma mark 获取蓝牙的信号强度
|
|
438
|
+
- (void)peripheralDidUpdateRSSI:(CBPeripheral *)peripheral error:(NSError *)error {
|
|
439
|
+
// NSLog(@"RSSI:%i", [[peripheral RSSI] intValue]);
|
|
440
|
+
int rssi;
|
|
441
|
+
rssi=[[peripheral RSSI] intValue];
|
|
442
|
+
NSString *fid;
|
|
443
|
+
fid= peripheral.identifier.UUIDString;
|
|
444
|
+
[[NSNotificationCenter defaultCenter] postNotificationName:@"BLE-RSSI-信号强度通知-Name" object:[NSString stringWithFormat:@"%@,%i",fid,rssi]];
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
/*
|
|
448
|
+
*Invoked upon completion of a -[readValueForCharacteristic:] request or on the reception of a notification/indication.
|
|
449
|
+
*收到数据
|
|
450
|
+
*/
|
|
451
|
+
|
|
452
|
+
#pragma mark -收到数据
|
|
453
|
+
- (void) peripheral:(CBPeripheral *)aPeripheral didUpdateValueForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error {
|
|
454
|
+
|
|
455
|
+
if (error) {
|
|
456
|
+
NSLog(@"error = %@",error);
|
|
457
|
+
// [[[UIAlertView alloc] initWithTitle:@"获取数据失败" message:nil delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil] show];
|
|
458
|
+
|
|
459
|
+
}else {
|
|
460
|
+
NSString *value = [NSString stringWithFormat:@"%@",characteristic.value];
|
|
461
|
+
NSMutableString *macString = [[NSMutableString alloc] init];
|
|
462
|
+
[macString appendString:[[value substringWithRange:NSMakeRange(16, 2)] uppercaseString]];
|
|
463
|
+
[macString appendString:@":"];
|
|
464
|
+
[macString appendString:[[value substringWithRange:NSMakeRange(14, 2)] uppercaseString]];
|
|
465
|
+
[macString appendString:@":"];
|
|
466
|
+
[macString appendString:[[value substringWithRange:NSMakeRange(12, 2)] uppercaseString]];
|
|
467
|
+
[macString appendString:@":"];
|
|
468
|
+
[macString appendString:[[value substringWithRange:NSMakeRange(5, 2)] uppercaseString]];
|
|
469
|
+
[macString appendString:@":"];
|
|
470
|
+
[macString appendString:[[value substringWithRange:NSMakeRange(3, 2)] uppercaseString]];
|
|
471
|
+
[macString appendString:@":"];
|
|
472
|
+
[macString appendString:[[value substringWithRange:NSMakeRange(1, 2)] uppercaseString]];
|
|
473
|
+
NSLog(@"mac == %@",macString);
|
|
474
|
+
NSLog(@"didUpdateValue :%@",characteristic.value);
|
|
475
|
+
NSLog(@" ******* didUpdateValue--UUID :%@",characteristic.UUID);
|
|
476
|
+
NSData *data = characteristic.value;
|
|
477
|
+
|
|
478
|
+
if (data == nil || [data isKindOfClass:[NSNull class]] || [data isEqual:@""]) {
|
|
479
|
+
return;
|
|
480
|
+
}
|
|
481
|
+
if (data) {
|
|
482
|
+
|
|
483
|
+
// 收到数据回调
|
|
484
|
+
if (self.receiveBlock!=nil) {
|
|
485
|
+
self.receiveBlock(characteristic);
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
[_dataArray addObject:[NSString stringWithFormat:@"收到:%@",data]];
|
|
489
|
+
}
|
|
490
|
+
if (_dataArray.count > 1000) {
|
|
491
|
+
[_dataArray removeObjectAtIndex:0];
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
|
|
495
|
+
//-------------------------------------------------------
|
|
496
|
+
//对接收到的数据进行处理
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
/*
|
|
502
|
+
*写数据成功
|
|
503
|
+
*/
|
|
504
|
+
#pragma mark 写入数据成功会进入此方法
|
|
505
|
+
- (void)peripheral:(CBPeripheral *)peripheral didWriteValueForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error {
|
|
506
|
+
|
|
507
|
+
if ([self.delegate respondsToSelector:@selector(BLEManagerDelegate:didWriteValueForCharacteristic:error:)]) {
|
|
508
|
+
[self.delegate BLEManagerDelegate:self didWriteValueForCharacteristic:characteristic error:error];
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
if (error)
|
|
512
|
+
{
|
|
513
|
+
NSLog(@"写入数据失败---Failed to write value for characteristic %@, reason: %@", characteristic, error);
|
|
514
|
+
}
|
|
515
|
+
else
|
|
516
|
+
{
|
|
517
|
+
// NSLog(@"写入数据成功---Did write value for characterstic %@, new value: %@", characteristic, [characteristic value]);
|
|
518
|
+
// NSLog(@">>> %@",[[characteristic value] description]);
|
|
519
|
+
// if ([[[characteristic value] description] isEqualToString:@"<440a0101>"]) {
|
|
520
|
+
// [self disconnectPeripheral:_peripheral];
|
|
521
|
+
// }
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
#pragma mark -
|
|
526
|
+
#pragma mark -其他自定义的方法
|
|
527
|
+
#pragma mark -
|
|
528
|
+
|
|
529
|
+
/**
|
|
530
|
+
* 连接超时
|
|
531
|
+
*/
|
|
532
|
+
- (void)connectTimeOutAction {
|
|
533
|
+
if (!self.isConnected) {
|
|
534
|
+
if (self.connectBlock) {
|
|
535
|
+
self.connectBlock(NO);
|
|
536
|
+
self.connectBlock = nil;
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
/*
|
|
542
|
+
*断开计时后确认断开
|
|
543
|
+
*/
|
|
544
|
+
- (void)disconnectTimerAction {
|
|
545
|
+
if (!_isConnected) { //确认是否断开
|
|
546
|
+
NSLog(@"蓝牙已断开连接");
|
|
547
|
+
[[[UIAlertView alloc] initWithTitle:@"device disconnect" message:nil delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil] show];
|
|
548
|
+
|
|
549
|
+
_isAutoDisconnect = NO;
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
#pragma mark 发送数据方法
|
|
554
|
+
-(void)sendDataWithPeripheral:(CBPeripheral *)peripheral withString:(NSString *)dataString coding:(NSStringEncoding)EncodingType
|
|
555
|
+
{
|
|
556
|
+
_writePeripheral = peripheral;
|
|
557
|
+
NSData *data;
|
|
558
|
+
data = [dataString dataUsingEncoding:EncodingType];
|
|
559
|
+
|
|
560
|
+
NSLog(@"%@",[NSString stringWithFormat:@"写入:%@",data]);
|
|
561
|
+
if (commandSendMode==0)
|
|
562
|
+
{
|
|
563
|
+
[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
564
|
+
}
|
|
565
|
+
else
|
|
566
|
+
{
|
|
567
|
+
NSDictionary *dict;
|
|
568
|
+
|
|
569
|
+
dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
570
|
+
[_commandBuffer addObject:dict];
|
|
571
|
+
}
|
|
572
|
+
if (data) {
|
|
573
|
+
[_dataArray addObject:[NSString stringWithFormat:@"写入:%@",data]];
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
//发送指令,推荐使用
|
|
579
|
+
-(void)writeCommadnToPrinterWthitData:(NSData *)data{
|
|
580
|
+
if (commandSendMode==0)
|
|
581
|
+
{
|
|
582
|
+
NSLog(@"writeCommadnToPrinterWthitData");
|
|
583
|
+
NSInteger oneTimeBytes = 20000;
|
|
584
|
+
NSInteger count = [data length] / oneTimeBytes + 1;
|
|
585
|
+
for (int i=0; i<count; i++) {
|
|
586
|
+
if (i<count-1) {
|
|
587
|
+
NSData* data1=[data subdataWithRange:NSMakeRange(i*oneTimeBytes, oneTimeBytes)];
|
|
588
|
+
[_writePeripheral writeValue:data1 forCharacteristic:write_characteristic type:CBCharacteristicWriteWithoutResponse];
|
|
589
|
+
}else{
|
|
590
|
+
NSData* data2=[data subdataWithRange:NSMakeRange(i*oneTimeBytes, [data length]%oneTimeBytes)];
|
|
591
|
+
[_writePeripheral writeValue:data2 forCharacteristic:write_characteristic type:CBCharacteristicWriteWithoutResponse];
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
//// NSLog(@"---->-->---%lu--%@",(unsigned long)[data length],data);
|
|
595
|
+
// //数据分包
|
|
596
|
+
// int BLE_SEND_MAX_LEN=20;
|
|
597
|
+
// NSData *sendData=[NSData data];
|
|
598
|
+
// for (int i=0; i<[data length]; i+=BLE_SEND_MAX_LEN)
|
|
599
|
+
// {
|
|
600
|
+
// if((i+BLE_SEND_MAX_LEN)<[data length]){
|
|
601
|
+
//
|
|
602
|
+
// NSRange range=NSMakeRange(i, BLE_SEND_MAX_LEN);
|
|
603
|
+
// //NSString *rangeStr=[NSString stringWithFormat:@"%i%i",i,i+BLE_SEND_MAX_LEN];
|
|
604
|
+
// NSData *subdata=[data subdataWithRange:range];
|
|
605
|
+
// sendData=subdata;
|
|
606
|
+
//// NSLog(@"---->-->---%i--%@",i,subdata);
|
|
607
|
+
//
|
|
608
|
+
// }else{
|
|
609
|
+
// NSRange range=NSMakeRange(i, (int)([data length]-i));
|
|
610
|
+
// //NSString *rangeStr=[NSString stringWithFormat:@"%i,@%i",i,(int)([data length]-i)];
|
|
611
|
+
// NSData *subdata=[data subdataWithRange:range];
|
|
612
|
+
// sendData=subdata;
|
|
613
|
+
//// NSLog(@"--------ss%@",subdata);
|
|
614
|
+
// }
|
|
615
|
+
//// [_writePeripheral writeValue:sendData forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
616
|
+
// [_writePeripheral writeValue:sendData forCharacteristic:write_characteristic type:CBCharacteristicWriteWithoutResponse];
|
|
617
|
+
//
|
|
618
|
+
// }
|
|
619
|
+
}
|
|
620
|
+
else
|
|
621
|
+
{
|
|
622
|
+
NSDictionary *dict;
|
|
623
|
+
|
|
624
|
+
dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
625
|
+
[_commandBuffer addObject:dict];
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
}
|
|
629
|
+
//带回调的发送指令方法,推荐使用
|
|
630
|
+
-(void)writeCommadnToPrinterWthitData:(NSData *)data withResponse:(BleManagerReceiveCallBack)block{
|
|
631
|
+
self.receiveBlock = block;
|
|
632
|
+
if (commandSendMode==0)
|
|
633
|
+
{
|
|
634
|
+
NSLog(@"writeCommadnToPrinterWthitData");
|
|
635
|
+
NSInteger oneTimeBytes = 10000;
|
|
636
|
+
NSInteger count = [data length] / oneTimeBytes + 1;
|
|
637
|
+
for (int i=0; i<count; i++) {
|
|
638
|
+
if (i<count-1) {
|
|
639
|
+
NSData* data1=[data subdataWithRange:NSMakeRange(i*oneTimeBytes, oneTimeBytes)];
|
|
640
|
+
[_writePeripheral writeValue:data1 forCharacteristic:write_characteristic type:CBCharacteristicWriteWithoutResponse];
|
|
641
|
+
}else{
|
|
642
|
+
NSData* data2=[data subdataWithRange:NSMakeRange(i*oneTimeBytes, [data length]%oneTimeBytes)];
|
|
643
|
+
[_writePeripheral writeValue:data2 forCharacteristic:write_characteristic type:CBCharacteristicWriteWithoutResponse];
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
//// NSLog(@"---->-->---%lu--%@",(unsigned long)[data length],data);
|
|
647
|
+
// //数据分包
|
|
648
|
+
// int BLE_SEND_MAX_LEN=20;
|
|
649
|
+
// NSData *sendData=[NSData data];
|
|
650
|
+
// for (int i=0; i<[data length]; i+=BLE_SEND_MAX_LEN)
|
|
651
|
+
// {
|
|
652
|
+
// if((i+BLE_SEND_MAX_LEN)<[data length]){
|
|
653
|
+
//
|
|
654
|
+
// NSRange range=NSMakeRange(i, BLE_SEND_MAX_LEN);
|
|
655
|
+
// //NSString *rangeStr=[NSString stringWithFormat:@"%i%i",i,i+BLE_SEND_MAX_LEN];
|
|
656
|
+
// NSData *subdata=[data subdataWithRange:range];
|
|
657
|
+
// sendData=subdata;
|
|
658
|
+
//// NSLog(@"---->-->---%i--%@",i,subdata);
|
|
659
|
+
//
|
|
660
|
+
// }else{
|
|
661
|
+
// NSRange range=NSMakeRange(i, (int)([data length]-i));
|
|
662
|
+
// //NSString *rangeStr=[NSString stringWithFormat:@"%i,@%i",i,(int)([data length]-i)];
|
|
663
|
+
// NSData *subdata=[data subdataWithRange:range];
|
|
664
|
+
// sendData=subdata;
|
|
665
|
+
//// NSLog(@"--------ss%@",subdata);
|
|
666
|
+
// }
|
|
667
|
+
//// [_writePeripheral writeValue:sendData forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
668
|
+
// [_writePeripheral writeValue:sendData forCharacteristic:write_characteristic type:CBCharacteristicWriteWithoutResponse];
|
|
669
|
+
//
|
|
670
|
+
// }
|
|
671
|
+
|
|
672
|
+
|
|
673
|
+
}
|
|
674
|
+
else
|
|
675
|
+
{
|
|
676
|
+
NSDictionary *dict;
|
|
677
|
+
|
|
678
|
+
dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
679
|
+
[_commandBuffer addObject:dict];
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
|
|
686
|
+
//#pragma mark - 发送TSC指令
|
|
687
|
+
//- (void)writeTSCCommndWithData:(NSData *)data withResponse:(BleManagerReceiveCallBack)block {
|
|
688
|
+
// self.receiveBlock = block;
|
|
689
|
+
// if (commandSendMode==0)
|
|
690
|
+
// {
|
|
691
|
+
// [_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
692
|
+
// }
|
|
693
|
+
// else
|
|
694
|
+
// {
|
|
695
|
+
// NSDictionary *dict;
|
|
696
|
+
//
|
|
697
|
+
// dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
698
|
+
// [_commandBuffer addObject:dict];
|
|
699
|
+
// }
|
|
700
|
+
//
|
|
701
|
+
// //[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
702
|
+
//}
|
|
703
|
+
//#pragma mark - 发送POS指令
|
|
704
|
+
//- (void)writePOSCommndWithData:(NSData *)data withResponse:(BleManagerReceiveCallBack)block {
|
|
705
|
+
// self.receiveBlock = block;
|
|
706
|
+
// if (commandSendMode==0)
|
|
707
|
+
// {
|
|
708
|
+
// [_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
709
|
+
// }
|
|
710
|
+
// else
|
|
711
|
+
// {
|
|
712
|
+
// NSDictionary *dict;
|
|
713
|
+
// dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
714
|
+
// [_commandBuffer addObject:dict];
|
|
715
|
+
// }
|
|
716
|
+
//
|
|
717
|
+
// //[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
718
|
+
//}
|
|
719
|
+
|
|
720
|
+
|
|
721
|
+
-(void)reScan
|
|
722
|
+
{
|
|
723
|
+
[self stopScan];
|
|
724
|
+
[_peripherals removeAllObjects];
|
|
725
|
+
if (_isConnected) {
|
|
726
|
+
[self disconnectPeripheral:_peripheral];
|
|
727
|
+
}
|
|
728
|
+
else
|
|
729
|
+
{
|
|
730
|
+
// [self startScan];
|
|
731
|
+
[self startScanWithInterval:3 completion: self.scanBlock];
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
-(void)disconnectForReScan
|
|
735
|
+
{
|
|
736
|
+
[self startScan];
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
-(void)disconnectRootPeripheral
|
|
740
|
+
{
|
|
741
|
+
if (![_peripheral isKindOfClass:[CBPeripheral class]]) {
|
|
742
|
+
return;
|
|
743
|
+
}
|
|
744
|
+
[_manager cancelPeripheralConnection:_peripheral];
|
|
745
|
+
_isConnected = NO;
|
|
746
|
+
_isAutoDisconnect = NO;
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
//#pragma mark - ===============打印机基本指令================
|
|
750
|
+
//#pragma mark - 水平定位
|
|
751
|
+
//- (void)horizontalPosition {
|
|
752
|
+
// Byte kValue[1] = {0};
|
|
753
|
+
// kValue[0] = 0x09;
|
|
754
|
+
// NSData *data = [NSData dataWithBytes:&kValue length:sizeof(kValue)];
|
|
755
|
+
// NSLog(@"%@",[NSString stringWithFormat:@"写入:%@",data]);
|
|
756
|
+
// if (commandSendMode==0)
|
|
757
|
+
// {
|
|
758
|
+
// [_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
759
|
+
// }
|
|
760
|
+
// else
|
|
761
|
+
// {
|
|
762
|
+
// NSDictionary *dict;
|
|
763
|
+
// dict=[[NSDictionary alloc]init];
|
|
764
|
+
// dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
765
|
+
// [_commandBuffer addObject:dict];
|
|
766
|
+
// }
|
|
767
|
+
//
|
|
768
|
+
// //[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
769
|
+
//}
|
|
770
|
+
//
|
|
771
|
+
//#pragma mark - 打印并换行
|
|
772
|
+
//- (void)printAndFeed {
|
|
773
|
+
// Byte kValue[1] = {0};
|
|
774
|
+
// kValue[0] = 0x0A;
|
|
775
|
+
//
|
|
776
|
+
// NSData *data = [NSData dataWithBytes:&kValue length:sizeof(kValue)];
|
|
777
|
+
// NSLog(@"%@",[NSString stringWithFormat:@"写入:%@",data]);
|
|
778
|
+
// if (commandSendMode==0)
|
|
779
|
+
// {
|
|
780
|
+
// [_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
781
|
+
// }
|
|
782
|
+
// else
|
|
783
|
+
// {
|
|
784
|
+
// NSDictionary *dict;
|
|
785
|
+
// dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
786
|
+
// [_commandBuffer addObject:dict];
|
|
787
|
+
// }
|
|
788
|
+
//
|
|
789
|
+
// //[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
790
|
+
//}
|
|
791
|
+
//
|
|
792
|
+
//#pragma mark - 打印并回到标准模式
|
|
793
|
+
//- (void)printAndBackToNormalModel {
|
|
794
|
+
// Byte kValue[1] = {0};
|
|
795
|
+
// kValue[0] = 0x0C;
|
|
796
|
+
// NSData *data = [NSData dataWithBytes:&kValue length:sizeof(kValue)];
|
|
797
|
+
// NSLog(@"%@",[NSString stringWithFormat:@"写入:%@",data]);
|
|
798
|
+
// if (commandSendMode==0)
|
|
799
|
+
// {
|
|
800
|
+
// [_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
801
|
+
// }
|
|
802
|
+
// else
|
|
803
|
+
// {
|
|
804
|
+
// NSDictionary *dict;
|
|
805
|
+
// dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
806
|
+
// [_commandBuffer addObject:dict];
|
|
807
|
+
// }
|
|
808
|
+
//
|
|
809
|
+
// //[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
810
|
+
//}
|
|
811
|
+
//#pragma mark - 页模式下取消打印
|
|
812
|
+
//- (void)cancelPrintData {
|
|
813
|
+
// Byte kValue[1] = {0};
|
|
814
|
+
// kValue[0] = 0x18;
|
|
815
|
+
// NSData *data = [NSData dataWithBytes:&kValue length:sizeof(kValue)];
|
|
816
|
+
// NSLog(@"%@",[NSString stringWithFormat:@"写入:%@",data]);
|
|
817
|
+
// if (commandSendMode==0)
|
|
818
|
+
// {
|
|
819
|
+
// [_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
820
|
+
// }
|
|
821
|
+
// else
|
|
822
|
+
// {
|
|
823
|
+
// NSDictionary *dict;
|
|
824
|
+
// dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
825
|
+
// [_commandBuffer addObject:dict];
|
|
826
|
+
// }
|
|
827
|
+
//
|
|
828
|
+
// //[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
829
|
+
//}
|
|
830
|
+
//
|
|
831
|
+
//#pragma mark -实时状态传送
|
|
832
|
+
//- (void)updataPrinterState:(int)n completion:(BleManagerReceiveCallBack)callBlock{
|
|
833
|
+
// self.receiveBlock = callBlock;
|
|
834
|
+
// Byte kValue[3] = {0};
|
|
835
|
+
// kValue[0] = 16;
|
|
836
|
+
// kValue[1] = 4;
|
|
837
|
+
// kValue[2] = n;
|
|
838
|
+
//
|
|
839
|
+
// NSData *data = [NSData dataWithBytes:&kValue length:sizeof(kValue)];
|
|
840
|
+
// NSLog(@"%@",[NSString stringWithFormat:@"写入:%@",data]);
|
|
841
|
+
// if (commandSendMode==0)
|
|
842
|
+
// {
|
|
843
|
+
// [_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
844
|
+
// }
|
|
845
|
+
// else
|
|
846
|
+
// {
|
|
847
|
+
// NSDictionary *dict;
|
|
848
|
+
// dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
849
|
+
// [_commandBuffer addObject:dict];
|
|
850
|
+
// }
|
|
851
|
+
//
|
|
852
|
+
// //[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
853
|
+
//
|
|
854
|
+
//}
|
|
855
|
+
//#pragma mark - 实时对打印机请求
|
|
856
|
+
//- (void)updataPrinterAnswer:(int)n {
|
|
857
|
+
// Byte kValue[3] = {0};
|
|
858
|
+
// kValue[0] = 16;
|
|
859
|
+
// kValue[1] = 5;
|
|
860
|
+
// kValue[2] = n;
|
|
861
|
+
//
|
|
862
|
+
// NSData *data = [NSData dataWithBytes:&kValue length:sizeof(kValue)];
|
|
863
|
+
// NSLog(@"%@",[NSString stringWithFormat:@"写入:%@",data]);
|
|
864
|
+
// if (commandSendMode==0)
|
|
865
|
+
// {
|
|
866
|
+
// [_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
867
|
+
// }
|
|
868
|
+
// else
|
|
869
|
+
// {
|
|
870
|
+
// NSDictionary *dict;
|
|
871
|
+
// dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
872
|
+
// [_commandBuffer addObject:dict];
|
|
873
|
+
// }
|
|
874
|
+
//
|
|
875
|
+
// //[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
876
|
+
//
|
|
877
|
+
//}
|
|
878
|
+
//
|
|
879
|
+
//#pragma mark - 实时产生钱箱开启脉冲
|
|
880
|
+
//- (void)openBoxAndPulse:(int)n m:(int)m t:(int)t {
|
|
881
|
+
// Byte kValue[5] = {0};
|
|
882
|
+
// kValue[0] = 16;
|
|
883
|
+
// kValue[1] = 20;
|
|
884
|
+
// kValue[2] = n;
|
|
885
|
+
// kValue[3] = m;
|
|
886
|
+
// kValue[4] = t;
|
|
887
|
+
//
|
|
888
|
+
// NSData *data = [NSData dataWithBytes:&kValue length:sizeof(kValue)];
|
|
889
|
+
// NSLog(@"%@",[NSString stringWithFormat:@"写入:%@",data]);
|
|
890
|
+
// if (commandSendMode==0)
|
|
891
|
+
// {
|
|
892
|
+
// [_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
893
|
+
// }
|
|
894
|
+
// else
|
|
895
|
+
// {
|
|
896
|
+
// NSDictionary *dict;
|
|
897
|
+
// dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
898
|
+
// [_commandBuffer addObject:dict];
|
|
899
|
+
// }
|
|
900
|
+
//
|
|
901
|
+
// //[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
902
|
+
//}
|
|
903
|
+
//
|
|
904
|
+
//#pragma mark - 页模式下打印
|
|
905
|
+
//- (void)printOnPageModel {
|
|
906
|
+
// Byte kValue[2] = {0};
|
|
907
|
+
// kValue[0] = 0x1B;
|
|
908
|
+
// kValue[1] = 0x0c;
|
|
909
|
+
//
|
|
910
|
+
// NSData *data = [NSData dataWithBytes:&kValue length:sizeof(kValue)];
|
|
911
|
+
// NSLog(@"%@",[NSString stringWithFormat:@"写入:%@",data]);
|
|
912
|
+
// if (commandSendMode==0)
|
|
913
|
+
// {
|
|
914
|
+
// [_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
915
|
+
// }
|
|
916
|
+
// else
|
|
917
|
+
// {
|
|
918
|
+
// NSDictionary *dict;
|
|
919
|
+
// dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
920
|
+
// [_commandBuffer addObject:dict];
|
|
921
|
+
// }
|
|
922
|
+
//
|
|
923
|
+
// //[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
924
|
+
//}
|
|
925
|
+
//
|
|
926
|
+
//#pragma mark - 设置字符右间距
|
|
927
|
+
//- (void)setCharRightMargin:(int)n {
|
|
928
|
+
// Byte kValue[3] = {0};
|
|
929
|
+
// kValue[0] = 27;
|
|
930
|
+
// kValue[1] = 32;
|
|
931
|
+
// kValue[2] = n;
|
|
932
|
+
//
|
|
933
|
+
// NSData *data = [NSData dataWithBytes:&kValue length:sizeof(kValue)];
|
|
934
|
+
// NSLog(@"%@",[NSString stringWithFormat:@"写入:%@",data]);
|
|
935
|
+
// if (commandSendMode==0)
|
|
936
|
+
// {
|
|
937
|
+
// [_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
938
|
+
// }
|
|
939
|
+
// else
|
|
940
|
+
// {
|
|
941
|
+
// NSDictionary *dict;
|
|
942
|
+
// dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
943
|
+
// [_commandBuffer addObject:dict];
|
|
944
|
+
// }
|
|
945
|
+
//
|
|
946
|
+
// //[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
947
|
+
//}
|
|
948
|
+
//
|
|
949
|
+
//#pragma mark - 选择打印模式
|
|
950
|
+
//- (void)selectPrintModel:(int)n {
|
|
951
|
+
// Byte kValue[3] = {0};
|
|
952
|
+
// kValue[0] = 27;
|
|
953
|
+
// kValue[1] = 33;
|
|
954
|
+
// kValue[2] = n;
|
|
955
|
+
//
|
|
956
|
+
// NSData *data = [NSData dataWithBytes:&kValue length:sizeof(kValue)];
|
|
957
|
+
// NSLog(@"%@",[NSString stringWithFormat:@"写入:%@",data]);
|
|
958
|
+
// if (commandSendMode==0)
|
|
959
|
+
// {
|
|
960
|
+
// [_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
961
|
+
// }
|
|
962
|
+
// else
|
|
963
|
+
// {
|
|
964
|
+
// NSDictionary *dict;
|
|
965
|
+
// dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
966
|
+
// [_commandBuffer addObject:dict];
|
|
967
|
+
// }
|
|
968
|
+
//
|
|
969
|
+
// //[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
970
|
+
//}
|
|
971
|
+
//
|
|
972
|
+
//#pragma mark - 设置打印绝对位置
|
|
973
|
+
//- (void)setPrintLocationWithParam:(int)nL nH:(int)nH{
|
|
974
|
+
//
|
|
975
|
+
// Byte kValue[4] = {0};
|
|
976
|
+
// kValue[0] = 27;
|
|
977
|
+
// kValue[1] = 36;
|
|
978
|
+
// kValue[2] = nL;
|
|
979
|
+
// kValue[3] = nH;
|
|
980
|
+
//
|
|
981
|
+
// NSData *data = [NSData dataWithBytes:&kValue length:sizeof(kValue)];
|
|
982
|
+
// NSLog(@"%@",[NSString stringWithFormat:@"写入:%@",data]);
|
|
983
|
+
// if (commandSendMode==0)
|
|
984
|
+
// {
|
|
985
|
+
// [_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
986
|
+
// }
|
|
987
|
+
// else
|
|
988
|
+
// {
|
|
989
|
+
// NSDictionary *dict;
|
|
990
|
+
// dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
991
|
+
// [_commandBuffer addObject:dict];
|
|
992
|
+
// }
|
|
993
|
+
//
|
|
994
|
+
// //[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
995
|
+
//}
|
|
996
|
+
//
|
|
997
|
+
//#pragma mark - 12.选择/取消用户自定义字符
|
|
998
|
+
//- (void)selectOrCancelCustomCharacter:(int)n {
|
|
999
|
+
// Byte kValue[3] = {0};
|
|
1000
|
+
// kValue[0] = 27;
|
|
1001
|
+
// kValue[1] = 37;
|
|
1002
|
+
// kValue[2] = n;
|
|
1003
|
+
//
|
|
1004
|
+
// NSData *data = [NSData dataWithBytes:&kValue length:sizeof(kValue)];
|
|
1005
|
+
// NSLog(@"%@",[NSString stringWithFormat:@"写入:%@",data]);
|
|
1006
|
+
// if (commandSendMode==0)
|
|
1007
|
+
// {
|
|
1008
|
+
// [_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1009
|
+
// }
|
|
1010
|
+
// else
|
|
1011
|
+
// {
|
|
1012
|
+
// NSDictionary *dict;
|
|
1013
|
+
// dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
1014
|
+
// [_commandBuffer addObject:dict];
|
|
1015
|
+
// }
|
|
1016
|
+
//
|
|
1017
|
+
// //[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1018
|
+
//}
|
|
1019
|
+
//
|
|
1020
|
+
//
|
|
1021
|
+
///**
|
|
1022
|
+
// * 13.定义用户自定义字符
|
|
1023
|
+
// */
|
|
1024
|
+
//- (void)definCustomCharacter:(int)y c1:(int)c1 c2:(int)c2 dx:(NSArray *)points
|
|
1025
|
+
//{
|
|
1026
|
+
// int length = 5 + points.count;
|
|
1027
|
+
//
|
|
1028
|
+
// Byte kValue[length];
|
|
1029
|
+
// kValue[0] = 27;
|
|
1030
|
+
// kValue[1] = 38;
|
|
1031
|
+
// kValue[2] = y;
|
|
1032
|
+
// kValue[3] = c1;
|
|
1033
|
+
// kValue[4] = c2;
|
|
1034
|
+
//
|
|
1035
|
+
// for (int i = 0; i<points.count; i++) {
|
|
1036
|
+
// NSString *str = points[i];
|
|
1037
|
+
// kValue[5+i] = str.intValue;
|
|
1038
|
+
// }
|
|
1039
|
+
//
|
|
1040
|
+
// NSData *data = [NSData dataWithBytes:&kValue length:sizeof(kValue)];
|
|
1041
|
+
// NSLog(@"%@",[NSString stringWithFormat:@"写入:%@",data]);
|
|
1042
|
+
// if (commandSendMode==0)
|
|
1043
|
+
// {
|
|
1044
|
+
// [_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1045
|
+
// }
|
|
1046
|
+
// else
|
|
1047
|
+
// {
|
|
1048
|
+
// NSDictionary *dict;
|
|
1049
|
+
// dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
1050
|
+
// [_commandBuffer addObject:dict];
|
|
1051
|
+
// }
|
|
1052
|
+
//
|
|
1053
|
+
// //[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1054
|
+
//}
|
|
1055
|
+
//
|
|
1056
|
+
///**
|
|
1057
|
+
// * 14.选择位图模式
|
|
1058
|
+
// */
|
|
1059
|
+
//- (void)selectBitmapModel:(int)m nL:(int)nL nH:(int)nH dx:(NSArray *)points
|
|
1060
|
+
//{ int length = 5 + points.count;
|
|
1061
|
+
// Byte kValue[length];
|
|
1062
|
+
// kValue[0] = 27;
|
|
1063
|
+
// kValue[1] = 42;
|
|
1064
|
+
// kValue[2] = m;
|
|
1065
|
+
// kValue[3] = nL;
|
|
1066
|
+
// kValue[4] = nH;
|
|
1067
|
+
//
|
|
1068
|
+
// for (int i = 0; i<points.count; i++) {
|
|
1069
|
+
// NSString *va = points[i];
|
|
1070
|
+
// kValue[5+i] = va.intValue;
|
|
1071
|
+
// }
|
|
1072
|
+
//
|
|
1073
|
+
// NSData *data = [NSData dataWithBytes:&kValue length:sizeof(kValue)];
|
|
1074
|
+
// NSLog(@"%@",[NSString stringWithFormat:@"写入:%@",data]);
|
|
1075
|
+
// if (commandSendMode==0)
|
|
1076
|
+
// {
|
|
1077
|
+
// [_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1078
|
+
// }
|
|
1079
|
+
// else
|
|
1080
|
+
// {
|
|
1081
|
+
// NSDictionary *dict;
|
|
1082
|
+
// dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
1083
|
+
// [_commandBuffer addObject:dict];
|
|
1084
|
+
// }
|
|
1085
|
+
//
|
|
1086
|
+
// //[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1087
|
+
//
|
|
1088
|
+
//}
|
|
1089
|
+
//
|
|
1090
|
+
///**
|
|
1091
|
+
// * 15.取消下划线模式
|
|
1092
|
+
// */
|
|
1093
|
+
//- (void)cancelUnderLineModel:(int)n {
|
|
1094
|
+
// Byte kValue[3] = {0};
|
|
1095
|
+
// kValue[0] = 27;
|
|
1096
|
+
// kValue[1] = 45;
|
|
1097
|
+
// kValue[2] = n;
|
|
1098
|
+
//
|
|
1099
|
+
// NSData *data = [NSData dataWithBytes:&kValue length:sizeof(kValue)];
|
|
1100
|
+
// NSLog(@"%@",[NSString stringWithFormat:@"写入:%@",data]);
|
|
1101
|
+
// if (commandSendMode==0)
|
|
1102
|
+
// {
|
|
1103
|
+
// [_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1104
|
+
// }
|
|
1105
|
+
// else
|
|
1106
|
+
// {
|
|
1107
|
+
// NSDictionary *dict;
|
|
1108
|
+
// dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
1109
|
+
// [_commandBuffer addObject:dict];
|
|
1110
|
+
// }
|
|
1111
|
+
//
|
|
1112
|
+
// //[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1113
|
+
//}
|
|
1114
|
+
///**
|
|
1115
|
+
// * 16.设置默认行间距
|
|
1116
|
+
// */
|
|
1117
|
+
//- (void)setDefaultLineMargin {
|
|
1118
|
+
// Byte kValue[2] = {0};
|
|
1119
|
+
// kValue[0] = 27;
|
|
1120
|
+
// kValue[1] = 50;
|
|
1121
|
+
//
|
|
1122
|
+
// NSData *data = [NSData dataWithBytes:&kValue length:sizeof(kValue)];
|
|
1123
|
+
// NSLog(@"%@",[NSString stringWithFormat:@"写入:%@",data]);
|
|
1124
|
+
// if (commandSendMode==0)
|
|
1125
|
+
// {
|
|
1126
|
+
// [_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1127
|
+
// }
|
|
1128
|
+
// else
|
|
1129
|
+
// {
|
|
1130
|
+
// NSDictionary *dict;
|
|
1131
|
+
// dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
1132
|
+
// [_commandBuffer addObject:dict];
|
|
1133
|
+
// }
|
|
1134
|
+
//
|
|
1135
|
+
// //[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1136
|
+
//}
|
|
1137
|
+
//
|
|
1138
|
+
///**
|
|
1139
|
+
// * 17.设置行间距
|
|
1140
|
+
// */
|
|
1141
|
+
//- (void)setLineMargin:(int)n {
|
|
1142
|
+
// Byte kValue[3] = {0};
|
|
1143
|
+
// kValue[0] = 27;
|
|
1144
|
+
// kValue[1] = 51;
|
|
1145
|
+
// kValue[2] = n;
|
|
1146
|
+
//
|
|
1147
|
+
// NSData *data = [NSData dataWithBytes:&kValue length:sizeof(kValue)];
|
|
1148
|
+
// NSLog(@"%@",[NSString stringWithFormat:@"写入:%@",data]);
|
|
1149
|
+
// if (commandSendMode==0)
|
|
1150
|
+
// {
|
|
1151
|
+
// [_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1152
|
+
// }
|
|
1153
|
+
// else
|
|
1154
|
+
// {
|
|
1155
|
+
// NSDictionary *dict;
|
|
1156
|
+
// dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
1157
|
+
// [_commandBuffer addObject:dict];
|
|
1158
|
+
// }
|
|
1159
|
+
//
|
|
1160
|
+
// //[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1161
|
+
//}
|
|
1162
|
+
//
|
|
1163
|
+
///**
|
|
1164
|
+
// * 18.选择打印机
|
|
1165
|
+
// */
|
|
1166
|
+
//- (void)selectPrinter:(int)n {
|
|
1167
|
+
// Byte kValue[3] = {0};
|
|
1168
|
+
// kValue[0] = 27;
|
|
1169
|
+
// kValue[1] = 61;
|
|
1170
|
+
// kValue[2] = n;
|
|
1171
|
+
//
|
|
1172
|
+
// NSData *data = [NSData dataWithBytes:&kValue length:sizeof(kValue)];
|
|
1173
|
+
// NSLog(@"%@",[NSString stringWithFormat:@"写入:%@",data]);
|
|
1174
|
+
// if (commandSendMode==0)
|
|
1175
|
+
// {
|
|
1176
|
+
// [_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1177
|
+
// }
|
|
1178
|
+
// else
|
|
1179
|
+
// {
|
|
1180
|
+
// NSDictionary *dict;
|
|
1181
|
+
// dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
1182
|
+
// [_commandBuffer addObject:dict];
|
|
1183
|
+
// }
|
|
1184
|
+
//
|
|
1185
|
+
// //[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1186
|
+
//}
|
|
1187
|
+
///**
|
|
1188
|
+
// * 19.取消用户自定义字符
|
|
1189
|
+
// */
|
|
1190
|
+
//- (void)cancelCustomCharacter:(int)n {
|
|
1191
|
+
// Byte kValue[3] = {0};
|
|
1192
|
+
// kValue[0] = 27;
|
|
1193
|
+
// kValue[1] = 63;
|
|
1194
|
+
// kValue[2] = n;
|
|
1195
|
+
//
|
|
1196
|
+
// NSData *data = [NSData dataWithBytes:&kValue length:sizeof(kValue)];
|
|
1197
|
+
// NSLog(@"%@",[NSString stringWithFormat:@"写入:%@",data]);
|
|
1198
|
+
// if (commandSendMode==0)
|
|
1199
|
+
// {
|
|
1200
|
+
// [_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1201
|
+
// }
|
|
1202
|
+
// else
|
|
1203
|
+
// {
|
|
1204
|
+
// NSDictionary *dict;
|
|
1205
|
+
// dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
1206
|
+
// [_commandBuffer addObject:dict];
|
|
1207
|
+
// }
|
|
1208
|
+
//
|
|
1209
|
+
// //[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1210
|
+
//}
|
|
1211
|
+
//
|
|
1212
|
+
///**
|
|
1213
|
+
// * 20.初始化打印机
|
|
1214
|
+
// */
|
|
1215
|
+
//- (void)initializePrinter {
|
|
1216
|
+
// Byte kValue[2] = {0};
|
|
1217
|
+
// kValue[0] = 27;
|
|
1218
|
+
// kValue[1] = 64;
|
|
1219
|
+
//
|
|
1220
|
+
// NSData *data = [NSData dataWithBytes:&kValue length:sizeof(kValue)];
|
|
1221
|
+
// NSLog(@"%@",[NSString stringWithFormat:@"写入:%@",data]);
|
|
1222
|
+
// if (commandSendMode==0)
|
|
1223
|
+
// {
|
|
1224
|
+
// [_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1225
|
+
// }
|
|
1226
|
+
// else
|
|
1227
|
+
// {
|
|
1228
|
+
// NSDictionary *dict;
|
|
1229
|
+
// dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
1230
|
+
// [_commandBuffer addObject:dict];
|
|
1231
|
+
// }
|
|
1232
|
+
//
|
|
1233
|
+
// //[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1234
|
+
//}
|
|
1235
|
+
///**
|
|
1236
|
+
// * 21.设置横向跳格位置
|
|
1237
|
+
// */
|
|
1238
|
+
//- (void)setTabLocationWith:(NSArray *)points {
|
|
1239
|
+
//
|
|
1240
|
+
// Byte kValue[3 + points.count];
|
|
1241
|
+
// kValue[0] = 27;
|
|
1242
|
+
// kValue[1] = 68;
|
|
1243
|
+
//
|
|
1244
|
+
// for (int i = 0; i<points.count; i++) {
|
|
1245
|
+
// NSString *str = points[i];
|
|
1246
|
+
// kValue[2+i] = str.intValue;
|
|
1247
|
+
// if (i == points.count-1) {
|
|
1248
|
+
// kValue[3+i] = 0;
|
|
1249
|
+
// }
|
|
1250
|
+
// }
|
|
1251
|
+
//
|
|
1252
|
+
// NSData *data = [NSData dataWithBytes:&kValue length:sizeof(kValue)];
|
|
1253
|
+
// NSLog(@"%@",[NSString stringWithFormat:@"写入:%@",data]);
|
|
1254
|
+
// if (commandSendMode==0)
|
|
1255
|
+
// {
|
|
1256
|
+
// [_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1257
|
+
// }
|
|
1258
|
+
// else
|
|
1259
|
+
// {
|
|
1260
|
+
// NSDictionary *dict;
|
|
1261
|
+
// dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
1262
|
+
// [_commandBuffer addObject:dict];
|
|
1263
|
+
// }
|
|
1264
|
+
//
|
|
1265
|
+
// //[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1266
|
+
//}
|
|
1267
|
+
///**
|
|
1268
|
+
// * 22.选择/取消加粗模式
|
|
1269
|
+
// */
|
|
1270
|
+
//- (void)selectOrCancelBoldModel:(int)n {
|
|
1271
|
+
// Byte kValue[3] = {0};
|
|
1272
|
+
// kValue[0] = 27;
|
|
1273
|
+
// kValue[1] = 69;
|
|
1274
|
+
// kValue[2] = n;
|
|
1275
|
+
//
|
|
1276
|
+
// NSData *data = [NSData dataWithBytes:&kValue length:sizeof(kValue)];
|
|
1277
|
+
// NSLog(@"%@",[NSString stringWithFormat:@"写入:%@",data]);
|
|
1278
|
+
// if (commandSendMode==0)
|
|
1279
|
+
// {
|
|
1280
|
+
// [_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1281
|
+
// }
|
|
1282
|
+
// else
|
|
1283
|
+
// {
|
|
1284
|
+
// NSDictionary *dict;
|
|
1285
|
+
// dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
1286
|
+
// [_commandBuffer addObject:dict];
|
|
1287
|
+
// }
|
|
1288
|
+
//
|
|
1289
|
+
// //[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1290
|
+
//}
|
|
1291
|
+
///**
|
|
1292
|
+
// * 23.选择/取消双重打印模式
|
|
1293
|
+
// */
|
|
1294
|
+
//- (void)selectOrCancelDoublePrintModel:(int)n {
|
|
1295
|
+
// Byte kValue[3] = {0};
|
|
1296
|
+
// kValue[0] = 27;
|
|
1297
|
+
// kValue[1] = 71;
|
|
1298
|
+
// kValue[2] = n;
|
|
1299
|
+
//
|
|
1300
|
+
// NSData *data = [NSData dataWithBytes:&kValue length:sizeof(kValue)];
|
|
1301
|
+
// NSLog(@"%@",[NSString stringWithFormat:@"写入:%@",data]);
|
|
1302
|
+
// if (commandSendMode==0)
|
|
1303
|
+
// {
|
|
1304
|
+
// [_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1305
|
+
// }
|
|
1306
|
+
// else
|
|
1307
|
+
// {
|
|
1308
|
+
// NSDictionary *dict;
|
|
1309
|
+
// dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
1310
|
+
// [_commandBuffer addObject:dict];
|
|
1311
|
+
// }
|
|
1312
|
+
//
|
|
1313
|
+
// //[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1314
|
+
//}
|
|
1315
|
+
///**
|
|
1316
|
+
// * 24.打印并走纸
|
|
1317
|
+
// */
|
|
1318
|
+
//- (void)printAndPushPage:(int)n {
|
|
1319
|
+
// Byte kValue[3] = {0};
|
|
1320
|
+
// kValue[0] = 27;
|
|
1321
|
+
// kValue[1] = 74;
|
|
1322
|
+
// kValue[2] = n;
|
|
1323
|
+
//
|
|
1324
|
+
// NSData *data = [NSData dataWithBytes:&kValue length:sizeof(kValue)];
|
|
1325
|
+
// NSLog(@"%@",[NSString stringWithFormat:@"写入:%@",data]);
|
|
1326
|
+
// if (commandSendMode==0)
|
|
1327
|
+
// {
|
|
1328
|
+
// [_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1329
|
+
// }
|
|
1330
|
+
// else
|
|
1331
|
+
// {
|
|
1332
|
+
// NSDictionary *dict;
|
|
1333
|
+
// dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
1334
|
+
// [_commandBuffer addObject:dict];
|
|
1335
|
+
// }
|
|
1336
|
+
//
|
|
1337
|
+
// //[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1338
|
+
//}
|
|
1339
|
+
///**
|
|
1340
|
+
// * 25.选择页模式
|
|
1341
|
+
// */
|
|
1342
|
+
//- (void)selectPageModel {
|
|
1343
|
+
// Byte kValue[2] = {0};
|
|
1344
|
+
// kValue[0] = 27;
|
|
1345
|
+
// kValue[1] = 76;
|
|
1346
|
+
//
|
|
1347
|
+
// NSData *data = [NSData dataWithBytes:&kValue length:sizeof(kValue)];
|
|
1348
|
+
// NSLog(@"%@",[NSString stringWithFormat:@"写入:%@",data]);
|
|
1349
|
+
// if (commandSendMode==0)
|
|
1350
|
+
// {
|
|
1351
|
+
// [_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1352
|
+
// }
|
|
1353
|
+
// else
|
|
1354
|
+
// {
|
|
1355
|
+
// NSDictionary *dict;
|
|
1356
|
+
// dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
1357
|
+
// [_commandBuffer addObject:dict];
|
|
1358
|
+
// }
|
|
1359
|
+
//
|
|
1360
|
+
// //[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1361
|
+
//}
|
|
1362
|
+
///**
|
|
1363
|
+
// * 26.选择字体
|
|
1364
|
+
// */
|
|
1365
|
+
//- (void)selectFont:(int)n {
|
|
1366
|
+
// Byte kValue[3] = {0};
|
|
1367
|
+
// kValue[0] = 27;
|
|
1368
|
+
// kValue[1] = 77;
|
|
1369
|
+
// kValue[2] = n;
|
|
1370
|
+
//
|
|
1371
|
+
// NSData *data = [NSData dataWithBytes:&kValue length:sizeof(kValue)];
|
|
1372
|
+
// NSLog(@"%@",[NSString stringWithFormat:@"写入:%@",data]);
|
|
1373
|
+
// if (commandSendMode==0)
|
|
1374
|
+
// {
|
|
1375
|
+
// [_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1376
|
+
// }
|
|
1377
|
+
// else
|
|
1378
|
+
// {
|
|
1379
|
+
// NSDictionary *dict;
|
|
1380
|
+
// dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
1381
|
+
// [_commandBuffer addObject:dict];
|
|
1382
|
+
// }
|
|
1383
|
+
//
|
|
1384
|
+
// //[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1385
|
+
//}
|
|
1386
|
+
///**
|
|
1387
|
+
// * 27.选择国际字符集
|
|
1388
|
+
// */
|
|
1389
|
+
//- (void)selectINTL_CHAR_SETWith:(int)n {
|
|
1390
|
+
// Byte kValue[3] = {0};
|
|
1391
|
+
// kValue[0] = 27;
|
|
1392
|
+
// kValue[1] = 82;
|
|
1393
|
+
// kValue[2] = n;
|
|
1394
|
+
//
|
|
1395
|
+
// NSData *data = [NSData dataWithBytes:&kValue length:sizeof(kValue)];
|
|
1396
|
+
// NSLog(@"%@",[NSString stringWithFormat:@"写入:%@",data]);
|
|
1397
|
+
// if (commandSendMode==0)
|
|
1398
|
+
// {
|
|
1399
|
+
// [_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1400
|
+
// }
|
|
1401
|
+
// else
|
|
1402
|
+
// {
|
|
1403
|
+
// NSDictionary *dict;
|
|
1404
|
+
// dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
1405
|
+
// [_commandBuffer addObject:dict];
|
|
1406
|
+
// }
|
|
1407
|
+
//
|
|
1408
|
+
// //[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1409
|
+
//}
|
|
1410
|
+
///**
|
|
1411
|
+
// * 28.选择标准模式
|
|
1412
|
+
// */
|
|
1413
|
+
//- (void)selectNormalModel {
|
|
1414
|
+
// Byte kValue[2] = {0};
|
|
1415
|
+
// kValue[0] = 27;
|
|
1416
|
+
// kValue[1] = 83;
|
|
1417
|
+
//
|
|
1418
|
+
// NSData *data = [NSData dataWithBytes:&kValue length:sizeof(kValue)];
|
|
1419
|
+
// NSLog(@"%@",[NSString stringWithFormat:@"写入:%@",data]);
|
|
1420
|
+
// if (commandSendMode==0)
|
|
1421
|
+
// {
|
|
1422
|
+
// [_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1423
|
+
// }
|
|
1424
|
+
// else
|
|
1425
|
+
// {
|
|
1426
|
+
// NSDictionary *dict;
|
|
1427
|
+
// dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
1428
|
+
// [_commandBuffer addObject:dict];
|
|
1429
|
+
// }
|
|
1430
|
+
//
|
|
1431
|
+
// //[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1432
|
+
//}
|
|
1433
|
+
///**
|
|
1434
|
+
// * 29.在页模式下选择打印区域方向
|
|
1435
|
+
// */
|
|
1436
|
+
//- (void)selectPrintDirectionOnPageModel:(int)n {
|
|
1437
|
+
// Byte kValue[3] = {0};
|
|
1438
|
+
// kValue[0] = 27;
|
|
1439
|
+
// kValue[1] = 84;
|
|
1440
|
+
// kValue[2] = n;
|
|
1441
|
+
//
|
|
1442
|
+
// NSData *data = [NSData dataWithBytes:&kValue length:sizeof(kValue)];
|
|
1443
|
+
// NSLog(@"%@",[NSString stringWithFormat:@"写入:%@",data]);
|
|
1444
|
+
// if (commandSendMode==0)
|
|
1445
|
+
// {
|
|
1446
|
+
// [_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1447
|
+
// }
|
|
1448
|
+
// else
|
|
1449
|
+
// {
|
|
1450
|
+
// NSDictionary *dict;
|
|
1451
|
+
// dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
1452
|
+
// [_commandBuffer addObject:dict];
|
|
1453
|
+
// }
|
|
1454
|
+
//
|
|
1455
|
+
// //[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1456
|
+
//}
|
|
1457
|
+
///**
|
|
1458
|
+
// * 30.选择/取消顺时针旋转90度
|
|
1459
|
+
// */
|
|
1460
|
+
//- (void)selectOrCancelRotationClockwise:(int)n {
|
|
1461
|
+
// Byte kValue[3] = {0};
|
|
1462
|
+
// kValue[0] = 27;
|
|
1463
|
+
// kValue[1] = 86;
|
|
1464
|
+
// kValue[2] = n;
|
|
1465
|
+
//
|
|
1466
|
+
// NSData *data = [NSData dataWithBytes:&kValue length:sizeof(kValue)];
|
|
1467
|
+
// NSLog(@"%@",[NSString stringWithFormat:@"写入:%@",data]);
|
|
1468
|
+
// if (commandSendMode==0)
|
|
1469
|
+
// {
|
|
1470
|
+
// [_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1471
|
+
// }
|
|
1472
|
+
// else
|
|
1473
|
+
// {
|
|
1474
|
+
// NSDictionary *dict;
|
|
1475
|
+
// dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
1476
|
+
// [_commandBuffer addObject:dict];
|
|
1477
|
+
// }
|
|
1478
|
+
//
|
|
1479
|
+
// //[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1480
|
+
//}
|
|
1481
|
+
//
|
|
1482
|
+
///**
|
|
1483
|
+
// * 31.页模式下设置打印区域
|
|
1484
|
+
// */
|
|
1485
|
+
//- (void)setprintLocationOnPageModelWithXL:(int)xL
|
|
1486
|
+
// xH:(int)xH
|
|
1487
|
+
// yL:(int)yL
|
|
1488
|
+
// yH:(int)yH
|
|
1489
|
+
// dxL:(int)dxL
|
|
1490
|
+
// dxH:(int)dxH
|
|
1491
|
+
// dyL:(int)dyL
|
|
1492
|
+
// dyH:(int)dyH
|
|
1493
|
+
//{
|
|
1494
|
+
// Byte kValue[10];
|
|
1495
|
+
// kValue[0] = 27;
|
|
1496
|
+
// kValue[1] = 87;
|
|
1497
|
+
// kValue[2] = xL;
|
|
1498
|
+
// kValue[3] = xH;
|
|
1499
|
+
// kValue[4] = yL;
|
|
1500
|
+
// kValue[5] = yH;
|
|
1501
|
+
// kValue[6] = dxL;
|
|
1502
|
+
// kValue[7] = dxH;
|
|
1503
|
+
// kValue[8] = dyL;
|
|
1504
|
+
// kValue[9] = dyH;
|
|
1505
|
+
//
|
|
1506
|
+
// NSData *data = [NSData dataWithBytes:&kValue length:sizeof(kValue)];
|
|
1507
|
+
// NSLog(@"%@",[NSString stringWithFormat:@"写入:%@",data]);
|
|
1508
|
+
// if (commandSendMode==0)
|
|
1509
|
+
// {
|
|
1510
|
+
// [_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1511
|
+
// }
|
|
1512
|
+
// else
|
|
1513
|
+
// {
|
|
1514
|
+
// NSDictionary *dict;
|
|
1515
|
+
// dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
1516
|
+
// [_commandBuffer addObject:dict];
|
|
1517
|
+
// }
|
|
1518
|
+
//
|
|
1519
|
+
// //[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1520
|
+
//}
|
|
1521
|
+
//
|
|
1522
|
+
///**
|
|
1523
|
+
// * 32.设置横向打印位置
|
|
1524
|
+
// */
|
|
1525
|
+
//- (void)setHorizonLocationWith:(int)nL nH:(int)nH {
|
|
1526
|
+
// Byte kValue[4] = {0};
|
|
1527
|
+
// kValue[0] = 27;
|
|
1528
|
+
// kValue[1] = 92;
|
|
1529
|
+
// kValue[2] = nL;
|
|
1530
|
+
// kValue[3] = nH;
|
|
1531
|
+
//
|
|
1532
|
+
// NSData *data = [NSData dataWithBytes:&kValue length:sizeof(kValue)];
|
|
1533
|
+
// NSLog(@"%@",[NSString stringWithFormat:@"写入:%@",data]);
|
|
1534
|
+
// if (commandSendMode==0)
|
|
1535
|
+
// {
|
|
1536
|
+
// [_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1537
|
+
// }
|
|
1538
|
+
// else
|
|
1539
|
+
// {
|
|
1540
|
+
// NSDictionary *dict;
|
|
1541
|
+
// dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
1542
|
+
// [_commandBuffer addObject:dict];
|
|
1543
|
+
// }
|
|
1544
|
+
//
|
|
1545
|
+
// //[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1546
|
+
//}
|
|
1547
|
+
//
|
|
1548
|
+
///**
|
|
1549
|
+
// * 33.选择对齐方式
|
|
1550
|
+
// */
|
|
1551
|
+
//- (void)selectAlignmentWithN:(int)n {
|
|
1552
|
+
// Byte kValue[3] = {0};
|
|
1553
|
+
// kValue[0] = 27;
|
|
1554
|
+
// kValue[1] = 97;
|
|
1555
|
+
// kValue[2] = n;
|
|
1556
|
+
//
|
|
1557
|
+
// NSData *data = [NSData dataWithBytes:&kValue length:sizeof(kValue)];
|
|
1558
|
+
// NSLog(@"%@",[NSString stringWithFormat:@"写入:%@",data]);
|
|
1559
|
+
// if (commandSendMode==0)
|
|
1560
|
+
// {
|
|
1561
|
+
// [_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1562
|
+
// }
|
|
1563
|
+
// else
|
|
1564
|
+
// {
|
|
1565
|
+
// NSDictionary *dict;
|
|
1566
|
+
// dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
1567
|
+
// [_commandBuffer addObject:dict];
|
|
1568
|
+
// }
|
|
1569
|
+
//
|
|
1570
|
+
// //[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1571
|
+
//}
|
|
1572
|
+
///**
|
|
1573
|
+
// * 34.选择打印纸传感器以输出信号
|
|
1574
|
+
// */
|
|
1575
|
+
//- (void)selectSensorForOutputSignal:(int)n {
|
|
1576
|
+
// Byte kValue[4] = {0};
|
|
1577
|
+
// kValue[0] = 27;
|
|
1578
|
+
// kValue[1] = 99;
|
|
1579
|
+
// kValue[2] = 51;
|
|
1580
|
+
// kValue[3] = n;
|
|
1581
|
+
//
|
|
1582
|
+
// NSData *data = [NSData dataWithBytes:&kValue length:sizeof(kValue)];
|
|
1583
|
+
// NSLog(@"%@",[NSString stringWithFormat:@"写入:%@",data]);
|
|
1584
|
+
// if (commandSendMode==0)
|
|
1585
|
+
// {
|
|
1586
|
+
// [_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1587
|
+
// }
|
|
1588
|
+
// else
|
|
1589
|
+
// {
|
|
1590
|
+
// NSDictionary *dict;
|
|
1591
|
+
// dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
1592
|
+
// [_commandBuffer addObject:dict];
|
|
1593
|
+
// }
|
|
1594
|
+
//
|
|
1595
|
+
// //[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1596
|
+
//}
|
|
1597
|
+
//
|
|
1598
|
+
///**
|
|
1599
|
+
// * 35.选择打印纸传感器以停止打印
|
|
1600
|
+
// */
|
|
1601
|
+
//- (void)selectSensorForStopPrint:(int)n {
|
|
1602
|
+
// Byte kValue[4] = {0};
|
|
1603
|
+
// kValue[0] = 27;
|
|
1604
|
+
// kValue[1] = 99;
|
|
1605
|
+
// kValue[2] = 52;
|
|
1606
|
+
// kValue[3] = n;
|
|
1607
|
+
//
|
|
1608
|
+
// NSData *data = [NSData dataWithBytes:&kValue length:sizeof(kValue)];
|
|
1609
|
+
// NSLog(@"%@",[NSString stringWithFormat:@"写入:%@",data]);
|
|
1610
|
+
// if (commandSendMode==0)
|
|
1611
|
+
// {
|
|
1612
|
+
// [_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1613
|
+
// }
|
|
1614
|
+
// else
|
|
1615
|
+
// {
|
|
1616
|
+
// NSDictionary *dict;
|
|
1617
|
+
// dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
1618
|
+
// [_commandBuffer addObject:dict];
|
|
1619
|
+
// }
|
|
1620
|
+
//
|
|
1621
|
+
// //[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1622
|
+
//}
|
|
1623
|
+
///**
|
|
1624
|
+
// * 36.允许/禁止按键
|
|
1625
|
+
// */
|
|
1626
|
+
//- (void)allowOrDisableKeypress:(int)n {
|
|
1627
|
+
// Byte kValue[4] = {0};
|
|
1628
|
+
// kValue[0] = 27;
|
|
1629
|
+
// kValue[1] = 99;
|
|
1630
|
+
// kValue[2] = 53;
|
|
1631
|
+
// kValue[3] = n;
|
|
1632
|
+
//
|
|
1633
|
+
// NSData *data = [NSData dataWithBytes:&kValue length:sizeof(kValue)];
|
|
1634
|
+
// NSLog(@"%@",[NSString stringWithFormat:@"写入:%@",data]);
|
|
1635
|
+
// if (commandSendMode==0)
|
|
1636
|
+
// {
|
|
1637
|
+
// [_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1638
|
+
// }
|
|
1639
|
+
// else
|
|
1640
|
+
// {
|
|
1641
|
+
// NSDictionary *dict;
|
|
1642
|
+
// dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
1643
|
+
// [_commandBuffer addObject:dict];
|
|
1644
|
+
// }
|
|
1645
|
+
//
|
|
1646
|
+
// //[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1647
|
+
//}
|
|
1648
|
+
///**
|
|
1649
|
+
// * 37.打印并向前走纸 N 行
|
|
1650
|
+
// */
|
|
1651
|
+
//- (void)printAndPushPageRow:(int)n {
|
|
1652
|
+
// Byte kValue[3] = {0};
|
|
1653
|
+
// kValue[0] = 27;
|
|
1654
|
+
// kValue[1] = 100;
|
|
1655
|
+
// kValue[2] = n;
|
|
1656
|
+
//
|
|
1657
|
+
// NSData *data = [NSData dataWithBytes:&kValue length:sizeof(kValue)];
|
|
1658
|
+
// NSLog(@"%@",[NSString stringWithFormat:@"写入:%@",data]);
|
|
1659
|
+
// if (commandSendMode==0)
|
|
1660
|
+
// {
|
|
1661
|
+
// [_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1662
|
+
// }
|
|
1663
|
+
// else
|
|
1664
|
+
// {
|
|
1665
|
+
// NSDictionary *dict;
|
|
1666
|
+
// dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
1667
|
+
// [_commandBuffer addObject:dict];
|
|
1668
|
+
// }
|
|
1669
|
+
//
|
|
1670
|
+
// //[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1671
|
+
//}
|
|
1672
|
+
///**
|
|
1673
|
+
// * 38.产生钱箱控制脉冲
|
|
1674
|
+
// */
|
|
1675
|
+
//- (void)makePulseWithCashboxWithM:(int)m t1:(int)t1 t2:(int)t2 {
|
|
1676
|
+
// Byte kValue[5];
|
|
1677
|
+
// kValue[0] = 27;
|
|
1678
|
+
// kValue[1] = 112;
|
|
1679
|
+
// kValue[2] = m;
|
|
1680
|
+
// kValue[3] = t1;
|
|
1681
|
+
// kValue[4] = t2;
|
|
1682
|
+
//
|
|
1683
|
+
// NSData *data = [NSData dataWithBytes:&kValue length:sizeof(kValue)];
|
|
1684
|
+
// NSLog(@"%@",[NSString stringWithFormat:@"写入:%@",data]);
|
|
1685
|
+
// if (commandSendMode==0)
|
|
1686
|
+
// {
|
|
1687
|
+
// [_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1688
|
+
// }
|
|
1689
|
+
// else
|
|
1690
|
+
// {
|
|
1691
|
+
// NSDictionary *dict;
|
|
1692
|
+
// dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
1693
|
+
// [_commandBuffer addObject:dict];
|
|
1694
|
+
// }
|
|
1695
|
+
//
|
|
1696
|
+
// //[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1697
|
+
//}
|
|
1698
|
+
///**
|
|
1699
|
+
// * 39.选择字符代码表
|
|
1700
|
+
// */
|
|
1701
|
+
//- (void)selectCharacterTabN:(int)n {
|
|
1702
|
+
// Byte kValue[3] = {0};
|
|
1703
|
+
// kValue[0] = 27;
|
|
1704
|
+
// kValue[1] = 116;
|
|
1705
|
+
// kValue[2] = n;
|
|
1706
|
+
//
|
|
1707
|
+
// NSData *data = [NSData dataWithBytes:&kValue length:sizeof(kValue)];
|
|
1708
|
+
// NSLog(@"%@",[NSString stringWithFormat:@"写入:%@",data]);
|
|
1709
|
+
// if (commandSendMode==0)
|
|
1710
|
+
// {
|
|
1711
|
+
// [_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1712
|
+
// }
|
|
1713
|
+
// else
|
|
1714
|
+
// {
|
|
1715
|
+
// NSDictionary *dict;
|
|
1716
|
+
// dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
1717
|
+
// [_commandBuffer addObject:dict];
|
|
1718
|
+
// }
|
|
1719
|
+
//
|
|
1720
|
+
// //[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1721
|
+
//}
|
|
1722
|
+
///**
|
|
1723
|
+
// * 40.选择/取消倒置打印模式
|
|
1724
|
+
// */
|
|
1725
|
+
//- (void)selectOrCancelInversionPrintModel:(int)n {
|
|
1726
|
+
// Byte kValue[3] = {0};
|
|
1727
|
+
// kValue[0] = 27;
|
|
1728
|
+
// kValue[1] = 123;
|
|
1729
|
+
// kValue[2] = n;
|
|
1730
|
+
//
|
|
1731
|
+
// NSData *data = [NSData dataWithBytes:&kValue length:sizeof(kValue)];
|
|
1732
|
+
// NSLog(@"%@",[NSString stringWithFormat:@"写入:%@",data]);
|
|
1733
|
+
// if (commandSendMode==0)
|
|
1734
|
+
// {
|
|
1735
|
+
// [_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1736
|
+
// }
|
|
1737
|
+
// else
|
|
1738
|
+
// {
|
|
1739
|
+
// NSDictionary *dict;
|
|
1740
|
+
// dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
1741
|
+
// [_commandBuffer addObject:dict];
|
|
1742
|
+
// }
|
|
1743
|
+
//
|
|
1744
|
+
// //[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1745
|
+
//}
|
|
1746
|
+
//
|
|
1747
|
+
///**
|
|
1748
|
+
// * 41.打印下载到FLASH中的位图
|
|
1749
|
+
// */
|
|
1750
|
+
//- (void)printFlashBitmapWithN:(int)n m:(int)m {
|
|
1751
|
+
// Byte kValue[4] = {0};
|
|
1752
|
+
// kValue[0] = 28;
|
|
1753
|
+
// kValue[1] = 112;
|
|
1754
|
+
// kValue[2] = n;
|
|
1755
|
+
// kValue[3] = m;
|
|
1756
|
+
//
|
|
1757
|
+
// NSData *data = [NSData dataWithBytes:&kValue length:sizeof(kValue)];
|
|
1758
|
+
// NSLog(@"%@",[NSString stringWithFormat:@"写入:%@",data]);
|
|
1759
|
+
//
|
|
1760
|
+
// if (commandSendMode==0)
|
|
1761
|
+
// {
|
|
1762
|
+
// [_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1763
|
+
// }
|
|
1764
|
+
// else
|
|
1765
|
+
// {
|
|
1766
|
+
// NSDictionary *dict;
|
|
1767
|
+
// dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
1768
|
+
// [_commandBuffer addObject:dict];
|
|
1769
|
+
// }
|
|
1770
|
+
// //[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1771
|
+
//}
|
|
1772
|
+
///**
|
|
1773
|
+
// * 42.定义FLASH位图
|
|
1774
|
+
// */
|
|
1775
|
+
//- (void)definFlashBitmapWithN:(int)n Points:(NSArray *)points;{
|
|
1776
|
+
// int length = points.count;
|
|
1777
|
+
// Byte kValue[3+length];
|
|
1778
|
+
// kValue[0] = 28;
|
|
1779
|
+
// kValue[1] = 113;
|
|
1780
|
+
// kValue[2] = n;
|
|
1781
|
+
//
|
|
1782
|
+
// for (int i = 0; i<points.count; i++) {
|
|
1783
|
+
// NSString *str = points[i];
|
|
1784
|
+
// kValue[3+i] = str.intValue;
|
|
1785
|
+
// }
|
|
1786
|
+
//
|
|
1787
|
+
// NSData *data = [NSData dataWithBytes:&kValue length:sizeof(kValue)];
|
|
1788
|
+
// NSLog(@"%@",[NSString stringWithFormat:@"写入:%@",data]);
|
|
1789
|
+
// if (commandSendMode==0)
|
|
1790
|
+
// {
|
|
1791
|
+
// [_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1792
|
+
// }
|
|
1793
|
+
// else
|
|
1794
|
+
// {
|
|
1795
|
+
// NSDictionary *dict;
|
|
1796
|
+
// dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
1797
|
+
// [_commandBuffer addObject:dict];
|
|
1798
|
+
// }
|
|
1799
|
+
// //[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1800
|
+
//}
|
|
1801
|
+
///**
|
|
1802
|
+
// * 43.选择字符大小
|
|
1803
|
+
// */
|
|
1804
|
+
//- (void)selectCharacterSize:(int)n {
|
|
1805
|
+
// Byte kValue[3] = {0};
|
|
1806
|
+
// kValue[0] = 29;
|
|
1807
|
+
// kValue[1] = 33;
|
|
1808
|
+
// kValue[2] = n;
|
|
1809
|
+
//
|
|
1810
|
+
// NSData *data = [NSData dataWithBytes:&kValue length:sizeof(kValue)];
|
|
1811
|
+
// NSLog(@"%@",[NSString stringWithFormat:@"写入:%@",data]);
|
|
1812
|
+
// if (commandSendMode==0)
|
|
1813
|
+
// {
|
|
1814
|
+
// [_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1815
|
+
// }
|
|
1816
|
+
// else
|
|
1817
|
+
// {
|
|
1818
|
+
// NSDictionary *dict;
|
|
1819
|
+
// dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
1820
|
+
// [_commandBuffer addObject:dict];
|
|
1821
|
+
// }
|
|
1822
|
+
// //[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1823
|
+
//}
|
|
1824
|
+
///**
|
|
1825
|
+
// * 44.页模式下设置纵向绝对位置
|
|
1826
|
+
// */
|
|
1827
|
+
//- (void)setVertLocationOnPageModelWithnL:(int)nL nH:(int)nH {
|
|
1828
|
+
// Byte kValue[4] = {0};
|
|
1829
|
+
// kValue[0] = 29;
|
|
1830
|
+
// kValue[1] = 36;
|
|
1831
|
+
// kValue[2] = nL;
|
|
1832
|
+
// kValue[3] = nH;
|
|
1833
|
+
//
|
|
1834
|
+
// NSData *data = [NSData dataWithBytes:&kValue length:sizeof(kValue)];
|
|
1835
|
+
// NSLog(@"%@",[NSString stringWithFormat:@"写入:%@",data]);
|
|
1836
|
+
// if (commandSendMode==0)
|
|
1837
|
+
// {
|
|
1838
|
+
// [_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1839
|
+
// }
|
|
1840
|
+
// else
|
|
1841
|
+
// {
|
|
1842
|
+
// NSDictionary *dict;
|
|
1843
|
+
// dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
1844
|
+
// [_commandBuffer addObject:dict];
|
|
1845
|
+
// }
|
|
1846
|
+
// //[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1847
|
+
//}
|
|
1848
|
+
///**
|
|
1849
|
+
// * 45.定义下载位图
|
|
1850
|
+
// */
|
|
1851
|
+
//- (void)defineLoadBitmapWithX:(int)x Y:(int)y Points:(NSArray *)points {
|
|
1852
|
+
// Byte kValue[4+points.count];
|
|
1853
|
+
// kValue[0] = 29;
|
|
1854
|
+
// kValue[1] = 42;
|
|
1855
|
+
// kValue[2] = x;
|
|
1856
|
+
// kValue[3] = y;
|
|
1857
|
+
//
|
|
1858
|
+
// for (int i = 0; i<points.count; i++) {
|
|
1859
|
+
// NSString *str = points[i];
|
|
1860
|
+
// kValue[4+i] = str.intValue;
|
|
1861
|
+
// }
|
|
1862
|
+
//
|
|
1863
|
+
//
|
|
1864
|
+
// NSData *data = [NSData dataWithBytes:&kValue length:sizeof(kValue)];
|
|
1865
|
+
// NSLog(@"%@",[NSString stringWithFormat:@"写入:%@",data]);
|
|
1866
|
+
// if (commandSendMode==0)
|
|
1867
|
+
// {
|
|
1868
|
+
// [_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1869
|
+
// }
|
|
1870
|
+
// else
|
|
1871
|
+
// {
|
|
1872
|
+
// NSDictionary *dict;
|
|
1873
|
+
// dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
1874
|
+
// [_commandBuffer addObject:dict];
|
|
1875
|
+
// }
|
|
1876
|
+
// //[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1877
|
+
//}
|
|
1878
|
+
///**
|
|
1879
|
+
// * 46.执行打印数据十六进制转储
|
|
1880
|
+
// */
|
|
1881
|
+
//- (void)printDataAndSaveAsHexWithpL:(int)pL pH:(int)pH n:(int)n m:(int)m {
|
|
1882
|
+
// Byte kValue[7];
|
|
1883
|
+
// kValue[0] = 29;
|
|
1884
|
+
// kValue[1] = 40;
|
|
1885
|
+
// kValue[2] = 65;
|
|
1886
|
+
// kValue[3] = pL;
|
|
1887
|
+
// kValue[4] = pH;
|
|
1888
|
+
// kValue[5] = n;
|
|
1889
|
+
// kValue[6] = m;
|
|
1890
|
+
//
|
|
1891
|
+
// NSData *data = [NSData dataWithBytes:&kValue length:sizeof(kValue)];
|
|
1892
|
+
// NSLog(@"%@",[NSString stringWithFormat:@"写入:%@",data]);
|
|
1893
|
+
// if (commandSendMode==0)
|
|
1894
|
+
// {
|
|
1895
|
+
// [_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1896
|
+
// }
|
|
1897
|
+
// else
|
|
1898
|
+
// {
|
|
1899
|
+
// NSDictionary *dict;
|
|
1900
|
+
// dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
1901
|
+
// [_commandBuffer addObject:dict];
|
|
1902
|
+
// }
|
|
1903
|
+
// //[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1904
|
+
//}
|
|
1905
|
+
///**
|
|
1906
|
+
// * 47.打印下载位图
|
|
1907
|
+
// */
|
|
1908
|
+
//- (void)printLoadBitmapM:(int)m {
|
|
1909
|
+
// Byte kValue[3] = {0};
|
|
1910
|
+
// kValue[0] = 29;
|
|
1911
|
+
// kValue[1] = 47;
|
|
1912
|
+
// kValue[2] = m;
|
|
1913
|
+
//
|
|
1914
|
+
// NSData *data = [NSData dataWithBytes:&kValue length:sizeof(kValue)];
|
|
1915
|
+
// NSLog(@"%@",[NSString stringWithFormat:@"写入:%@",data]);
|
|
1916
|
+
// if (commandSendMode==0)
|
|
1917
|
+
// {
|
|
1918
|
+
// [_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1919
|
+
// }
|
|
1920
|
+
// else
|
|
1921
|
+
// {
|
|
1922
|
+
// NSDictionary *dict;
|
|
1923
|
+
// dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
1924
|
+
// [_commandBuffer addObject:dict];
|
|
1925
|
+
// }
|
|
1926
|
+
// //[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1927
|
+
//}
|
|
1928
|
+
///**
|
|
1929
|
+
// * 48.开始/结束宏定义
|
|
1930
|
+
// */
|
|
1931
|
+
//- (void)beginOrEndDefine {
|
|
1932
|
+
// Byte kValue[2] = {0};
|
|
1933
|
+
// kValue[0] = 29;
|
|
1934
|
+
// kValue[1] = 58;
|
|
1935
|
+
//
|
|
1936
|
+
// NSData *data = [NSData dataWithBytes:&kValue length:sizeof(kValue)];
|
|
1937
|
+
// NSLog(@"%@",[NSString stringWithFormat:@"写入:%@",data]);
|
|
1938
|
+
// if (commandSendMode==0)
|
|
1939
|
+
// {
|
|
1940
|
+
// [_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1941
|
+
// }
|
|
1942
|
+
// else
|
|
1943
|
+
// {
|
|
1944
|
+
// NSDictionary *dict;
|
|
1945
|
+
// dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
1946
|
+
// [_commandBuffer addObject:dict];
|
|
1947
|
+
// }
|
|
1948
|
+
// //[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1949
|
+
//}
|
|
1950
|
+
///**
|
|
1951
|
+
// * 49.选择/取消黑白反显打印模式
|
|
1952
|
+
// */
|
|
1953
|
+
//- (void)selectORCancelBWPrintModel:(int)n {
|
|
1954
|
+
// Byte kValue[3] = {0};
|
|
1955
|
+
// kValue[0] = 29;
|
|
1956
|
+
// kValue[1] = 66;
|
|
1957
|
+
// kValue[2] = n;
|
|
1958
|
+
//
|
|
1959
|
+
// NSData *data = [NSData dataWithBytes:&kValue length:sizeof(kValue)];
|
|
1960
|
+
// NSLog(@"%@",[NSString stringWithFormat:@"写入:%@",data]);
|
|
1961
|
+
// if (commandSendMode==0)
|
|
1962
|
+
// {
|
|
1963
|
+
// [_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1964
|
+
// }
|
|
1965
|
+
// else
|
|
1966
|
+
// {
|
|
1967
|
+
// NSDictionary *dict;
|
|
1968
|
+
// dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
1969
|
+
// [_commandBuffer addObject:dict];
|
|
1970
|
+
// }
|
|
1971
|
+
// //[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1972
|
+
//}
|
|
1973
|
+
///**
|
|
1974
|
+
// * 50.选择HRI字符的打印位置
|
|
1975
|
+
// */
|
|
1976
|
+
//- (void)selectHRIPrintLocation:(int)n {
|
|
1977
|
+
// Byte kValue[3] = {0};
|
|
1978
|
+
// kValue[0] = 29;
|
|
1979
|
+
// kValue[1] = 72;
|
|
1980
|
+
// kValue[2] = n;
|
|
1981
|
+
//
|
|
1982
|
+
// NSData *data = [NSData dataWithBytes:&kValue length:sizeof(kValue)];
|
|
1983
|
+
// NSLog(@"%@",[NSString stringWithFormat:@"写入:%@",data]);
|
|
1984
|
+
// if (commandSendMode==0)
|
|
1985
|
+
// {
|
|
1986
|
+
// [_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1987
|
+
// }
|
|
1988
|
+
// else
|
|
1989
|
+
// {
|
|
1990
|
+
// NSDictionary *dict;
|
|
1991
|
+
// dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
1992
|
+
// [_commandBuffer addObject:dict];
|
|
1993
|
+
// }
|
|
1994
|
+
// //[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
1995
|
+
//}
|
|
1996
|
+
///**
|
|
1997
|
+
// * 51.设置左边距
|
|
1998
|
+
// */
|
|
1999
|
+
//- (void)setLeftMarginWithnL:(int)nL nH:(int)nH {
|
|
2000
|
+
// Byte kValue[4] = {0};
|
|
2001
|
+
// kValue[0] = 29;
|
|
2002
|
+
// kValue[1] = 76;
|
|
2003
|
+
// kValue[2] = nL;
|
|
2004
|
+
// kValue[3] = nH;
|
|
2005
|
+
//
|
|
2006
|
+
// NSData *data = [NSData dataWithBytes:&kValue length:sizeof(kValue)];
|
|
2007
|
+
// NSLog(@"%@",[NSString stringWithFormat:@"写入:%@",data]);
|
|
2008
|
+
// if (commandSendMode==0)
|
|
2009
|
+
// {
|
|
2010
|
+
// [_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
2011
|
+
// }
|
|
2012
|
+
// else
|
|
2013
|
+
// {
|
|
2014
|
+
// NSDictionary *dict;
|
|
2015
|
+
// dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
2016
|
+
// [_commandBuffer addObject:dict];
|
|
2017
|
+
// }
|
|
2018
|
+
// //[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
2019
|
+
//}
|
|
2020
|
+
///**
|
|
2021
|
+
// * 52.设置横向和纵向移动单位
|
|
2022
|
+
// */
|
|
2023
|
+
//- (void)setHoriAndVertUnitXWith:(int)x y:(int)y {
|
|
2024
|
+
// Byte kValue[4] = {0};
|
|
2025
|
+
// kValue[0] = 29;
|
|
2026
|
+
// kValue[1] = 80;
|
|
2027
|
+
// kValue[2] = x;
|
|
2028
|
+
// kValue[3] = y;
|
|
2029
|
+
//
|
|
2030
|
+
// NSData *data = [NSData dataWithBytes:&kValue length:sizeof(kValue)];
|
|
2031
|
+
// NSLog(@"%@",[NSString stringWithFormat:@"写入:%@",data]);
|
|
2032
|
+
// if (commandSendMode==0)
|
|
2033
|
+
// {
|
|
2034
|
+
// [_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
2035
|
+
// }
|
|
2036
|
+
// else
|
|
2037
|
+
// {
|
|
2038
|
+
// NSDictionary *dict;
|
|
2039
|
+
// dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
2040
|
+
// [_commandBuffer addObject:dict];
|
|
2041
|
+
// }
|
|
2042
|
+
// //[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
2043
|
+
//}
|
|
2044
|
+
///**
|
|
2045
|
+
// * 53.选择切纸模式并切纸
|
|
2046
|
+
// */
|
|
2047
|
+
//- (void)selectCutPaperModelAndCutPaperWith:(int)m n:(int)n selectedModel:(int)model{
|
|
2048
|
+
// Byte kValue[4] = {0};
|
|
2049
|
+
// kValue[0] = 29;
|
|
2050
|
+
// kValue[1] = 86;
|
|
2051
|
+
// kValue[2] = m;
|
|
2052
|
+
// if (model == 1) {
|
|
2053
|
+
// kValue[3] = n;
|
|
2054
|
+
// }
|
|
2055
|
+
//
|
|
2056
|
+
// NSData *data = [NSData dataWithBytes:&kValue length:sizeof(kValue)];
|
|
2057
|
+
// NSLog(@"%@",[NSString stringWithFormat:@"写入:%@",data]);
|
|
2058
|
+
// if (commandSendMode==0)
|
|
2059
|
+
// {
|
|
2060
|
+
// [_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
2061
|
+
// }
|
|
2062
|
+
// else
|
|
2063
|
+
// {
|
|
2064
|
+
// NSDictionary *dict;
|
|
2065
|
+
// dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
2066
|
+
// [_commandBuffer addObject:dict];
|
|
2067
|
+
// }
|
|
2068
|
+
// //[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
2069
|
+
//}
|
|
2070
|
+
///**
|
|
2071
|
+
// * 54.设置打印区域宽高
|
|
2072
|
+
// */
|
|
2073
|
+
//- (void)setPrintLocationWith:(int)nL nH:(int)nH {
|
|
2074
|
+
// Byte kValue[4] = {0};
|
|
2075
|
+
// kValue[0] = 29;
|
|
2076
|
+
// kValue[1] = 87;
|
|
2077
|
+
// kValue[2] = nL;
|
|
2078
|
+
// kValue[3] = nH;
|
|
2079
|
+
//
|
|
2080
|
+
// NSData *data = [NSData dataWithBytes:&kValue length:sizeof(kValue)];
|
|
2081
|
+
// NSLog(@"%@",[NSString stringWithFormat:@"写入:%@",data]);
|
|
2082
|
+
// if (commandSendMode==0)
|
|
2083
|
+
// {
|
|
2084
|
+
// [_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
2085
|
+
// }
|
|
2086
|
+
// else
|
|
2087
|
+
// {
|
|
2088
|
+
// NSDictionary *dict;
|
|
2089
|
+
// dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
2090
|
+
// [_commandBuffer addObject:dict];
|
|
2091
|
+
// }
|
|
2092
|
+
// //[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
2093
|
+
//}
|
|
2094
|
+
///**
|
|
2095
|
+
// * 55.页模式下设置纵向相对位置
|
|
2096
|
+
// */
|
|
2097
|
+
//- (void)setVertRelativeLocationOnPageModelWith:(int)nL nH:(int)nH {
|
|
2098
|
+
// Byte kValue[4] = {0};
|
|
2099
|
+
// kValue[0] = 29;
|
|
2100
|
+
// kValue[1] = 92;
|
|
2101
|
+
// kValue[2] = nL;
|
|
2102
|
+
// kValue[3] =nH;
|
|
2103
|
+
//
|
|
2104
|
+
// NSData *data = [NSData dataWithBytes:&kValue length:sizeof(kValue)];
|
|
2105
|
+
// NSLog(@"%@",[NSString stringWithFormat:@"写入:%@",data]);
|
|
2106
|
+
// if (commandSendMode==0)
|
|
2107
|
+
// {
|
|
2108
|
+
// [_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
2109
|
+
// }
|
|
2110
|
+
// else
|
|
2111
|
+
// {
|
|
2112
|
+
// NSDictionary *dict;
|
|
2113
|
+
// dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
2114
|
+
// [_commandBuffer addObject:dict];
|
|
2115
|
+
// }
|
|
2116
|
+
// //[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
2117
|
+
//}
|
|
2118
|
+
///**
|
|
2119
|
+
// * 56.执行宏命令
|
|
2120
|
+
// */
|
|
2121
|
+
//- (void)runMacroMommandWith:(int)r t:(int)t m:(int)m {
|
|
2122
|
+
// Byte kValue[5] = {0};
|
|
2123
|
+
// kValue[0] = 29;
|
|
2124
|
+
// kValue[1] = 94;
|
|
2125
|
+
// kValue[2] = r;
|
|
2126
|
+
// kValue[3] = t;
|
|
2127
|
+
// kValue[4] = m;
|
|
2128
|
+
//
|
|
2129
|
+
// NSData *data = [NSData dataWithBytes:&kValue length:sizeof(kValue)];
|
|
2130
|
+
// NSLog(@"%@",[NSString stringWithFormat:@"写入:%@",data]);
|
|
2131
|
+
// if (commandSendMode==0)
|
|
2132
|
+
// {
|
|
2133
|
+
// [_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
2134
|
+
// }
|
|
2135
|
+
// else
|
|
2136
|
+
// {
|
|
2137
|
+
// NSDictionary *dict;
|
|
2138
|
+
// dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
2139
|
+
// [_commandBuffer addObject:dict];
|
|
2140
|
+
// }
|
|
2141
|
+
// //[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
2142
|
+
//}
|
|
2143
|
+
///**
|
|
2144
|
+
// * 57.打开/关闭自动状态反传功能(ASB)
|
|
2145
|
+
// */
|
|
2146
|
+
//- (void)openOrCloseASB:(int)n {
|
|
2147
|
+
// Byte kValue[3] = {0};
|
|
2148
|
+
// kValue[0] = 29;
|
|
2149
|
+
// kValue[1] = 97;
|
|
2150
|
+
// kValue[2] = n;
|
|
2151
|
+
//
|
|
2152
|
+
// NSData *data = [NSData dataWithBytes:&kValue length:sizeof(kValue)];
|
|
2153
|
+
// NSLog(@"%@",[NSString stringWithFormat:@"写入:%@",data]);
|
|
2154
|
+
// if (commandSendMode==0)
|
|
2155
|
+
// {
|
|
2156
|
+
// [_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
2157
|
+
// }
|
|
2158
|
+
// else
|
|
2159
|
+
// {
|
|
2160
|
+
// NSDictionary *dict;
|
|
2161
|
+
// dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
2162
|
+
// [_commandBuffer addObject:dict];
|
|
2163
|
+
// }
|
|
2164
|
+
// //[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
2165
|
+
//}
|
|
2166
|
+
///**
|
|
2167
|
+
// * 58.选择HRI使用字体
|
|
2168
|
+
// */
|
|
2169
|
+
//- (void)selectHRIFontToUse:(int)n {
|
|
2170
|
+
// Byte kValue[3] = {0};
|
|
2171
|
+
// kValue[0] = 29;
|
|
2172
|
+
// kValue[1] = 102;
|
|
2173
|
+
// kValue[2] = n;
|
|
2174
|
+
//
|
|
2175
|
+
// NSData *data = [NSData dataWithBytes:&kValue length:sizeof(kValue)];
|
|
2176
|
+
// NSLog(@"%@",[NSString stringWithFormat:@"写入:%@",data]);
|
|
2177
|
+
// if (commandSendMode==0)
|
|
2178
|
+
// {
|
|
2179
|
+
// [_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
2180
|
+
// }
|
|
2181
|
+
// else
|
|
2182
|
+
// {
|
|
2183
|
+
// NSDictionary *dict;
|
|
2184
|
+
// dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
2185
|
+
// [_commandBuffer addObject:dict];
|
|
2186
|
+
// }
|
|
2187
|
+
// //[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
2188
|
+
//}
|
|
2189
|
+
///**
|
|
2190
|
+
// * 59. 选择条码高度
|
|
2191
|
+
// */
|
|
2192
|
+
//- (void)selectBarcodeHeight:(int)n {
|
|
2193
|
+
// Byte kValue[3] = {0};
|
|
2194
|
+
// kValue[0] = 29;
|
|
2195
|
+
// kValue[1] = 104;
|
|
2196
|
+
// kValue[2] = n;
|
|
2197
|
+
//
|
|
2198
|
+
// NSData *data = [NSData dataWithBytes:&kValue length:sizeof(kValue)];
|
|
2199
|
+
// NSLog(@"%@",[NSString stringWithFormat:@"写入:%@",data]);
|
|
2200
|
+
// if (commandSendMode==0)
|
|
2201
|
+
// {
|
|
2202
|
+
// [_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
2203
|
+
// }
|
|
2204
|
+
// else
|
|
2205
|
+
// {
|
|
2206
|
+
// NSDictionary *dict;
|
|
2207
|
+
// dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
2208
|
+
// [_commandBuffer addObject:dict];
|
|
2209
|
+
// }
|
|
2210
|
+
// //[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
2211
|
+
//}
|
|
2212
|
+
///**
|
|
2213
|
+
// * 60.打印条码
|
|
2214
|
+
// */
|
|
2215
|
+
//- (void)printBarCodeWithPoints:(int)m n:(int)n points:(NSArray *)points selectModel:(int)model{
|
|
2216
|
+
//
|
|
2217
|
+
// Byte kValue[4+points.count];
|
|
2218
|
+
// kValue[0] = 29;
|
|
2219
|
+
// kValue[1] = 107;
|
|
2220
|
+
// kValue[2] = m;
|
|
2221
|
+
//
|
|
2222
|
+
// if (model == 0) {
|
|
2223
|
+
// for (int i = 0; i<points.count; i++) {
|
|
2224
|
+
// NSString *str = points[i];
|
|
2225
|
+
// kValue[3+i] = str.intValue;
|
|
2226
|
+
// if (i == points.count-1) {
|
|
2227
|
+
// kValue[4+i] = 0;
|
|
2228
|
+
// }
|
|
2229
|
+
// }
|
|
2230
|
+
// }else if (model == 1) {
|
|
2231
|
+
// kValue[3] = n;
|
|
2232
|
+
// for (int i = 0; i<points.count; i++) {
|
|
2233
|
+
// NSString *str = points[i];
|
|
2234
|
+
// kValue[4+i] = str.intValue;
|
|
2235
|
+
// }
|
|
2236
|
+
// }
|
|
2237
|
+
//
|
|
2238
|
+
// NSData *data = [NSData dataWithBytes:&kValue length:sizeof(kValue)];
|
|
2239
|
+
// NSLog(@"%@",[NSString stringWithFormat:@"写入:%@",data]);
|
|
2240
|
+
// if (commandSendMode==0)
|
|
2241
|
+
// {
|
|
2242
|
+
// [_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
2243
|
+
// }
|
|
2244
|
+
// else
|
|
2245
|
+
// {
|
|
2246
|
+
// NSDictionary *dict;
|
|
2247
|
+
// dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
2248
|
+
// [_commandBuffer addObject:dict];
|
|
2249
|
+
// }
|
|
2250
|
+
// //[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
2251
|
+
//
|
|
2252
|
+
//}
|
|
2253
|
+
///**
|
|
2254
|
+
// * 61.返回状态
|
|
2255
|
+
// */
|
|
2256
|
+
//- (void)callBackStatus:(int)n completion:(BleManagerReceiveCallBack)block{
|
|
2257
|
+
// self.receiveBlock = block;
|
|
2258
|
+
// Byte kValue[3] = {0};
|
|
2259
|
+
// kValue[0] = 29;
|
|
2260
|
+
// kValue[1] = 114;
|
|
2261
|
+
// kValue[2] = n;
|
|
2262
|
+
//
|
|
2263
|
+
// NSData *data = [NSData dataWithBytes:&kValue length:sizeof(kValue)];
|
|
2264
|
+
// NSLog(@"%@",[NSString stringWithFormat:@"写入:%@",data]);
|
|
2265
|
+
// if (commandSendMode==0)
|
|
2266
|
+
// {
|
|
2267
|
+
// [_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
2268
|
+
// }
|
|
2269
|
+
// else
|
|
2270
|
+
// {
|
|
2271
|
+
// NSDictionary *dict;
|
|
2272
|
+
// dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
2273
|
+
// [_commandBuffer addObject:dict];
|
|
2274
|
+
// }
|
|
2275
|
+
//
|
|
2276
|
+
// //[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
2277
|
+
//}
|
|
2278
|
+
///**
|
|
2279
|
+
// * 62.打印光栅位图
|
|
2280
|
+
// */
|
|
2281
|
+
//- (void)printRasterBitmapWith:(int)m
|
|
2282
|
+
// xL:(int)xL
|
|
2283
|
+
// xH:(int)xH
|
|
2284
|
+
// yl:(int)yL
|
|
2285
|
+
// yh:(int)yH
|
|
2286
|
+
// points:(NSArray *)points
|
|
2287
|
+
//{
|
|
2288
|
+
// Byte kValue[8+points.count];
|
|
2289
|
+
// kValue[0] = 29;
|
|
2290
|
+
// kValue[1] = 118;
|
|
2291
|
+
// kValue[2] = 48;
|
|
2292
|
+
// kValue[3] = m;
|
|
2293
|
+
// kValue[4] = xL;
|
|
2294
|
+
// kValue[5] = xH;
|
|
2295
|
+
// kValue[6] = yL;
|
|
2296
|
+
// kValue[7] = yH;
|
|
2297
|
+
//
|
|
2298
|
+
// for (int i = 0; i<points.count; i++) {
|
|
2299
|
+
// NSString *str = points[i];
|
|
2300
|
+
// kValue[8+i] =str.intValue;
|
|
2301
|
+
// }
|
|
2302
|
+
//
|
|
2303
|
+
// NSData *data = [NSData dataWithBytes:&kValue length:sizeof(kValue)];
|
|
2304
|
+
// NSLog(@"%@",[NSString stringWithFormat:@"写入:%@",data]);
|
|
2305
|
+
// if (commandSendMode==0)
|
|
2306
|
+
// {
|
|
2307
|
+
// [_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
2308
|
+
// }
|
|
2309
|
+
// else
|
|
2310
|
+
// {
|
|
2311
|
+
// NSDictionary *dict;
|
|
2312
|
+
// dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
2313
|
+
// [_commandBuffer addObject:dict];
|
|
2314
|
+
// }
|
|
2315
|
+
// //[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
2316
|
+
//}
|
|
2317
|
+
///**
|
|
2318
|
+
// * 63.设置条码宽度
|
|
2319
|
+
// */
|
|
2320
|
+
//- (void)setBarcodeWidth:(int)n {
|
|
2321
|
+
// Byte kValue[3] = {0};
|
|
2322
|
+
// kValue[0] = 29;
|
|
2323
|
+
// kValue[1] = 119;
|
|
2324
|
+
// kValue[2] = n;
|
|
2325
|
+
//
|
|
2326
|
+
// NSData *data = [NSData dataWithBytes:&kValue length:sizeof(kValue)];
|
|
2327
|
+
// NSLog(@"%@",[NSString stringWithFormat:@"写入:%@",data]);
|
|
2328
|
+
// if (commandSendMode==0)
|
|
2329
|
+
// {
|
|
2330
|
+
// [_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
2331
|
+
// }
|
|
2332
|
+
// else
|
|
2333
|
+
// {
|
|
2334
|
+
// NSDictionary *dict;
|
|
2335
|
+
// dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
2336
|
+
// [_commandBuffer addObject:dict];
|
|
2337
|
+
// }
|
|
2338
|
+
// //[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
2339
|
+
//}
|
|
2340
|
+
//#pragma mark - ============汉字字符控制命令============
|
|
2341
|
+
///**
|
|
2342
|
+
// * 64.设置汉字字符模式
|
|
2343
|
+
// */
|
|
2344
|
+
//- (void)setChineseCharacterModel:(int)n {
|
|
2345
|
+
// Byte kValue[3] = {0};
|
|
2346
|
+
// kValue[0] = 28;
|
|
2347
|
+
// kValue[1] = 33;
|
|
2348
|
+
// kValue[2] = n;
|
|
2349
|
+
//
|
|
2350
|
+
// NSData *data = [NSData dataWithBytes:&kValue length:sizeof(kValue)];
|
|
2351
|
+
// NSLog(@"%@",[NSString stringWithFormat:@"写入:%@",data]);
|
|
2352
|
+
// if (commandSendMode==0)
|
|
2353
|
+
// {
|
|
2354
|
+
// [_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
2355
|
+
// }
|
|
2356
|
+
// else
|
|
2357
|
+
// {
|
|
2358
|
+
// NSDictionary *dict;
|
|
2359
|
+
// dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
2360
|
+
// [_commandBuffer addObject:dict];
|
|
2361
|
+
// }
|
|
2362
|
+
// //[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
2363
|
+
//}
|
|
2364
|
+
///**
|
|
2365
|
+
// * 65.选择汉字模式
|
|
2366
|
+
// */
|
|
2367
|
+
//- (void)selectChineseCharacterModel {
|
|
2368
|
+
// Byte kValue[2] = {0};
|
|
2369
|
+
// kValue[0] = 28;
|
|
2370
|
+
// kValue[1] = 38;
|
|
2371
|
+
//
|
|
2372
|
+
// NSData *data = [NSData dataWithBytes:&kValue length:sizeof(kValue)];
|
|
2373
|
+
// NSLog(@"%@",[NSString stringWithFormat:@"写入:%@",data]);
|
|
2374
|
+
// if (commandSendMode==0)
|
|
2375
|
+
// {
|
|
2376
|
+
// [_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
2377
|
+
// }
|
|
2378
|
+
// else
|
|
2379
|
+
// {
|
|
2380
|
+
// NSDictionary *dict;
|
|
2381
|
+
// dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
2382
|
+
// [_commandBuffer addObject:dict];
|
|
2383
|
+
// }
|
|
2384
|
+
// //[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
2385
|
+
//}
|
|
2386
|
+
///**
|
|
2387
|
+
// * 66.选择/取消汉字下划线模式
|
|
2388
|
+
// */
|
|
2389
|
+
//- (void)selectOrCancelChineseUderlineModel:(int)n {
|
|
2390
|
+
// Byte kValue[3] = {0};
|
|
2391
|
+
// kValue[0] = 28;
|
|
2392
|
+
// kValue[1] = 45;
|
|
2393
|
+
// kValue[2] = n;
|
|
2394
|
+
//
|
|
2395
|
+
// NSData *data = [NSData dataWithBytes:&kValue length:sizeof(kValue)];
|
|
2396
|
+
// NSLog(@"%@",[NSString stringWithFormat:@"写入:%@",data]);
|
|
2397
|
+
// if (commandSendMode==0)
|
|
2398
|
+
// {
|
|
2399
|
+
// [_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
2400
|
+
// }
|
|
2401
|
+
// else
|
|
2402
|
+
// {
|
|
2403
|
+
// NSDictionary *dict;
|
|
2404
|
+
// dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
2405
|
+
// [_commandBuffer addObject:dict];
|
|
2406
|
+
// }
|
|
2407
|
+
// //[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
2408
|
+
//}
|
|
2409
|
+
///**
|
|
2410
|
+
// * 67.取消汉字模式
|
|
2411
|
+
// */
|
|
2412
|
+
//- (void)cancelChineseModel {
|
|
2413
|
+
// Byte kValue[2] = {0};
|
|
2414
|
+
// kValue[0] = 28;
|
|
2415
|
+
// kValue[1] = 46;
|
|
2416
|
+
//
|
|
2417
|
+
// NSData *data = [NSData dataWithBytes:&kValue length:sizeof(kValue)];
|
|
2418
|
+
// NSLog(@"%@",[NSString stringWithFormat:@"写入:%@",data]);
|
|
2419
|
+
// if (commandSendMode==0)
|
|
2420
|
+
// {
|
|
2421
|
+
// [_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
2422
|
+
// }
|
|
2423
|
+
// else
|
|
2424
|
+
// {
|
|
2425
|
+
// NSDictionary *dict;
|
|
2426
|
+
// dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
2427
|
+
// [_commandBuffer addObject:dict];
|
|
2428
|
+
// }
|
|
2429
|
+
// //[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
2430
|
+
//}
|
|
2431
|
+
///**
|
|
2432
|
+
// * 68.定义用户自定义汉字
|
|
2433
|
+
// */
|
|
2434
|
+
//- (void)defineCustomChinesePointsC1:(int)c1 c2:(int)c2 points:(NSArray *)points {
|
|
2435
|
+
// Byte kValue[4 + points.count];
|
|
2436
|
+
// kValue[0] = 28;
|
|
2437
|
+
// kValue[1] = 50;
|
|
2438
|
+
// kValue[2] = c1;
|
|
2439
|
+
// kValue[3] = c2;
|
|
2440
|
+
//
|
|
2441
|
+
// for (int i=0; i<points.count; i++) {
|
|
2442
|
+
// NSString *str = points[i];
|
|
2443
|
+
// kValue[4+i] = str.intValue;
|
|
2444
|
+
// }
|
|
2445
|
+
//
|
|
2446
|
+
// NSData *data = [NSData dataWithBytes:&kValue length:sizeof(kValue)];
|
|
2447
|
+
// NSLog(@"%@",[NSString stringWithFormat:@"写入:%@",data]);
|
|
2448
|
+
// if (commandSendMode==0)
|
|
2449
|
+
// {
|
|
2450
|
+
// [_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
2451
|
+
// }
|
|
2452
|
+
// else
|
|
2453
|
+
// {
|
|
2454
|
+
// NSDictionary *dict;
|
|
2455
|
+
// dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
2456
|
+
// [_commandBuffer addObject:dict];
|
|
2457
|
+
// }
|
|
2458
|
+
// //[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
2459
|
+
//
|
|
2460
|
+
//}
|
|
2461
|
+
///**
|
|
2462
|
+
// * 69.设置汉字字符左右间距
|
|
2463
|
+
// */
|
|
2464
|
+
//- (void)setChineseMarginWithLeftN1:(int)n1 n2:(int)n2 {
|
|
2465
|
+
// Byte kValue[4] = {0};
|
|
2466
|
+
// kValue[0] = 28;
|
|
2467
|
+
// kValue[1] = 83;
|
|
2468
|
+
// kValue[2] = n1;
|
|
2469
|
+
// kValue[3] = n2;
|
|
2470
|
+
//
|
|
2471
|
+
// NSData *data = [NSData dataWithBytes:&kValue length:sizeof(kValue)];
|
|
2472
|
+
// NSLog(@"%@",[NSString stringWithFormat:@"写入:%@",data]);
|
|
2473
|
+
// if (commandSendMode==0)
|
|
2474
|
+
// {
|
|
2475
|
+
// [_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
2476
|
+
// }
|
|
2477
|
+
// else
|
|
2478
|
+
// {
|
|
2479
|
+
// NSDictionary *dict;
|
|
2480
|
+
// dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
2481
|
+
// [_commandBuffer addObject:dict];
|
|
2482
|
+
// }
|
|
2483
|
+
// //[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
2484
|
+
//}
|
|
2485
|
+
///**
|
|
2486
|
+
// * 70.选择/取消汉字倍高倍宽
|
|
2487
|
+
// */
|
|
2488
|
+
//- (void)selectOrCancelChineseHModelAndWModel:(int)n {
|
|
2489
|
+
// Byte kValue[3] = {0};
|
|
2490
|
+
// kValue[0] = 28;
|
|
2491
|
+
// kValue[1] = 87;
|
|
2492
|
+
// kValue[2] = n;
|
|
2493
|
+
//
|
|
2494
|
+
// NSData *data = [NSData dataWithBytes:&kValue length:sizeof(kValue)];
|
|
2495
|
+
// NSLog(@"%@",[NSString stringWithFormat:@"写入:%@",data]);
|
|
2496
|
+
// if (commandSendMode==0)
|
|
2497
|
+
// {
|
|
2498
|
+
// [_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
2499
|
+
// }
|
|
2500
|
+
// else
|
|
2501
|
+
// {
|
|
2502
|
+
// NSDictionary *dict;
|
|
2503
|
+
// dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
2504
|
+
// [_commandBuffer addObject:dict];
|
|
2505
|
+
// }
|
|
2506
|
+
// //[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
2507
|
+
//}
|
|
2508
|
+
//#pragma mark - ============打印机提示命令============
|
|
2509
|
+
///**
|
|
2510
|
+
// * 72.打印机来单打印蜂鸣提示
|
|
2511
|
+
// */
|
|
2512
|
+
//- (void)printerSound:(int)n t:(int)t {
|
|
2513
|
+
// Byte kValue[4] = {0};
|
|
2514
|
+
// kValue[0] = 27;
|
|
2515
|
+
// kValue[1] = 66;
|
|
2516
|
+
// kValue[2] = n;
|
|
2517
|
+
// kValue[3] = t;
|
|
2518
|
+
//
|
|
2519
|
+
// NSData *data = [NSData dataWithBytes:&kValue length:sizeof(kValue)];
|
|
2520
|
+
// NSLog(@"%@",[NSString stringWithFormat:@"写入:%@",data]);
|
|
2521
|
+
// //[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
2522
|
+
//}
|
|
2523
|
+
///**
|
|
2524
|
+
// * 73.打印机来单打印蜂鸣提示及报警灯闪烁
|
|
2525
|
+
// */
|
|
2526
|
+
//- (void)printerSoundAndAlarmLight:(int)m t:(int)t n:(int)n{
|
|
2527
|
+
// Byte kValue[5] = {0};
|
|
2528
|
+
// kValue[0] = 27;
|
|
2529
|
+
// kValue[1] = 67;
|
|
2530
|
+
// kValue[2] = m;
|
|
2531
|
+
// kValue[3] = t;
|
|
2532
|
+
// kValue[4] = n;
|
|
2533
|
+
//
|
|
2534
|
+
// NSData *data = [NSData dataWithBytes:&kValue length:sizeof(kValue)];
|
|
2535
|
+
// NSLog(@"%@",[NSString stringWithFormat:@"写入:%@",data]);
|
|
2536
|
+
// //[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
2537
|
+
//}
|
|
2538
|
+
//#pragma mark - =========TSC指令==========
|
|
2539
|
+
///**
|
|
2540
|
+
// * 1.设置标签尺寸
|
|
2541
|
+
// */
|
|
2542
|
+
//- (void)ZywelladdSizeWidth:(int)width height:(int)height; {
|
|
2543
|
+
//
|
|
2544
|
+
// NSString *sizeStr = [NSString stringWithFormat:@"SIZE %d mm,%d mm",width,height];
|
|
2545
|
+
//
|
|
2546
|
+
// [self writeTSCWith:sizeStr];
|
|
2547
|
+
//
|
|
2548
|
+
//}
|
|
2549
|
+
///**
|
|
2550
|
+
// * 2.设置间隙长度
|
|
2551
|
+
// */
|
|
2552
|
+
//- (void)ZywelladdGap:(int)gap {
|
|
2553
|
+
//
|
|
2554
|
+
// NSString *gapStr = [NSString stringWithFormat:@"GAP %d mm,0",gap];
|
|
2555
|
+
// [self writeTSCWith:gapStr];
|
|
2556
|
+
//}
|
|
2557
|
+
///**
|
|
2558
|
+
// * 3.产生钱箱控制脉冲
|
|
2559
|
+
// */
|
|
2560
|
+
//- (void)ZywelladdCashDrwer:(int)m t1:(int)t1 t2:(int)t2 {
|
|
2561
|
+
// NSString *cash = [NSString stringWithFormat:@"CASHDRAWER %d,%d,%d",m,t1,t2];
|
|
2562
|
+
// [self writeTSCWith:cash];
|
|
2563
|
+
//}
|
|
2564
|
+
///**
|
|
2565
|
+
// * 4.控制每张标签的停止位置
|
|
2566
|
+
// */
|
|
2567
|
+
//- (void)ZywelladdOffset:(float)offset {
|
|
2568
|
+
// NSString *offsetStr = [NSString stringWithFormat:@"OFFSET %.1f mm",offset];
|
|
2569
|
+
// [self writeTSCWith:offsetStr];
|
|
2570
|
+
//}
|
|
2571
|
+
///**
|
|
2572
|
+
// * 5.设置打印速度
|
|
2573
|
+
// */
|
|
2574
|
+
//- (void)ZywelladdSpeed:(float)speed {
|
|
2575
|
+
// NSString *speedStr = [NSString stringWithFormat:@"SPEED %.1f",speed];
|
|
2576
|
+
// [self writeTSCWith:speedStr];
|
|
2577
|
+
//}
|
|
2578
|
+
///**
|
|
2579
|
+
// * 6.设置打印浓度
|
|
2580
|
+
// */
|
|
2581
|
+
//- (void)ZywelladdDensity:(int)n {
|
|
2582
|
+
// NSString *denStr = [NSString stringWithFormat:@"DENSITY %d",n];
|
|
2583
|
+
// [self writeTSCWith:denStr];
|
|
2584
|
+
//}
|
|
2585
|
+
///**
|
|
2586
|
+
// * 7.设置打印方向和镜像
|
|
2587
|
+
// */
|
|
2588
|
+
//- (void)ZywelladdDirection:(int)n {
|
|
2589
|
+
// NSString *directionStr = [NSString stringWithFormat:@"DIRECTION %d",n];
|
|
2590
|
+
// [self writeTSCWith:directionStr];
|
|
2591
|
+
//}
|
|
2592
|
+
///**
|
|
2593
|
+
// * 8.设置原点坐标
|
|
2594
|
+
// */
|
|
2595
|
+
//- (void)ZywelladdReference:(int)x y:(int)y {
|
|
2596
|
+
// NSString *refStr = [NSString stringWithFormat:@"REFERENCE %d,%d",x,y];
|
|
2597
|
+
// [self writeTSCWith:refStr];
|
|
2598
|
+
//}
|
|
2599
|
+
///**
|
|
2600
|
+
// * 9.清除打印缓冲区数据
|
|
2601
|
+
// */
|
|
2602
|
+
//- (void)ZywelladdCls {
|
|
2603
|
+
// NSString *clsStr = @"CLS ";
|
|
2604
|
+
// [self writeTSCWith:clsStr];
|
|
2605
|
+
//}
|
|
2606
|
+
///**
|
|
2607
|
+
// * 10.走纸
|
|
2608
|
+
// */
|
|
2609
|
+
//- (void)ZywelladdFeed:(int)feed {
|
|
2610
|
+
// NSString *feedStr = [NSString stringWithFormat:@"FEED %d",feed];
|
|
2611
|
+
// [self writeTSCWith:feedStr];
|
|
2612
|
+
//}
|
|
2613
|
+
///**
|
|
2614
|
+
// * 11.退纸
|
|
2615
|
+
// */
|
|
2616
|
+
//- (void)ZywelladdBackFeed:(int)feed {
|
|
2617
|
+
// NSString *back = [NSString stringWithFormat:@"BACKFEED %d",feed];
|
|
2618
|
+
// [self writeTSCWith:back];
|
|
2619
|
+
//}
|
|
2620
|
+
///**
|
|
2621
|
+
// * 12.走一张标签纸距离
|
|
2622
|
+
// */
|
|
2623
|
+
//- (void)ZywelladdFormFeed {
|
|
2624
|
+
// [self writeTSCWith:@"FORMFEED "];
|
|
2625
|
+
//}
|
|
2626
|
+
///**
|
|
2627
|
+
// * 13.标签位置进行一次校准
|
|
2628
|
+
// */
|
|
2629
|
+
//- (void)ZywelladdHome {
|
|
2630
|
+
// [self writeTSCWith:@"HOME "];
|
|
2631
|
+
//}
|
|
2632
|
+
///**
|
|
2633
|
+
// * 14.打印标签
|
|
2634
|
+
// */
|
|
2635
|
+
//- (void)ZywelladdPrint:(int)m {
|
|
2636
|
+
// NSString *printStr = [NSString stringWithFormat:@"PRINT %d",m];
|
|
2637
|
+
// [self writeTSCWith:printStr];
|
|
2638
|
+
//}
|
|
2639
|
+
///**
|
|
2640
|
+
// * 15.设置国际代码页
|
|
2641
|
+
// */
|
|
2642
|
+
//- (void)ZywelladdCodePage:(int)page {
|
|
2643
|
+
// NSString *code = [NSString stringWithFormat:@"CODEPAGE %d",page];
|
|
2644
|
+
// [self writeTSCWith:code];
|
|
2645
|
+
//}
|
|
2646
|
+
///**
|
|
2647
|
+
// * 16.设置蜂鸣器
|
|
2648
|
+
// */
|
|
2649
|
+
//- (void)ZywelladdSound:(int)level interval:(int)interval {
|
|
2650
|
+
// NSString *soundStr = [NSString stringWithFormat:@"SOUND %d,%d",level,interval];
|
|
2651
|
+
// [self writeTSCWith:soundStr];
|
|
2652
|
+
//}
|
|
2653
|
+
///**
|
|
2654
|
+
// * 17.设置打印机报错
|
|
2655
|
+
// */
|
|
2656
|
+
//- (void)ZywelladdLimitFeed:(int)feed {
|
|
2657
|
+
// NSString *limitStr = [NSString stringWithFormat:@"LIMITFEED %d mm",feed];
|
|
2658
|
+
// [self writeTSCWith:limitStr];
|
|
2659
|
+
//}
|
|
2660
|
+
///**
|
|
2661
|
+
// * 18.在打印缓冲区绘制黑块
|
|
2662
|
+
// */
|
|
2663
|
+
//- (void)ZywelladdBar:(int)x y:(int)y width:(int)width height:(int)height {
|
|
2664
|
+
// NSString *barStr = [NSString stringWithFormat:@"BAR %d,%d,%d,%d",x,y,width,height];
|
|
2665
|
+
// [self writeTSCWith:barStr];
|
|
2666
|
+
//}
|
|
2667
|
+
///**
|
|
2668
|
+
// * 19.在打印缓冲区绘制一维条码
|
|
2669
|
+
// */
|
|
2670
|
+
//- (void)Zywelladd1DBarcodeX:(int)x
|
|
2671
|
+
// y:(int)y
|
|
2672
|
+
// type:(NSString *)type
|
|
2673
|
+
// height:(int)height
|
|
2674
|
+
// readable:(int)readable
|
|
2675
|
+
// rotation:(int)rotation
|
|
2676
|
+
// narrow:(int)narrow
|
|
2677
|
+
// wide:(int)wide
|
|
2678
|
+
// content:(NSString *)content
|
|
2679
|
+
//{
|
|
2680
|
+
// NSString *codeStr = [NSString stringWithFormat:@"BARCODE %d,%d,\"%@\",%d,%d,%d,%d,%d,\"%@\"",x,y,type,height,readable,rotation,narrow,wide,content];
|
|
2681
|
+
// [self writeTSCWith:codeStr];
|
|
2682
|
+
//}
|
|
2683
|
+
//
|
|
2684
|
+
///**
|
|
2685
|
+
// * 20.在打印缓冲区绘制矩形
|
|
2686
|
+
// */
|
|
2687
|
+
//- (void)ZywelladdBox:(int)x y:(int)y xend:(int)xend yend:(int)yend {
|
|
2688
|
+
// NSString *boxStr = [NSString stringWithFormat:@"BOX %d,%d,%d,%d",x,y,xend,yend];
|
|
2689
|
+
// [self writeTSCWith:boxStr];
|
|
2690
|
+
//}
|
|
2691
|
+
///**
|
|
2692
|
+
// * 21.在打印缓冲区绘制位图
|
|
2693
|
+
// */
|
|
2694
|
+
//- (void)ZywelladdBitmap:(int)x
|
|
2695
|
+
// y:(int)y
|
|
2696
|
+
// width:(int)width
|
|
2697
|
+
// height:(int)height
|
|
2698
|
+
// mode:(int)mode data:(int)data {
|
|
2699
|
+
// NSString *bitStr = [NSString stringWithFormat:@"BITMAP %d,%d,%d,%d,%d,%d",x,y,width,height,mode,data];
|
|
2700
|
+
// [self writeTSCWith:bitStr];
|
|
2701
|
+
//}
|
|
2702
|
+
///**
|
|
2703
|
+
// * 22.擦除打印缓冲区中指定区域的数据
|
|
2704
|
+
// */
|
|
2705
|
+
//- (void)ZywelladdErase:(int)x y:(int)y xwidth:(int)xwidth yheight:(int)yheight {
|
|
2706
|
+
// NSString *eraseStr = [NSString stringWithFormat:@"ERASE %d,%d,%d,%d",x,y,xwidth,yheight];
|
|
2707
|
+
// [self writeTSCWith:eraseStr];
|
|
2708
|
+
//}
|
|
2709
|
+
///**
|
|
2710
|
+
// * 23.将指定区域的数据黑白反色
|
|
2711
|
+
// */
|
|
2712
|
+
//- (void)ZywelladdReverse:(int)x y:(int)y xwidth:(int)xwidth yheight:(int)yheight {
|
|
2713
|
+
// NSString *revStr = [NSString stringWithFormat:@"REVERSE %d,%d,%d,%d",x,y,xwidth,yheight];
|
|
2714
|
+
// [self writeTSCWith:revStr];
|
|
2715
|
+
//}
|
|
2716
|
+
///**
|
|
2717
|
+
// * 24.将指定区域的数据黑白反色
|
|
2718
|
+
// */
|
|
2719
|
+
//- (void)ZywelladdQRCode:(int)x y:(int)y level:(int)level cellWidth:(int)cellWidth rotation:(int)totation data:(NSString *)dataStr {
|
|
2720
|
+
// NSString *text = [NSString stringWithFormat:@"TEXT %d,%d,%d,%d,%d,%@",x,y,level,cellWidth,totation,dataStr];
|
|
2721
|
+
// [self writeTSCWith:text];
|
|
2722
|
+
//}
|
|
2723
|
+
///**
|
|
2724
|
+
// * 25.在打印缓冲区中绘制文字
|
|
2725
|
+
// */
|
|
2726
|
+
//- (void)ZywelladdQRCode:(NSString *)enable {
|
|
2727
|
+
// NSString *qrCode = [@"QRCODE " stringByAppendingString:enable];
|
|
2728
|
+
// [self writeTSCWith:qrCode];
|
|
2729
|
+
//}
|
|
2730
|
+
///**
|
|
2731
|
+
// * 26.设置剥离功能是否开启
|
|
2732
|
+
// */
|
|
2733
|
+
//- (void)ZywelladdPeel:(NSString *)enable {
|
|
2734
|
+
// NSString *peel = [@"SET PEEL " stringByAppendingString:enable];
|
|
2735
|
+
// [self writeTSCWith:peel];
|
|
2736
|
+
//}
|
|
2737
|
+
///**
|
|
2738
|
+
// * 27.设置撕离功能是否开启
|
|
2739
|
+
// */
|
|
2740
|
+
//- (void)ZywelladdTear:(NSString *)enable {
|
|
2741
|
+
// NSString *tear = [@"SET TEAR " stringByAppendingString:enable];
|
|
2742
|
+
// [self writeTSCWith:tear];
|
|
2743
|
+
//}
|
|
2744
|
+
///**
|
|
2745
|
+
// * 28.设置切刀功能是否开启
|
|
2746
|
+
// */
|
|
2747
|
+
//- (void)ZywelladdCut:(NSString *)enable {
|
|
2748
|
+
// NSString *cut = [@"SET CUTTER " stringByAppendingString:enable];
|
|
2749
|
+
// [self writeTSCWith:cut];
|
|
2750
|
+
//}
|
|
2751
|
+
///**
|
|
2752
|
+
// * 29.设置打印机出错时,是否打印上一张内容
|
|
2753
|
+
// */
|
|
2754
|
+
//- (void)ZywelladdReprint:(NSString *)enable {
|
|
2755
|
+
// NSString *reprint = [@"SET REPRINT " stringByAppendingString:enable];
|
|
2756
|
+
// [self writeTSCWith:reprint];
|
|
2757
|
+
//}
|
|
2758
|
+
///**
|
|
2759
|
+
// * 30.设置是否按走纸键打印最近一张标签
|
|
2760
|
+
// */
|
|
2761
|
+
//- (void)ZywelladdPrintKeyEnable:(NSString *)enable {
|
|
2762
|
+
// NSString *printKey = [@"SET PRINTKEY " stringByAppendingString:enable];
|
|
2763
|
+
// [self writeTSCWith:printKey];
|
|
2764
|
+
//}
|
|
2765
|
+
///**
|
|
2766
|
+
// * 31.设置按走纸键打印最近一张标签的份数
|
|
2767
|
+
// */
|
|
2768
|
+
//- (void)ZywelladdPrintKeyNum:(int)m {
|
|
2769
|
+
// NSString *printKey = [NSString stringWithFormat:@"SET PRINTKEY %d",m];
|
|
2770
|
+
// [self writeTSCWith:printKey];
|
|
2771
|
+
//}
|
|
2772
|
+
|
|
2773
|
+
- (void)writeTSCWith:(NSString *)str {
|
|
2774
|
+
str = [str stringByAppendingString:@"\r\n"];
|
|
2775
|
+
NSData *data = [str dataUsingEncoding:NSASCIIStringEncoding];
|
|
2776
|
+
if (commandSendMode==0)
|
|
2777
|
+
{
|
|
2778
|
+
[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
2779
|
+
}
|
|
2780
|
+
else
|
|
2781
|
+
{
|
|
2782
|
+
NSDictionary *dict;
|
|
2783
|
+
dict = [NSDictionary dictionaryWithObjectsAndKeys: data,@"data",_writePeripheral,@"writePeripheral",nil];
|
|
2784
|
+
[_commandBuffer addObject:dict];
|
|
2785
|
+
}
|
|
2786
|
+
//[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
2787
|
+
}
|
|
2788
|
+
|
|
2789
|
+
-(NSArray*)GetBuffer
|
|
2790
|
+
{
|
|
2791
|
+
NSMutableArray *commandBufferFilter;
|
|
2792
|
+
commandBufferFilter=[[NSMutableArray alloc]init];
|
|
2793
|
+
for (int t=0;t<[_commandBuffer count];t++)
|
|
2794
|
+
{
|
|
2795
|
+
NSDictionary *dict;
|
|
2796
|
+
CBPeripheral *dictPeripheral;
|
|
2797
|
+
NSData *data;
|
|
2798
|
+
dict=[_commandBuffer objectAtIndex:t];
|
|
2799
|
+
dictPeripheral=[dict objectForKey:@"writePeripheral"];
|
|
2800
|
+
//if (dictPeripheral == aPeripheral)
|
|
2801
|
+
{
|
|
2802
|
+
data=[dict objectForKey:@"data"];
|
|
2803
|
+
[commandBufferFilter addObject:data];
|
|
2804
|
+
}
|
|
2805
|
+
}
|
|
2806
|
+
|
|
2807
|
+
return [commandBufferFilter copy ];
|
|
2808
|
+
}
|
|
2809
|
+
|
|
2810
|
+
-(void)ClearBuffer
|
|
2811
|
+
{
|
|
2812
|
+
[_commandBuffer removeAllObjects];
|
|
2813
|
+
}
|
|
2814
|
+
|
|
2815
|
+
-(void)sendCommand:(NSData *)data
|
|
2816
|
+
{
|
|
2817
|
+
|
|
2818
|
+
[_writePeripheral writeValue:data forCharacteristic:write_characteristic type:CBCharacteristicWriteWithResponse];
|
|
2819
|
+
|
|
2820
|
+
|
|
2821
|
+
}
|
|
2822
|
+
|
|
2823
|
+
-(void)SendCommandBuffer
|
|
2824
|
+
{
|
|
2825
|
+
float timeInterver=0.5;
|
|
2826
|
+
|
|
2827
|
+
for (int t=0;t<[_commandBuffer count];t++)
|
|
2828
|
+
{
|
|
2829
|
+
NSDictionary *dict;
|
|
2830
|
+
CBPeripheral *dictPeripheral;
|
|
2831
|
+
NSData *data;
|
|
2832
|
+
dict=[_commandBuffer objectAtIndex:t];
|
|
2833
|
+
data=[dict objectForKey:@"data"];
|
|
2834
|
+
[self performSelector:@selector(sendCommand:) withObject:data afterDelay:timeInterver];
|
|
2835
|
+
timeInterver=timeInterver+0.2;
|
|
2836
|
+
}
|
|
2837
|
+
}
|
|
2838
|
+
|
|
2839
|
+
- (void)ZywellSetCommandMode:(int)Mode{
|
|
2840
|
+
commandSendMode=Mode;
|
|
2841
|
+
}
|
|
2842
|
+
@end
|