From: liangzhenying <867174124@qq.com> Date: Wed, 7 May 2025 01:59:49 +0000 (+0800) Subject: 添加命令日志,输出给维盛 X-Git-Url: http://git.snicker.com.cn/sitemap.xml?a=commitdiff_plain;h=09c4878b4e06aef2c1a949ccb133de9cc6263653;p=mirrors%2FMouseSdk-MacOS.git 添加命令日志,输出给维盛 --- diff --git a/Demo/MouseSdk/MouseSdk.xcworkspace/xcuserdata/yaozuopan.xcuserdatad/UserInterfaceState.xcuserstate b/Demo/MouseSdk/MouseSdk.xcworkspace/xcuserdata/yaozuopan.xcuserdatad/UserInterfaceState.xcuserstate index d4f787b..1d76089 100644 Binary files a/Demo/MouseSdk/MouseSdk.xcworkspace/xcuserdata/yaozuopan.xcuserdatad/UserInterfaceState.xcuserstate and b/Demo/MouseSdk/MouseSdk.xcworkspace/xcuserdata/yaozuopan.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/Demo/MouseSdk/MouseSdk/ViewController.m b/Demo/MouseSdk/MouseSdk/ViewController.m index 3f6b6c3..5e367e2 100644 --- a/Demo/MouseSdk/MouseSdk/ViewController.m +++ b/Demo/MouseSdk/MouseSdk/ViewController.m @@ -101,7 +101,7 @@ }]; manager.begainRecoredCallBack = ^(void) { - NSLog(@"开始录音"); + //NSLog(@"开始录音"); }; manager.recordingCallBack = ^(NSString * _Nonnull data) { //NSLog(@"%@",[NSString stringWithFormat:@"语音数据 = %@",data]); @@ -110,7 +110,7 @@ //NSLog(@"%@",[NSString stringWithFormat:@"结束录音 = %@",data]); }; manager.aiMouseSendCmdDataCallBack = ^(NSString * _Nonnull data) { - NSLog(@"%@",[NSString stringWithFormat:@"按键指令 = %@",data]); + // NSLog(@"%@",[NSString stringWithFormat:@"按键指令 = %@",data]); }; } @@ -173,6 +173,8 @@ } + + - (void)geviceInfoAction{ [[DeviceManger shared] getDeviceInfo:^(AiMouseDeviceInfo *deviceInfo, NSError *error) { if (deviceInfo) { diff --git a/MouseSdk/AiMouseSdk/Manager/DeviceManger.h b/MouseSdk/AiMouseSdk/Manager/DeviceManger.h index 0f0ab5e..577bbd9 100644 --- a/MouseSdk/AiMouseSdk/Manager/DeviceManger.h +++ b/MouseSdk/AiMouseSdk/Manager/DeviceManger.h @@ -54,7 +54,7 @@ NS_ASSUME_NONNULL_BEGIN /// 开始监听鼠标 /// - Parameters: /// - mouseName: 空字符 -/// - callBack: connectType:0蓝牙模式,1 usb。connected:连接状态,false未连接,true已连接 +/// - callBack: 连接状况回调。connectType:0蓝牙模式,1 usb。connected:连接状态,false未连接,true已连接 - (void)begainMonitorAiMouseConnectStateDidChange:(NSString *)mouseName callBack:(void(^)(int connectType, BOOL connected))callBack; diff --git a/MouseSdk/AiMouseSdk/Manager/DeviceManger.m b/MouseSdk/AiMouseSdk/Manager/DeviceManger.m index 3ed65b9..e060cf2 100644 --- a/MouseSdk/AiMouseSdk/Manager/DeviceManger.m +++ b/MouseSdk/AiMouseSdk/Manager/DeviceManger.m @@ -51,7 +51,7 @@ - (instancetype)init{ self = [super init]; if (self) { - self.version = @"MouseSdk_v2025043001"; + self.version = @"MouseSdk_v2025050601"; } return self; } @@ -752,35 +752,20 @@ cmd = 0x28; } - if (self.aiMouseSendCmdDataCallBack) { - self.aiMouseSendCmdDataCallBack([NSString stringWithFormat:@"%X",cmd]); - } + [self sendCmdToApp:cmd]; if(cmd == 0x04 || cmd == 0x07 || cmd == 0x31 || cmd == 0x21 || cmd == 0x25 ||cmd == 0x27){ - [self showLog:@"开始录音"]; - self.recordData = [[NSMutableData alloc] init]; - if (self.begainRecoredCallBack) { - self.begainRecoredCallBack(); - } + [self sendBegainRecoredToApp]; } else if(cmd == 0x05 || cmd == 0x08 || cmd == 0x32 || cmd == 0x22 || cmd == 0x26 ||cmd == 0x28){ - [self showLog:@"结束录音"]; - [self finishRecored:self.recordData]; - if (self.finishRecoredCallBack) { - NSString *base64String = [self.recordData base64EncodedStringWithOptions:0]; - self.finishRecoredCallBack(base64String); - } + [self sendEndRecoredToApp]; } } /// 录音回调 /// - Parameter data: pcm格式语音数据 - (void)tlwMouseSendRecordData:(NSData *)data{ - [self.recordData appendData:data]; - if (self.recordingCallBack) { - // 将NSData转换为Base64编码的字符串 - self.recordingCallBack( [data base64EncodedStringWithOptions:0]); - } + [self sendRecordingCallBackToApp:data]; } /// hid错误 -(void)tlwHidDataError{ @@ -833,10 +818,7 @@ - (void)nMouseSendCmdData:(NSData *)data{ uint8 cmd; [data getBytes:&cmd length:1]; - [self showLog:[NSString stringWithFormat:@"收到指令 = %X",cmd]]; - if (self.aiMouseSendCmdDataCallBack) { - self.aiMouseSendCmdDataCallBack([NSString stringWithFormat:@"%X",cmd]); - } + [self sendCmdToApp:cmd]; } /// 输出sdk日志 @@ -872,10 +854,7 @@ - (void)keyboardSendCmdData:(NSData *)data{ uint8 cmd; [data getBytes:&cmd length:1]; - [self showLog:[NSString stringWithFormat:@"收到指令 = %X",cmd]]; - if (self.aiMouseSendCmdDataCallBack) { - self.aiMouseSendCmdDataCallBack([NSString stringWithFormat:@"%X",cmd]); - } + [self sendCmdToApp:cmd]; } /// 输出sdk日志 @@ -930,34 +909,20 @@ uint8 cmd; [data getBytes:&cmd length:1]; - if (self.aiMouseSendCmdDataCallBack) { - self.aiMouseSendCmdDataCallBack([NSString stringWithFormat:@"%X",cmd]); - } + [self sendCmdToApp:cmd]; if(cmd == 0x31 || cmd == 0x21 || cmd == 0x25 ||cmd == 0x27){ - [self showLog:@"开始录音"]; - self.recordData = [[NSMutableData alloc] init]; - if (self.begainRecoredCallBack) { - self.begainRecoredCallBack(); - } + [self sendBegainRecoredToApp]; } else if(cmd == 0x32 || cmd == 0x22 || cmd == 0x26 ||cmd == 0x28){ - [self showLog:@"结束录音"]; - [self finishRecored:self.recordData]; - if (self.finishRecoredCallBack) { - NSString *base64String = [self.recordData base64EncodedStringWithOptions:0]; - self.finishRecoredCallBack(base64String); - } + [self sendEndRecoredToApp]; } } /// 录音回调 /// - Parameter data: pcm格式语音数据 - (void)aiMouseSendRecordData:(NSData *)data{ - [self.recordData appendData:data]; - if (self.recordingCallBack) { - self.recordingCallBack( [data base64EncodedStringWithOptions:0]); - } + [self sendRecordingCallBackToApp:data]; } /// 输出sdk日志 @@ -1086,34 +1051,20 @@ else if( cmd == 0x08){ cmd = 0x08; } - if (self.aiMouseSendCmdDataCallBack) { - self.aiMouseSendCmdDataCallBack([NSString stringWithFormat:@"%X",cmd]); - } + [self sendCmdToApp:cmd]; if(cmd == 0x04 || cmd == 0x07 || cmd == 0x31 || cmd == 0x21 || cmd == 0x25 ||cmd == 0x27){ - [self showLog:@"开始录音"]; - self.recordData = [[NSMutableData alloc] init]; - if (self.begainRecoredCallBack) { - self.begainRecoredCallBack(); - } + [self sendBegainRecoredToApp]; } else if(cmd == 0x05 || cmd == 0x08 || cmd == 0x32 || cmd == 0x22 || cmd == 0x26 ||cmd == 0x28){ - [self showLog:@"结束录音"]; - [self finishRecored:self.recordData]; - if (self.finishRecoredCallBack) { - NSString *base64String = [self.recordData base64EncodedStringWithOptions:0]; - self.finishRecoredCallBack(base64String); - } + [self sendEndRecoredToApp]; } } /// 录音回调 /// - Parameter data: pcm格式语音数据 - (void)m8MouseSendRecordData:(NSData *)data{ - [self.recordData appendData:data]; - if (self.recordingCallBack) { - self.recordingCallBack( [data base64EncodedStringWithOptions:0]); - } + [self sendRecordingCallBackToApp:data]; } /// hid数据异常,需要重新开启监听usb设备 @@ -1149,5 +1100,36 @@ } } +#pragma mark - sendToApp +- (void)sendCmdToApp:(uint8_t)cmd{ + [self showLog:[NSString stringWithFormat:@"收到指令 = %X",cmd]]; + if (self.aiMouseSendCmdDataCallBack) { + self.aiMouseSendCmdDataCallBack([NSString stringWithFormat:@"%X",cmd]); + } +} + +- (void)sendBegainRecoredToApp{ + [self showLog:@"开始录音"]; + self.recordData = [[NSMutableData alloc] init]; + if (self.begainRecoredCallBack) { + self.begainRecoredCallBack(); + } +} +- (void)sendEndRecoredToApp{ + [self showLog:@"结束录音"]; + [self finishRecored:self.recordData]; + if (self.finishRecoredCallBack) { + NSString *base64String = [self.recordData base64EncodedStringWithOptions:0]; + self.finishRecoredCallBack(base64String); + } +} +- (void)sendRecordingCallBackToApp:(NSData *)data{ + [self.recordData appendData:data]; + if (self.recordingCallBack) { + // 将NSData转换为Base64编码的字符串 + self.recordingCallBack( [data base64EncodedStringWithOptions:0]); + } +} + @end diff --git a/MouseSdk/AiMouseSdk/Manager/HidManager.m b/MouseSdk/AiMouseSdk/Manager/HidManager.m index 0a25599..c5f6eff 100644 --- a/MouseSdk/AiMouseSdk/Manager/HidManager.m +++ b/MouseSdk/AiMouseSdk/Manager/HidManager.m @@ -43,7 +43,7 @@ /// 匹配到设备回调 static void hidAppearDevice(void *inContext,IOReturn inResult,void *inSender,IOHIDDeviceRef inIOHIDDeviceRef) { if ([DeviceManger shared].isConneted) { - [[HidManager shared] showLog:(@"当前处于连接状态,对监听到有USB 插入 的事件不做处理")]; +// [[HidManager shared] showLog:(@"当前处于连接状态,对监听到有USB 插入 的事件不做处理")]; return; } uint32_t pid = IOHIDDevGetUInt32Property(inIOHIDDeviceRef, CFSTR(kIOHIDProductIDKey)); diff --git a/MouseSdk/MouseSdk.xcworkspace/xcuserdata/yaozuopan.xcuserdatad/UserInterfaceState.xcuserstate b/MouseSdk/MouseSdk.xcworkspace/xcuserdata/yaozuopan.xcuserdatad/UserInterfaceState.xcuserstate index f6f1cef..9fcb43c 100644 Binary files a/MouseSdk/MouseSdk.xcworkspace/xcuserdata/yaozuopan.xcuserdatad/UserInterfaceState.xcuserstate and b/MouseSdk/MouseSdk.xcworkspace/xcuserdata/yaozuopan.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/MouseSdk/MouseSdk/ViewController.m b/MouseSdk/MouseSdk/ViewController.m index c847456..0996e86 100644 --- a/MouseSdk/MouseSdk/ViewController.m +++ b/MouseSdk/MouseSdk/ViewController.m @@ -101,7 +101,7 @@ }]; manager.begainRecoredCallBack = ^(void) { - NSLog(@"开始录音"); +// NSLog(@"开始录音"); }; manager.recordingCallBack = ^(NSString * _Nonnull data) { //NSLog(@"%@",[NSString stringWithFormat:@"语音数据 = %@",data]); @@ -110,7 +110,7 @@ //NSLog(@"%@",[NSString stringWithFormat:@"结束录音 = %@",data]); }; manager.aiMouseSendCmdDataCallBack = ^(NSString * _Nonnull data) { - NSLog(@"%@",[NSString stringWithFormat:@"按键指令 = %@",data]); +// NSLog(@"%@",[NSString stringWithFormat:@"按键指令 = %@",data]); }; } diff --git a/MouseSdk_mac_v2025050601.zip b/MouseSdk_mac_v2025050601.zip new file mode 100644 index 0000000..3bdfa56 Binary files /dev/null and b/MouseSdk_mac_v2025050601.zip differ