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.
58 lines
1.5 KiB
58 lines
1.5 KiB
1 year ago
|
//
|
||
|
// FRIUpdateOTAManager.h
|
||
|
// FRQBluetoothKit
|
||
|
//
|
||
|
// Created by chunhai xu on 2021/1/3.
|
||
|
//
|
||
|
|
||
|
#import <Foundation/Foundation.h>
|
||
|
#import <CoreBluetooth/CoreBluetooth.h>
|
||
|
|
||
|
NS_ASSUME_NONNULL_BEGIN
|
||
|
|
||
|
typedef NS_ENUM(NSUInteger, FRIOTAStatus) {
|
||
|
FRIOTAStatusNotStart, //未开始
|
||
|
FRIOTAStatusGetBaseAddr, //获取基地址
|
||
|
FRIOTAStatusEraseOut, //擦除
|
||
|
FRIOTAStatusFileTransform, //文件传输
|
||
|
FRIOTAStatusReboot, //重启
|
||
|
FRIOTAStatusFailure, //失败
|
||
|
FRIOTAStatusFinish, //成功
|
||
|
FRIOTAStatusCanceled, //cancel
|
||
|
};
|
||
|
|
||
|
@class FRIUpdateOTAManager;
|
||
|
@protocol FRIUpdateOTAManagerDelegate <NSObject>
|
||
|
|
||
|
-(void)onOTAUpdateStatusDidChange:(FRIUpdateOTAManager *)ota withProgress:(float)aProgress;
|
||
|
-(void)onOTAUpdateStatusCompletion:(FRIUpdateOTAManager *)ota;
|
||
|
-(void)onOTAUpdateStart:(FRIUpdateOTAManager *)ota;
|
||
|
-(void)onOTAUpdateStatusFailure:(FRIUpdateOTAManager *)ota error:(NSError *)err;
|
||
|
|
||
|
@end
|
||
|
|
||
|
|
||
|
@interface FRIUpdateOTAManager : NSObject
|
||
|
|
||
|
@property(nonatomic, weak) id<FRIUpdateOTAManagerDelegate> delegate;
|
||
|
|
||
|
@property(nonatomic, assign, readonly) FRIOTAStatus otaStatus; //!< ota操作状态
|
||
|
@property(nonatomic, strong, readonly) CBPeripheral *curPeripheral; //当前连接外设
|
||
|
|
||
|
@property(nonatomic, strong) NSData *binData; //bin file data
|
||
|
|
||
|
/// 升级版本号
|
||
|
@property(nonatomic, strong) NSString *updateVersion;
|
||
|
|
||
|
|
||
|
-(void)resetOTAStatus;
|
||
|
|
||
|
-(void)startUpdateOTA:(CBPeripheral *)peripheral writeCharacteristic:(CBCharacteristic *)writeCharacteristic;
|
||
|
|
||
|
-(void)cancelOTAUpdate;
|
||
|
|
||
|
|
||
|
@end
|
||
|
|
||
|
NS_ASSUME_NONNULL_END
|