// // ELAILinkBleManager.h // // Created by LarryZhang on 2022/8/13. // Copyright © 2022 iot_iMac. All rights reserved. // #import #import #import "NELBleManagerHeader.h" #import "ELSDKHeader.h" #import "AILinkBleSDK_Version.h" #import "ELAILinkBleManagerProtocol.h" #import "ELAILinkPeripheral.h" NS_ASSUME_NONNULL_BEGIN @class ELAILinkPeripheral; @class ELBleWifiDetailModel; @protocol ELAILinkBleWifiDelegate; @protocol ELAILinkBleManagerDelegate; @interface ELAILinkBleManager : NSObject //不是必须使用单例 + (instancetype)sharedManager; - (NSString *)sdkVersion; + (NSString *)sdkVersion; @property(nonatomic, assign, readonly, getter=isScanning) BOOL scanning; @property(nonatomic, assign, readonly) CBCentralManager *central; @property (nonatomic, weak) id delegate DEPRECATED_MSG_ATTRIBUTE("use 'ailinkDelegate' only"); @property (nonatomic, weak) id ailinkDelegate; //Bluetooth wifi proxy(蓝牙wifi代理) @property (nonatomic, weak) id bleWifiDelegate; //模块版本号 @property (nonatomic, copy) NSString *bmVersion; @property (nonatomic, copy) NSString *bmVersionPro; //电池状态 @property (nonatomic, assign) struct ELBatteryStruct battery; //单位列表 @property (nonatomic, strong) NSArray *weightArray; @property (nonatomic, strong) NSArray *heightArray; @property (nonatomic, strong) NSArray *temperatureArray; @property (nonatomic, strong) NSArray *bloodPressureArray; @property (nonatomic, strong) NSArray *pressureArray; @property (nonatomic, strong) NSArray *bloodSugarUnitArray; @property (nonatomic, strong) NSArray *volumeUnitArray; @end #pragma mark - scan @interface ELAILinkBleManager (scan) - (void)scanAll; - (void)scanFilterWithCidArray:(NSArray *_Nonnull)cidArray; - (void)scanFilterWithMacArray:(NSArray *_Nonnull)macArray; - (void)scanFilterWithCidArray:(NSArray *_Nonnull)cidArray macArray:(NSArray *_Nonnull)macArray; // 获取当前连接到系统的 peripheral 设备的列表(如被其它程序连接着) - (NSArray *)retrieveConnectedPeripherals; //NELBleManager - (void)stopScan; @end #pragma mark - connect @interface ELAILinkBleManager (connect) //- (void)connectPeripheral:(CBPeripheral *)peripheral; - (void)disconnectPeripheral; - (void)connectAILinkPeripheral:(ELAILinkPeripheral * _Nonnull)ailinkPeripheral; - (ELAILinkPeripheral * _Nullable)currentAILinkPeripheral; @end #pragma mark - send @interface ELAILinkBleManager (send) - (void)sendA7Payload:(NSData *)payload; - (void)sendA7PayloadNoEncryption:(NSData *)payload; - (void)sendA6Payload:(NSData *)payload; /// base method of 'sendA7Payload' & 'sendA6Payload' - (void)sendCmd:(NSData *)cmdData; //最大发送数据长度 - (NSUInteger)maximumWriteValueLength; //最大发送A7 payload长度 - (NSUInteger)maximumWriteA7PayloadLength; //最大发送A6 payload长度 - (NSUInteger)maximumWriteA6PayloadLength; //发送队列发送周期 - (void)configWriteDataQueueInterval:(CGFloat)interval; @end #pragma mark - Open @interface ELAILinkBleManager (Open) //解析指令 外部开放 Method - (void)processA7Data:(NSMutableData *)rawData withMac:(NSData *)mac withCid:(UInt16)cid; - (void)processA6Data:(NSMutableData *)rawData; //生成数据包 外部开放 Method - (NSData * _Nullable)makePacketA7Payload:(NSData *)payload withMac:(NSData *)mac withCid:(UInt16)cid; - (NSData * _Nullable)makePacketA6Payload:(NSData *)payload; @end #pragma mark - A6Method @interface ELAILinkBleManager (A6Method) /** Get Bluetooth information(获取蓝牙信息) @param type ELInetGetCmdType (ELInetGetCmdTypeGetHandshake除外) */ - (void)getBluetoothInfoWithELInetGetCmdType:(ELInetGetCmdType)type; /** Sync the current time of phone to BLE(设置手机本地时间给蓝牙模块,只在蓝牙体脂秤等需要蓝牙模块保存历史记录时才调用) @param enable NO: In addition to the ability to turn off the time function, you can save part of the current (default)(除能,关闭时间功能,可省部分电流(默认)) YES:Enable, turn on the timer function timer(使能,开启计时功能定时器) */ - (void)syncBleNowDate:(BOOL)enable; ///仅WIFI秤调用,同步世界时间(0时区)到wifi-ble模块 - (void)syncBleGMTNowDate:(BOOL)enable; ///同步手机本地时间给mcu,每次连接成功后会自动调用 - (void)syncMCUNowDate; ///查询mqtt链接状态 CMD=0xC5 - (void)checkMqttState; @end #pragma mark - specialMethod @interface ELAILinkBleManager (specialMethod) - (BOOL)specialMethodWithCid:(UInt16)cid vid:(UInt16)vid pid:(UInt16)pid secret:(NSString *)secret; @end NS_ASSUME_NONNULL_END