//
//  S1LanBrowser.h
//  PrinterSDK
//
//  Created by ldc on 2025/6/18.
//  Copyright © 2025 Mellow. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <RYCommunication/RYUDPBrowser.h>
#import <PrinterSDK/S1Type.h>
#import <RYCommunication/RYUDPBrowser.h>

NS_ASSUME_NONNULL_BEGIN

@interface S1UdpLanTarget : NSObject <RYUDPPort>
// 名字
@property(strong,nonatomic,readwrite) NSString *name;
///< \~chinese 蓝牙物理地址 \~english mac address
@property(strong,nonatomic,readwrite) NSString *mac;
///< \~chinese 蓝牙外设UUID \~english Unique identifier
@property(strong,nonatomic,readwrite) NSString *uuid;
///< \~chinese 序列号 \~english sn
@property(strong,nonatomic,readwrite) NSString *sn;
///< \~chinese 打印宽度 \~english print width
@property(strong,nonatomic,readwrite) NSString *printWidth;
///< \~chinese 分辨率 \~english dpi
@property(strong,nonatomic,readwrite) NSString *dpi;

@property(strong,nonatomic,readwrite) NSString *status;
  
@property(strong,nonatomic,readwrite) NSString *version;

@property(assign,nonatomic,readwrite) BOOL isEth;

@property(assign, nonatomic,readwrite) BOOL dhcpEnable;

@property(strong,nonatomic,readwrite) NSString *mask;

@property(strong,nonatomic,readwrite) NSString *gateway;

@property(assign,nonatomic,readwrite) BOOL isSta;

@property(strong,nonatomic,readwrite) NSString *wifiSsid;

@property(assign,nonatomic,readwrite) S1WiFiEncryption wifiSecurity;

@property(strong,nonatomic,readwrite) NSString *wifiPwd;

@end

@interface S1EthernetConfig : NSObject

@property (nonatomic, assign) BOOL dhcpEnable;

@property (nonatomic, copy, nullable) NSString *ip;

@property (nonatomic, copy, nullable) NSString *mask;

@property (nonatomic, copy, nullable) NSString *gateway;

@end

@interface S1WifiSTAConfig : NSObject

/// 名称
@property (nonatomic, copy) NSString *ssid;

/// 密码
@property (nonatomic, copy, nullable) NSString *password;

/// 加密方式
@property (nonatomic, assign) S1WiFiEncryption encrytion;

@property (nonatomic, assign) BOOL dhcpEnable;

@property (nonatomic, copy, nullable) NSString *ip;

@property (nonatomic, copy, nullable) NSString *mask;

@property (nonatomic, copy, nullable) NSString *gateway;

@end

@interface S1WifiAPConfig : NSObject

/// 名称
@property (nonatomic, copy) NSString *ssid;

/// 密码
@property (nonatomic, copy, nullable) NSString *password;

/// 加密方式
@property (nonatomic, assign) S1WiFiEncryption encrytion;

@property (nonatomic, copy, nullable) NSString *ip;

@end

/// 设备搜索器
@interface S1LanBrowser : NSObject

@property (nonatomic, strong, readonly) RYUDPBrowser *browser;

/// 开始搜索
/// - Parameters:
///   - timeout: 搜索超时时间
///   - discovePortBlock: 发现设备回调
///   - searchTimeoutBlock: 搜索超时回调
///   - filterBlock: 过滤条件
///   - portGenerateBlock: 设备对象生成回调
///   - socketDisconnectedBlock: socket连接断开回调
///   - error: 开始搜索错误
/// - Returns: 搜索任务ID，用于停止
- (NSString * _Nullable)startSearch:(NSTimeInterval)timeout
                   discovePortBlock:(void (^ _Nullable)(S1UdpLanTarget *))discovePortBlock
                 searchTimeoutBlock:(void (^ _Nullable )(void))searchTimeoutBlock
            socketDisconnectedBlock:(void (^ _Nullable)(NSError * _Nullable))socketDisconnectedBlock
                              error:(NSError * _Nullable *)error;


/// 停止搜索
/// - Parameter identity: 任务标识
- (void)stopSearch:(NSString *)identity;


/// 发起广播
/// - Parameter data: 广播数据
- (void)broadcast:(NSData *)data;

@end

NS_ASSUME_NONNULL_END
