添加命令日志,输出给维盛
authorliangzhenying <867174124@qq.com>
Wed, 7 May 2025 01:59:49 +0000 (09:59 +0800)
committerliangzhenying <867174124@qq.com>
Wed, 7 May 2025 01:59:49 +0000 (09:59 +0800)
Demo/MouseSdk/MouseSdk.xcworkspace/xcuserdata/yaozuopan.xcuserdatad/UserInterfaceState.xcuserstate
Demo/MouseSdk/MouseSdk/ViewController.m
MouseSdk/AiMouseSdk/Manager/DeviceManger.h
MouseSdk/AiMouseSdk/Manager/DeviceManger.m
MouseSdk/AiMouseSdk/Manager/HidManager.m
MouseSdk/MouseSdk.xcworkspace/xcuserdata/yaozuopan.xcuserdatad/UserInterfaceState.xcuserstate
MouseSdk/MouseSdk/ViewController.m
MouseSdk_mac_v2025050601.zip [new file with mode: 0644]

index d4f787b..1d76089 100644 (file)
Binary files a/Demo/MouseSdk/MouseSdk.xcworkspace/xcuserdata/yaozuopan.xcuserdatad/UserInterfaceState.xcuserstate and b/Demo/MouseSdk/MouseSdk.xcworkspace/xcuserdata/yaozuopan.xcuserdatad/UserInterfaceState.xcuserstate differ
index 3f6b6c3..5e367e2 100644 (file)
     }];
     
     manager.begainRecoredCallBack = ^(void) {
-        NSLog(@"开始录音");
+        //NSLog(@"开始录音");
     };
     manager.recordingCallBack = ^(NSString * _Nonnull data) {
         //NSLog(@"%@",[NSString stringWithFormat:@"语音数据 = %@",data]);
         //NSLog(@"%@",[NSString stringWithFormat:@"结束录音 = %@",data]);
     };
     manager.aiMouseSendCmdDataCallBack = ^(NSString * _Nonnull data) {
-        NSLog(@"%@",[NSString stringWithFormat:@"按键指令 = %@",data]);
+        //        NSLog(@"%@",[NSString stringWithFormat:@"按键指令 = %@",data]);
     };
 }
 
 }
 
 
+
+
 - (void)geviceInfoAction{
     [[DeviceManger shared] getDeviceInfo:^(AiMouseDeviceInfo *deviceInfo, NSError *error) {
         if (deviceInfo) {
index 0f0ab5e..577bbd9 100644 (file)
@@ -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;
 
 
index 3ed65b9..e060cf2 100644 (file)
@@ -51,7 +51,7 @@
 - (instancetype)init{
     self = [super init];
     if (self) {
-        self.version = @"MouseSdk_v2025043001";
+        self.version = @"MouseSdk_v2025050601";
     }
     return self;
 }
         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{
 - (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日志
 - (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日志
     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日志
     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设备
     }
 }
 
+#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
index 0a25599..c5f6eff 100644 (file)
@@ -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));
index f6f1cef..9fcb43c 100644 (file)
Binary files a/MouseSdk/MouseSdk.xcworkspace/xcuserdata/yaozuopan.xcuserdatad/UserInterfaceState.xcuserstate and b/MouseSdk/MouseSdk.xcworkspace/xcuserdata/yaozuopan.xcuserdatad/UserInterfaceState.xcuserstate differ
index c847456..0996e86 100644 (file)
     }];
     
     manager.begainRecoredCallBack = ^(void) {
-        NSLog(@"开始录音");
+//        NSLog(@"开始录音");
     };
     manager.recordingCallBack = ^(NSString * _Nonnull data) {
         //NSLog(@"%@",[NSString stringWithFormat:@"语音数据 = %@",data]);
         //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 (file)
index 0000000..3bdfa56
Binary files /dev/null and b/MouseSdk_mac_v2025050601.zip differ