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.

219 lines
7.0 KiB

2 years ago
//
// RTKOTAPeripheral.h
// RTKOTASDK
//
// Created by jerome_gu on 2019/4/16.
// Copyright © 2019 Realtek. All rights reserved.
//
#ifdef RTK_SDK_IS_STATIC_LIBRARY
#import "libRTKLEFoundation.h"
#import "RTKOTAInstalledBin.h"
#else
#import <RTKLEFoundation/RTKLEFoundation.h>
#import <RTKOTASDK/RTKOTAInstalledBin.h>
#endif
NS_ASSUME_NONNULL_BEGIN
typedef enum : NSUInteger {
RTKOTAProtocolTypeGATTSPP = 0x0000,
RTKOTAProtocolTypeGATT = 0x0010,
RTKOTAProtocolTypeSPP = 0x0011,
} RTKOTAProtocolType;
/**
* Represents the ear bud information about the remote device.
*/
typedef enum : NSUInteger {
RTKOTAEarbudUnkown, ///< The earbud info is not known.
RTKOTAEarbudPrimary, ///< The earbud is primary bud.
RTKOTAEarbudSecondary, ///< The earbud is secondary bud.
RTKOTAEarbudSingle, ///< The earbud is a single bud.
} RTKOTAEarbud;
/**
* Represents the bank info about the remote device.
*/
typedef enum : NSInteger {
RTKOTABankTypeInvalid = -1, ///< The bank info is not valid.
RTKOTABankTypeSingle = 0x00, ///< A single bank.
RTKOTABankTypeBank0, ///< The primary Bank in a dual bank case.
RTKOTABankTypeBank1, ///< The secondary Bank in a dual bank case.
} RTKOTABankType;
@class RTKOTAPeripheral;
/**
* @protocol RTKOTAPeripheralDelegate
*
* RTKOTAPeripheralDelegate define methods to notify information determination event.
*/
@protocol RTKOTAPeripheralDelegate <RTKLEPeripheralDelegate>
/**
* Invoked when RTKOTAClient has determined information about OTA.
*/
- (void)OTAPeripheral:(RTKOTAPeripheral *)peripheral didDetermineInfoWithError:(nullable NSError*)error;
@end
/**
* @class RTKOTAPeripheral
*
* Represents a remote LE device, exposing OTA upgrade related information.
*
* @discussion An RTKOTAPeripheral object gives your app information about a LE device which is able for DFU upgrade. You can use the information in this class to determine whether your app can start a normal DFU upgrade or a silent DFU upgrade, and have a knowlege of which feature the device support.
*
* The class does not provide any methods to start upgrade, it's a responsibility of a DFUPeripehral object. You call -[RTKOTAProfile translatePeripheral:toDFUPeripheralWithCompletion:] to get a DFUPeripheral for normal upgrade, and call -[RTKOTAProfile DFUPeripheralOfOTAPeripheral:] to get a DFUPeripheral for silent upgrade.
*/
@interface RTKOTAPeripheral : RTKLEPeripheral
/**
* Indicates if the remote device information has determined.
*
* @discussion Other APIs should not be called if the value is NO. A success connection by call <code>-[RTKOTAProfile connectTo:]</code> will set this value to YES.
*/
@property (readonly) BOOL infoSettled;
/// Not available
@property (readonly) BOOL isBBpro;
/**
* The delegate object specified to receive peripheral events.
*/
@property (nonatomic, weak) id <RTKOTAPeripheralDelegate> delegate;
/// The version number which the remote device implemented.
@property (readonly) NSUInteger OTAVersion;
/// @warning Not available
@property (readonly) NSUInteger securityVersion;
/**
* The @b BDAddress of this device.
*/
@property (readonly) BDAddressType bdAddress;
/**
* The @b BDAddress of the companion device.
*
* @discussion If the remote device have a companion device, this value return the companion device @b BDAddress. If does not, return a zero value.
*/
@property (readonly) BDAddressType pairedBDAddress;
/// The version of Application image type in remote device.
/// @warning Not available in newer implementation.
@property (readonly) uint16_t appVersion;
/// The version of Patch image type in remote device.
/// @warning Not available in newer implementation.
@property (readonly) uint16_t patchVersion;
/// The Link Key of the LE Connection with remote device.
/// @warning Not available in newer implementation.
@property (readonly, nullable) NSString *linkKey;
/// The memory size used for temp buffer.
@property (readonly) NSUInteger tempBufferSize;
/// The bank used currently.
/// @discussion Return @b RTKOTABankTypeBank0 or @b RTKOTABankTypeBank1 when dual-bank feature is supported, otherwise @b RTKOTABankTypeSingle is returned.
@property (readonly) RTKOTABankType activeBank;
/// The used bank of Application image type in remote device.
/// @warning Not available in newer implementation.
@property (readonly) NSUInteger appFreeBank;
/// The used bank of Application image type in remote device.
/// @warning Not available in newer implementation.
@property (readonly) NSUInteger patchFreeBank;
/// Indicates whether buffer check is supported on the remote device .
@property (readonly) BOOL bufferCheckEnable;
/// Indicates whether AES encryption is supported on the remote device .
@property (readonly) BOOL AESEnable;
/// The encryption mode used in the remoter device..
@property (readonly) NSUInteger encryptionMode;
/// Indicate whether Copy image is supported.
@property (readonly) BOOL copyImage;
/// Indicate whether Upgrade multiple images is supported.
@property (readonly) BOOL updateMultiImages;
/// Indicates whether this peripheral is a one bud of RWS bud
@property (readonly) BOOL isRWS;
/// Indicates which bud type the remote device is.
@property (readonly) RTKOTAEarbud budType;
/// Indicates whether the device is in engaged with companion device.
@property (readonly) BOOL notEngaged;
/// Indicate whether this peripheral have received images right now, but not active.
@property (readonly) BOOL upgradedCurrently;
/// For SDK internal use.
@property (readonly) uint32_t imageIndicator;
/// For SDK internal use.
@property (readonly) RTKOTAProtocolType protocolType;
/**
* A list of image binarys resides in remote device.
*
* @discussion Use this property to get a knowledge of binarys installed in the device, such as image type and version.
*/
@property (readonly) NSArray <RTKOTAInstalledBin*> *bins;
/**
* Indicates whether the device can upgrade using normal upgrade procedure.
*
* @discussion If this value is YES, call @b -enterOTAMode to make the device transition to a running mode dedicated to Upgrade.
*/
@property (readonly) BOOL canEnterOTAMode;
/**
* Indicates whether the device can upgrade using silent upgrade procedure.
*
* @discussion If this value is YES, DFU upgrade can be start in current runing mode. Call @b -[RTKOTAProfile @b DFUPeripheralOfOTAPeripheral] to obtain a DFUPeripheral instance for Upgrade.
*/
@property (readonly) BOOL canUpgradeSliently;
/**
* Request peripheral to make a transition to OTA runing mode.
*
* @discussion Typically, you should not call this method to start a transition. Instead, call @b -[RTKOTAProfile @b translatePeripheral:toDFUPeripheralWithCompletion:] to start the transition.
*/
- (void)enterOTAMode;
@end
@interface RTKOTAPeripheral (DualBank)
/**
* A list of inactive image binarys resides in remote device.
*
* @discussion inactiveBins containing a list of images which is not in use currently.
*/
@property (readonly, nullable) NSArray <RTKOTAInstalledBin*> *inactiveBins;
@end
NS_ASSUME_NONNULL_END