|
@@ -59,12 +59,12 @@ static connectDeviceManager *connectDeviceManagerInstance = nil;
|
|
|
{
|
|
|
if(needReconnect){
|
|
|
_curConnectDeviceState = DeviceConnectGetThridMsging;
|
|
|
-
|
|
|
+
|
|
|
//更换设备
|
|
|
- NSString *curSdnId = self.DeviceThirdIdMod.data.sdnId;
|
|
|
- if(curSdnId){
|
|
|
- _Pre_sdnId = curSdnId;
|
|
|
- }
|
|
|
+// NSString *curSdnId = self.DeviceThirdIdMod.data.sdnId;
|
|
|
+// if(curSdnId){
|
|
|
+// _Pre_sdnId = curSdnId;
|
|
|
+// }
|
|
|
|
|
|
}
|
|
|
|
|
@@ -139,13 +139,15 @@ static connectDeviceManager *connectDeviceManagerInstance = nil;
|
|
|
|
|
|
#pragma mark 初始化瑞云的SDK等
|
|
|
- (void)initRuiyunSDKFun{
|
|
|
- HLog(@"initRuiyunSDKFun");
|
|
|
|
|
|
-// bool connected = [RaylinkProxy.sharedManager isSdnConnected];
|
|
|
-// if(connected){
|
|
|
-// [self disconnect];
|
|
|
-// }
|
|
|
+ bool connected = [RaylinkProxy.sharedManager isSdnConnected];
|
|
|
+ if(connected){
|
|
|
+ [self onConnectFun];
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
+ HLog(@"initRuiyunSDKFun");
|
|
|
+
|
|
|
self.sdnConnected = NO;
|
|
|
self.peerConnected = NO;
|
|
|
|
|
@@ -180,7 +182,7 @@ static connectDeviceManager *connectDeviceManagerInstance = nil;
|
|
|
NSLog(@"accept ok %d",self.serverSocket.localPort);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ KWeakSelf
|
|
|
/// 启动定时器监听 SND 连接状态
|
|
|
self.connectCheckTimer = [NSTimer scheduledTimerWithTimeInterval:0.5 repeats:YES block:^(NSTimer * _Nonnull timer) {
|
|
|
|
|
@@ -194,6 +196,9 @@ static connectDeviceManager *connectDeviceManagerInstance = nil;
|
|
|
|
|
|
if (self.sdnConnected) {
|
|
|
|
|
|
+ [weakSelf onConnectFun];
|
|
|
+ [self->_connectCheckTimer invalidate];
|
|
|
+
|
|
|
//self.sdnConnectStateLab.text = @"SDN state: Connected";
|
|
|
//self.sdnIDLab.text = [@"My SDN ID: " stringByAppendingString:[RaylinkProxy.sharedManager getSdnId]];
|
|
|
|
|
@@ -206,34 +211,34 @@ static connectDeviceManager *connectDeviceManagerInstance = nil;
|
|
|
}];
|
|
|
|
|
|
|
|
|
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
|
- mainBlock(^{
|
|
|
- [self onConnectFun];
|
|
|
- });
|
|
|
- });
|
|
|
+// dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
|
+// mainBlock(^{
|
|
|
+// [self onConnectFun];
|
|
|
+// });
|
|
|
+// });
|
|
|
}
|
|
|
|
|
|
|
|
|
- (void)onConnectFun{
|
|
|
|
|
|
// 2. 监听SDN 连接状态
|
|
|
- bool connected = [RaylinkProxy.sharedManager isSdnConnected];
|
|
|
-
|
|
|
- HLog(@"协助瑞云看日志onConnectFun isSdnConnected:%d",connected);
|
|
|
-
|
|
|
- if(!connected){
|
|
|
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
|
- mainBlock(^{
|
|
|
- [self onConnectFun];
|
|
|
- });
|
|
|
- });
|
|
|
-
|
|
|
- return;
|
|
|
- }
|
|
|
+// bool connected = [RaylinkProxy.sharedManager isSdnConnected];
|
|
|
+//
|
|
|
+// HLog(@"协助瑞云看日志onConnectFun isSdnConnected:%d",connected);
|
|
|
+//
|
|
|
+// if(!connected){
|
|
|
+// dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
|
+// mainBlock(^{
|
|
|
+// [self onConnectFun];
|
|
|
+// });
|
|
|
+// });
|
|
|
+//
|
|
|
+// return;
|
|
|
+// }
|
|
|
|
|
|
if (self.peerConnected == YES) {
|
|
|
[self disconnect];
|
|
|
- return;
|
|
|
+ //return;
|
|
|
}
|
|
|
|
|
|
_curConnectDeviceState = DeviceConnectDeciceing;
|
|
@@ -321,6 +326,9 @@ static connectDeviceManager *connectDeviceManagerInstance = nil;
|
|
|
[self.socket connectToHost:@"127.0.0.1" onPort:self.tcpPort error:NULL];
|
|
|
|
|
|
_curConnectDeviceState = DeviceConnectDeciceOk;
|
|
|
+
|
|
|
+ _Pre_sdnId = self.DeviceThirdIdMod.data.sdnId;
|
|
|
+
|
|
|
// [self.connectBtn setTitle:@"连接成功" forState:UIControlStateDisabled];
|
|
|
// [self.sendBtn setEnabled:YES];
|
|
|
} else {
|