//
//  ELMeatProbeScreenBoxBleCmdTool.m
//  Pods
//
//  Created by Larry Zhang on 2024/2/26.
//

#import "ELMeatProbeScreenBoxBleCmdTool.h"
#import <AILinkBleSDK/ELAILinkBleManager.h>
#import "ELMeatProbeScreenBoxBleBBQParamModel.h"

@implementation ELMeatProbeScreenBoxBleCmdTool

//APP获取设备基础信息
+ (NSData *)requestStatus:(ELAILinkBleManager *)manager {
    const Byte cmd = ELMeatProbeScreenBoxCMDAppGetStatus_Type01;
    Byte payloadBytes[] = { cmd, 0x01 };
    NSData *payloadData = [NSData dataWithBytes:payloadBytes length:sizeof(payloadBytes)];
    [manager sendA7Payload:payloadData];
    return [NSData dataWithBytes:payloadBytes length:sizeof(payloadBytes)];
}

//切换单位
+ (NSData *)switchUnit:(UInt8)unit manager:(ELAILinkBleManager *)manager {
    if (unit > 1) { return nil; }
    const Byte cmd = ELMeatProbeScreenBoxCCMDAppSwitchUnit_Type03;
    Byte payloadBytes[] = { cmd, unit };
    NSData *payloadData = [NSData dataWithBytes:payloadBytes length:sizeof(payloadBytes)];
    [manager sendA7Payload:payloadData];
    return [NSData dataWithBytes:payloadBytes length:sizeof(payloadBytes)];
}

+ (NSData *)requestParams:(ELAILinkBleManager *)manager {
    const Byte cmd = ELMeatProbeScreenBoxCMDSetInfo_Type09;
    Byte payloadBytes[] = { cmd, 0x01 };
    NSData *payloadData = [NSData dataWithBytes:payloadBytes length:sizeof(payloadBytes)];
    [manager sendA7Payload:payloadData];
    return [NSData dataWithBytes:payloadBytes length:sizeof(payloadBytes)];
}

+ (NSData *)setupParams:(NSArray <ELMeatProbeScreenBoxBleBBQParamModel *>*)params supportProbe:(UInt8)supportProbe manager:(ELAILinkBleManager *)manager {
    const Byte cmd = ELMeatProbeScreenBoxCMDSetInfo_Type09;
    Byte payloadBytes[] = { cmd, 0x00, supportProbe };
    NSMutableData *payloadData = [NSMutableData dataWithBytes:payloadBytes length:sizeof(payloadBytes)];
    for (ELMeatProbeScreenBoxBleBBQParamModel *param in params) {
        [payloadData appendData:param.dataValue];
    }
    [manager sendA7Payload:payloadData.copy];
    return [NSData dataWithBytes:payloadBytes length:sizeof(payloadBytes)];
}

+ (void)requestOTAStatusWithManager:(ELAILinkBleManager *)manager {
    const Byte ELInetGetCmdTypeSpecialFunc = 0x49, op = 0x01;
    Byte payloadBytes[16] = { ELInetGetCmdTypeSpecialFunc, op };
    NSData *payloadData = [NSData dataWithBytes:payloadBytes length:sizeof(payloadBytes)];
    [manager sendA6Payload:payloadData.copy];
}

@end
