//
//  ELMeatProbeBoxBleParser.h
//  AILinkBleSDK
//
//  Created by LarryZhang on 2023/2/16.
//

#import <Foundation/Foundation.h>
#import <AILinkBleSDK/ELSDKHeader.h>

NS_ASSUME_NONNULL_BEGIN

@class ELMeatProbeBoxBleBoxStatusModel, ELMeatProbeBoxBleProbeStatusModel;

@protocol ELMeatProbeBoxBleParserDelegate;

@interface ELMeatProbeBoxBleParser : NSObject

@property (nonatomic, copy) NSString *mac;

@property (nonatomic, weak) id<ELMeatProbeBoxBleParserDelegate> delegate;

- (void)parseA7Payload:(NSData *)payloadData;

@end


@protocol ELMeatProbeBoxBleParserDelegate <NSObject>

@optional

//MCU 上报设备状态数据（Type：02）
- (void)meatProbeBoxBleParser:(ELMeatProbeBoxBleParser *)bleParser boxStatus:(ELMeatProbeBoxBleBoxStatusModel *)boxStatus probeStatus:(ELMeatProbeBoxBleProbeStatusModel *)probeStatus offline:(BOOL)offline;

//设置、获取设备参数数据（Type：03）
- (void)meatProbeBoxBleParser:(ELMeatProbeBoxBleParser *)bleParser state:(BOOL)state mac:(NSString *)mac customData:(NSData *)customData;

//切换单位（Type：04）
- (void)meatProbeBoxBleParser:(ELMeatProbeBoxBleParser *)bleParser unit:(ELDeviceTemperatureUnit)unit;

@end

@interface ELMeatProbeBoxBleBoxStatusModel : NSObject

//设备状态数据协议版本：0x01
@property (nonatomic, assign) UInt8 version;

//支持的探针数量 M
@property (nonatomic, assign) UInt8 probeMaxCount;

//当前连接的探针数量 N
@property (nonatomic, assign) UInt8 probeCount;

//充电盒电池状态
@property (nonatomic, assign) UInt8 batteryStatus;
@property (nonatomic, assign) UInt8 batteryPercent;

//温度单位
@property (nonatomic, assign) ELDeviceTemperatureUnit unit;

//生成时间
@property (nonatomic, assign) double timestamp;

@end

@interface ELMeatProbeBoxBleProbeStatusModel : NSObject

//探针编号(1-M) 无法确定可连 接探针的编号，上报 0xFF
@property (nonatomic, assign) UInt8 index;
@property (nonatomic, assign) UInt8 dataIndex;

//探针 mac 地址
@property (nonatomic, strong) NSData *macData;
@property (nonatomic, copy) NSString *macString;

//食物温度
@property (nonatomic, assign) NSInteger internalTemperature;
@property (nonatomic, assign) ELDeviceTemperatureUnit internalTemperatureUnit;
@property (nonatomic, assign) UInt16 internalTemperatureRaw;

//环境温度
@property (nonatomic, assign) NSInteger ambientTemperature;
@property (nonatomic, assign) ELDeviceTemperatureUnit ambientTemperatureUnit;
@property (nonatomic, assign) UInt16 ambientTemperatureRaw;

//探针电池状态
@property (nonatomic, assign) UInt8 batteryStatus;
@property (nonatomic, assign) UInt8 batteryPercent;
@property (nonatomic, assign) UInt8 batteryRaw;

//探针插入食物状态
@property (nonatomic, assign) UInt8 insertStatusRaw;

//生成时间
@property (nonatomic, assign) double timestamp;

//数据无效
- (void)makeInvalid;

@end

NS_ASSUME_NONNULL_END
