成功获取到设备信息后再给app回调鉴权成功
authorliangzhenying <867174124@qq.com>
Thu, 26 Dec 2024 09:35:18 +0000 (17:35 +0800)
committerliangzhenying <867174124@qq.com>
Thu, 26 Dec 2024 09:35:18 +0000 (17:35 +0800)
Demo/MouseSdk/MouseSdk.xcworkspace/xcuserdata/yaozuopan.xcuserdatad/UserInterfaceState.xcuserstate
Demo/MouseSdk/Pods/Pods.xcodeproj/xcuserdata/yaozuopan.xcuserdatad/xcschemes/xcschememanagement.plist
MouseSdk/AiMouseSdk/AiMouseSdk.xcodeproj/xcuserdata/yaozuopan.xcuserdatad/xcschemes/xcschememanagement.plist
MouseSdk/AiMouseSdk/AiMouseSdk/AiDeviceInfoManager.m
MouseSdk/AiMouseSdk/AiMouseSdk/AiMouseSdk.m
MouseSdk/AiMouseSdk/ByteDance/ByteDanceSdk.m
MouseSdk/AiMouseSdk/Manager/DeviceManger.m
MouseSdk/MouseSdk.xcworkspace/xcuserdata/yaozuopan.xcuserdatad/UserInterfaceState.xcuserstate
MouseSdk/MouseSdk.xcworkspace/xcuserdata/yaozuopan.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
MouseSdk/Pods/Pods.xcodeproj/xcuserdata/yaozuopan.xcuserdatad/xcschemes/xcschememanagement.plist

index f5bef6d..61667c4 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 aeb998b..dab8f62 100644 (file)
@@ -7,12 +7,12 @@
                <key>Masonry.xcscheme_^#shared#^_</key>
                <dict>
                        <key>orderHint</key>
-                       <integer>1</integer>
+                       <integer>2</integer>
                </dict>
                <key>Pods-MouseSdk.xcscheme_^#shared#^_</key>
                <dict>
                        <key>orderHint</key>
-                       <integer>2</integer>
+                       <integer>1</integer>
                </dict>
        </dict>
 </dict>
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 2cce84d..cc8fd6c 100644 (file)
@@ -83,7 +83,7 @@
             [self showLog:@"deviceSecret未设置"];
             [self.deviceInfo setValue:nil forKey:@"deviceSecret"];
             if(self.deviceInfoBlock){
-                [self showLog:self.deviceInfo.description];
+//                [self showLog:self.deviceInfo.description];
                 self.deviceInfoBlock(self.deviceInfo, nil);
                 self.deviceInfoBlock= nil;
             }
     else if(dict[@"deviceSecret"]) {
         [self.deviceInfo setValue:dict[@"deviceSecret"] forKey:@"deviceSecret"];
         if(self.deviceInfoBlock){
-            [self showLog:self.deviceInfo.description];
+//            [self showLog:self.deviceInfo.description];
             self.deviceInfoBlock(self.deviceInfo, nil);
             self.deviceInfoBlock= nil;
         }
index fb64d88..8aaa0dd 100644 (file)
@@ -37,7 +37,7 @@
 @end
 
 @interface AiMouse()
-
+@property (nonatomic, strong) NSMutableData *voiceData;
 @property (nonatomic, strong) ByteDanceSdk *byteSdk;
 @property (nonatomic, strong) AiAudioManager *audioManager;
 @property (nonatomic, strong) AiRecordManager *recordManager;
@@ -60,6 +60,7 @@
 -(instancetype)init{
     if (self = [super init]) {
         _connectType =  AiMouseConnectType_bluetooth;
+        self.voiceData = [[NSMutableData alloc] init];
         [self.recordManager checkPermissions];
         
         if ([DeviceManger shared].appType == 2 || [DeviceManger shared].appType == 4) {
@@ -78,8 +79,8 @@
         __weak typeof(self) ws = self;
         _deviceInfoManager.sendToBleBlock = ^(NSData * _Nonnull data) {
             if (ws.delegate) {
-                [ws showLog:[NSString stringWithFormat:@"[send][info][json] %@",[[NSString alloc]initWithData:data encoding:NSUTF8StringEncoding]]];
-                [ws showLog:[NSString stringWithFormat:@"[send][info][byte] %@",[AiMouseTools dataToHexString:data]]];
+                [ws showLog:[NSString stringWithFormat:@"[send][info]%@",[[NSString alloc]initWithData:data encoding:NSUTF8StringEncoding]]];
+                [ws showLog:[NSString stringWithFormat:@"[send][info]%@",[AiMouseTools dataToHexString:data]]];
                 [ws.delegate aiMouseSendDeviceInfoData:data];
             }
         };
         if (type == AiMouseConnectType_hid ) {
             [self.recordManager checkPermissions];
         }
-        if([self.delegate respondsToSelector:@selector(aiMouseConnectStateDidChange:)]) [self.delegate aiMouseConnectStateDidChange:self.connected];
         
-        if ([DeviceManger shared].appType == 2 || [DeviceManger shared].appType == 4) {
-            [self.byteSdk startAuth:^(ByteDanceInfo *info) {
-                if(self.delegate) [self.delegate aiMouseAuthenticationResult:AiMouseAuthState_Success];
-            }];
-        }
-        else{
-            if(self.delegate) [self.delegate aiMouseAuthenticationResult:AiMouseAuthState_Success];
-        }
+        __weak typeof(self) ws = self;
+        [self.deviceInfoManager getDeviceInfo:^(AiMouseDeviceInfo * _Nonnull deviceInfo, NSError * _Nonnull error) {
+            if (error != nil) {
+                [ws switchConnect:ws.connectType isConnected:false];
+                return;
+            }
+            if ([DeviceManger shared].appType == 2 || [DeviceManger shared].appType == 4) {
+                [self.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:AiMouseAuthState_Success];
+                }];
+            }
+            else{
+                if([ws.delegate respondsToSelector:@selector(aiMouseConnectStateDidChange:)]) [ws.delegate aiMouseConnectStateDidChange:ws.connected];
+                if(ws.delegate) [ws.delegate aiMouseAuthenticationResult:AiMouseAuthState_Success];
+            }            
+        }];
     }
     else{
         if (self.connected) {
     }
 }
 
+
 #pragma mark - deviceInfoManager
 -(void)sendDeviceDataToSdk:(NSData *)data{
     if (data.length == 0 || (data.length == 6 && [[AiMouseTools dataToHexString:data] hasSuffix:@"f77f"])) {
         [self showLog:@"收到异常数据!!!"];
         return;
     }
-    [self showLog:[NSString stringWithFormat:@"[receive][info][json] %@",[AiMouseTools dataToHexString:data]]];
-    [self showLog:[NSString stringWithFormat:@"[receive][info][byte] %@",[AiMouseTools dataToUtf8String:data]]];
+    [self showLog:[NSString stringWithFormat:@"[receive][info] %@",[AiMouseTools dataToHexString:data]]];
+    [self showLog:[NSString stringWithFormat:@"[receive][info] %@",[AiMouseTools dataToUtf8String:data]]];
 
     
     if ([DeviceManger shared].appType == 2 || [DeviceManger shared].appType == 4) {
     
     __weak typeof(self) ws = self;
     [self.deviceInfoManager getDeviceInfo:^(AiMouseDeviceInfo * _Nonnull deviceInfo, NSError * _Nonnull error) {
-        if ([DeviceManger shared].appType == 2 || [DeviceManger shared].appType == 4) {
+        if (deviceInfo && ([DeviceManger shared].appType == 2 || [DeviceManger shared].appType == 4)) {
             deviceInfo.byteAuthInfo = ws.byteSdk.info;
+            [ws showLog:deviceInfo.description];
         }
         complete(deviceInfo,error);
         if (error != nil) {
 #pragma mark - other
 - (void)sendRecordData:(NSData *)data{
 //    [self showLog:[NSString stringWithFormat:@"[audio] %@",data]];
-    if (self.delegate)  [self.delegate aiMouseSendRecordData:data];
+    if ([DeviceManger shared].appType == 2 || [DeviceManger shared].appType == 4) {
+        [self.voiceData appendData:data];
+        if (self.voiceData.length > 5000) {
+            if (self.delegate)  [self.delegate aiMouseSendRecordData:self.voiceData];
+            self.voiceData = [[NSMutableData alloc] init];
+        }
+    }
+    else{
+        if (self.delegate)  [self.delegate aiMouseSendRecordData:data];
+    }
 }
 - (void)sendCmdData:(NSData *)data{
     [self showLog:[NSString stringWithFormat:@"[send] %@",data]];
 - (void)startRecord{
 //    [self showLog:@"开始录音"];
     [self.recordManager start];
+    self.voiceData = [[NSMutableData alloc] init];
 }
 
 - (void)stopRecord:(BOOL)sendCmd{
 
 
 - (void)sendToBle:(NSData *)data{
-    [self showLog:[NSString stringWithFormat:@"[send][info][byte] %@",[AiMouseTools dataToHexString:data]]];
+    [self showLog:[NSString stringWithFormat:@"[send][info] %@",[AiMouseTools dataToHexString:data]]];
     if (self.delegate) {
         [self.delegate aiMouseSendDeviceInfoData:data];
     };
index 34b33bf..1d436d9 100644 (file)
@@ -35,7 +35,8 @@
 - (void)initSdk{
     [[LogManager shared] addLog:@"开始初始化"];
     stb_app_printf_str_register(cus_printf_str);
-    NSString *appId = @"tis_test";
+//    NSString *appId = @"tis_test";
+    NSString *appId = @"app_10dyx2ai21r2qkar";
     int code = stb_app_init([appId UTF8String]);
     stb_app_event_callback_register(cust_event_callback_func);
     stb_app_send_data_to_device_register(cus_hal_send_data2device);
@@ -46,9 +47,6 @@
     self.byteDanceAuthInfoCallback = complete;
     self.info = [[ByteDanceInfo alloc] init];
     stb_app_start_identify();
-//        [self sendCmdToBle:@{@"cmd":@"set_config",
-//                                  @"set_VMouse_MAC":@"C0:34:56:78:AB:6D"
-//                                }];
 }
 
 - (void)sendToSdk:(NSData *)data{
@@ -193,19 +191,21 @@ static void cust_event_callback_func(uint32_t type,uint8_t *report, uint32_t dat
 
 int32_t STB_STDCALL cus_hal_send_data2device(uint8_t* data, uint32_t len)
 {
-    
-//    dispatch_async(dispatch_get_main_queue(), ^{
+//    if ([[AiMouseTools dataToHexString_placeholder:[[NSData alloc] initWithBytes:data length:len]] hasPrefix:@"07"]) {
+//        NSData *data = [AiMouseTools hexStringToData:@"2D2424073137333532303432363434313624242D0A"];
+//        [[AiMouse shared] sendToBle:data];
+//        return 0;
+//    }
         NSData *cmdData = [[NSData alloc] initWithBytes:data length:len];
         [[LogManager shared] addLog:[NSString stringWithFormat:@"send_data2device = %@",[AiMouseTools dataToHexString_placeholder:cmdData]]];
         NSMutableData *fullData = [[NSMutableData alloc] init];
         
         uint8_t head[] = { 0x2d, 0x24, 0x24};
-        uint8_t tail[] = {0x24, 0x24,0x2d};
+        uint8_t tail[] = {0x24, 0x24,0x2d,0x0a};
         [fullData appendBytes:&head length:3];
         [fullData appendData:cmdData];
         [fullData appendBytes:&tail length:3];
         [[AiMouse shared] sendToBle:fullData];
-//    });
     return 0;
 }
 
index 729411f..515307e 100644 (file)
@@ -59,7 +59,7 @@
 - (void)initSdk:(int)appType{
     _appType = appType;
     
-    NSString *version = @"MouseSdk_v2024122601";
+    NSString *version = @"MouseSdk_v2024122602";
     NSLog(@"[AiMouseSdk] %@",version);
     NSLog(@"[AiMouseSdk] %d",appType);
     [self showLog:version];
index fe3057a..56de63c 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 6f99efd..11b513f 100644 (file)
             landmarkType = "7">
          </BreakpointContent>
       </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            uuid = "29B61A37-1C91-4041-B4D4-6808C309F66F"
+            shouldBeEnabled = "Yes"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "AiMouseSdk/AiMouseSdk/AiDeviceInfoManager.m"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "510"
+            endingLineNumber = "510"
+            landmarkName = "-sendCmdToBle:"
+            landmarkType = "7">
+         </BreakpointContent>
+      </BreakpointProxy>
    </Breakpoints>
 </Bucket>
index 8988d3e..c230d1a 100644 (file)
@@ -7,7 +7,7 @@
                <key>Masonry.xcscheme_^#shared#^_</key>
                <dict>
                        <key>orderHint</key>
-                       <integer>4</integer>
+                       <integer>2</integer>
                </dict>
                <key>Pods-MouseSdk.xcscheme_^#shared#^_</key>
                <dict>