BLEManager Class Reference
Inherits from | NSObject |
---|---|
Conforms to | CBCentralManagerDelegate CBPeripheralDelegate |
Declared in | BLEManager.h BLEManager.m |
Other Methods
scanBlock
Peripheral device scan callback
@property (copy, nonatomic) BleManagerDiscoverPeripheralCallBack scanBlock
Discussion
Peripheral device scan callback
Declared In
BLEManager.h
connectBlock
Connect Bluetooth callback
@property (copy, nonatomic) BleManagerConnectPeripheralCallBack connectBlock
Discussion
Connect Bluetooth callback
Declared In
BLEManager.h
receiveBlock
Receive data callback
@property (nonatomic, copy) BleManagerReceiveCallBack receiveBlock
Discussion
Receive data callback
Declared In
BLEManager.h
+ sharedBLEManager
Singleton method
+ (instancetype)sharedBLEManager
Return Value
self
Discussion
Singleton method
Declared In
BLEManager.h
– startScan
Turn on Bluetooth scanning
- (void)startScan
Discussion
Turn on Bluetooth scanning
Declared In
BLEManager.h
– startScanWithInterval:completion:
Start scanning and stop after scanInterval seconds
- (void)startScanWithInterval:(NSInteger)scanInterval completion:(BleManagerDiscoverPeripheralCallBack)callBack
Parameters
scanInterval |
scanInterval |
---|---|
callBack |
callBack |
Discussion
Start scanning and stop after scanInterval seconds
Declared In
BLEManager.m
– connectPeripheral:
Connect to specified device
- (void)connectPeripheral:(CBPeripheral *)peripheral
Discussion
Connect to specified device
Declared In
BLEManager.h
– connectPeripheral:completion:
Connect bluetooth device
- (void)connectPeripheral:(CBPeripheral *)peripheral completion:(BleManagerConnectPeripheralCallBack)callBack
Parameters
peripheral |
Peripheral |
---|---|
callBack |
CallBack |
Discussion
Connect bluetooth device
Declared In
BLEManager.m
– reConnectPeripheral:
Reconnect device
- (void)reConnectPeripheral:(CBPeripheral *)peripheral
Parameters
peripheral |
Peripheral |
---|
Discussion
Reconnect device
Declared In
BLEManager.m
– disconnectPeripheral:
Disconnect the specified peripheral
- (void)disconnectPeripheral:(CBPeripheral *)peripheral
Discussion
Disconnect the specified peripheral
Declared In
BLEManager.h
– sendDataWithPeripheral:withString:coding:
Send data to the device, the data sent is of type NSString, and the encoding type must be specified
- (void)sendDataWithPeripheral:(CBPeripheral *)peripheral withString:(NSString *)dataString coding:(NSStringEncoding)EncodingType
Parameters
peripheral |
peripheral |
---|---|
dataString |
Data sent |
EncodingType |
EncodingType |
Discussion
Send data to the device, the data sent is of type NSString, and the encoding type must be specified
Declared In
BLEManager.h
– writeCommadnToPrinterWthitData:
Send instructions to the printer
- (void)writeCommadnToPrinterWthitData:(NSData *)data
Parameters
data |
Command sent |
---|
Discussion
Send instructions to the printer
Declared In
BLEManager.h
– writeCommadnToPrinterWthitData:withResponse:
Send instructions to the printer with callback method
- (void)writeCommadnToPrinterWthitData:(NSData *)data withResponse:(BleManagerReceiveCallBack)block
Parameters
data |
Data sent |
---|---|
block |
CallBack |
Discussion
Send instructions to the printer with callback method
Declared In
BLEManager.h
– disconnectRootPeripheral
断开设备
- (void)disconnectRootPeripheral
Discussion
断开设备
Declared In
BLEManager.m
– GetBuffer
32.Return the contents of the buffer to be sent
- (NSArray *)GetBuffer
Discussion
32.Return the contents of the buffer to be sent
Declared In
BLEManager.h
– ClearBuffer
33.Clear buffer contents
- (void)ClearBuffer
Discussion
33.Clear buffer contents
Declared In
BLEManager.h
– SendCommandBuffer
34.Send buffer command
- (void)SendCommandBuffer
Discussion
34.Send buffer command
Declared In
BLEManager.h
– sendCommand:
34.Send a single command
- (void)sendCommand:(NSData *)data
Parameters
data |
发送的数据 |
---|
Discussion
34.Send a single command
Declared In
BLEManager.h
– ZywellSetCommandMode:
Set command mode
- (void)ZywellSetCommandMode:(int)Mode
Parameters
Mode |
mode |
---|
Discussion
Set command mode
Declared In
BLEManager.h
Other Methods
– checkConnectedPeripherals
Check connected devices
- (BOOL)checkConnectedPeripherals
Discussion
Check connected devices
Declared In
BLEManager.m
– centralManagerDidUpdateState:
Device Bluetooth status has changed
- (void)centralManagerDidUpdateState:(CBCentralManager *)central
Parameters
central |
Central Management Object |
---|
Discussion
Device Bluetooth status has changed
Declared In
BLEManager.m
– centralManager:didDiscoverPeripheral:advertisementData:RSSI:
Discover Bluetooth devices
- (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)aPeripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI
Parameters
central |
Central Management Object |
---|---|
aPeripheral |
Device Information |
advertisementData |
Broadcast data |
RSSI |
Signal strength |
Discussion
Discover Bluetooth devices
Declared In
BLEManager.m
– centralManager:didRetrievePeripherals:
When the central manager is called to retrieve the known peripherals in the list. Automatically connect to the first known peripheral
- (void)centralManager:(CBCentralManager *)central didRetrievePeripherals:(NSArray *)peripherals
Parameters
central |
Central manager |
---|---|
peripherals |
Device Information |
Discussion
When the central manager is called to retrieve the known peripherals in the list. Automatically connect to the first known peripheral
Declared In
BLEManager.m
– centralManager:didConnectPeripheral:
Connected to the device—–every time the call is successfully created to connect to the peripheral. Peripheral discovery of available services
- (void)centralManager:(CBCentralManager *)central didConnectPeripheral:(CBPeripheral *)aPeripheral
Parameters
central |
Central manager |
---|---|
aPeripheral |
Device Information |
Discussion
Connected to the device—–every time the call is successfully created to connect to the peripheral. Peripheral discovery of available services
Declared In
BLEManager.m
– centralManager:didDisconnectPeripheral:error:
Device is disconnected
- (void)centralManager:(CBCentralManager *)central didDisconnectPeripheral:(CBPeripheral *)aPeripheral error:(NSError *)error
Parameters
central |
Central manager |
---|---|
aPeripheral |
Device Information |
error |
wrong description |
Discussion
Device is disconnected
Declared In
BLEManager.m
– centralManager:didFailToConnectPeripheral:error:
Failed to connect to device
- (void)centralManager:(CBCentralManager *)central didFailToConnectPeripheral:(CBPeripheral *)aPeripheral error:(NSError *)error
Parameters
central |
Central manager |
---|---|
aPeripheral |
Device Information |
error |
wrong description |
Discussion
Failed to connect to device
Declared In
BLEManager.m
– peripheral:didDiscoverServices:
Discovery Service
- (void)peripheral:(CBPeripheral *)aPeripheral didDiscoverServices:(NSError *)error
Parameters
aPeripheral |
Device Information |
---|---|
error |
wrong description |
Discussion
Discovery Service
Declared In
BLEManager.m
– peripheral:didDiscoverCharacteristicsForService:error:
Discovery of service characteristic values
- (void)peripheral:(CBPeripheral *)aPeripheral didDiscoverCharacteristicsForService:(CBService *)service error:(NSError *)error
Parameters
aPeripheral |
Device Information |
---|---|
service |
服务 |
error |
wrong description |
Discussion
Discovery of service characteristic values
Declared In
BLEManager.m
– peripheralDidUpdateRSSI:error:
获取蓝牙的信号强度
- (void)peripheralDidUpdateRSSI:(CBPeripheral *)peripheral error:(NSError *)error
Parameters
peripheral |
Device Information |
---|---|
error |
wrong description |
Discussion
获取蓝牙的信号强度
Declared In
BLEManager.m
– peripheral:didUpdateValueForCharacteristic:error:
收到数据
- (void)peripheral:(CBPeripheral *)aPeripheral didUpdateValueForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error
Parameters
aPeripheral |
Device Information |
---|---|
characteristic |
characteristic |
error |
wrong description |
Discussion
收到数据
Declared In
BLEManager.m
– peripheral:didWriteValueForCharacteristic:error:
写入数据成功
- (void)peripheral:(CBPeripheral *)peripheral didWriteValueForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error
Parameters
peripheral |
Device Information |
---|---|
characteristic |
characteristic |
error |
wrong description |
Discussion
写入数据成功
Declared In
BLEManager.m
– connectTimeOutAction
Connection timed out
- (void)connectTimeOutAction
Discussion
Connection timed out
Declared In
BLEManager.m
– disconnectForReScan
再次扫描前断开连接
- (void)disconnectForReScan
Discussion
再次扫描前断开连接
Declared In
BLEManager.m