Forráskód Böngészése

1.调试跟进sn获取sdnid接口
2.保存卡密码接口
3.调试瑞云sdk链接成功

huangxiaodong 2 éve%!(EXTRA string=óta)
szülő
commit
393fd26987

+ 40 - 0
创维盒子/双子星云手机.xcodeproj/project.pbxproj

@@ -140,6 +140,12 @@
 		18FCE5492AD15E750020F623 /* PlayerViewController+AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 18FCE5472AD15E750020F623 /* PlayerViewController+AppDelegate.m */; };
 		6B3F96342AD2A15A008E349E /* netWorkManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B3F96322AD2A15A008E349E /* netWorkManager.h */; };
 		6B3F96352AD2A15A008E349E /* netWorkManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B3F96332AD2A15A008E349E /* netWorkManager.m */; };
+		6B3F963A2AD2AD0B008E349E /* newWorkInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B3F96392AD2AD0B008E349E /* newWorkInterface.h */; };
+		6BF0F3D02AD391D8000AA133 /* connectDeviceManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 6BF0F3CE2AD391D8000AA133 /* connectDeviceManager.h */; };
+		6BF0F3D12AD391D8000AA133 /* connectDeviceManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 6BF0F3CF2AD391D8000AA133 /* connectDeviceManager.m */; };
+		6BF0F3D52AD3937B000AA133 /* DeviceThirdIdModel.h in Headers */ = {isa = PBXBuildFile; fileRef = 6BF0F3D32AD3937B000AA133 /* DeviceThirdIdModel.h */; };
+		6BF0F3D62AD3937B000AA133 /* DeviceThirdIdModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 6BF0F3D42AD3937B000AA133 /* DeviceThirdIdModel.m */; };
+		6BF0F3D82AD3DB3C000AA133 /* planet.1ali_3ry_peer in Resources */ = {isa = PBXBuildFile; fileRef = 6BF0F3D72AD3DB3C000AA133 /* planet.1ali_3ry_peer */; };
 		6C21BF39CEECF8E81BD97788 /* libPods-双子星云手机Tests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 16C83602E592F43A82A92B3E /* libPods-双子星云手机Tests.a */; };
 		82762E13327622CA8A8512E6 /* libPods-隐私保护-双子星云手机UITests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5A7C795CAC690A410AE1E306 /* libPods-隐私保护-双子星云手机UITests.a */; };
 		A00221DB27EAFF4A00E45F78 /* HWAddBookmarkViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A00221D927EAFF4A00E45F78 /* HWAddBookmarkViewController.m */; };
@@ -427,6 +433,12 @@
 		5A7C795CAC690A410AE1E306 /* libPods-隐私保护-双子星云手机UITests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-隐私保护-双子星云手机UITests.a"; sourceTree = BUILT_PRODUCTS_DIR; };
 		6B3F96322AD2A15A008E349E /* netWorkManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = netWorkManager.h; sourceTree = "<group>"; };
 		6B3F96332AD2A15A008E349E /* netWorkManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = netWorkManager.m; sourceTree = "<group>"; };
+		6B3F96392AD2AD0B008E349E /* newWorkInterface.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = newWorkInterface.h; sourceTree = "<group>"; };
+		6BF0F3CE2AD391D8000AA133 /* connectDeviceManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = connectDeviceManager.h; sourceTree = "<group>"; };
+		6BF0F3CF2AD391D8000AA133 /* connectDeviceManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = connectDeviceManager.m; sourceTree = "<group>"; };
+		6BF0F3D32AD3937B000AA133 /* DeviceThirdIdModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DeviceThirdIdModel.h; sourceTree = "<group>"; };
+		6BF0F3D42AD3937B000AA133 /* DeviceThirdIdModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DeviceThirdIdModel.m; sourceTree = "<group>"; };
+		6BF0F3D72AD3DB3C000AA133 /* planet.1ali_3ry_peer */ = {isa = PBXFileReference; lastKnownFileType = file; path = planet.1ali_3ry_peer; sourceTree = "<group>"; };
 		71D630B0FBD97501D316E4AB /* Pods-隐私保护.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-隐私保护.release.xcconfig"; path = "Target Support Files/Pods-隐私保护/Pods-隐私保护.release.xcconfig"; sourceTree = "<group>"; };
 		86FBD9FD629A5194B7C58D9F /* Pods-双子星云手机-双子星云手机UITests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-双子星云手机-双子星云手机UITests.debug.xcconfig"; path = "Target Support Files/Pods-双子星云手机-双子星云手机UITests/Pods-双子星云手机-双子星云手机UITests.debug.xcconfig"; sourceTree = "<group>"; };
 		A00221D827EAFF4A00E45F78 /* HWAddBookmarkViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HWAddBookmarkViewController.h; sourceTree = "<group>"; };
@@ -960,10 +972,31 @@
 			children = (
 				6B3F96322AD2A15A008E349E /* netWorkManager.h */,
 				6B3F96332AD2A15A008E349E /* netWorkManager.m */,
+				6B3F96392AD2AD0B008E349E /* newWorkInterface.h */,
 			);
 			path = netWork;
 			sourceTree = "<group>";
 		};
+		6BF0F3CD2AD391BE000AA133 /* connectDeviceManager */ = {
+			isa = PBXGroup;
+			children = (
+				6BF0F3D72AD3DB3C000AA133 /* planet.1ali_3ry_peer */,
+				6BF0F3D22AD3933A000AA133 /* model */,
+				6BF0F3CE2AD391D8000AA133 /* connectDeviceManager.h */,
+				6BF0F3CF2AD391D8000AA133 /* connectDeviceManager.m */,
+			);
+			path = connectDeviceManager;
+			sourceTree = "<group>";
+		};
+		6BF0F3D22AD3933A000AA133 /* model */ = {
+			isa = PBXGroup;
+			children = (
+				6BF0F3D32AD3937B000AA133 /* DeviceThirdIdModel.h */,
+				6BF0F3D42AD3937B000AA133 /* DeviceThirdIdModel.m */,
+			);
+			path = model;
+			sourceTree = "<group>";
+		};
 		A003F69D27D841C800715CBF /* Base */ = {
 			isa = PBXGroup;
 			children = (
@@ -1220,6 +1253,7 @@
 		A02FF69827D7054200D59D3F /* 双子星云手机 */ = {
 			isa = PBXGroup;
 			children = (
+				6BF0F3CD2AD391BE000AA133 /* connectDeviceManager */,
 				6B3F96312AD2A0FA008E349E /* netWork */,
 				183AE6812A8C9ACA00B11CB0 /* CloudPlayer */,
 				183AE5DD2A89CD3C00B11CB0 /* SuperModel */,
@@ -1315,10 +1349,13 @@
 				1868201D2AB97BE1005702A6 /* TipsQRCodeViewController.h in Headers */,
 				181E85002A8F6B1800292B96 /* LogoSelectView.h in Headers */,
 				18BA24872AA5C57900BA01EE /* RSATool.h in Headers */,
+				6B3F963A2AD2AD0B008E349E /* newWorkInterface.h in Headers */,
 				18F9CAFC2ABD35C4003FF71A /* ModifyPWDFirstViewController.h in Headers */,
 				1810F9012AA1839C00322116 /* PhoneTimeInfoModel.h in Headers */,
+				6BF0F3D52AD3937B000AA133 /* DeviceThirdIdModel.h in Headers */,
 				18FCE5332AD12FE00020F623 /* ConnectTestViewController.h in Headers */,
 				181E84F22A8F0A9B00292B96 /* HelpDownScrollView.h in Headers */,
+				6BF0F3D02AD391D8000AA133 /* connectDeviceManager.h in Headers */,
 				18FCE5442AD136FF0020F623 /* ShortcutManager.h in Headers */,
 				181E84FB2A8F57A500292B96 /* ChangeLogoViewController.h in Headers */,
 				18C4754F2A8E0DB5006129C0 /* MySetViewController.h in Headers */,
@@ -1489,6 +1526,7 @@
 				1893CDD92A178DC10074B92F /* HWAboutViewController.xib in Resources */,
 				A003F6FA27D8776C00715CBF /* HWSearchBar.xib in Resources */,
 				A02FF6A627D7054700D59D3F /* Assets.xcassets in Resources */,
+				6BF0F3D82AD3DB3C000AA133 /* planet.1ali_3ry_peer in Resources */,
 				1893CDE02A178FE70074B92F /* HWHistoryViewController.xib in Resources */,
 				A031DD8227EC820400909527 /* agreement.txt in Resources */,
 			);
@@ -1692,6 +1730,7 @@
 				184C8AD12A94980D00F26650 /* CustomerWebViewController.m in Sources */,
 				A08A94FD27E9A4E400C544BB /* NSObject+BGModel.m in Sources */,
 				181E84F32A8F0A9B00292B96 /* HelpDownScrollView.m in Sources */,
+				6BF0F3D12AD391D8000AA133 /* connectDeviceManager.m in Sources */,
 				181E84F62A8F451D00292B96 /* MineViewCell.m in Sources */,
 				18FCE5412AD136670020F623 /* PlayerViewController+AdjustBtnFrame.m in Sources */,
 				184C8ADE2A949DBD00F26650 /* HWVersionModel.m in Sources */,
@@ -1725,6 +1764,7 @@
 				A003F6D227D8425C00715CBF /* HWDataManager.m in Sources */,
 				18C475502A8E0DB5006129C0 /* MySetViewController.m in Sources */,
 				A003F6C127D841FF00715CBF /* FLAnimatedImageView.m in Sources */,
+				6BF0F3D62AD3937B000AA133 /* DeviceThirdIdModel.m in Sources */,
 				184C8ACD2A94557200F26650 /* HidenMaskSetViewController.m in Sources */,
 				18963B472AB84398006E7C50 /* GuideView.m in Sources */,
 				18FCE5452AD136FF0020F623 /* ShortcutManager.m in Sources */,

+ 3 - 0
创维盒子/双子星云手机/AppDelegate/AppDelegate.m

@@ -101,4 +101,7 @@
         }
     });
 }
+
+
+
 @end

+ 9 - 1
创维盒子/双子星云手机/AppDelegate/PrefixHeader.pch

@@ -38,6 +38,10 @@
 #import "ColorDefine.h"
 #import "BaseModel.h"
 
+//网络相关
+#import "netWorkManager.h"
+#import "newWorkInterface.h"
+
 #define globalBlock(block) dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), block)
 
 /**宏定义*/
@@ -75,8 +79,12 @@ isBangsScreen; \
 #define WAUTOSCALE ([[UIScreen mainScreen] bounds].size.width / 375)
 #define HAUTOSCALE ([[UIScreen mainScreen] bounds].size.height / 667)
 
-#define CloudService           @"http://14.18.190.141:11180"
+//#define CloudService           @"http://14.18.190.141:11180"
 //#define CloudService           @"http://14.18.190.141:1280"
+//创维盒子 测试地址
+//#define CloudService   @"http://14.18.190.141:1801"
+#define CloudService   @"http://hiboxde.armclouding.com:7780"
+
 #define FileService            @"http://file.phone.androidscloud.com:8210"
 #define Const_File_Access_Key  @"13d0arghebcc4cm49cf04"
 #define CloudGameService       @"http://14.18.190.140:9090"

+ 25 - 1
创维盒子/双子星云手机/AppDelegate/SceneDelegate.m

@@ -17,6 +17,7 @@
 #import "SetPWDFirstViewController.h"
 #import "ConnectTestViewController.h"
 #import "PlayerViewController.h"
+#import "connectDeviceManager.h"
 
 @interface SceneDelegate ()<SetUsePWDViewControllerDelegate,GuideViewControllerDelegate>
 @property(nonatomic, strong)   CalculatorViewController *calculatorVC;
@@ -37,7 +38,9 @@
         [self initBrowserWindow];
         // 加载主页面
         [self enterMainVCFromScene];
-
+        //
+        [self getNetWorkPopViewFun];
+        
         [self.window makeKeyAndVisible];
     }
 }
@@ -67,6 +70,14 @@
         return;
     }
     
+    //有设备了先去做链接准备  // 80bec9c5
+    NSString *SNStr = deviceDict[@"Const_Have_Add_Device_SN"];
+    if(SNStr){
+        [[connectDeviceManager shareInstance] getThridMsgBySN:SNStr];
+    }
+
+   
+    
     //    GuideViewController
     BOOL haveGuide = [HWDataManager getBoolWithKey:Const_Have_Show_Guide];
     if (haveGuide) {
@@ -74,6 +85,7 @@
     }else {
         GuideViewController *guiDeVC = [[GuideViewController alloc] init];
         guiDeVC.delegate = self;
+        guiDeVC.sn = SNStr;
         self.window.rootViewController = guiDeVC;
         
         return;
@@ -381,4 +393,16 @@
     [self enterMainVCFromScene];
 }
 
+#pragma mark 调起系统网络允许
+-(void)getNetWorkPopViewFun
+{
+    NSMutableDictionary *paraDict = [NSMutableDictionary new];
+    
+//    KWeakSelf
+    [[netWorkManager shareInstance] CommonGetWithCallBackCode:@"" Parameters:paraDict success:^(id  _Nonnull responseObject) {
+    
+    } failure:^(NSError * _Nonnull error) {
+    }];
+}
+
 @end

+ 6 - 9
创维盒子/双子星云手机/Class/Guide/GuideViewController.m

@@ -11,6 +11,7 @@
 #import "GuideView.h"
 #import "GuideLastView.h"
 #import "SetPWDFirstViewController.h"
+#import "connectDeviceManager.h"
 
 @interface GuideViewController ()
 {
@@ -32,6 +33,11 @@
     [super viewDidLoad];
     // Do any additional setup after loading the view.
     [self drawAnyView];
+    
+    
+    if([[connectDeviceManager shareInstance] curConnectDeviceState] == DeviceConnectUnknown){
+        [[connectDeviceManager shareInstance] getThridMsgBySN:sn];
+    }
 }
 
 - (void)viewDidAppear:(BOOL)animated{
@@ -100,14 +106,5 @@
 }
 
 
-/*
-#pragma mark - Navigation
-
-// In a storyboard-based application, you will often want to do a little preparation before navigation
-- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
-    // Get the new view controller using [segue destinationViewController].
-    // Pass the selected object to the new view controller.
-}
-*/
 
 @end

+ 12 - 0
创维盒子/双子星云手机/Class/Guide/SetPWDSecondViewController.m

@@ -8,6 +8,7 @@
 #import "SetPWDSecondViewController.h"
 #import <Masonry.h>
 
+#import "connectDeviceManager.h"
 @interface SetPWDSecondViewController (){
     NSString *pwd;
     UILabel *pointView0;
@@ -241,7 +242,18 @@
             NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithDictionary:deviceDict];
             [dict setObject:pwd forKey:Const_Have_Add_Device_PWD];
             [HWDataManager setObjectWithKey:Const_Have_Add_Device value:dict];
+           
+            
+            if (deviceDict && [[deviceDict allKeys] containsObject:Const_Have_Add_Device_SN]){
+                //有设备了先去做链接准备  // 80bec9c5
+                NSString *SNStr = deviceDict[@"Const_Have_Add_Device_SN"];
+                if(SNStr){
+                    [[connectDeviceManager shareInstance] updateCardInfoBySN:SNStr withPwdStr:pwd];
+                }
+            }
+            
             [[NSNotificationCenter defaultCenter] postNotificationName:GuideOkNotification object:nil];
+            
         }else{
             /*提示密码不一致*/
             [topLabel setText:NSLocalizedString(@"guide_set_pwd_no_same",nil)];

+ 12 - 0
创维盒子/双子星云手机/Info.plist

@@ -64,6 +64,18 @@
 	</array>
 	<key>NSAppTransportSecurity</key>
 	<dict>
+		<key>NSExceptionDomains</key>
+		<dict>
+			<key>hiboxde.armclouding.com</key>
+			<dict>
+				<key>NSExceptionRequiresForwardSecrecy</key>
+				<false/>
+				<key>NSExceptionAllowsInsecureHTTPLoads</key>
+				<true/>
+				<key>NSIncludesSubdomains</key>
+				<true/>
+			</dict>
+		</dict>
 		<key>NSAllowsArbitraryLoads</key>
 		<true/>
 		<key>NSAllowsArbitraryLoadsInWebContent</key>

+ 1 - 1
创维盒子/双子星云手机/SuperModel/SuperModel.h

@@ -11,7 +11,7 @@
 @interface SuperModel : JSONModel
 
 @property(nonatomic,copy) NSString* msg;//描述信息
-@property(nonatomic,strong) NSNumber* status; //错误码
+@property(nonatomic,assign) NSInteger status; //错误码
 
 
 @end

+ 36 - 0
创维盒子/双子星云手机/connectDeviceManager/connectDeviceManager.h

@@ -0,0 +1,36 @@
+//
+//  connectDeviceManager.h
+//  隐私保护
+//
+//  Created by xd h on 2023/10/9.
+//
+
+#import <Foundation/Foundation.h>
+#import "DeviceThirdIdModel.h"
+NS_ASSUME_NONNULL_BEGIN
+
+typedef enum{
+    DeviceConnectUnknown = -1,
+    DeviceConnectGetThridMsging = 0,
+    DeviceConnectGetThridOK,
+    DeviceConnectGetThridFail,
+    DeviceConnectDeciceing,
+    DeviceConnectDeciceOk,
+}connectDeviceState;
+
+@interface connectDeviceManager : NSObject
++(connectDeviceManager *)shareInstance;
+
+@property(nonatomic,strong) DeviceThirdIdModel *DeviceThirdIdMod;//设备的第三方信息  连接时需要
+@property(nonatomic,assign) connectDeviceState  curConnectDeviceState;
+
+@property(nonatomic,copy) NSString*  tcpPortStr;
+
+#pragma mark 根据扫码的sn获取第三方信息
+-(void)getThridMsgBySN:(NSString*)snStr;
+
+#pragma mark 保持卡密码
+-(void)updateCardInfoBySN:(NSString*)snStr withPwdStr:(NSString*)pwd;
+@end
+
+NS_ASSUME_NONNULL_END

+ 306 - 0
创维盒子/双子星云手机/connectDeviceManager/connectDeviceManager.m

@@ -0,0 +1,306 @@
+//
+//  connectDeviceManager.m
+//  隐私保护
+//
+//  Created by xd h on 2023/10/9.
+//
+
+//第三方  瑞云 的链接服务
+#import "connectDeviceManager.h"
+
+#import <RayProxy/RaylinkProxy.h>
+#import <CocoaAsyncSocket/GCDAsyncSocket.h>
+
+@interface connectDeviceManager ()<
+GCDAsyncSocketDelegate,
+RaylinkProxyDelegate
+>
+{
+    dispatch_queue_t initProxyQueue;
+}
+
+@property (nonatomic, strong) NSTimer *connectCheckTimer;
+
+@property (nonatomic, strong) GCDAsyncSocket *socket;
+
+@property (nonatomic, strong) GCDAsyncSocket *serverSocket;
+
+@property (nonatomic, assign) BOOL sdnConnected;
+@property (nonatomic, assign) BOOL peerConnected;
+
+@property (nonatomic, assign) NSInteger tcpPort;
+
+
+@end
+
+@implementation connectDeviceManager
+static connectDeviceManager *connectDeviceManagerInstance = nil;
++(connectDeviceManager *)shareInstance;
+{
+    static dispatch_once_t onceToken;
+    
+    dispatch_once(&onceToken, ^{
+        connectDeviceManagerInstance = [[connectDeviceManager alloc] init];
+        connectDeviceManagerInstance.curConnectDeviceState = DeviceConnectUnknown;
+    });
+    
+    return connectDeviceManagerInstance;
+}
+
+
+#pragma mark 根据扫码的sn获取第三方信息
+-(void)getThridMsgBySN:(NSString*)snStr
+{
+    _curConnectDeviceState = DeviceConnectGetThridMsging;
+    
+    NSMutableDictionary *paraDict = [NSMutableDictionary new];
+    [paraDict setValue:snStr forKey:@"sn"];
+    
+    KWeakSelf
+    [[netWorkManager shareInstance] CommonGetWithCallBackCode:getThirdIdBySn Parameters:paraDict success:^(id  _Nonnull responseObject) {
+        
+        
+        weakSelf.DeviceThirdIdMod = [[DeviceThirdIdModel alloc] initWithDictionary:responseObject error:nil];
+
+        if(weakSelf.DeviceThirdIdMod.status == 0)
+        {
+            weakSelf.curConnectDeviceState = DeviceConnectGetThridOK;
+            [weakSelf initRuiyunSDKFun];
+        }
+        
+        
+        
+    } failure:^(NSError * _Nonnull error) {
+        HLog("网络报错");
+    }];
+}
+
+#pragma mark 初始化瑞云的SDK等
+- (void)initRuiyunSDKFun{
+   
+        
+    self.sdnConnected = NO;
+    self.peerConnected = NO;
+    
+    //self.sendBtn.enabled = NO;
+    
+    //self.sdnConnectStateLab.text = @"SDN state: Connectting";
+    //self.sdnIDLab.text = @"My SDN ID:";
+    
+    RaylinkProxy.sharedManager.delegate = self;
+    
+    initProxyQueue = dispatch_queue_create("init_proxy", 0);
+    
+    NSURL *logUrl = [[NSFileManager.defaultManager URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask].firstObject URLByAppendingPathComponent:@"logs"];
+    
+    if (![NSFileManager.defaultManager fileExistsAtPath:logUrl.path]) {
+        [NSFileManager.defaultManager createDirectoryAtURL:logUrl withIntermediateDirectories:YES attributes:NULL error:NULL];
+    }
+    
+    dispatch_async(initProxyQueue, ^{
+        NSData *sdnInfo = [NSData dataWithContentsOfURL:[[NSBundle.mainBundle bundleURL] URLByAppendingPathComponent:@"planet.1ali_3ry_peer"]];
+        
+        /// 1. 初始化代理库
+        [RaylinkProxy.sharedManager initProxy:logUrl.path rootSdnInfo:sdnInfo];
+    });
+    
+    
+    /// 作为服务端时,启动端口监听
+    self.serverSocket = [[GCDAsyncSocket alloc] initWithDelegate:self delegateQueue:dispatch_get_main_queue()];
+    
+    if ([self.serverSocket acceptOnPort:0 error:NULL]) {
+        //self.serverPortLab.text = [NSString stringWithFormat: @"server port: %d", self.serverSocket.localPort];
+        NSLog(@"accept ok %d",self.serverSocket.localPort);
+    }
+    
+    
+    /// 启动定时器监听 SND 连接状态
+    self.connectCheckTimer = [NSTimer scheduledTimerWithTimeInterval:0.5 repeats:YES block:^(NSTimer * _Nonnull timer) {
+        
+        /// 2. 监听SDN 连接状态
+        bool connected = [RaylinkProxy.sharedManager isSdnConnected];
+        if (self.sdnConnected == connected) {
+            return;
+        }
+        
+        self.sdnConnected = connected;
+        
+        if (self.sdnConnected) {
+            
+            //self.sdnConnectStateLab.text = @"SDN state: Connected";
+            //self.sdnIDLab.text = [@"My SDN ID: " stringByAppendingString:[RaylinkProxy.sharedManager getSdnId]];
+            
+                
+        } else {
+            //self.sdnConnectStateLab.text = @"SDN state: Connectting";
+        }
+        
+        
+    }];
+    
+    
+    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
+        mainBlock(^{
+            [self onConnectFun];
+        });
+    });
+}
+
+
+- (void)onConnectFun{
+    
+    if (self.peerConnected == YES) {
+        [self disconnect];
+        return;
+    }
+    
+    _curConnectDeviceState = DeviceConnectDeciceing;
+
+    
+    /// 3. 根据对端的 SDN ID 创建连接
+    [RaylinkProxy.sharedManager createNewConnection:self.DeviceThirdIdMod.data.sdnId];
+    
+    /// 4. 创建 HttpService
+    self.tcpPort = [RaylinkProxy.sharedManager createHttpService:self.DeviceThirdIdMod.data.sdnId];
+    self.tcpPortStr = [[NSString alloc] initWithFormat:@"%ld",self.tcpPort];
+    
+    self.socket = [[GCDAsyncSocket alloc] initWithDelegate:self delegateQueue:dispatch_get_main_queue()];
+    
+    /// 6. 添加端口防火墙
+    [RaylinkProxy.sharedManager addSdnId:self.DeviceThirdIdMod.data.sdnId allowPort:9100];
+    
+    //[self.connectBtn setEnabled:NO];
+    
+    //[self.connectBtn setTitle:@"连接中..." forState:UIControlStateDisabled];
+    
+}
+
+- (void)disconnect {
+//    [RaylinkProxy.sharedManager closeConnection:self.sdnIdTF.text];
+//    [RaylinkProxy.sharedManager closeHttpService:self.sdnIdTF.text];
+//    [self.connectBtn setTitle:@"连接" forState:UIControlStateNormal];
+    self.peerConnected = NO;
+}
+
+- (IBAction)onClickSend:(id)sender {
+    
+//    if (self.messageTF.text.length <= 0) {
+//        return;
+//    }
+    
+    [self.socket writeData:[@"111" dataUsingEncoding:NSUTF8StringEncoding] withTimeout:-1 tag:0];
+    
+}
+
+- (void)socket:(GCDAsyncSocket *)sock didAcceptNewSocket:(GCDAsyncSocket *)newSocket {
+    
+    NSLog(@"didAcceptNewSocket");
+    
+    
+    [newSocket setDelegate:self delegateQueue:dispatch_get_main_queue()];
+    
+    NSThread *revcThread = [[NSThread alloc] initWithBlock:^{
+        
+        while (true) {
+            [newSocket readDataWithTimeout:-1 tag:0];
+            [NSThread sleepForTimeInterval:0.1];
+        }
+    }];
+    
+    [revcThread start];
+    
+}
+
+- (void)onProxyConnected:(NSString *)sdnId status:(int)status {
+    
+    
+    if (status == 0) {
+        /// 6. 等待连接成功回调,创建 TCP socket 连接 HttpService 的端口
+        [self.socket connectToHost:@"127.0.0.1" onPort:self.tcpPort error:NULL];
+        
+        _curConnectDeviceState = DeviceConnectDeciceOk;
+//        [self.connectBtn setTitle:@"连接成功" forState:UIControlStateDisabled];
+//        [self.sendBtn setEnabled:YES];
+    } else {
+//        [self.connectBtn setTitle:@"连接中..." forState:UIControlStateDisabled];
+//        [self.sendBtn setEnabled:NO];
+    }
+}
+
+- (void)socket:(GCDAsyncSocket *)sock didConnectToHost:(NSString *)host port:(uint16_t)port {
+    
+    NSLog(@"didConnectToHost %d", port);
+    
+    NSThread *thread = [[NSThread alloc] initWithBlock:^{
+        while (true) {
+
+            [self.socket readDataWithTimeout:-1 tag:0];
+            [NSThread sleepForTimeInterval:0.1];
+
+        }
+    }];
+
+    [thread start];
+    
+    /// 7. Socket 连接成功后,通过 socket  发送, self.peerPortTF 为对端服务端口
+    [sock writeData:[[NSString stringWithFormat:@"CONNECT 127.0.0.1:%@ HTTP/1.0\r\n\r\n", @"9100"] dataUsingEncoding:NSUTF8StringEncoding] withTimeout:-1 tag:0];
+
+    NSLog(@"readDataToData");
+    
+}
+
+- (void)socket:(GCDAsyncSocket *)sock didWriteDataWithTag:(long)tag
+{
+    NSLog(@"socket:%p didWriteDataWithTag:%ld", sock, tag);
+}
+
+- (void)socket:(GCDAsyncSocket *)sock didReadData:(NSData *)data withTag:(long)tag {
+    
+    
+    if (tag == 0) {
+        
+        NSString *str = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
+        
+        /// 8. 收到包含 `HTTP/1.0 200`的字符串,则认为连接成功。可以正常给对端发消息了
+        if ([str containsString:@"HTTP/1.0 200"]) {
+            NSLog(@"Connected");
+            self.peerConnected = YES;
+//            self.connectBtn.enabled = YES;
+//            [self.connectBtn setTitle:@"断开连接" forState:UIControlStateNormal];
+        }
+        
+    }
+    
+    //self.revcLab.text = [NSString stringWithFormat:@"接收:%@", [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]];
+}
+
+
+
+
+#pragma mark 保持卡密码
+-(void)updateCardInfoBySN:(NSString*)snStr withPwdStr:(NSString*)pwd
+{
+    
+    
+    NSMutableDictionary *paraDict = [NSMutableDictionary new];
+    [paraDict setValue:snStr forKey:@"sn"];
+    [paraDict setValue:pwd forKey:@"password"];
+    
+    KWeakSelf
+    [[netWorkManager shareInstance] CommonGetWithCallBackCode:updateCardInfo Parameters:paraDict success:^(id  _Nonnull responseObject) {
+        
+        
+        SuperModel*model = [[SuperModel alloc] initWithDictionary:responseObject error:nil];
+
+        if(model.status == 0)
+        {
+            
+        }
+        
+        
+        
+    } failure:^(NSError * _Nonnull error) {
+        HLog("网络报错");
+    }];
+}
+@end

+ 33 - 0
创维盒子/双子星云手机/connectDeviceManager/model/DeviceThirdIdModel.h

@@ -0,0 +1,33 @@
+//
+//  DeviceThirdIdModel.h
+//  隐私保护
+//
+//  Created by xd h on 2023/10/9.
+//
+
+#import "SuperModel.h"
+#import "JSONModel.h"
+NS_ASSUME_NONNULL_BEGIN
+
+@interface DeviceThirdDataModel : JSONModel
+
+/**板卡类型*/
+@property(nonatomic,copy) NSString  *broadType;//
+/**第一次绑定时间 ??*/
+@property(nonatomic,copy) NSString  *firstTime;//
+/**ip */
+@property(nonatomic,copy) NSString  *ip;//
+
+/**没有密码要去设置密码 */
+@property(nonatomic,copy) NSString  *sdnId;//
+
+/**sn*/
+@property (nonatomic,copy) NSString *sn; //
+
+@end
+
+@interface DeviceThirdIdModel : SuperModel
+@property(nonatomic,strong) DeviceThirdDataModel*data;
+@end
+
+NS_ASSUME_NONNULL_END

+ 16 - 0
创维盒子/双子星云手机/connectDeviceManager/model/DeviceThirdIdModel.m

@@ -0,0 +1,16 @@
+//
+//  DeviceThirdIdModel.m
+//  隐私保护
+//
+//  Created by xd h on 2023/10/9.
+//
+
+#import "DeviceThirdIdModel.h"
+
+@implementation DeviceThirdDataModel
+
+@end
+
+@implementation DeviceThirdIdModel
+
+@end

BIN
创维盒子/双子星云手机/connectDeviceManager/planet.1ali_3ry_peer


+ 3 - 14
创维盒子/双子星云手机/netWork/netWorkManager.m

@@ -49,7 +49,7 @@ static netWorkManager *Game_NetWorkShareInstance = nil;
 
 - (void)initManager
 {
-    mCloudService = @"http//....";
+    mCloudService = CloudService;
    
     
     if ([mCloudService rangeOfString:@"https"].location != NSNotFound)
@@ -144,12 +144,7 @@ static netWorkManager *Game_NetWorkShareInstance = nil;
 - (void)CommonPostCallBackCode:(NSString*)code  Parameters:(NSDictionary*)dict success:(netWork_Success)success failure:(netWork_Faild)failure
 {
     
-    NSString *curServer = @"";// RC_Game_SDK_CloudService;
-    NSString *customServer = @"";//[RCGameTool getCustomServerUrl];
-    
-    if (customServer && customServer.length >0 ) {
-        curServer = customServer;
-    }
+    NSString *curServer = mCloudService;
     
     HLog(@"地址:%@ \n接口名称:%@,\n 参数:%@\n",curServer,code,dict);
     
@@ -186,13 +181,7 @@ static netWorkManager *Game_NetWorkShareInstance = nil;
 - (void)CommonGetWithCallBackCode:(NSString *)code Parameters:(NSDictionary *_Nullable)dic success:(netWork_Success)success failure:(netWork_Faild)faildStr
 {
     
-    NSString *curServer = @"";//RC_Game_SDK_CloudService;
-    NSString *customServer = @"";//[RCGameTool getCustomServerUrl];
-    
-    if (customServer && customServer.length >0 ) {
-        curServer = customServer;
-    }
-    
+    NSString *curServer = mCloudService;
 
     NSString *url = [NSString stringWithFormat:@"%@%@",curServer,code];
     

+ 25 - 0
创维盒子/双子星云手机/netWork/newWorkInterface.h

@@ -0,0 +1,25 @@
+//
+//  newWorkInterface.h
+//  隐私保护
+//
+//  Created by xd h on 2023/10/8.
+//
+
+#ifndef newWorkInterface_h
+#define newWorkInterface_h
+
+/*1 根据盒子SN号获取对应信息   get请求
+输入参数     sn  贴在盒子上的sn好
+
+ 
+ 返回数据模型 */
+#define getThirdIdBySn  @"/box/queryThirdId"
+
+/*2 修改/保存密码   POST请求
+输入参数     sn  贴在盒子上的sn好
+输入参数     password  用户输入的密码
+ 
+ 返回数据模型 */
+#define updateCardInfo  @"/box/updateCardInfo"
+
+#endif /* newWorkInterface_h */