字节兼容usb模式、修复断开连接后无法再次鉴权bug
authorliangzhenying <867174124@qq.com>
Thu, 2 Jan 2025 10:06:01 +0000 (18:06 +0800)
committerliangzhenying <867174124@qq.com>
Thu, 2 Jan 2025 10:06:01 +0000 (18:06 +0800)
MouseSdk/AiMouseSdk/AiMouseSdk.xcodeproj/xcuserdata/yaozuopan.xcuserdatad/xcschemes/xcschememanagement.plist
MouseSdk/AiMouseSdk/AiMouseSdk/AiMouseSdk.m
MouseSdk/AiMouseSdk/ByteDance/ByteDanceSdk.m
MouseSdk/AiMouseSdk/Manager/DeviceManger.m
MouseSdk/AiMouseSdk/Manager/HidManager.m
MouseSdk/MouseSdk.xcworkspace/xcuserdata/yaozuopan.xcuserdatad/UserInterfaceState.xcuserstate
MouseSdk/MouseSdk.xcworkspace/xcuserdata/yaozuopan.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
MouseSdk/MouseSdk/ViewController.m
MouseSdk/Pods/Pods.xcodeproj/xcuserdata/yaozuopan.xcuserdatad/xcschemes/xcschememanagement.plist

index 64bd978..27157b9 100644 (file)
@@ -7,7 +7,7 @@
                <key>AiMouseSdk copy.xcscheme_^#shared#^_</key>
                <dict>
                        <key>orderHint</key>
-                       <integer>2</integer>
+                       <integer>4</integer>
                </dict>
                <key>AiMouseSdk.xcscheme_^#shared#^_</key>
                <dict>
index b860527..fd5fabf 100644 (file)
                 [ws switchConnect:ws.connectType isConnected:false];
                 return;
             }
-            if ([DeviceManger shared].appType == 2 || [DeviceManger shared].appType == 4) {
-                [self.byteSdk startAuth:^(ByteDanceInfo *info) {
+//            if ([DeviceManger shared].appType == 2 || [DeviceManger shared].appType == 4) {
+            if (([DeviceManger shared].appType == 2 || [DeviceManger shared].appType == 4) && ws.byteSdk.info == nil) {
+                [ws.byteSdk startAuth:^(ByteDanceInfo *info) {
                     deviceInfo.byteAuthInfo = info;
                     [ws showLog:deviceInfo.description];
-                    if([self.delegate respondsToSelector:@selector(aiMouseConnectStateDidChange:)]) [self.delegate aiMouseConnectStateDidChange:self.connected];
-                    if(self.delegate) [self.delegate aiMouseAuthenticationResult:true];
+                    if([ws.delegate respondsToSelector:@selector(aiMouseConnectStateDidChange:)]) [ws.delegate aiMouseConnectStateDidChange:ws.connected];
+                    if(ws.delegate) [ws.delegate aiMouseAuthenticationResult:true];
                 }];
             }
             else{
index 53e565e..c4deac4 100644 (file)
 
 - (void)checkAuthSuccess{
     if (self.info.urlParams && self.info.expireTime && self.info.token && self.info.host) {
-        if(self.byteDanceAuthInfoCallback)self.byteDanceAuthInfoCallback(self.info);
-        stb_app_stop_identify();
+        if(self.byteDanceAuthInfoCallback){
+            self.byteDanceAuthInfoCallback(self.info);           
+        }
+//        [self performSelector:@selector(stopAuth) withObject:nil afterDelay:5];
     }
 }
+- (void)stopAuth{
+    stb_app_stop_identify();
+}
 - (void)sendCmdToBle:(NSDictionary *)dict{
     NSData *data = [AiMouseTools dictionaryToData:dict];
     NSString *str = [AiMouseTools dataToUtf8String:data];
@@ -202,10 +207,19 @@ int32_t STB_STDCALL cus_hal_send_data2device(uint8_t* data, uint32_t len)
         NSMutableData *fullData = [[NSMutableData alloc] init];
         
         uint8_t head[] = { 0x2d, 0x24, 0x24};
-        uint8_t tail[] = {0x24, 0x24,0x2d,0x0a};
+        uint8_t tail[] = {0x24, 0x24,0x2d};
         [fullData appendBytes:&head length:3];
         [fullData appendData:cmdData];
         [fullData appendBytes:&tail length:3];
+    
+    if (fullData.length < 64) {
+        NSInteger len = 64 - fullData.length;
+        for (NSInteger i = 0; i < len; i++) {
+            uint8_t d = 0x00;
+            [fullData  appendBytes:&d length:1];
+        }
+    }
+    
         [[AiMouse shared] sendToBle:fullData];
     return 0;
 }
index 18a936a..2f0617f 100644 (file)
@@ -54,7 +54,7 @@
 //        [self setupBle];
 //        [self setupHid];
 //        [self setupTimer];
-        self.version = @"MouseSdk_v2024122602";
+        self.version = @"MouseSdk_v2025010301";
     }
     return self;
 }
 }
 ///获取设备信息
 - (void)getDeviceInfo:(void (^)(AiMouseDeviceInfo *deviceInfo,NSError *error))finished{
+    [self showLog:@"app主动获取设备信息 。。。"];
     if(self.productType == AiMouseProductType_keyboard){
         [self.kbSdk getDeviceInfo:finished];
     }
index 22e4532..fde3c58 100644 (file)
@@ -12,7 +12,7 @@
 #import <Carbon/Carbon.h>
 #import <Cocoa/Cocoa.h>
 #import "AiDeviceAuthManager.h"
-
+#import "TlwTools.h"
 @interface HidManager ()
 @property(nonatomic, assign) IOHIDManagerRef hidManager;///hid管理
 @property(nonatomic, assign) IOHIDDeviceRef deviceInfoCha;//设备信息通道
@@ -199,7 +199,7 @@ static void hidReceiveData(void* context, IOReturn result, void* sender, IOHIDRe
     }
     else{
         NSData *data1 = [[NSData alloc] initWithBytes:report length:reportLength];
-        //                [[HidManager shared] showLog:[NSString stringWithFormat:@"receive = %@",data1]];
+        [[HidManager shared] showLog:[NSString stringWithFormat:@"收到usb  = %@",[TlwTools dataToHexString:data1]]];
         
         NSInteger len = get_data_len(report, reportLength);
         NSData *data = [[NSData alloc] initWithBytes:report length:len];
@@ -288,12 +288,22 @@ static void hidReceiveData(void* context, IOReturn result, void* sender, IOHIDRe
     if(self.logCallBack) self.logCallBack(text);
 }
 
+///// 实际到数据长度
+//static inline int get_data_len(uint8_t *buf, u_long len) {
+//    if (len <= 0 ) return 0;
+//    int url_len = 0;
+//    while (buf[url_len] != 0x00) url_len++;
+//    return url_len;
+//}
+
 /// 实际到数据长度
-static inline int get_data_len(uint8_t *buf, u_long len) {
+static inline int get_data_len(uint8_t *buf, int len) {
     if (len <= 0 ) return 0;
-    int url_len = 0;
-    while (buf[url_len] != 0x00) url_len++;
-    return url_len;
+    int end = len - 1;
+    while (end >= 0 && (buf[end] == 0 || buf[end - 1] == 0)) {
+        end--;
+    }
+    return end + 1;
 }
 
 /// 获取对应属性值
index d68a1e1..16c4631 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 ab46afa..81258ac 100644 (file)
@@ -5,19 +5,15 @@
    version = "2.0">
    <Breakpoints>
       <BreakpointProxy
-         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         BreakpointExtensionID = "Xcode.Breakpoint.ExceptionBreakpoint">
          <BreakpointContent
-            uuid = "29B61A37-1C91-4041-B4D4-6808C309F66F"
+            uuid = "B13C82BB-F468-4E93-A44A-F14FFAD4D10D"
             shouldBeEnabled = "Yes"
             ignoreCount = "0"
             continueAfterRunningActions = "No"
-            filePath = "AiMouseSdk/AiMouseSdk/AiDeviceInfoManager.m"
-            startingColumnNumber = "9223372036854775807"
-            endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "510"
-            endingLineNumber = "510"
-            landmarkName = "-sendCmdToBle:"
-            landmarkType = "7">
+            breakpointStackSelectionBehavior = "1"
+            scope = "1"
+            stopOnStyle = "0">
          </BreakpointContent>
       </BreakpointProxy>
    </Breakpoints>
index 14ba3ae..2dfccfa 100644 (file)
@@ -93,8 +93,8 @@
 #pragma mark - action
 - (void)setupDeviceManger{
     DeviceManger *manager = [DeviceManger shared];
-    [manager initSdk:1];
-    manager.debugLevel = 1;
+    [manager initSdk:2];
+    manager.debugLevel = 2;
     
     __weak typeof(self) ws = self;
 //    manager.aiMouseAddLogCallBack = ^(NSString * _Nonnull log) {
index 30f1cdd..c230d1a 100644 (file)
@@ -7,12 +7,12 @@
                <key>Masonry.xcscheme_^#shared#^_</key>
                <dict>
                        <key>orderHint</key>
-                       <integer>3</integer>
+                       <integer>2</integer>
                </dict>
                <key>Pods-MouseSdk.xcscheme_^#shared#^_</key>
                <dict>
                        <key>orderHint</key>
-                       <integer>4</integer>
+                       <integer>3</integer>
                </dict>
        </dict>
 </dict>