From: liangzhenying <867174124@qq.com> Date: Tue, 27 Aug 2024 09:27:50 +0000 (+0800) Subject: 设备调试 X-Git-Tag: 千寻适配d9~37 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=4d354c2c610f29e5b098d6471ebd71b000d97971;p=mirrors%2FMouseSdk-MacOS.git 设备调试 --- diff --git a/MouseSdk/AiMouseSdk/TlwMouseSdk/TlwMouseSdk.m b/MouseSdk/AiMouseSdk/TlwMouseSdk/TlwMouseSdk.m index 6dd6a43..bfde2e6 100644 --- a/MouseSdk/AiMouseSdk/TlwMouseSdk/TlwMouseSdk.m +++ b/MouseSdk/AiMouseSdk/TlwMouseSdk/TlwMouseSdk.m @@ -107,11 +107,13 @@ // [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]; } } @@ -387,16 +389,16 @@ 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; diff --git a/MouseSdk/MouseSdk.xcworkspace/xcuserdata/apple.xcuserdatad/UserInterfaceState.xcuserstate b/MouseSdk/MouseSdk.xcworkspace/xcuserdata/apple.xcuserdatad/UserInterfaceState.xcuserstate index 355ba17..900de24 100644 Binary files a/MouseSdk/MouseSdk.xcworkspace/xcuserdata/apple.xcuserdatad/UserInterfaceState.xcuserstate and b/MouseSdk/MouseSdk.xcworkspace/xcuserdata/apple.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/MouseSdk/MouseSdk.xcworkspace/xcuserdata/apple.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/MouseSdk/MouseSdk.xcworkspace/xcuserdata/apple.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist index b9c3bbe..8d38756 100644 --- a/MouseSdk/MouseSdk.xcworkspace/xcuserdata/apple.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +++ b/MouseSdk/MouseSdk.xcworkspace/xcuserdata/apple.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -111,5 +111,21 @@ landmarkType = "0"> + + + + diff --git a/MouseSdk/MouseSdk/Ble/BleManager.m b/MouseSdk/MouseSdk/Ble/BleManager.m index be15414..23f090e 100644 --- a/MouseSdk/MouseSdk/Ble/BleManager.m +++ b/MouseSdk/MouseSdk/Ble/BleManager.m @@ -190,7 +190,7 @@ if (self.deviceInfoCha ==nil) { return; } - [self showLog:[NSString stringWithFormat:@"向蓝牙设备发送数据 %@",data]]; +// [self showLog:[NSString stringWithFormat:@"向蓝牙设备发送数据 %@",data]]; [self.crrentPeripheral writeValue:data forCharacteristic:self.deviceInfoCha type:CBCharacteristicWriteWithResponse]; } diff --git a/MouseSdk/MouseSdk/Ble/DeviceManger.m b/MouseSdk/MouseSdk/Ble/DeviceManger.m index 4689003..9105a5b 100644 --- a/MouseSdk/MouseSdk/Ble/DeviceManger.m +++ b/MouseSdk/MouseSdk/Ble/DeviceManger.m @@ -54,19 +54,20 @@ __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]; @@ -88,10 +89,10 @@ [[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]; @@ -121,7 +122,7 @@ [self.ble startScanWithName:mouseName]; [TimerManager shared].timerCallBack = ^{ -// [self showLog:@"定时器。。。"]; + [self showLog:@"timer action。。。"]; if([TlwMouse shared].connected){ [self.ble stopScan]; // [self.hid close]; @@ -136,16 +137,16 @@ - (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"; @@ -162,7 +163,21 @@ /// 设置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值设置错误"}]); + } } /// 设置品牌名称 @@ -341,7 +356,7 @@ // 连接状态改变 - (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) { @@ -359,8 +374,8 @@ - (void)showLog:(NSString *)log{ NSLog(@"[AiMouseSdk] %@",log); - [self aiMouseAddLog:log]; } + //将录音数据保存 - (void)finishRecored:(NSData *)data{ NSString *doc = NSTemporaryDirectory(); diff --git a/MouseSdk/MouseSdk/Ble/HidManager.m b/MouseSdk/MouseSdk/Ble/HidManager.m index e20f681..b4e3d91 100644 --- a/MouseSdk/MouseSdk/Ble/HidManager.m +++ b/MouseSdk/MouseSdk/Ble/HidManager.m @@ -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); } diff --git a/MouseSdk/MouseSdk/Ble/TimerManager.m b/MouseSdk/MouseSdk/Ble/TimerManager.m index 9401170..ced8f49 100644 --- a/MouseSdk/MouseSdk/Ble/TimerManager.m +++ b/MouseSdk/MouseSdk/Ble/TimerManager.m @@ -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]; }); diff --git a/MouseSdk/MouseSdk/ViewController.m b/MouseSdk/MouseSdk/ViewController.m index 3d39ab4..d5d77f6 100644 --- a/MouseSdk/MouseSdk/ViewController.m +++ b/MouseSdk/MouseSdk/ViewController.m @@ -264,7 +264,7 @@ }]; } - (void)setDPI:(NSMenuItem*)sender { - [[DeviceManger shared] setCPI:2 completation:^(BOOL isSuccess, NSError * _Nonnull error) { + [[DeviceManger shared] setCPI:800 completation:^(BOOL isSuccess, NSError * _Nonnull error) { }]; }