设备调试
authorliangzhenying <867174124@qq.com>
Tue, 27 Aug 2024 09:27:50 +0000 (17:27 +0800)
committerliangzhenying <867174124@qq.com>
Tue, 27 Aug 2024 09:27:50 +0000 (17:27 +0800)
MouseSdk/AiMouseSdk/TlwMouseSdk/TlwMouseSdk.m
MouseSdk/MouseSdk.xcworkspace/xcuserdata/apple.xcuserdatad/UserInterfaceState.xcuserstate
MouseSdk/MouseSdk.xcworkspace/xcuserdata/apple.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
MouseSdk/MouseSdk/Ble/BleManager.m
MouseSdk/MouseSdk/Ble/DeviceManger.m
MouseSdk/MouseSdk/Ble/HidManager.m
MouseSdk/MouseSdk/Ble/TimerManager.m
MouseSdk/MouseSdk/ViewController.m

index 6dd6a43..bfde2e6 100644 (file)
 //        [self.connectManager disConnected];
 //    }
     _connected = isConneted;
-    _connectType = type;
-    [self showLog:type == AiMouseConnectType_bluetooth?@"sdk切换到蓝牙模式":@"sdk切换到usb模式"];
+    if (isConneted) {
+        _connectType = type;
+    }
+//    [self showLog:type == AiMouseConnectType_bluetooth?@"sdk切换到蓝牙模式":@"sdk切换到usb模式"];
     [self TlwConnectManager:self.connectManager connectStateDidChange:isConneted];
 
-    if (type == AiMouseConnectType_hid) {
+    if (type == AiMouseConnectType_hid && isConneted) {
         [self.recordManager checkPermissions];
     }
 }
         case 0x9c:
         { //鼠标状态查询回复
             uint16_t version;
-            [[data subdataWithRange:NSMakeRange(3, 2)] getBytes:&version length:2];
+            [[data subdataWithRange:NSMakeRange(7, 2)] getBytes:&version length:2];
             
             uint16_t DPI;
-            [[data subdataWithRange:NSMakeRange(5, 2)] getBytes:&DPI length:2];
+            [[data subdataWithRange:NSMakeRange(9, 2)] getBytes:&DPI length:2];
             
             uint16_t batteryState;
-            [[data subdataWithRange:NSMakeRange(7, 1)] getBytes:&batteryState length:1];
+            [[data subdataWithRange:NSMakeRange(11, 1)] getBytes:&batteryState length:1];
             
             uint16_t batteryValue;
-            [[data subdataWithRange:NSMakeRange(8, 1)] getBytes:&batteryValue length:1];
+            [[data subdataWithRange:NSMakeRange(12, 1)] getBytes:&batteryValue length:1];
             
             TlwDeviceInfo *info = [[TlwDeviceInfo alloc] init];
             info.version = version;
index 355ba17..900de24 100644 (file)
Binary files a/MouseSdk/MouseSdk.xcworkspace/xcuserdata/apple.xcuserdatad/UserInterfaceState.xcuserstate and b/MouseSdk/MouseSdk.xcworkspace/xcuserdata/apple.xcuserdatad/UserInterfaceState.xcuserstate differ
index b9c3bbe..8d38756 100644 (file)
             landmarkType = "0">
          </BreakpointContent>
       </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            uuid = "C13039FF-9A3F-41DA-BFBF-DB7E074186A0"
+            shouldBeEnabled = "Yes"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "MouseSdk/Ble/DeviceManger.m"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "256"
+            endingLineNumber = "256"
+            landmarkName = "-tlwMouseSendDeviceInfoData:"
+            landmarkType = "7">
+         </BreakpointContent>
+      </BreakpointProxy>
    </Breakpoints>
 </Bucket>
index be15414..23f090e 100644 (file)
     if (self.deviceInfoCha ==nil) {
         return;
     }
-    [self showLog:[NSString stringWithFormat:@"向蓝牙设备发送数据 %@",data]];
+//    [self showLog:[NSString stringWithFormat:@"向蓝牙设备发送数据 %@",data]];
     [self.crrentPeripheral writeValue:data forCharacteristic:self.deviceInfoCha type:CBCharacteristicWriteWithResponse];
 }
 
index 4689003..9105a5b 100644 (file)
     __weak typeof(self) ws = self;
     
     self.hid.connectStateCallBack = ^(BOOL connected) {
-        if (connected) {
-            [[TlwMouse shared] switchConnect:AiMouseConnectType_hid isConnected:connected];
-        }
-        else{
-            if ([TlwMouse shared].connectType ==  AiMouseConnectType_hid && [TlwMouse shared].connected){
-                [[TlwMouse shared] switchConnect:AiMouseConnectType_hid isConnected:false];
-            }
-        }
-        
-       if(ws.authCallBack && connected)ws.authCallBack(true);
-        if (ws.aiMouseConnectStateDidChangeCallBack) {
-            ws.aiMouseConnectStateDidChangeCallBack(AiMouseConnectType_hid,connected);
-        }
+        [[TlwMouse shared] switchConnect:AiMouseConnectType_hid isConnected:connected];
+//        if (connected) {
+//            [[TlwMouse shared] switchConnect:AiMouseConnectType_hid isConnected:connected];
+//        }
+//        else{
+//            if ([TlwMouse shared].connectType ==  AiMouseConnectType_hid && [TlwMouse shared].connected){
+//                [[TlwMouse shared] switchConnect:AiMouseConnectType_hid isConnected:false];
+//            }
+//        }
+//        
+//       if(ws.authCallBack && connected)ws.authCallBack(true);
+//        if (ws.aiMouseConnectStateDidChangeCallBack) {
+//            ws.aiMouseConnectStateDidChangeCallBack(AiMouseConnectType_hid,connected);
+//        }
     };
     self.hid.receiveInfoDataCallBack = ^(NSData *data) {
         [[TlwMouse shared] sendDeviceDataToSdk:data];
         
         [[TlwMouse shared] switchConnect:AiMouseConnectType_bluetooth isConnected:connected];
         
-       if(ws.authCallBack && connected)ws.authCallBack(true);
-        if (ws.aiMouseConnectStateDidChangeCallBack) {
-            ws.aiMouseConnectStateDidChangeCallBack(AiMouseConnectType_bluetooth,connected);
-        }
+//       if(ws.authCallBack && connected)ws.authCallBack(true);
+//        if (ws.aiMouseConnectStateDidChangeCallBack) {
+//            ws.aiMouseConnectStateDidChangeCallBack(AiMouseConnectType_bluetooth,connected);
+//        }
     };
     self.ble.receiveInfoDataCallBack = ^(NSData *data) {
         [[TlwMouse shared] sendDeviceDataToSdk:data];
     [self.ble startScanWithName:mouseName];
     
     [TimerManager shared].timerCallBack = ^{
-//        [self showLog:@"定时器。。。"];
+        [self showLog:@"timer action。。。"];
         if([TlwMouse shared].connected){
             [self.ble stopScan];
 //            [self.hid close];
 - (void)getDeviceInfo:(void (^)(AiMouseDeviceInfo *deviceInfo,NSError *error))completation{
     [[TlwMouse shared] getDeviceInfo:^(TlwDeviceInfo *deviceInfo, NSError *error) {
         
-//        NSString *CPI_list = @"800,1200,1800,2400";// 1-4,800 1200 1800 2400
-//        NSString *cpi = [[CPI_list componentsSeparatedByString:@","] objectAtIndex:deviceInfo.DPI - 1];
+        NSString *CPI_list = @"800,1200,1800,2400";// 1-4,800 1200 1800 2400
+        NSString *cpi = [[CPI_list componentsSeparatedByString:@","] objectAtIndex:deviceInfo.DPI - 1];
         
         AiMouseDeviceInfo *info = [[AiMouseDeviceInfo alloc] init];
         info.battery_power = [NSString stringWithFormat:@"%d",deviceInfo.batteryValue] ;
         info.version = [NSString stringWithFormat:@"%d",deviceInfo.version];
-//        info.CPI_list = CPI_list;// 1-4,800 1200 1800 2400
+        info.CPI_list = CPI_list;// 1-4,800 1200 1800 2400
+        info.CPI = cpi;
+//        info.CPI_list = @"1,2,3,4";// 1-4,800 1200 1800 2400
 //        info.CPI = [NSString stringWithFormat:@"%d",deviceInfo.DPI];
-        info.CPI_list = @"1,2,3,4";// 1-4,800 1200 1800 2400
-        info.CPI = [NSString stringWithFormat:@"%d",deviceInfo.DPI];
         info.brand = @"NNMouse";
         info.sn = @"MSCL1BKZ12105000042371";
         info.mac = @"C0310000A583";
 
 /// 设置CPI
 - (void)setCPI:(NSInteger)value completation:(void (^)(BOOL isSuccess,NSError *error))finished{
-    [[TlwMouse shared] setDPI:value completation:finished];
+    NSDictionary *dict = @{
+        @"800":@"1",
+        @"1200":@"2",
+        @"1800":@"3",
+        @"2400":@"4"
+    };
+    
+    if (dict[[NSString stringWithFormat:@"%ld",value]]) {
+        int num = [dict[[NSString stringWithFormat:@"%ld",value]] intValue];
+        [[TlwMouse shared] setDPI:num completation:finished];
+    }
+    else{
+        [self showLog:[NSString stringWithFormat:@"CPI值设置错误 %ld",value]];
+        finished(false,[NSError errorWithDomain:@"AiMouse SDK Error" code:AiMouseErrorCode_unknown userInfo:@{@"NSLocalizedDescriptionKey":@"CPI值设置错误"}]);
+    }
 }
 
 /// 设置品牌名称
 // 连接状态改变
 - (void)tlwMouseConnectStateDidChange:(BOOL)connected{
     [self showLog:@"连接结果回调"];
-    [self showLog:[NSString stringWithFormat:@"设备连接状态返回: %@",@(connected)]];
+    [self showLog:[NSString stringWithFormat:@"%@设备连接状态返回: %@",[TlwMouse shared].connectType == AiMouseConnectType_bluetooth ? @"蓝牙 ":@"USB",connected ? @"true":@"false"]];
     
     [self showLog:@"准备连接回调"];
     if (self.aiMouseConnectStateDidChangeCallBack) {
 
 - (void)showLog:(NSString *)log{
     NSLog(@"[AiMouseSdk] %@",log);
-    [self aiMouseAddLog:log];
 }
+
 //将录音数据保存
 - (void)finishRecored:(NSData *)data{
     NSString *doc = NSTemporaryDirectory();
index e20f681..b4e3d91 100644 (file)
@@ -69,10 +69,12 @@ static void hidReceiveData(void* context, IOReturn result, void* sender, IOHIDRe
         //鼠标键盘活动事件
         return;
     }
-    NSInteger len = get_data_len(report, reportLength);
-    NSData *data = [[NSData alloc] initWithBytes:report length:len];
+//    NSInteger len = get_data_len(report, reportLength);
+//    NSData *data = [[NSData alloc] initWithBytes:report length:len];
+    
+//    NSInteger len = get_data_len(report, reportLength);
+    NSData *data = [[NSData alloc] initWithBytes:report length:reportLength];
     
-//    [[HidManager shared] showLog:@"hidReceiveData:device数据"];
     [HidManager shared].receiveInfoDataCallBack(data);
 }
 
index 9401170..ced8f49 100644 (file)
@@ -28,7 +28,7 @@
 #pragma mark - timer
 - (void)addSendTimer{
     dispatch_async(dispatch_queue_create("timeoutQueue", DISPATCH_QUEUE_SERIAL), ^{
-        self.timer = [NSTimer timerWithTimeInterval:2 target:self selector:@selector(timerAction) userInfo:nil repeats:true];
+        self.timer = [NSTimer timerWithTimeInterval:5 target:self selector:@selector(timerAction) userInfo:nil repeats:true];
         [[NSRunLoop currentRunLoop] addTimer:self.timer forMode:NSRunLoopCommonModes];
         [[NSRunLoop currentRunLoop] run];
     });
index 3d39ab4..d5d77f6 100644 (file)
     }];
 }
 - (void)setDPI:(NSMenuItem*)sender {
-    [[DeviceManger shared] setCPI:2 completation:^(BOOL isSuccess, NSError * _Nonnull error) {
+    [[DeviceManger shared] setCPI:800 completation:^(BOOL isSuccess, NSError * _Nonnull error) {
         
     }];
 }