//
//  ELAILinkBleManager+MeatProbeBox.m
//  AILinkBleSDK
//
//  Created by LarryZhang on 2023/2/16.
//

#import "ELAILinkBleManager+MeatProbeBox.h"
#import "ELMeatProbeBoxBleHeader.h"

@implementation ELAILinkBleManager (MeatProbeBox)

//APP 获取设备状态数据（Type：01）
- (NSData *)meatProbeBoxGetStatus {
    Byte bytes[] = { ELMeatProbeBoxCMDAppGetStatus_Type01, 0x01 };
    NSData *payload = [[NSData alloc] initWithBytes:bytes length:sizeof(bytes)];
    [self sendA7PayloadNoEncryption:payload];
    return payload;
}

//设置、获取设备参数数据（Type：03）
- (NSData *)meatProbeBoxSendCustomData:(NSData *)customData withMac:(NSData *)macData {
    Byte bytes[] = { ELMeatProbeBoxCMDCustomData_Type03, 0x01 };
    NSMutableData *payload = [[NSMutableData alloc] initWithBytes:bytes length:sizeof(bytes)];
    [payload appendData:macData];
    [payload appendData:customData];
    [self sendA7PayloadNoEncryption:payload.copy];
    return payload.copy;
}

- (NSData *)meatProbeBoxRequestCustomDataWithMac:(NSData *)macData {
    Byte bytes[] = { ELMeatProbeBoxCMDCustomData_Type03, 0x02 };
    NSMutableData *payload = [[NSMutableData alloc] initWithBytes:bytes length:sizeof(bytes)];
    [payload appendData:macData];
    [self sendA7PayloadNoEncryption:payload.copy];
    return payload.copy;
}

- (NSData *)meatProbeBoxClearCustomDataWithMac:(NSData *)macData {
    Byte bytes[] = { ELMeatProbeBoxCMDCustomData_Type03, 0x00 };
    NSMutableData *payload = [[NSMutableData alloc] initWithBytes:bytes length:sizeof(bytes)];
    [payload appendData:macData];
    [self sendA7PayloadNoEncryption:payload.copy];
    return payload.copy;
}

//切换单位（Type：04）
- (NSData *)meatProbeBoxSwitchUint:(ELDeviceTemperatureUnit)unit {
    Byte bytes[] = { ELMeatProbeBoxCMDAppSwitchUnit_Type04, unit };
    NSData *payload = [[NSData alloc] initWithBytes:bytes length:sizeof(bytes)];
    [self sendA7PayloadNoEncryption:payload];
    return payload;
}

@end
