//
// S1V1ProtocolPrinter.h
// S1V1Protocol
//
//  Created by ldc on 2024/10/23.
//

#import <Foundation/Foundation.h>
#import <RYCommunication/RYSharedAccessory.h>
#import <PrinterSDK/types.h>
#import <PrinterSDK/S1Type.h>

NS_ASSUME_NONNULL_BEGIN

@interface S1V1ProtocolPrinter : RYSharedAccessory

/// 获取打印机wifi信号强度
///   - completeBlock: 结果回调，0~100%
- (void)getPrinterWifiLink:(RYIntegerResultBlock)completeBlock;

/// 获取打印机MAC地址
/// - Parameters:
///   - type: MAC地址类型（0=蓝牙MAC, 1=WiFi MAC, 2=以太网MAC）
///   - completeBlock: 结果回调
- (void)getPrinterMAC:(HVPPrinterMAC) type complete:(RYStringResultBlock) completeBlock;

/// 获取Wi-Fi热点列表
///   - completeBlock: 结果回调
- (void)getPrinterWifiHotspots:(RYDataResultBlock) completeBlock;

/// 获取已保存的 Wi-Fi 列表
/// - Parameters:
///   - completeBlock: 结果回调，成功时返回 SSID 数组
- (void)getSavedWifiList:(void (^ _Nullable)(NSArray<NSString *> * _Nullable wifiList, NSError * _Nullable error))completeBlock;

/// 获取当前连接的 Wi-Fi
/// - Parameter completeBlock: 结果回调，成功时返回当前连接的 SSID
- (void)getCurrentConnectedWifi:(RYStringResultBlock)completeBlock;
    
/// 获取打印机WiFi工作模式
///   - completeBlock: 结果回调 工作模式（1=AP, 2=STA, -1=获取失败）
- (void)getPrinterWifiWorkMode:(RYIntegerResultBlock)completeBlock;

/// 获取打印机WiFi配置Key值
/// - Parameters:
///   - keyValue key值（122, 123, 124, 125）
///   - bytes    字节数（32或64）
///   - completeBlock: 结果回调
- (void)getPrinterWifiKey:(NSInteger) keyValue bytes:(Byte) bytes complete:(RYStringResultBlock) completeBlock;

/// 获取打印机WiFi IP地址相关信息（IP、网关、子网掩码）
/// - Parameters:
///   - keyValue key值（ 128,129,133,134,154,155）
///   - completeBlock: 结果回调（如: 192.168.1.100）
- (void)getPrinterWifiIP:(NSInteger ) keyValue complete:(RYStringResultBlock) completeBlock;

/// 使用Command.setKey方法配置打印机WiFi
/// - Parameters:
///   - wifiName WiFi名称
///   - wifiPassword WiFi密码
///   - isApMode     是否为AP模式(true=AP, false=STA)
///   - completeBlock: 结果回调，配置是否成功（30s等待时间）
- (void)configPrinterWifiWithWifiName:(NSString *)wifiName wifiPassword:(NSString *)wifiPassword isApMode:(BOOL )isApMode complete:(RYEmptyResultBlock) completeBlock;

/// 添加并连接新的 Wi-Fi
/// - Parameters:
///   - ssid: Wi-Fi 名称
///   - password: Wi-Fi 密码
///   - completeBlock: 结果回调，成功后会等待设备完成切换并连续两次确认 STA IP 可用
- (void)addAndConnectWifi:(NSString *)ssid password:(NSString *)password complete:(RYEmptyResultBlock)completeBlock;

/// 连接已保存的 Wi-Fi
/// - Parameters:
///   - ssid: 已保存的 Wi-Fi 名称
///   - completeBlock: 结果回调，发送完成后会等待设备完成切换并连续两次确认 STA IP 可用
- (void)connectSavedWifi:(NSString *)ssid complete:(RYEmptyResultBlock)completeBlock;

/// 删除已保存的 Wi-Fi
/// - Parameters:
///   - ssid: 已保存的 Wi-Fi 名称
///   - completeBlock: 结果回调，发送完成即认为成功
- (void)deleteSavedWifi:(NSString *)ssid complete:(RYEmptyResultBlock)completeBlock;

/// 获取打印机WiFi RSSI（信号强度）
/// - Parameter completeBlock: 结果回调 RSSI值字符串（如: -45）
- (void)getPrinterWifiRSSI:(RYStringResultBlock)completeBlock;

/// 获取打印机4G RSSI（信号强度）
/// - Parameters:
///   - name: 名称
///   - completeBlock: 结果回调 RSSI值字符串（如: -45）
- (void)getPrinter4GRSSI:(RYStringResultBlock)completeBlock;

/// 设置STA Wi-Fi名称
/// - Parameters:
///   - name: 名称
///   - completeBlock: 结果回调
- (void)valSetStaSsid:(NSString *)name complete:(RYEmptyResultBlock _Nullable)completeBlock;

/// 设置STA DHCP
/// - Parameters:
///   - enable: 是否开启
///   - completeBlock: 结果回调
- (void)valSetStaDhcp:(BOOL)enable complete:(RYEmptyResultBlock _Nullable)completeBlock;

/// 设置主机名
/// - Parameters:
///   - name: 名称
///   - completeBlock: 结果回调
- (void)valSetStaHostName:(NSString *)name complete:(RYEmptyResultBlock _Nullable)completeBlock;

/// 设置STA加密方式
/// - Parameters:
///   - encryption: 加密方式
///   - completeBlock: 结果回调
- (void)valSetStaEncription:(HVPHotspotEncription)encryption complete:(RYEmptyResultBlock _Nullable)completeBlock;

/// 设置STA密码
/// - Parameters:
///   - password: 密码
///   - completeBlock: 结果回调
- (void)valSetStaPassword:(NSString *)password complete:(RYEmptyResultBlock _Nullable)completeBlock;

/// 设置STA静态IP
/// - Parameters:
///   - ip: IP
///   - completeBlock: 结果回调
- (void)valSetStaStaticIp:(NSString *)ip complete:(RYEmptyResultBlock _Nullable)completeBlock;

/// 设置AP模式名称
/// - Parameters:
///   - name: 名称
///   - completeBlock: 结果回调
- (void)valSetApSsid:(NSString *)name complete:(RYEmptyResultBlock _Nullable)completeBlock;

/// 设置AP加密方式
/// - Parameters:
///   - encryption: 加密方式
///   - completeBlock: 结果回调
- (void)valSetApEncription:(HVPHotspotEncription)encryption complete:(RYEmptyResultBlock _Nullable)completeBlock;

/// 设置AP模式密码
/// - Parameters:
///   - password: 密码
///   - completeBlock: 结果回调
- (void)valSetApPassword:(NSString *)password complete:(RYEmptyResultBlock _Nullable)completeBlock;

/// 设置AP模式IP
/// - Parameters:
///   - ip: IP
///   - completeBlock: 结果回调
- (void)valSetApIp:(NSString *)ip complete:(RYEmptyResultBlock _Nullable)completeBlock;

/// 设置Wi-Fi模式
/// - Parameters:
///   - isSta: 是否是STA模式
///   - completeBlock: 结果回调
- (void)valSetWiFiMode:(BOOL)isSta complete:(RYEmptyResultBlock _Nullable)completeBlock;

/// 保存Wi-Fi设置
/// - Parameter completeBlock: 结果回调
- (void)saveWiFiSettings:(RYEmptyResultBlock _Nullable)completeBlock;

/// 获取STA Wi-Fi名称
/// - Parameter completeBlock: 结果回调
- (void)valGetStaSsid:(RYEmptyResultBlock _Nullable)completeBlock;

/// 获取版本号
/// - Parameter completeBlock: 结果回调
- (void)getVersion:(RYStringResultBlock)completeBlock;

/// 获取4G信号
/// - Parameter completeBlock: 结果回调
- (void)get4gRssi:(RYStringResultBlock)completeBlock;

/// 固件升级
/// - Parameters:
///   - firmwareData: 固件数据
///   - progressBlock: 升级进度
///   - completeBlock: 结果回调
- (void)otaUpgrade:(NSData *)firmwareData
          progress:(void (^)(NSProgress *))progressBlock
          complete:(RYEmptyResultBlock)completeBlock;

/// 重启打印机
/// - Parameter completeBlock: 结果回调
- (void)reboot:(RYEmptyResultBlock _Nullable)completeBlock;

/// 打印自检页
/// - Parameter completeBlock: 结果回调
- (void)printConfiggurationPage:(RYEmptyResultBlock _Nullable)completeBlock;

#pragma mark --base

/// 使用数据发起请求，低级接口，上层自己负责解析数据
/// - Parameters:
///   - data: 请求数据
///   - completeBlock: 结果回调
- (void)dataRequest:(NSData *)data complete:(RYDataResultBlock)completeBlock;

/// 使用指令生成器发起请求，低级接口，上层自己负责解析数据
/// - Parameters:
///   - generater: 指令生成器
///   - completeBlock: 结果回调
- (void)cmdRequest:(id<S1CmdGenerator>)generater complete:(RYDataResultBlock)completeBlock;

/// 执行指令
/// - Parameters:
///   - generater: 指令生成器
///   - block: 发送进度回调
- (void)execute:(id<S1CmdGenerator>)generater progress:(void(^_Nullable)(NSProgress *))block;

#pragma mark --deprecated

/// 获取Beta版本号
/// - Parameter completeBlock: 结果回调
- (void)getBetaVersion:(RYStringResultBlock)completeBlock __attribute__((deprecated("deprecated")));

/// 获取温度
/// - Parameter completeBlock: 结果回调
- (void)getTemp:(RYStringResultBlock)completeBlock __attribute__((deprecated("deprecated")));

/// 获取温度
/// - Parameter completeBlock: 结果回调
- (void)getTemperature:(RYStringResultBlock)completeBlock __attribute__((deprecated("deprecated")));

/// 获取电压
/// - Parameter completeBlock: 结果回调
- (void)getVoltage:(RYStringResultBlock)completeBlock __attribute__((deprecated("deprecated")));

@end

NS_ASSUME_NONNULL_END
