//
//  AIRTCBluetoothLinkProtocol.h
//  RTCXDeviceCenter
//
//  Created by Apple on 2026/4/7.
//

#import <Foundation/Foundation.h>
#import <RTCXDeviceCenter/AIRTCBluetoothLinkModel.h>
NS_ASSUME_NONNULL_BEGIN
typedef NS_ENUM(NSInteger, BluetoothAuthorizeStatus)
{
    BluetoothAuthorizeStatus_Unknown = -1,//未知
    BluetoothAuthorizeStatus_Unsupported,//该设备不支持蓝牙低功耗
    BluetoothAuthorizeStatus_Unauthorized,//该程序无权使用蓝牙低功耗
    BluetoothAuthorizeStatus_PoweredOff,//蓝牙关闭
    BluetoothAuthorizeStatus_PoweredOn,//蓝牙打开
};

typedef NS_ENUM(NSInteger, BluetoothLinkError)
{
    BluetoothLinkError_RequestAuthCodeFail      = 0x01,//获取授权码失败
    BluetoothLinkError_ConnectFail              = 0x02,//蓝牙连接失败
    BluetoothLinkError_Disconnect               = 0x03,//蓝牙断开连接
    BluetoothLinkError_WriteUnsupported         = 0x04,//蓝牙不支持写入
    BluetoothLinkError_SendMessageFail          = 0x05,//蓝牙消息发送失败
    BluetoothLinkError_MessageAnalysisFail      = 0x06,//蓝牙消息异常, 解码失败
    BluetoothLinkError_LinkTimeout              = 0x07,//添加超时
};

typedef void(^BluetoothAuthorizeStatusBlock)(BluetoothAuthorizeStatus authorizeStatus);

typedef void(^BluetoothDeviceResponseHandler)(BOOL success, id _Nullable response, NSError * _Nullable error);

@protocol AIRTCBluetoothLinkProtocol <NSObject>
/**
 检查蓝牙授权
 
 @param authorizeStatusBlock 授权结果回调
 */
- (void)checkBluetoothAuthorizeStatus:(BluetoothAuthorizeStatusBlock )authorizeStatusBlock;
/**
 开始扫描蓝牙设备
 
 @param req  请求参数对象
 @param scanResultBlock 扫描结果回调
 */
- (void)startScanBluetoothDevicesWithReq:(AIRTCBluetoothLinkScanReq *)req completedBlock:(BluetoothDeviceResponseHandler )scanResultBlock;
/**
 停止扫描蓝牙设备
 
 */
- (void)stopScanBluetoothDevices;
/**
 蓝牙设备连接
 
 @param req  请求参数对象，只需要传sn
 @param connectResultBlock 连接结果回调
 */
- (void)connectBluetoothDeviceWithReq:(AIRTCBluetoothLinkNetworkingReq *)req completedBlock:(BluetoothDeviceResponseHandler )connectResultBlock;
/**
 蓝牙设备配网
 
 @param req  请求参数对象，只需要传content

 @param networkingResultBlock 绑定结果回调
 */
- (void)networkingBluetoothDeviceWithReq:(AIRTCBluetoothLinkNetworkingReq *)req completedBlock:(BluetoothDeviceResponseHandler )networkingResultBlock;
/**
 蓝牙设备连接 + 配网，（不需要再单独调用连接和配网方法，该方法已经聚合了）
 
 @param req  请求参数对象，需要传sn和content

 @param networkingResultBlock 绑定结果回调
 */
- (void)connectCombineNetworkingBluetoothDeviceWithReq:(AIRTCBluetoothLinkNetworkingReq *)req completedBlock:(BluetoothDeviceResponseHandler )networkingResultBlock;
/**
 获取蓝牙设备信息
 
 @param devInfoResultBlock 获取设备信息结果回调
 */
- (void)getBluetoothDeviceInfoWithCompletedBlock:(BluetoothDeviceResponseHandler )devInfoResultBlock;
@end

NS_ASSUME_NONNULL_END
