IOS蓝牙小票打印

本文介绍了如何在iOS平台上使用蓝牙小票打印机的SDK进行小票打印。主要内容包括引入SDK静态库和头文件、创建UartLib对象并设置代理、实现蓝牙设备的搜索、连接、断开及打印内容的方法,通过代理方法控制蓝牙状态,并通过定时器发送打印指令完成小票打印。
摘要由CSDN通过智能技术生成

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
评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值