You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

128 lines
3.2 KiB

//
// HPlusBluetoothManager.h
// HPlusBluetooth_Example
//
// Created by lemo. on 2019/5/14.
// Copyright © 2019 chentingfeng. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <CoreBluetooth/CoreBluetooth.h>
#import <ECellBluetooth/ECellBluetoothDelegate.h>
#import <ECellBluetooth/ECellPeripheralModel.h>
#import <ECellBluetooth/ECellBLEEnum.h>
#import <ECellBluetooth/ECellBLEConst.h>
#import <ECellBluetooth/ECellBLEItem.h>
NS_ASSUME_NONNULL_BEGIN
@interface ECellBluetoothManager : NSObject
/**
设置代理 | Setting up the agent
*/
@property (nonatomic,weak) id<ECellBluetoothDelegate> delegate;
/**
蓝牙管理中心 | Bluetooth Management Center
*/
@property (nonatomic,strong) CBCentralManager *centralManager;
/**
外围设备 | Peripherals
*/
@property (nullable, nonatomic,strong) CBPeripheral *currenPeripheral;
/** 请求结果回调 */
@property (nonatomic, copy ) ResultBlock result;
/**
蓝牙是否开启 | Is Bluetooth enabled?
*/
@property (nonatomic,assign,readonly) BOOL poweredOn;
/**
蓝牙是否连接 | Bluetooth is connected
*/
@property (nonatomic,assign,readonly) BOOL connected;
/**
当前连接设备是否绑定 | Is the current connected device bound?
*/
@property (nonatomic,assign) BOOL isBind;
/**
当前是否是杰里 (默认为NO,如果是杰里,初始化蓝牙后必须设置) | Is it Jerry right now
*/
@property (nonatomic,assign) BOOL isJL;
/**
* 设置扫描过滤信号弱的设备 默认值 80 大于80会被过滤
* Set the device with weak scan filtering signal. Default value 80 is greater than 80 will be filtered.
*/
@property (nonatomic,assign) NSInteger rssiNum;
/**
* 发送指令超时时长 默认5秒
* Send command timeout defaults to 5 seconds by default
*/
@property (nonatomic, assign) NSInteger commandTimeOutNumber;
/**
开始扫描 | Start scanning
*/
- (void)startScan;
/**
停止扫描 | Stop scanning
*/
- (void)stopScan;
/**
* @brief 选择外围设备连接 | Select peripheral connection
* @param model ECellPeripheralModel 对象 | ECellPeripheralModel object
*/
- (void)connectDeviceWithModel:(ECellPeripheralModel *)model;
/**
断开当前外围设备的连接 (将会清空设备信息不再重连) | Disconnect the current peripheral device (The device information will be cleared and will not be reconnected)
*/
- (void)cancelCurrentPeripheralConnection;
/**
注册SDK服务 | Register for SDK service
@param outputSdkLog 是否输出蓝牙协议运行日志 (默认NO) | Whether to output the Bluetooth protocol running log (default NO)
@param isReconnect 是否需要重连机制 (默认YES) | Whether a reconnect mechanism is required (default YES)
*/
- (void)registrationServices:(BOOL)outputSdkLog
IsReconnect:(BOOL)isReconnect;
/**
* @brief 初始化蓝牙管理中心对象
* Initialize the Bluetooth Management Center object
* @return HPlusBluetoothManager
*/
+ (__kindof ECellBluetoothManager *)shareInstance;
- (void)writeWithBleItem:(ECellBLEItem *)item;
/**
* 处理接收的原因数据
*/
- (void)handleReceiveData:(NSData *)receiveData ParseResult:(ParseCmdResultBlock)resultBlock;
/**
重连系统已配对设备
*/
- (void)startAndStopReconnect;
@end
NS_ASSUME_NONNULL_END