IOS蓝牙小票打印
一、首先,蓝牙小票打印机,有自己的demoSDK
1.我这里的SDK ,主要有两个文件,一:libUartLib.a 二:UartLib.h 即封装好的静态库,和头文件
UartLib.h 代码:
#import <Foundation/Foundation.h>
#import <CoreBluetooth/CoreBluetooth.h>
typedef enum {
DISCONNECT =0X00,
CONNECTING,
CONNECTED,
}ConnectStatus;
/***********************************
Ble scan Delegate
*************************************/
@protocol BleScanDelegate <NSObject>
- (void) peripheralItemRefresh;
- (void) peripheralStatePoweredOff;
@end
@protocol UartDelegate <NSObject>
/*!
* @method didBluetoothPoweredOff
*
*
*/
- (void) didBluetoothPoweredOff;
/*!
* @method didScanedPeripherals:(NSMutableArray *)foundPeripherals
*
* @param foundPeripherals A <code>foundPeripherals</code> object.
*
* @discussion This method is invoked while scanning, upon the discovery
*
*/
- (void) didScanedPeripherals:(NSMutableArray *)foundPeripherals;
/*!
* @method didConnectPeripheral:(CBPeripheral *)peripheral
*
* @param peripheral The <code>CBPeripheral</code> that has connected.
*
* @discussion This method is invoked when a connection initiated by@link UartLib:ConnectPeripheral: @/link has succeeded.
*
*/
- (void) didConnectPeripheral:(CBPeripheral *)peripheral;
/*!
* @method didDisconnectPeripheral:(CBPeripheral *)peripheral error:(NSError *)error;
*
* @param peripheral The <code>CBPeripheral</code> that has disconnected.
* @param error If an error occurred, the cause of the failure.
*
* @discussion This method is invoked upon the disconnection of a peripheral that was connected by@link UartLib:ConnectPeripheral: @/link. If the disconnection
* was not initiated by @link UartLib:disconnectPeripheral: @/link, the cause will be detailed in the <i>error</i> parameter.
*
*/
- (void) didDisconnectPeripheral:(CBPeripheral *)peripheral error:(NSError *)error;
- (void) didReceiveData:(CBPeripheral *)peripheral recvData:(NSData *)recvData;
- (void) didWriteData:(CBPeripheral *)peripheral error:(NSError