Commit c2da9865 authored by lujunye's avatar lujunye

1231232323

parent b1c7310b
......@@ -15,6 +15,8 @@
E007B1D8248F7276004D14CC /* CGDCell1.swift in Sources */ = {isa = PBXBuildFile; fileRef = E007B1D6248F7276004D14CC /* CGDCell1.swift */; };
E007B1D9248F7276004D14CC /* CGDCell1.xib in Resources */ = {isa = PBXBuildFile; fileRef = E007B1D7248F7276004D14CC /* CGDCell1.xib */; };
E007B1DB248F8F57004D14CC /* PurchaseInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = E007B1DA248F8F57004D14CC /* PurchaseInterface.swift */; };
E00892E12638047700FA09C3 /* 3.png in Resources */ = {isa = PBXBuildFile; fileRef = E00892E02638047700FA09C3 /* 3.png */; };
E00892E62638058E00FA09C3 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E00892E52638058E00FA09C3 /* Foundation.framework */; };
E00ACBEB2490D6C800128052 /* YDLBVc.swift in Sources */ = {isa = PBXBuildFile; fileRef = E00ACBE92490D6C800128052 /* YDLBVc.swift */; };
E00ACBEC2490D6C800128052 /* YDLBVc.xib in Resources */ = {isa = PBXBuildFile; fileRef = E00ACBEA2490D6C800128052 /* YDLBVc.xib */; };
E00B0B1B24629E99006DC846 /* SJMapCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = E00B0B1924629E99006DC846 /* SJMapCell.swift */; };
......@@ -236,6 +238,8 @@
E0707DCE2462479300E039A8 /* SJMapViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E0707DCD2462479300E039A8 /* SJMapViewController.swift */; };
E07337F82579E8660039767A /* GYS_FX_Product_ListVc.swift in Sources */ = {isa = PBXBuildFile; fileRef = E07337F62579E8660039767A /* GYS_FX_Product_ListVc.swift */; };
E07337F92579E8660039767A /* GYS_FX_Product_ListVc.xib in Resources */ = {isa = PBXBuildFile; fileRef = E07337F72579E8660039767A /* GYS_FX_Product_ListVc.xib */; };
E07413042637AE950098006A /* GSDK.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E07412F82637AE950098006A /* GSDK.a */; };
E07413112637AEBA0098006A /* ConnecterManager.m in Sources */ = {isa = PBXBuildFile; fileRef = E07413102637AEBA0098006A /* ConnecterManager.m */; };
E074B69C24DD305600777003 /* TitleHeaderCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = E074B69A24DD305500777003 /* TitleHeaderCell.swift */; };
E074B69D24DD305600777003 /* TitleHeaderCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = E074B69B24DD305500777003 /* TitleHeaderCell.xib */; };
E07723032616B78C00344F11 /* P_P_H_Time_Select_View.swift in Sources */ = {isa = PBXBuildFile; fileRef = E07723022616B78C00344F11 /* P_P_H_Time_Select_View.swift */; };
......@@ -802,6 +806,8 @@
E007B1D6248F7276004D14CC /* CGDCell1.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CGDCell1.swift; sourceTree = "<group>"; };
E007B1D7248F7276004D14CC /* CGDCell1.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = CGDCell1.xib; sourceTree = "<group>"; };
E007B1DA248F8F57004D14CC /* PurchaseInterface.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PurchaseInterface.swift; sourceTree = "<group>"; };
E00892E02638047700FA09C3 /* 3.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = 3.png; sourceTree = "<group>"; };
E00892E52638058E00FA09C3 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
E00ACBE92490D6C800128052 /* YDLBVc.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YDLBVc.swift; sourceTree = "<group>"; };
E00ACBEA2490D6C800128052 /* YDLBVc.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = YDLBVc.xib; sourceTree = "<group>"; };
E00B0B1924629E99006DC846 /* SJMapCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SJMapCell.swift; sourceTree = "<group>"; };
......@@ -1037,6 +1043,15 @@
E0707DD324624A6800E039A8 /* CoreLocation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreLocation.framework; path = System/Library/Frameworks/CoreLocation.framework; sourceTree = SDKROOT; };
E07337F62579E8660039767A /* GYS_FX_Product_ListVc.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GYS_FX_Product_ListVc.swift; sourceTree = "<group>"; };
E07337F72579E8660039767A /* GYS_FX_Product_ListVc.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = GYS_FX_Product_ListVc.xib; sourceTree = "<group>"; };
E07412F82637AE950098006A /* GSDK.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = GSDK.a; sourceTree = "<group>"; };
E07412FC2637AE950098006A /* EthernetConnecter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EthernetConnecter.h; sourceTree = "<group>"; };
E07412FD2637AE950098006A /* EscCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EscCommand.h; sourceTree = "<group>"; };
E07412FE2637AE950098006A /* ConnecterBlock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ConnecterBlock.h; sourceTree = "<group>"; };
E07412FF2637AE950098006A /* TscCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TscCommand.h; sourceTree = "<group>"; };
E07413002637AE950098006A /* BLEConnecter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BLEConnecter.h; sourceTree = "<group>"; };
E07413012637AE950098006A /* Connecter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Connecter.h; sourceTree = "<group>"; };
E074130F2637AEBA0098006A /* ConnecterManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ConnecterManager.h; sourceTree = "<group>"; };
E07413102637AEBA0098006A /* ConnecterManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ConnecterManager.m; sourceTree = "<group>"; };
E074B69A24DD305500777003 /* TitleHeaderCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TitleHeaderCell.swift; sourceTree = "<group>"; };
E074B69B24DD305500777003 /* TitleHeaderCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = TitleHeaderCell.xib; sourceTree = "<group>"; };
E07723022616B78C00344F11 /* P_P_H_Time_Select_View.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = P_P_H_Time_Select_View.swift; sourceTree = "<group>"; };
......@@ -1664,6 +1679,7 @@
E0AA7F362589A8AA0099193F /* jpush-ios-3.4.0.a in Frameworks */,
F96A581D24790D9A0070A057 /* libxml2.2.tbd in Frameworks */,
E09B3AD424B2FCAF00E3B238 /* ShareSDKConfigFile.framework in Frameworks */,
E00892E62638058E00FA09C3 /* Foundation.framework in Frameworks */,
E09B3ADA24B2FCAF00E3B238 /* ShareSDK.framework in Frameworks */,
E09B3AD924B2FCAF00E3B238 /* WechatConnector.framework in Frameworks */,
F93E32092473CD6500524DFC /* libresolv.tbd in Frameworks */,
......@@ -1675,6 +1691,7 @@
E03984942468F2CA00DFA56F /* UIKit.framework in Frameworks */,
E09B3AD524B2FCAF00E3B238 /* ShareSDKExtension.framework in Frameworks */,
E09B3AD624B2FCAF00E3B238 /* ShareSDKUI.framework in Frameworks */,
E07413042637AE950098006A /* GSDK.a in Frameworks */,
E09B3AD024B2FCAF00E3B238 /* ShareSDKConnector.framework in Frameworks */,
E05AEF98261572D500FB7CF4 /* AMapFoundationKit.framework in Frameworks */,
E03984902468F2AB00DFA56F /* MapKit.framework in Frameworks */,
......@@ -1723,6 +1740,7 @@
824621C23DA37CD28A2F345F /* Frameworks */ = {
isa = PBXGroup;
children = (
E00892E52638058E00FA09C3 /* Foundation.framework */,
E05AEF562615721000FB7CF4 /* AMapLocationKit.framework */,
E05AEF0C2615706E00FB7CF4 /* MAMapKit.framework */,
E05AEF0026156F8B00FB7CF4 /* AMapSearchKit.framework */,
......@@ -2278,6 +2296,39 @@
path = "地图";
sourceTree = "<group>";
};
E07412F52637AE700098006A /* GBDEMO */ = {
isa = PBXGroup;
children = (
E00892E02638047700FA09C3 /* 3.png */,
E074130F2637AEBA0098006A /* ConnecterManager.h */,
E07413102637AEBA0098006A /* ConnecterManager.m */,
E07412F82637AE950098006A /* GSDK.a */,
E07412F92637AE950098006A /* include */,
);
path = GBDEMO;
sourceTree = "<group>";
};
E07412F92637AE950098006A /* include */ = {
isa = PBXGroup;
children = (
E07412FB2637AE950098006A /* GSDK */,
);
path = include;
sourceTree = "<group>";
};
E07412FB2637AE950098006A /* GSDK */ = {
isa = PBXGroup;
children = (
E07412FC2637AE950098006A /* EthernetConnecter.h */,
E07412FD2637AE950098006A /* EscCommand.h */,
E07412FE2637AE950098006A /* ConnecterBlock.h */,
E07412FF2637AE950098006A /* TscCommand.h */,
E07413002637AE950098006A /* BLEConnecter.h */,
E07413012637AE950098006A /* Connecter.h */,
);
path = GSDK;
sourceTree = "<group>";
};
E077DC5C25512489000B0DA5 /* 供应商合作管理 */ = {
isa = PBXGroup;
children = (
......@@ -2572,6 +2623,7 @@
E09B3AB624B2FCAF00E3B238 /* SDK */ = {
isa = PBXGroup;
children = (
E07412F52637AE700098006A /* GBDEMO */,
E0DA8A9325E8F3C900425099 /* HLPrinter */,
E09B3AB724B2FCAF00E3B238 /* ShareSDK */,
E09B3ACD24B2FCAF00E3B238 /* Required */,
......@@ -4019,6 +4071,7 @@
E09B03B72445B85A00211A51 /* LoginViewController.xib in Resources */,
E063A75D2616A5F80020EEDC /* WXTS_View.xib in Resources */,
F96E9D61246657B500B5B94A /* HGImage.storyboard in Resources */,
E00892E12638047700FA09C3 /* 3.png in Resources */,
E09F4C9E2452BEBB00BE033D /* JiPaiFangShiViewController.xib in Resources */,
F9A4AB6F24C927E900094BD1 /* LogisticsCostDetailViewController.xib in Resources */,
E0B5307F247266F400FFCC15 /* DKXDAdrCell.xib in Resources */,
......@@ -4564,6 +4617,7 @@
F9D44E8824CBC6A400FBD8DB /* ToAndFormSelectViewController.swift in Sources */,
E0D197BD2448431C002B080C /* BabySpeaker.m in Sources */,
F9956B22246408A6001A617D /* GoodsClassViewController.swift in Sources */,
E07413112637AEBA0098006A /* ConnecterManager.m in Sources */,
F950FDDA24518B9500C40530 /* FSCalendarCell.m in Sources */,
F9A1D4A4255B77070018DA8A /* RetailManageViewCell.swift in Sources */,
F96E9D5D246656A700B5B94A /* HGImagePickerController.swift in Sources */,
......@@ -4989,6 +5043,7 @@
"$(PROJECT_DIR)/GeliBusinessPlatform/Other/SDK/GPrinter",
"$(PROJECT_DIR)/GeliBusinessPlatform/Other/SDK/GprinterSDKforIOS_v1.0.8",
"$(PROJECT_DIR)/GeliBusinessPlatform/Other/SDK",
"$(PROJECT_DIR)/GeliBusinessPlatform/Other/SDK/GBDEMO",
);
MARKETING_VERSION = 1.7.5;
OTHER_LDFLAGS = (
......@@ -5130,6 +5185,7 @@
"$(PROJECT_DIR)/GeliBusinessPlatform/Other/SDK/GPrinter",
"$(PROJECT_DIR)/GeliBusinessPlatform/Other/SDK/GprinterSDKforIOS_v1.0.8",
"$(PROJECT_DIR)/GeliBusinessPlatform/Other/SDK",
"$(PROJECT_DIR)/GeliBusinessPlatform/Other/SDK/GBDEMO",
);
MARKETING_VERSION = 1.7.5;
OTHER_LDFLAGS = (
......
......@@ -26,10 +26,15 @@
#import "JZLocationConverter.h"
#import "HLBLEManager.h"
#import "SVProgressHUD.h"
#import "BtViewController.h"
#import "HLPrinter.h"
#import "WKWebView+UIImage.h"
#import "BLEConnecter.h"
#import "EthernetConnecter.h"
#import "Connecter.h"
#import "ConnecterManager.h"
#import "TscCommand.h"
#endif /* Bridge_Header_h */
......@@ -27,10 +27,10 @@ let systemVersion = (UIDevice.current.systemVersion as String)
//接口地址
//test
let SERVERCE_ImageHost = "https://z.gelifood.com/"
let SERVERCE_HOST = "https://z.gelifood.com/admin/"
//let SERVERCE_ImageHost = "https://zx.gelifood.com/"
//let SERVERCE_HOST = "https://zx.gelifood.com/admin/"
//let SERVERCE_ImageHost = "https://z.gelifood.com/"
//let SERVERCE_HOST = "https://z.gelifood.com/admin/"
let SERVERCE_ImageHost = "https://zx.gelifood.com/"
let SERVERCE_HOST = "https://zx.gelifood.com/admin/"
//online
//视图常量
......
......@@ -81,6 +81,7 @@
<true/>
<key>UIBackgroundModes</key>
<array>
<string>bluetooth-central</string>
<string>fetch</string>
<string>remote-notification</string>
</array>
......
......@@ -346,6 +346,7 @@ class addPinPinOrder_model: Mappable {
class addPinPinOrderData_model: Mappable {
var id:String?
var wb_no : String?
var lwb_no :String?
required init?( map: Map) {
......@@ -353,6 +354,7 @@ class addPinPinOrderData_model: Mappable {
func mapping(map: Map) {
id <- map["id"]
wb_no <- map["wb_no"]
lwb_no <- map["lwb_no"]
}
}
//MARK: - 拼拼货计算价格
......
//
// ConnecterManager.h
// GSDK
//
// Created by 猿史森林 on 2018/6/21.
// Copyright © 2018年 Smarnet. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "BLEConnecter.h"
#import "EthernetConnecter.h"
#import "Connecter.h"
/**
* @enum ConnectMethod
* @discussion 连接方式
* @constant BLUETOOTH 蓝牙连接
* @constant ETHERNET 网口连接(wifi连接)
*/
typedef enum : NSUInteger{
BLUETOOTH,
ETHERNET
}ConnectMethod;
#define Manager [ConnecterManager sharedInstance]
@interface ConnecterManager : NSObject
@property(nonatomic,strong)BLEConnecter *bleConnecter;
@property(nonatomic,strong)EthernetConnecter *ethernetConnecter;
@property(nonatomic,strong)Connecter *connecter;
+(instancetype)sharedInstance;
/**
* 方法说明:连接指定ip和端口号的网络设备
* @param ip 设备的ip地址
* @param port 设备端口号
* @param connectState 连接状态
* @param callback 读取数据接口
*/
-(void)connectIP:(NSString *)ip port:(int)port connectState:(void (^)(ConnectState state))connectState callback:(void (^)(NSData *))callback;
-(void)closePeripheral:(CBPeripheral *)peripheral;
/**
* 方法说明:关闭连接
*/
-(void)close;
/**
* 方法说明: 向输出流中写入数据(只适用于蓝牙)
* @param data 需要写入的数据
* @param progress 写入数据进度
* @param callBack 读取输入流中的数据
*/
-(void)write:(NSData *_Nullable)data progress:(void(^_Nullable)(NSUInteger total,NSUInteger progress))progress receCallBack:(void (^_Nullable)(NSData *_Nullable))callBack;
/**
* 方法说明:向输出流中写入数据
* @param callBack 读取数据接口
*/
-(void)write:(NSData *)data receCallBack:(void (^)(NSData *))callBack;
/**
* 方法说明:向输出流中写入数据
* @param data 需要写入的数据
*/
-(void)write:(NSData *)data;
/**
* 方法说明:停止扫描
*/
-(void)stopScan;
/**
* 方法说明:更新蓝牙状态
* @param state 蓝牙状态
*/
-(void)didUpdateState:(void(^)(NSInteger state))state;
/**
* 方法说明:连接外设
* @param peripheral 需连接的外设
* @param options 其它可选操作
* @param timeout 连接时间
* @param connectState 连接状态
*/
-(void)connectPeripheral:(CBPeripheral *)peripheral options:(nullable NSDictionary<NSString *,id> *)options timeout:(NSUInteger)timeout connectBlack:(void(^_Nullable)(ConnectState state)) connectState;
/**
* 方法说明:连接外设
* @param peripheral 需连接的外设
* @param options 其它可选操作
*/
-(void)connectPeripheral:(CBPeripheral * _Nullable)peripheral options:(nullable NSDictionary<NSString *,id> *)options;
/**
* 方法说明:扫描外设
* @param serviceUUIDs 需要发现外设的UUID,设置为nil则发现周围所有外设
* @param options 其它可选操作
* @param discover 发现的设备
*/
-(void)scanForPeripheralsWithServices:(nullable NSArray<CBUUID *> *)serviceUUIDs options:(nullable NSDictionary<NSString *, id> *)options discover:(void(^_Nullable)(CBPeripheral *_Nullable peripheral,NSDictionary<NSString *, id> *_Nullable advertisementData,NSNumber *_Nullable RSSI))discover;
@end
//
// ConnecterManager.m
// GSDK
//
// Created by 猿史森林 on 2018/6/21.
// Copyright © 2018年 Smarnet. All rights reserved.
//
#import "ConnecterManager.h"
@interface ConnecterManager(){
ConnectMethod currentConnMethod;
}
@end
@implementation ConnecterManager
static ConnecterManager *manager;
static dispatch_once_t once;
+(instancetype)sharedInstance {
dispatch_once(&once, ^{
manager = [[ConnecterManager alloc]init];
});
return manager;
}
/**
* 方法说明:连接指定ip和端口号的网络设备
* @param ip 设备的ip地址
* @param port 设备端口号
* @param connectState 连接状态
* @param callback 读取数据接口
*/
-(void)connectIP:(NSString *)ip port:(int)port connectState:(void (^)(ConnectState state))connectState callback:(void (^)(NSData *))callback {
dispatch_async(dispatch_get_global_queue(0, 0), ^{
if (_ethernetConnecter == nil) {
currentConnMethod = ETHERNET;
[self initConnecter:currentConnMethod];
}
[_ethernetConnecter connectIP:ip port:port connectState:connectState callback:callback];
});
}
/**
* 方法说明:扫描外设
* @param serviceUUIDs 需要发现外设的UUID,设置为nil则发现周围所有外设
* @param options 其它可选操作
* @param discover 发现的设备
*/
-(void)scanForPeripheralsWithServices:(nullable NSArray<CBUUID *> *)serviceUUIDs options:(nullable NSDictionary<NSString *, id> *)options discover:(void(^_Nullable)(CBPeripheral *_Nullable peripheral,NSDictionary<NSString *, id> *_Nullable advertisementData,NSNumber *_Nullable RSSI))discover{
[_bleConnecter scanForPeripheralsWithServices:serviceUUIDs options:options discover:discover];
}
/**
* 方法说明:更新蓝牙状态
* @param state 蓝牙状态
*/
-(void)didUpdateState:(void(^)(NSInteger state))state {
if (_bleConnecter == nil) {
currentConnMethod = BLUETOOTH;
[self initConnecter:currentConnMethod];
}
[_bleConnecter didUpdateState:state];
}
-(void)initConnecter:(ConnectMethod)connectMethod {
switch (connectMethod) {
case BLUETOOTH:
_bleConnecter = [BLEConnecter new];
_connecter = _bleConnecter;
break;
case ETHERNET:
_ethernetConnecter = [EthernetConnecter new];
_connecter = _ethernetConnecter;
break;
default:
break;
}
}
/**
* 方法说明:停止扫描
*/
-(void)stopScan {
[_bleConnecter stopScan];
}
/**
* 连接
*/
-(void)connectPeripheral:(CBPeripheral *)peripheral options:(nullable NSDictionary<NSString *,id> *)options timeout:(NSUInteger)timeout connectBlack:(void(^_Nullable)(ConnectState state)) connectState{
[_bleConnecter connectPeripheral:peripheral options:options timeout:timeout connectBlack:connectState];
}
-(void)closePeripheral:(CBPeripheral *)peripheral{
[_bleConnecter closePeripheral:peripheral];
}
-(void)connectPeripheral:(CBPeripheral * _Nullable)peripheral options:(nullable NSDictionary<NSString *,id> *)options {
[_bleConnecter connectPeripheral:peripheral options:options];
}
-(void)write:(NSData *_Nullable)data progress:(void(^_Nullable)(NSUInteger total,NSUInteger progress))progress receCallBack:(void (^_Nullable)(NSData *_Nullable))callBack {
[_bleConnecter write:data progress:progress receCallBack:callBack];
}
-(void)write:(NSData *)data receCallBack:(void (^)(NSData *))callBack {
#ifdef DEBUG
NSLog(@"[ConnecterManager] write:receCallBack:");
#endif
_bleConnecter.writeProgress = nil;
[_connecter write:data receCallBack:callBack];
}
-(void)write:(NSData *)data {
#ifdef DEBUG
NSLog(@"[ConnecterManager] write:");
#endif
_bleConnecter.writeProgress = nil;
[_connecter write:data];
}
-(void)close {
if (_connecter) {
[_connecter close];
}
switch (currentConnMethod) {
case BLUETOOTH:
_bleConnecter = nil;
break;
case ETHERNET:
_ethernetConnecter = nil;
break;
}
}
@end
//
// Connecter.h
// GSDK
//
// Created by 猿史森林 on 2018/6/15.
// Copyright © 2018年 Smarnet. All rights reserved.
//
#import "Connecter.h"
#import <CoreBluetooth/CoreBluetooth.h>
@interface BLEConnecter :Connecter
@property(nonatomic,strong)CBCharacteristic *airPatchChar;
@property(nonatomic,strong)CBCharacteristic *transparentDataWriteChar;
@property(nonatomic,strong)CBCharacteristic *transparentDataReadOrNotifyChar;
@property(nonatomic,strong)CBCharacteristic *connectionParameterChar;
@property(nonatomic,strong)CBUUID *transServiceUUID;
@property(nonatomic,strong)CBUUID *transTxUUID;
@property(nonatomic,strong)CBUUID *transRxUUID;
@property(nonatomic,strong)CBUUID *disUUID1;
@property(nonatomic,strong)CBUUID *disUUID2;
@property(nonatomic,strong)NSArray *serviceUUID;
@property(nonatomic,copy)DiscoverDevice discover;
@property(nonatomic,copy)UpdateState updateState;
@property(nonatomic,copy)WriteProgress writeProgress;
/**数据包大小,默认130个字节*/
@property(nonatomic,assign)NSUInteger datagramSize;
@property(nonatomic,strong)CBPeripheral *connPeripheral;
//+(instancetype)sharedInstance;
/**
* 方法说明:设置特定的Service UUID,以及Service对应的具有读、写特征值
* @param serviceUUID 蓝牙模块的service uuid
* @param txUUID 具有写入权限特征值
* @param rxUUID 具有读取权限特征值
*/
- (void)configureTransparentServiceUUID: (NSString *)serviceUUID txUUID:(NSString *)txUUID rxUUID:(NSString *)rxUUID;
/**
* 方法说明:扫描外设
* @param serviceUUIDs 需要连接的外设UUID
* @param options 其它可选操作
* @param discover 发现设备
* peripheral 发现的外设
* advertisementData
* RSSI 外设信号强度
*/
-(void)scanForPeripheralsWithServices:(nullable NSArray<CBUUID *> *)serviceUUIDs options:(nullable NSDictionary<NSString *, id> *)options discover:(void(^_Nullable)(CBPeripheral *_Nullable peripheral,NSDictionary<NSString *, id> *_Nullable advertisementData,NSNumber *_Nullable RSSI))discover;
/**
* 方法说明:停止扫描蓝牙外设
*/
-(void)stopScan;
/**
* 方法说明:更新蓝牙状态
* @param state 更新蓝牙状态
*/
-(void)didUpdateState:(void(^_Nullable)(NSInteger state))state;
/**
* 方法说明:连接外设
* @param peripheral 需要连接的外设
* @param options 其它可选操作
* @param timeout 连接超时
* @param connectState 连接状态
*/
-(void)connectPeripheral:(CBPeripheral *_Nullable)peripheral options:(nullable NSDictionary<NSString *,id> *)options timeout:(NSUInteger)timeout connectBlack:(void(^_Nullable)(ConnectState state)) connectState;
/**
* 方法说明:连接外设
* @param peripheral 需要连接的外设
* @param options 其它可选操作
*/
-(void)connectPeripheral:(CBPeripheral * _Nullable)peripheral options:(nullable NSDictionary<NSString *,id> *)options;
/**
* 方法说明:断开连接
* @param peripheral 需要断开连接的外设
*/
-(void)closePeripheral:(nonnull CBPeripheral *)peripheral;
/**
* 方法说明: 往蓝牙模块中写入数据
* @param data 往蓝牙模块中写入的数据
* @param progress 写入数据的进度
* @param callBack 读取蓝牙模块返回数据
*/
-(void)write:(NSData *_Nullable)data progress:(void(^_Nullable)(NSUInteger total,NSUInteger progress))progress receCallBack:(void (^_Nullable)(NSData *_Nullable))callBack;
/**
* 方法说明: 往蓝牙模块中写入数据
* @param characteristic 特征值
* @param data 往蓝牙模块中写入的数据
* @param type 写入方式<b>CBCharacteristicWriteWithResponse</b>写入方式是带流控写入方式。<b>CBCharacteristicWriteWithoutResponse</b>不带流控写入方式 <p><b>@see CBCharacteristicWriteType</b></p>
*/
-(void)writeValue:(NSData *)data forCharacteristic:(nonnull CBCharacteristic *)characteristic type:(CBCharacteristicWriteType)type;
@end
//
// Connecter.h
// GSDK
//
// Created by 猿史森林 on 2018/6/16.
// Copyright © 2018年 Smarnet. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "ConnecterBlock.h"
@interface Connecter:NSObject
//读取数据
@property(nonatomic,copy)ReadData readData;
//连接状态
@property(nonatomic,copy)ConnectDeviceState state;
/**
* 方法说明: 连接
*/
-(void)connect;
/**
* 方法说明: 连接到指定设备
* @param connectState 连接状态
*/
-(void)connect:(void(^)(ConnectState state))connectState;
/**
* 方法说明: 关闭连接
*/
-(void)close;
/**
* 发送数据
* 向输出流中写入数据
*/
-(void)write:(NSData *)data receCallBack:(void(^)(NSData *data))callBack;
-(void)write:(NSData *)data;
/**
* 读取数据
* @parma data 读取到的数据
*/
-(void)read:(void(^)(NSData *data))data;
@end
//
// ConnecterBlock.h
// GSDK
//
// Created by 猿史森林 on 2018/6/16.
// Copyright © 2018年 Smarnet. All rights reserved.
//
#ifndef ConnecterBlock_h
#define ConnecterBlock_h
#import <CoreBluetooth/CBPeripheral.h>
/**
* @enum ConnectState
* @discussion 连接状态
* @constant CONNECT_STATE_DISCONNECT ConnectDeviceState返回state为该状态是表示已断开连接
* @constant CONNECT_STATE_CONNECTING ConnectDeviceState返回state为该状态是表示正在连接中
* @constant CONNECT_STATE_CONNECTED ConnectDeviceState返回state为该状态是表示连接成功
* @constant CONNECT_STATE_TIMEOUT ConnectDeviceState返回state为该状态是表示连接超时
* @constant CONNECT_STATE_FAILT ConnectDeviceState返回state为该状态是表示连接失败
*/
typedef enum : NSUInteger {
NOT_FOUND_DEVICE,//未找到设备
CONNECT_STATE_DISCONNECT,//断开连接
CONNECT_STATE_CONNECTING,//连接中
CONNECT_STATE_CONNECTED,//连接上
CONNECT_STATE_TIMEOUT,//连接超时
CONNECT_STATE_FAILT//连接失败
}ConnectState;
/**发现设备*/
typedef void(^DiscoverDevice)(CBPeripheral *_Nullable peripheral,NSDictionary<NSString *, id> * _Nullable advertisementData,NSNumber * _Nullable RSSI);
/**蓝牙状态更新*/
typedef void(^UpdateState)(NSInteger state);
/**连接状态*/
typedef void(^ConnectDeviceState)(ConnectState state);
/**读取数据*/
typedef void(^ReadData)(NSData * _Nullable data);
/**发送数据进度 只适用于蓝牙发送数据*/
typedef void(^WriteProgress)(NSUInteger total,NSUInteger progress);
//typedef void (^Error)(id error);
#endif /* ConnecterBlock_h */
//
// EscCommand.h
// Gprinter
//
// Created by Wind on 14/12/22.
// Copyright (c) 2014年 JiaBo. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@interface EscCommand : NSObject
/**
* 方法说明:打印UPCA条码
* @param content 数据范围0-9,长度为11位
*/
-(void) addUPCAtest:(NSString*) content;
/**
* 方法说明:插入文字
* @param text 文本
*/
-(void) addText:(NSString*) text;
/**
* 方法说明:获得打印命令
* @return NSData*
*/
-(NSData*) getCommand;
/**
* 方法说明:将字符串转成十六进制码
* @param str 命令字符串
*/
-(void) addStrToCommand:(NSString *) str;
/**
* 方法说明:打印机初始化,必须是第一个打印命令0x1b,0x40
*/
-(void) addInitializePrinter;
/**
* 方法说明:打印并且走纸多少行,默认为8行,打印完内容后发送
* @param n 行数
*/
-(void) addPrintAndFeedLines:(int) n;
/**
* 方法说明:换行
*/
-(void)addPrintAndLineFeed;
/**
* 方法说明:设置打印模式,0x1B 0x21 n(0-255),根据n的值设置字符打印模式
*@param n 二进制默认为00000000(0X0),10001000(0X88)表示下划线和加粗,00001000(0X08)表示加粗,10000000(0X80)表示下划线
*/
-(void) addPrintMode:(int) n;
/**
* 方法说明:设置国际字符集,默认为美国0
* @param n 字符集编号
*/
-(void) addSetInternationalCharacterSet:(int) n;
/**
* 方法说明:设置字符是否旋转90°,默认为0
* @param n 是否旋转
*/
-(void) addSet90ClockWiseRotatin:(int) n;
/**
* 方法说明:设置对齐方式
* @param n 左 中 右对齐,0左对齐,1中间对齐,2右对齐
*/
-(void) addSetJustification:(int) n;
/**
* 方法说明:开钱箱
* @param m 钱箱引脚号
* @param t1 高电平时间
* @param t2 低电平时间
*/
-(void) addOpenCashDawer:(int) m :(int) t1 :(int) t2;
/**
* 方法说明:蜂鸣器
* @param m 报警灯和鸣叫次数
* @param t 时间
* @param n 方式
*/
-(void) addSound:(int) m :(int) t :(int) n;
/**
* 方法说明:设置行间距,不用设置,打印机默认为30
* @param n 行间距高度,包含文字
*/
-(void) addLineSpacing:(int) n;
/**
* 方法说明:设置倒置模式 选择/取消倒置打印模式。
* @param n 是否倒置,默认为0, 0 ≤n ≤255 当n的最低位为0时,取消倒置打印模式。当n的最低位为1时,选择倒置打印模式。只有n的最低位有效;
*/
-(void) addSetUpsideDownMode:(int) n;
/**
* 方法说明:设置字符放大,限制为不放大和放大2倍,n=0x11
* @param n = width | height 宽度放大倍数,0 ≤n ≤255 (1 ≤ 纵向放大倍数 ≤8,1 ≤ 横向放达倍数 ≤8)[描述] 用0 到2 位选择字符高度,4 到7 位选择字符宽度
*/
-(void) addSetCharcterSize:(int) n;
/**
* 方法说明:设置反白模式,黑白反显打印模式
* @param n 是否反白,当n的最低位为0时,取消反显打印模式。当n的最低位为1时,选择反显打印模式。只有n的最低位有效;
*/
-(void) addSetReverseMode:(int) n;
/**
* 方法说明:打印机实时状态请求
* @param n PRINTER_STATUS 打印机状态 1 ≤n ≤4
* PRINTER_OFFLINE 脱机状态
* PRINTER_ERROR 错误状态
* PRINTER_PAPER 纸张状态
*/
-(void) queryRealtimeStatus:(int) n;
/**
* 方法说明:设置切纸后走纸
* @param n 走纸距离
*/
-(void) addCutPaperAndFeed:(int) n;
/**
* 方法说明:切纸 0全切纸,1是半切
*/
-(void) addCutPaper:(int) m;
/**
* 方法说明:设置条码可识别字符,选择HRI字符的打印位置
* @param n 可识别字符位置,0, 48 不打印 1, 49 条码上方 2, 50 条码下方 3, 51 条码上、下方都打印
*/
-(void) addSetBarcodeHRPosition:(int) n;
/**
* 方法说明:设置条码字符种类,选择HRI使用字体
*/
-(void) addSetBarcodeHRIFont;
/**
* 方法说明:设置条码高度
* @param n 高度 条码高度为n点,默认为40
*/
-(void) addSetBarcodeHeight:(int) n;
/**
* 方法说明:设置条码单元宽度,不用设置,使用打印机内部默认值
* @param n 条码宽度 2 ≤n ≤6
*/
-(void) addSetBarcodeWidth:(int) n;
/**
* 方法说明:打印EAN13码
* @param content 数据范围0-9,长度为12位
*/
-(void) addEAN13:(NSString*) content;
/**
* 方法说明:打印EAN8码
* @param content 数据范围0-9,长度为7位
*/
-(void) addEAN8:(NSString*) content;
/**
* 方法说明:打印UPCA条码
* @param content 数据范围0-9,长度为11位
*/
-(void) addUPCA:(NSString*) content;
/**
* 方法说明:打印ITF14条码
* @param content 数据范围 0-9 数据长度 偶数个
*/
-(void) addITF:(NSString*) content;
/**
* 方法说明:打印CODE39条码
* @param content 数据范围0-9 A-Z SP $ % + - . / ,*为 (开始/结束字符)
*/
-(void) addCODE39:(NSString*) content;
/**
* 方法说明:打印CODE128码
* 采用的是1D 6B 49 n的命令格式,n为后面所有打印字符串的长度,包括了字符集的声明。默认使用CODEB字符集: {B , 0x7B, 0x42
* @param charset ,CODEB字符集有 {A {B {C,charset默认值用B ,实际上,字符集可以插入到content中,一个content可以有多个字符集定义。
* @param content 数据范围0x00-0x7f
*/
-(void) addCODE128:(char) charset :(NSString*) content;
/**
* 方法说明:打印CODE128码支持混合{A {B {C打印,支持58mm纸打印超过14位的奇数数字,例如15位 17位 19位的数字串
* 采用的是1D 6B 49 n的命令格式,n为后面所有打印字符串的长度,包括了字符集的声明。默认使用CODEB字符集: {B , 0x7B, 0x42
* CODEB字符集有 {A {B {C,默认值用B ,实际上,字符集可以插入到data中,一个data可以有多个字符集定义。
* @param height 条码高度
* @param width 条码宽度
* @param data 数据范围0x00-0x7f,全部为16进制
*/
-(void) addCODE128ABC:(int) height :(int) width :(NSData*) data;
/**
* 方法说明:addNVLOGO
* @param n 序号,1<=n<=20 m默认为0
*/
-(void) addNVLOGO:(int) n :(int) m;
/*
十六进制码 1D 76 30 m xL xH yL yH d1...dk
0 ≤ m ≤ 3, 48 ≤ m ≤ 51
0 ≤ xL ≤ 255
0 ≤ xH ≤ 255
0 ≤ yL ≤ 255
0 ≤ yH ≤ 255
0 ≤ d ≤ 255
k = ( xL + xH × 256) × ( yL + yH × 256) ( k ≠ 0)
参 数 说 明
m 模式
0, 48 正常
1, 49 倍宽
2, 50 倍高
3, 51 倍宽、倍高
xL、 xH表示水平方向位图字节数( xL+ xH × 256)
yL、 yH表示垂直方向位图点数( yL+ yH × 256)
data 影像数据
*/
-(void) addESCBitmapwithM:(int) m withxL:(int) xL withxH:(int) xH withyL:(int) yL
withyH:(int) yH withData:(NSData*) data;
/**
* 方法说明:打印光栅位图
* @param image 图片
* @param width 图片宽度
*/
-(void)addOriginrastBitImage:(UIImage *)image width:(int)width;
/**
* 方法说明:打印光栅位图
* @param image 图片
*/
-(void)addOriginrastBitImage:(UIImage *)image;
/*
正确的ESC指令下QRCode打印流程为四步:
1、设定QRCode大小;(可以省略)
2、设定纠错等级;(一般无需设定,忽略)
3、将QRCode对应的文字信息存入打印机缓存中;(必须要有)
4、发送打印QRCode命令。
一共有四个命令对应上述四步。
*/
/*
1、设定QRCode大小;(可以省略)
[格式] ASCII码 GS ( K pL pH cn fn n
十六进制码 1D 28 6B 03 00 31 43 n
[范围] (pL+pH×256)=3 (pL=3,pH=0)
cn=49
fn=67
1 ≤n≤16
[默认值] n=3
*/
-(void) addQRCodeSizewithpL:(int) pL withpH:(int) pH withcn:(int) cn
withyfn:(int) fn withn:(int) n;
/*
2、设定纠错等级;(一般无需设定,忽略)
[格式] ASCII码 GS ( K pL pH cn fn m d1...dk
十六进制码 1D 28 6B 03 00 31 45 n
[范围] (pL+pH×256)=3 (pL=3,pH=0)
cn=49
fn=69
48≤n≤51
[默认值] n=48
*/
-(void) addQRCodeLevelwithpL:(int) pL withpH:(int) pH withcn:(int) cn
withyfn:(int) fn withn:(int) n;
/*
3、将QRCode对应的文字信息存入打印机缓存中;(必须要有)
[格式] ASCII码 GS ( K pL pH cn fn m d1...dk
十六进制码 1D 28 6B pL pH 31 50 30 d1...dk
[范围] 4≤(pL+pH×256)≤7092 (0≤pL≤255,0≤pH≤27)
cn=49
fn=80
m=48
k=(pL+pH×256)-3
[描述] 存储QR CODE数据(d1...dk)到符号存储区
[注释] • 将QRCode的数据存储到打印机中
• 执行esc @或打印机掉电后,恢复默认值
*/
-(void) addQRCodeSavewithpL:(int) pL withpH:(int) pH withcn:(int) cn
withyfn:(int) fn withm:(int) m withData:(NSData*) data;
/*
4、发送打印QRCode命令。
[格式] ASCII码 GS ( K pL pH cn fn m
十六进制码 1D 28 6B 03 00 31 51 m
[范围] (pL+pH×256)=3 (pL=3,pH=0)
cn=49
fn=81
m=48
[描述] 打印QRCode条码,在发送此命令之前,需通过( K< Function 180)命令将QRCode数据存储在打印机中。
*/
-(void) addQRCodePrintwithpL:(int) pL withpH:(int) pH withcn:(int) cn
withyfn:(int) fn withm:(int) m;
/**
* 方法说明:设置是否汉字字体
* @param n 是否倍宽 是否倍高 是否下划线
*/
-(void) addSetKanjiFontMode:(int) n;
/**
* 方法说明:设置汉字有效
*/
-(void) addSelectKanjiMode;
/**
* 方法说明:设置汉字下划线
* @param n 根据 n 的值,选择或取消汉字的下划线:
* n 功能
* 0, 48 取消汉字下划线
* 1, 49 选择汉字下划线(1 点宽)
* 2, 50 选择汉字下划线(2点宽)
*/
-(void)addSetKanjiUnderLine:(int) n;
/**
* 方法说明:设置汉字无效
*/
-(void) addCancelKanjiMode;
/**
* 方法说明:设置字符右间距
* @param n 间距长度
* 0 ≤ n≤255
* [描述] 设置字符的右间距为[n×横向移动单位或纵向移动单位]英寸。
* [注释] • 当字符放大时,右间距随之放大相同的倍数。
* • 此命令设置的值在页模式和标准模式下是相互独立的。
* • 横向或纵向移动单位由GS P指定。改变横向或纵向移动单位不改变当前右间距。
* • GS P 命令可改变水平(和垂直)运动单位。但是该值不得小于最小水平移动量,
* 并且必须为最小水平移动量的偶数单位。
* • 标准模式下,使用横向移动单位。
* • 最大右间距是31 .91 毫米(255/203 英寸) 。 任何超过这个值的设置都自动转换为最
* 大右间距。
* [默认值] n = 0
*/
-(void) addSetCharacterRightSpace:(int) n;
/**
* 方法说明:设置汉字左右间距
* @param n1 左间距 0 ≤ n1 ≤ 255
* @param n2 右间距 0 ≤ n2 ≤ 255
*/
-(void) addSetKanjiLefttandRightSpace:(int) n1 :(int) n2;
/**
* 方法说明:设置加粗模式
* @param n 是否加粗
* 0 ≤ n ≤ 255
* [描述] 选择或取消加粗模式
* 当n的最低位为0时,取消加粗模式。
* 当n的最低位为1 时,选择加粗模式。
* [注释] • n只有最低位有效。
* • ESC ! 同样可以选择/取消加粗模式,最后接收的命令有效。
* [默认值] n = 0
*/
-(void) addTurnEmphasizedModeOnOrOff:(int) n;
/**
* 方法说明:设置加重模式
* @param n 是否加重
* 0 ≤ n ≤ 255
* [描述] 选择/取消双重打印模式。
* • 当n的最低位为0时,取消双重打印模式。
* • 当n的最低位为1 时,选择双重打印模式。
* [注释] • n只有最低位有效。
* • 该命令与加粗打印效果相同。
* [默认值] n = 0
*/
-(void) addTurnDoubleStrikeOnOrOff:(int) n;
/**
* 方法说明:发送16进制数据,例如data=0x0A或data=0x0D
*/
-(void) addNSDataToCommand:(NSData*) data;
/**
* 方法说明:设置水平和垂直单位距离
* @param x 水平单位
* @param y 垂直单位
*/
-(void)addSetHorAndVerMotionUnitsX:(int)x Y:(int)y;
/**
* 方法说明:设置绝对打印位置
* @param n 与起始打印位置距离
*/
-(void)addSetAbsolutePrintPosition:(int)n;
/**
* 方法说明:设置打印宽度
*
* @param width
* 打印宽度
*/
-(void)addSetPrintingAreaWidth:(int)width;
/**
* 方法说明: 票据默认倍高(重启不失效)
* @param n1 宽 默认为0,翻倍为1
* @param n2 高 默认为0,翻倍为1
* @param n3 汉字宽 默认为0,翻倍为1
* @param n4 汉字高 默认为0,翻倍为1
*/
-(void)receiptDoubleHeightOrDefaultPrintN1:(int)n1 N2:(int)n2 N3:(int)n3 N4:(int)n4;
/**
* 方法说明: 设置默认代码页
* @param n 代码页 n的参数范围为(0-10,16-32,50-89)
*/
-(void)setDefaultCodePage:(int)n;
/**
* 方法说明: 波特率
* @param baudRate 波特率
*/
-(void)setBaudRate:(int)baudRate;
/**
* 方法说明: 查询打印机电量。
* <p>返回值: 31(低电量);32 (中电量);33 (高电量);35 (正在充电)</p>
*
*/
-(void)queryElectricity;
@end
//
// EthernetConnecter.h
// GSDK
//
// Created by 猿史森林 on 2018/6/16.
// Copyright © 2018年 猿史森林. All rights reserved.
//
#import "Connecter.h"
@interface EthernetConnecter :Connecter
/**连接设备的ip地址*/
@property(nonatomic,strong)NSString *ip;
/**连接设备的端口号*/
@property(nonatomic,assign)int port;
//+(instancetype)sharedInstance;
/**
* 方法说明: 连接设备
* @param ip 连接设备的ip地址
* @param port 连接设备的端口号
* @param connectState 连接状态 @see ConnectState
* @param callback 输入流数据回调
*/
-(void)connectIP:(NSString *)ip port:(int)port connectState:(void (^)(ConnectState state))connectState callback:(void(^)(NSData *data))callback;
-(void)connectIP:(NSString *)ip port:(int)port connectState:(void (^)(ConnectState))connectState;
@end
//
// TscCommand.h
// Gprinter
//
// Created by Wind on 2018/6/15.
// Copyright (c) 2018年 Smarnet. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
typedef NS_ENUM (NSUInteger,Response){
OFF = 0,//关闭自动返回状态功能
ON = 1,//打开自动返回状态功能,每打印完一张返回一次
BATCH = 2,//打开自动返回状态功能,打印完毕后返回一次
};
@interface TscCommand : NSObject
/**
* 方法说明:设置标签尺寸的宽和高
* @param width 标签宽度
* @param height 标签高度
*/
-(void) addSize:(int) width :(int) height;
/**
* 方法说明:设置标签间隙尺寸 单位mm
* @param m 间隙长度
* @param n 间隙偏移
*/
-(void) addGapWithM:(int) m withN:(int) n;
/**
* 方法说明:设置标签原点坐标
* @param x 横坐标
* @param y 纵坐标
*/
-(void) addReference:(int) x :(int)y;
/**
* 方法说明:设置打印速度
* @param speed 打印速度
*/
-(void) addSpeed:(int) speed;
/**
* 方法说明:设置打印浓度
* @param density 浓度
*/
-(void) addDensity:(int) density;
/**
* 方法说明:设置打印方向
* @param direction 方向
*/
-(void) addDirection:(int) direction;
/**
* 方法说明:清除打印缓冲区
*/
-(void) addCls;
/**
* 方法说明:在标签上绘制文字
* @param x 横坐标
* @param y 纵坐标
* @param font 字体类型
* @param rotation 旋转角度
* @param xScal 横向放大
* @param yScal 纵向放大
* @param text 文字字符串
*/
-(void) addTextwithX:(int)x withY:(int)y withFont:(NSString*)font withRotation:(int)rotation withXscal:(int)xScal withYscal:(int)yScal withText:(NSString*)text;
/*
BITMAP X, Y, width, height, mode, bitmap data
参 数 说 明
x 点阵影像的水平启始位置
y 点阵影像的垂直启始位置
width 影像的宽度,以 byte 表示
height 影像的高度,以点(dot)表示
mode 影像绘制模式
0 OVERWRITE
1 OR
2 XOR
bitmap data 影像数据
*/
-(void) addBitmapwithX:(int)x withY:(int) y withWidth:(int) width withHeight:(int) height withMode:(int) mode withData:(NSData*) data;
-(void)addBitmapwithX:(int)x withY:(int)y withMode:(int)mode withWidth:(int)width withImage:(UIImage *)image;
-(void)addBitmapwithX:(int)x withY:(int)y withMode:(int)mode withImage:(UIImage *)image;
/**
* 方法说明:在标签上绘制一维条码
* @param x 横坐标
* @param y 纵坐标
* @param barcodeType 条码类型
* @param height 条码高度,默认为40
* @param readable 是否可识别,0: 人眼不可识,1: 人眼可识
* @param rotation 旋转角度,条形码旋转角度,顺时钟方向,0不旋转,90顺时钟方向旋转90度,180顺时钟方向旋转180度,270顺时钟方向旋转270度
* @param narrow 默认值2,窄 bar 宽度,以点(dot)表示
* @param wide 默认值4,宽 bar 宽度,以点(dot)表示
* @param content 条码内容
BARCODE X,Y,"code type",height,human readable,rotation,narrow,wide,"code"
BARCODE 100,100,"39",40,1,0,2,4,"1000"
BARCODE 10,10,"128",40,1,0,2,2,"124096ABCDEFZ$%+-./*"
"code type":
EAN13("EAN13"),
EAN8("EAN8"),
UPCA("UPCA"),
ITF14("ITF14"),
CODE39("39"),
CODE128("128"),
*/
-(void) add1DBarcode:(int)x :(int)y :(NSString*)barcodeType :(int)height :(int)readable :(int)rotation :(int)narrow :(int)wide :(NSString*)content;
/**
* 方法说明:在标签上绘制QRCode二维码
* @param x 横坐标
* @param y 纵坐标
* @param ecclever 选择QRCODE纠错等级,L为7%,M为15%,Q为25%,H为30%
* @param cellwidth 二维码宽度1~10,默认为4
* @param mode 默认为A,A为Auto,M为Manual
* @param rotation 旋转角度,QRCode二维旋转角度,顺时钟方向,0不旋转,90顺时钟方向旋转90度,180顺时钟方向旋转180度,270顺时钟方向旋转270度
* @param content 条码内容
* QRCODE X,Y ,ECC LEVER ,cell width,mode,rotation, "data string"
* QRCODE 20,24,L,4,A,0,"佳博集团网站www.Gprinter.com.cn"
*/
-(void) addQRCode:(int)x :(int)y :(NSString*)ecclever :(int)cellwidth :(NSString*)mode :(int)rotation :(NSString*)content;
/**
* 方法说明:执行打印
* @param m
* @param n
*/
-(void) addPrint:(int) m :(int) n;
/**
* 方法说明:获得打印命令
*/
-(NSData*) getCommand;
/**
* 方法说明:将字符串转成十六进制码
* @param str 命令字符串
*/
-(void) addStrToCommand:(NSString *) str;
-(void) addNSDataToCommand:(NSData*) data;
/**
* 方法说明:发送一些TSC的固定命令,在cls命令之前发送
*/
-(void) addComonCommand;
/**
* 方法说明:打印自检页,打印测试页
*/
-(void) addSelfTest;
/**
* 方法说明 :查询打印机型号
*/
-(void) queryPrinterType;
/**
* 方法说明:设置打印机剥离模式
* @param peel ON/OFF 是否开启
*/
-(void) addPeel:(NSString *) peel;
/**
* 方法说明:设置打印机撕离模式
* @param tear ON/OFF 是否开启
*/
-(void) addTear:(NSString *) tear;
/**
* 方法说明:设置切刀是否有效
* @param cutter 是否开启 OFF/pieces (0<=pieces<=127)设定几张标签切一次
*/
-(void) addCutter:(NSString *) cutter;
/**
* 方法说明:设置切刀半切是否有效
* @param cutter 是否开启
*/
-(void) addPartialCutter:(NSString *) cutter;
/**
* 方法说明:设置蜂鸣器
* @param level 频率
* @param interval 时间ms
*/
-(void) addSound:(int) level :(int) interval;
/**
* 方法说明:打开钱箱命令,CASHDRAWER m,t1,t2
* @param m 钱箱号 m 0,48 钱箱插座的引脚2 1,49 钱箱插座的引脚5
* @param t1 高电平时间0 ≤ t1 ≤ 255输出由t1和t2设定的钱箱开启脉冲到由m指定的引脚
* @param t2 低电平时间0 ≤ t2 ≤ 255输出由t1和t2设定的钱箱开启脉冲到由m指定的引脚
*/
-(void) addCashdrawer:(int) m :(int) t1 :(int) t2;
/**
* 方法说明:在标签上绘制黑块,画线
* @param x 起始横坐标
* @param y 起始纵坐标
* @param width 线宽,以点(dot)表示
* @param height 线高,以点(dot)表示
*/
-(void) addBar:(int) x :(int) y :(int) width :(int) height;
/**
* 方法说明:在标签上绘制矩形
* @param xStart 起始横坐标
* @param yStart 起始纵坐标
* @param xEnd 终点横坐标
* @param yEnd 终点纵坐标
* @param lineThickness 矩形框线厚度或宽度,以点(dot)表示
*/
-(void) addBox:(int) xStart :(int) yStart :(int) xEnd :(int) yEnd :(int) lineThickness;
/**
* 方法说明:查询打印机状态<ESC>!?
*询问打印机状态指令为立即响应型指令,该指令控制字符是以<ESC> (ASCII 27=0x1B, escape字符)为控制字符.!(ASCII 33=0x21),?(ASCII 63=0x3F)
*即使打印机在错误状态中仍能透过 RS-232 回传一个 byte 资料来表示打印机状态,若回传值为 0 则表示打印
*机处于正常的状态
*/
-(void) queryPrinterStatus;
/**
* 方法说明:将指定的区域反向打印(黑色变成白色,白色变成黑色)
* @param xStart 起始横坐标
* @param yStart 起始横坐标
* @param xWidth X坐标方向宽度,dot为单位
* @param yHeight Y坐标方向高度,dot为单位
*/
-(void) addReverse:(int) xStart :(int) yStart :(int) xWidth :(int) yHeight;
/**
* 方法说明: 打印机打印完成时,自动返回状态。可用于实现连续打印功能
* @param response 自动返回状态 <a>@see Response</a>
* OFF 关闭自动返回状态功能
* ON 开启自动返回状态功能
* BATCH 全部打印完成后返回状态
*/
-(void)addQueryPrinterStatus:(Response)response;
/**
* 方法说明: 查询打印机电量。
* <p>返回值: 31(低电量);32 (中电量);33 (高电量);35 (正在充电)</p>
*
*/
-(void)queryElectricity;
@end
......@@ -198,7 +198,21 @@ class NewCKVc: BaseViewController,UITableViewDelegate,UITableViewDataSource,CKNo
}
var goodsInfoArr:Array<Any> = []
@IBOutlet weak var gm_view: UIView!
@IBAction func ck_action(_ sender: UIButton) {
let command = TscCommand()
command.addSize(40, 30)
command.addGap(withM: 2, withN: 0)
command.addReference(0, 0)
command.addTear("ON")
command.addQueryPrinterStatus(Response(rawValue: 1)!)
command.addCls()
let image = UIImage(named: "3.png")
command.addBitmapwithX(0, withY: 0, withMode: 0, withWidth: 400, with: image)
command.addPrint(1, 1)
ConnecterManager.sharedInstance()?.write(command.getCommand())
return
if isGm {
if typeSelect == nil {
......
......@@ -32,6 +32,7 @@ class XiaYunDanViewController: BaseViewController,UITableViewDelegate,UITableVie
vc.receiveArr = pph_receive_arr
vc.add_order_time = (model.data?.create_time)!
vc.wb_no = pph_wb_no
vc.lwb_no = pph_lwb_no
vc.car_type = pphCarTypesArr[pph_selectCarType].name!
vc.price = totalPrice
vc.pay_time = (model.data?.pay_time)!
......@@ -47,6 +48,7 @@ class XiaYunDanViewController: BaseViewController,UITableViewDelegate,UITableVie
var paymentView:PaymentView?
var res = -1
var pph_wb_no = ""
var pph_lwb_no = ""
@IBAction func PPH_PayAction(_ sender: Any) {
if apply_btn.isSelected == false {
HUD.flash(.label("您好,请同意《电子运单契约条款》,方可下单。谢谢"), delay: 1.2)
......@@ -114,6 +116,7 @@ class XiaYunDanViewController: BaseViewController,UITableViewDelegate,UITableVie
addPinPinOrder(dict) {[self] (data) in
let model = data as! addPinPinOrder_model
self.pph_wb_no = (model.data?.wb_no)!
self.pph_lwb_no = (model.data?.lwb_no)!
if paymentView == nil{
paymentView = PaymentView(frame: view.bounds)
paymentView?.delegate = self
......
......@@ -127,7 +127,7 @@ class PPH_YDXQ_VC: BaseViewController,UITableViewDelegate,UITableViewDataSource,
let l = (modelData?.pph_info!.driverMobile)!.suffix(3)
mobile = (modelData?.pph_info!.driverMobile)!
if (modelData?.pph_info?.driverName!.count)! > 0 {
driver = (modelData?.pph_info!.driverName)! + "(\(f)*****\(l)"
driver = (modelData?.pph_info!.driverName)! + "(\(f)*****\(l))"
}
if (modelData?.sale_plat!.count)! > 0 {
plan = (modelData?.sale_plat)!
......
......@@ -9,7 +9,7 @@
import UIKit
class PPH_SUC_VC: BaseViewController,UITableViewDelegate,UITableViewDataSource {
var lwb_no = ""
var sendArr:Array<addPinPinOrder_adrInfo>?
var receiveArr:Array<addPinPinOrder_adrInfo>?
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
......@@ -27,7 +27,7 @@ class PPH_SUC_VC: BaseViewController,UITableViewDelegate,UITableViewDataSource {
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if indexPath.section == 0 {
let cell = tableView.dequeueReusableCell(withIdentifier: "Suc_Top_Cell") as! Suc_Top_Cell
cell.wb_no_lbl.text = wb_no
cell.wb_no_lbl.text = lwb_no
cell.order_time_lbl.text = add_order_time
return cell
}
......
......@@ -7,11 +7,12 @@
//
#import <UIKit/UIKit.h>
#import "ConnecterManager.h"
NS_ASSUME_NONNULL_BEGIN
@interface BtViewController : UIViewController
@property(nonatomic,copy)ConnectDeviceState state;
@end
NS_ASSUME_NONNULL_END
......@@ -16,97 +16,95 @@
@interface BtViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (weak, nonatomic) IBOutlet UITableView *tableView;
@property (strong, nonatomic)NSMutableArray *deviceArray; /**< 蓝牙设备个数 */
@property (strong, nonatomic)NSMutableArray *devices; /**< 蓝牙设备个数 */
@property (strong, nonatomic)NSMutableArray *selectArray;//选择蓝牙
@property (copy, nonatomic) void(^printBlock)(HLPrinter *printer);
@property (nonatomic, strong) HLBLEManager *manager;
@property(nonatomic,strong)NSMutableDictionary *dicts;
@end
@implementation BtViewController
-(NSMutableArray *)devices {
if (!_devices) {
_devices = [[NSMutableArray alloc]init];
}
return _devices;
}
-(NSMutableDictionary *)dicts {
if (!_dicts) {
_dicts = [[NSMutableDictionary alloc]init];
}
return _dicts;
}
- (IBAction)backAction:(id)sender {
[self.navigationController popViewControllerAnimated:YES];
}
-(void)dealloc{
[Manager close];
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
_deviceArray = [[NSMutableArray alloc] init];
_selectArray = [[NSMutableArray alloc]init];
if (!_selectArray) {
_selectArray = [NSMutableArray array];
}
_tableView.rowHeight = 44;
[_tableView registerNib:[UINib nibWithNibName:@"Bt_Cell" bundle:NULL] forCellReuseIdentifier:@"Bt_Cell"];
HLBLEManager *manager = [HLBLEManager sharedInstance];
__weak HLBLEManager *weakManager = manager;
manager.stateUpdateBlock = ^(CBCentralManager *central) {
NSString *info = nil;
switch (central.state) {
case CBCentralManagerStatePoweredOn:
info = @"蓝牙已打开,并且可用";
//三种种方式
// 方式1
[weakManager scanForPeripheralsWithServiceUUIDs:nil options:nil];
// // 方式2
// [central scanForPeripheralsWithServices:nil options:nil];
// // 方式3
// [weakManager scanForPeripheralsWithServiceUUIDs:nil options:nil didDiscoverPeripheral:^(CBCentralManager *central, CBPeripheral *peripheral, NSDictionary *advertisementData, NSNumber *RSSI) {
//
// }];
break;
case CBCentralManagerStatePoweredOff:
info = @"蓝牙可用,未打开";
break;
case CBCentralManagerStateUnsupported:
info = @"SDK不支持";
break;
case CBCentralManagerStateUnauthorized:
info = @"程序未授权";
break;
case CBCentralManagerStateResetting:
info = @"CBCentralManagerStateResetting";
break;
case CBCentralManagerStateUnknown:
info = @"CBCentralManagerStateUnknown";
break;
}
[SVProgressHUD setDefaultStyle:SVProgressHUDStyleDark];
[SVProgressHUD showInfoWithStatus:info ];
};
manager.discoverPeripheralBlcok = ^(CBCentralManager *central, CBPeripheral *peripheral, NSDictionary *advertisementData, NSNumber *RSSI) {
if (peripheral.name.length <= 0) {
return ;
}
if (self.deviceArray.count == 0) {
NSDictionary *dict = @{@"peripheral":peripheral, @"RSSI":RSSI};
[self.deviceArray addObject:dict];
} else {
BOOL isExist = NO;
for (int i = 0; i < self.deviceArray.count; i++) {
NSDictionary *dict = [self.deviceArray objectAtIndex:i];
CBPeripheral *per = dict[@"peripheral"];
if ([per.identifier.UUIDString isEqualToString:peripheral.identifier.UUIDString]) {
isExist = YES;
NSDictionary *dict = @{@"peripheral":peripheral, @"RSSI":RSSI};
[_deviceArray replaceObjectAtIndex:i withObject:dict];
}
}
-(void)viewDidAppear:(BOOL)animated {
if (Manager.bleConnecter == nil) {
[Manager didUpdateState:^(NSInteger state) {
switch (state) {
case CBCentralManagerStateUnsupported:
NSLog(@"The platform/hardware doesn't support Bluetooth Low Energy.");
break;
case CBCentralManagerStateUnauthorized:
NSLog(@"The app is not authorized to use Bluetooth Low Energy.");
break;
case CBCentralManagerStatePoweredOff:
NSLog(@"Bluetooth is currently powered off.");
break;
case CBCentralManagerStatePoweredOn:
[self startScane];
NSLog(@"Bluetooth power on");
break;
case CBCentralManagerStateUnknown:
default:
break;
}
if (!isExist) {
NSDictionary *dict = @{@"peripheral":peripheral, @"RSSI":RSSI};
[self.deviceArray addObject:dict];
}];
} else {
[self startScane];
}
}
-(void)startScane {
[Manager scanForPeripheralsWithServices:nil options:nil discover:^(CBPeripheral * _Nullable peripheral, NSDictionary<NSString *,id> * _Nullable advertisementData, NSNumber * _Nullable RSSI) {
if (peripheral.name != nil) {
NSLog(@"name -> %@",peripheral.name);
NSUInteger oldCounts = [self.dicts count];
[self.dicts setObject:peripheral forKey:peripheral.identifier.UUIDString];
if (oldCounts < [self.dicts count]) {
[_tableView reloadData];
}
}
[self.tableView reloadData];
};
}];
}
-(void)viewDidDisappear:(BOOL)animated{
[super viewWillDisappear:animated];
[Manager stopScan];
}
#pragma mark - UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
......@@ -118,39 +116,57 @@
if (section == 0) {
return _selectArray.count;
}
return _deviceArray.count;
return [[self.dicts allKeys]count];;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[Manager closePeripheral: _selectArray.firstObject];
[self.selectArray removeAllObjects];
if (indexPath.section == 1){
NSDictionary *dict = [self.deviceArray objectAtIndex:indexPath.row];
CBPeripheral *peripheral = dict[@"peripheral"];
[self.selectArray addObject:peripheral];
[self loadBLEInfo];
[tableView reloadData];
if (indexPath.section == 1) {
CBPeripheral *peripheral = [self.dicts objectForKey:[self.dicts allKeys][indexPath.row]];
[self connectDevice:peripheral];
}else{
[_manager cancelPeripheralConnection];
[SVProgressHUD showErrorWithStatus:@"断开连接"];
}
[_tableView reloadData];
}
-(void)connectDevice:(CBPeripheral *)peripheral {
[Manager connectPeripheral:peripheral options:nil timeout:2 connectBlack:^(ConnectState state) {
if (state == 3) {
if ([_selectArray count] == 0) {
[self.selectArray addObject:peripheral];
[_tableView reloadData];
}
[SVProgressHUD showSuccessWithStatus:@"连接成功"];
}
if (state == 5){
[SVProgressHUD showErrorWithStatus:@"连接失败"];
}
}];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
Bt_Cell *cell = [tableView dequeueReusableCellWithIdentifier:@"Bt_Cell"];
NSDictionary *dict = [self.deviceArray objectAtIndex:indexPath.row];
CBPeripheral *peripherral = dict[@"peripheral"];
CBPeripheral *peripheral = [self.dicts objectForKey:[self.dicts allKeys][indexPath.row]];
cell.title_lbl.text = peripheral.name;
cell.statusImg.hidden = YES;
if (indexPath.section == 0) {
CBPeripheral *p = _selectArray[0];
cell.statusImg.hidden = NO;
cell.title_lbl.text = p.name;
}
cell.title_lbl.text = peripherral.name;
return cell;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
......@@ -179,7 +195,7 @@
}
break;
}
return view;
return view;
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 46)];
......@@ -202,79 +218,6 @@
}
return view;
}
// UIWebView *webView = [[UIWebView alloc]init];
// webView.delegate = self;
// [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"https://c.gelifood.com/market/src/views/Order/codeDetail.html?order_id=12767"]]];
//- (void)webViewDidFinishLoad:(UIWebView *)webView
//{
// HLPrinter *printer = [[HLPrinter alloc] init];
// UIImage *image = [webView imageForWebView];
// [printer appendImage:image alignment:HLTextAlignmentLeft maxWidth:450];
//
// if (_printBlock) {
// _printBlock(printer);
// }
//}
- (void)loadBLEInfo
{
CBPeripheral *perpheral = _selectArray.firstObject;
HLBLEManager *manager = [HLBLEManager sharedInstance];
_manager = manager;
[manager connectPeripheral:perpheral
connectOptions:@{CBConnectPeripheralOptionNotifyOnDisconnectionKey:@(YES)}
stopScanAfterConnected:YES
servicesOptions:nil
characteristicsOptions:nil
completeBlock:^(HLOptionStage stage, CBPeripheral *peripheral, CBService *service, CBCharacteristic *character, NSError *error) {
switch (stage) {
case HLOptionStageConnection:
{
if (error) {
[SVProgressHUD showErrorWithStatus:@"连接失败"];
} else {
[SVProgressHUD showSuccessWithStatus:@"连接成功"];
}
break;
}
case HLOptionStageSeekServices:
{
if (error) {
// [SVProgressHUD showSuccessWithStatus:@"查找服务失败"];
} else {
// [SVProgressHUD showSuccessWithStatus:@"查找服务成功"];
}
break;
}
case HLOptionStageSeekCharacteristics:
{
// 该block会返回多次,每一个服务返回一次
if (error) {
NSLog(@"查找特性失败");
} else {
NSLog(@"查找特性成功");
[_tableView reloadData];
}
break;
}
case HLOptionStageSeekdescriptors:
{
// 该block会返回多次,每一个特性返回一次
if (error) {
NSLog(@"查找特性的描述失败");
} else {
// NSLog(@"查找特性的描述成功");
}
break;
}
default:
break;
}
}];
}
@end
......@@ -821,7 +821,7 @@ class YDLBVc: BaseViewController,UITableViewDelegate,UITableViewDataSource,UISea
cell.acButton.setTitle("支付运费", for: .normal)
}
}else{
if rowModel.delivery_status == 1 {
if rowModel.delivery_status == 1 && rowModel.lc_name != "拼拼货"{
cell.acButton.isHidden = false
cell.acButton.setTitle("取消运单", for: .normal)
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment