要使用CocoaPods安装wiseBle,请将其集成到您现有的Podfile中,或创建一个新的Podfile:
target 'MyApp' do
pod 'wiseBle'
end
然后 pod install
.
将WiseBle文件夹添加到项目中
#import <wiseBle/WiseBle.h>
/**
* 下发数据预处理 会在发送数据之前调用该函数预处理
*
* @param ble 蓝牙
* @param peripheral 蓝牙设备
* @param characteristic 发送的服务
* @param data 当前蓝牙的状态
*
*/
- (NSData *)ble:(WWBluetoothLE *)ble didPreSend:(CBPeripheral *)peripheral characteristic:(WWCharacteristic *)characteristic data:(NSData *)data;
/**
* 上行数据预处理 会在接收数据之后调用该函数预处理,当该函数返回不为空时,在调用接收回调函数或者结束接收等待
*
* @param ble 蓝牙
* @param peripheral 蓝牙设备
* @param characteristic 发送的服务
* @param data 当前蓝牙的状态
*
*/
- (NSData *)ble:(WWBluetoothLE *)ble didPreReceive:(CBPeripheral *)peripheral characteristic:(WWCharacteristic *)characteristic data:(NSData *)data;
/**
* 蓝牙状态,仅在本地蓝牙状态为开启时, 即WWBleLocalStatePowerOn,其他函数方可使用
*
* @param ble 蓝牙
* @param state 当前蓝牙的状态
*
*/
- (void)ble:(WWBluetoothLE *)ble didLocalState:(WWBleLocalState)state;
/**
* 扫描函数回调
*
* @param ble 蓝牙
* @param peripheral 扫描到的蓝牙设备
* @param advertisementData 广播数据
* @param rssi rssi值
*
*/
- (void)ble:(WWBluetoothLE *)ble didScan:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData rssi:(NSNumber *)rssi;
/**
* 蓝牙链接回调
*
* @param ble 蓝牙
* @param peripheral 蓝牙设备
* @param isSuccess 成功true或失败false
*
*/
- (void)ble:(WWBluetoothLE *)ble didConnect:(CBPeripheral *)peripheral result:(BOOL)isSuccess;
/**
* 蓝牙断开回调,主动断开不会走此回调
*
* @param ble 蓝牙
* @param peripheral 蓝牙设备
*
*/
- (void)ble:(WWBluetoothLE *)ble didDisconnect:(CBPeripheral *)peripheral;
/**
* 蓝牙通知回调
*
* @param ble 蓝牙
* @param peripheral 蓝牙设备
* @param characteristic 改变的服务
* @param enable 打开通知true,否则false
* @param isSuccess 成功true或失败false
*
*/
- (void)ble:(WWBluetoothLE *)ble didNotify:(CBPeripheral *)peripheral characteristic:(WWCharacteristic *)characteristic enable:(BOOL)enable result:(BOOL)isSuccess;
/**
* 蓝牙发送数据回调
*
* @param ble 蓝牙
* @param peripheral 蓝牙设备
* @param characteristic 发送的服务
* @param isSuccess 成功true或失败false
*
*/
- (void)ble:(WWBluetoothLE *)ble didSendData:(CBPeripheral *)peripheral characteristic:(WWCharacteristic *)characteristic result:(BOOL)isSuccess;
/**
* 蓝牙接收数据回调
*
* @param ble 蓝牙
* @param peripheral 蓝牙设备
* @param characteristic 接收的服务
* @param data 接收的数据
*
*/
- (void)ble:(WWBluetoothLE *)ble didReceiveData:(CBPeripheral *)peripheral characteristic:(WWCharacteristic *)characteristic data:(NSData *)data;
/**
* 蓝牙RSSI更新回调
*
* @param ble 蓝牙
* @param peripheral 蓝牙设备
* @param rssi rssi
* @param isSuccess 成功true或失败false
*
*/
- (void)ble:(WWBluetoothLE *)ble didUpdateRssi:(CBPeripheral *)peripheral rssi:(NSNumber *)rssi result:(BOOL)isSuccess;