From 5614a0a9319ebe23979b3a0ead7f89a25abec337 Mon Sep 17 00:00:00 2001 From: xuemh Date: Mon, 6 Aug 2018 22:51:30 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=9B=9E=E8=B0=83=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E7=9A=84=E8=A7=A3=E6=9E=90=E8=BF=87=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Ifish.xcodeproj/project.pbxproj | 6 +++++ .../ConnectHotpotViewController.m | 4 ++++ .../leftcontrollers/IFishHotpotUDPHelper.m | 13 +++++++---- .../IFishUDPHelperBackMsgModel.h | 19 +++++++++++++++ .../IFishUDPHelperBackMsgModel.m | 23 +++++++++++++++++++ 5 files changed, 61 insertions(+), 4 deletions(-) create mode 100644 Ifish/controllers/leftcontrollers/IFishUDPHelperBackMsgModel.h create mode 100644 Ifish/controllers/leftcontrollers/IFishUDPHelperBackMsgModel.m diff --git a/Ifish.xcodeproj/project.pbxproj b/Ifish.xcodeproj/project.pbxproj index c67abe2..279fbd8 100644 --- a/Ifish.xcodeproj/project.pbxproj +++ b/Ifish.xcodeproj/project.pbxproj @@ -2468,6 +2468,7 @@ E52B400621042ED2003BBA3E /* ConnectHotspotTipViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = E52B400421042ED2003BBA3E /* ConnectHotspotTipViewController.xib */; }; E5317A1321188F170014AFDD /* ResetDeviceModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E5317A1221188F170014AFDD /* ResetDeviceModel.m */; }; E5317A1621188F8A0014AFDD /* RestartDeviceModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E5317A1521188F8A0014AFDD /* RestartDeviceModel.m */; }; + E5317A19211896080014AFDD /* IFishUDPHelperBackMsgModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E5317A18211896080014AFDD /* IFishUDPHelperBackMsgModel.m */; }; E547870B20728F390060C2C2 /* back_btn@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = E547870A20728F380060C2C2 /* back_btn@2x.png */; }; E547870F2073192E0060C2C2 /* introlImage_iphonex_1.jpg in Resources */ = {isa = PBXBuildFile; fileRef = E547870C2073192D0060C2C2 /* introlImage_iphonex_1.jpg */; }; E54787102073192E0060C2C2 /* introlImage_iphonex_2.jpg in Resources */ = {isa = PBXBuildFile; fileRef = E547870D2073192D0060C2C2 /* introlImage_iphonex_2.jpg */; }; @@ -6271,6 +6272,8 @@ E5317A1221188F170014AFDD /* ResetDeviceModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ResetDeviceModel.m; sourceTree = ""; }; E5317A1421188F8A0014AFDD /* RestartDeviceModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RestartDeviceModel.h; sourceTree = ""; }; E5317A1521188F8A0014AFDD /* RestartDeviceModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RestartDeviceModel.m; sourceTree = ""; }; + E5317A17211896080014AFDD /* IFishUDPHelperBackMsgModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = IFishUDPHelperBackMsgModel.h; sourceTree = ""; }; + E5317A18211896080014AFDD /* IFishUDPHelperBackMsgModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = IFishUDPHelperBackMsgModel.m; sourceTree = ""; }; E547870A20728F380060C2C2 /* back_btn@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "back_btn@2x.png"; sourceTree = ""; }; E547870C2073192D0060C2C2 /* introlImage_iphonex_1.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = introlImage_iphonex_1.jpg; sourceTree = ""; }; E547870D2073192D0060C2C2 /* introlImage_iphonex_2.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = introlImage_iphonex_2.jpg; sourceTree = ""; }; @@ -9656,6 +9659,8 @@ 883E78201D48A5E50030E075 /* SetViewController.m */, E567026B21187E7C00E61993 /* ConnectHotspotModel.h */, E567026C21187E7C00E61993 /* ConnectHotspotModel.m */, + E5317A17211896080014AFDD /* IFishUDPHelperBackMsgModel.h */, + E5317A18211896080014AFDD /* IFishUDPHelperBackMsgModel.m */, E5F1B03E21184F9400A879A1 /* IFishHotpotUDPHelper.h */, E5F1B03D21184F9300A879A1 /* IFishHotpotUDPHelper.m */, E56A745F20FCDBFC000129C9 /* ConnectHotpotViewController.h */, @@ -15659,6 +15664,7 @@ 885928CA1E67EC0400E0011E /* JingYanValuelist.m in Sources */, 886F4E041D76CCDC001EDA34 /* PingfenModel.m in Sources */, 8815D2051E037AFD00BEA2DA /* P2PPlayingbackVC.m in Sources */, + E5317A19211896080014AFDD /* IFishUDPHelperBackMsgModel.m in Sources */, 8815D1241DFA8A6500BEA2DA /* CameraRecordViewController.m in Sources */, 883E78D21D48A5E50030E075 /* NetManager.m in Sources */, 881672231EA5DE2B00BEBF23 /* UMComChangeBorderBtn.m in Sources */, diff --git a/Ifish/controllers/leftcontrollers/ConnectHotpotViewController.m b/Ifish/controllers/leftcontrollers/ConnectHotpotViewController.m index 3a181ff..7258781 100644 --- a/Ifish/controllers/leftcontrollers/ConnectHotpotViewController.m +++ b/Ifish/controllers/leftcontrollers/ConnectHotpotViewController.m @@ -128,6 +128,10 @@ #pragma mark - IFishHotpotUDPHelperDelegate +- (void)udpHelperCommandExecutedSuccess { + [self.view makeToast:@"连接设置成功"]; +} + - (void)udpHelperMessage:(NSString *)msg { [self.view makeToast:msg]; } diff --git a/Ifish/controllers/leftcontrollers/IFishHotpotUDPHelper.m b/Ifish/controllers/leftcontrollers/IFishHotpotUDPHelper.m index f1edd77..30fb838 100644 --- a/Ifish/controllers/leftcontrollers/IFishHotpotUDPHelper.m +++ b/Ifish/controllers/leftcontrollers/IFishHotpotUDPHelper.m @@ -12,6 +12,7 @@ #import "ConnectHotspotModel.h" #import "ResetDeviceModel.h" #import "RestartDeviceModel.h" +#import "IFishUDPHelperBackMsgModel.h" @interface IFishHotpotUDPHelper () { @@ -135,10 +136,14 @@ NSLog(@"didReceiveData%@",result); NSLog(@"port%hu",port); - AppDelegate *app =(AppDelegate*)[UIApplication sharedApplication].delegate; - [app.window makeToast:[NSString stringWithFormat:@"收到答复:%@", result]]; - if ([self.delegate respondsToSelector:@selector(udpHelperCommandExecutedSuccess)]) { - [self.delegate udpHelperCommandExecutedSuccess]; + IFishUDPHelperBackMsgModel *model = [[IFishUDPHelperBackMsgModel alloc] initWithData:data]; + if ([model.result isEqualToString:@"01"]) { + if ([self.delegate respondsToSelector:@selector(udpHelperCommandExecutedSuccess)]) { + [self.delegate udpHelperCommandExecutedSuccess]; + } + } else { + AppDelegate *app =(AppDelegate*)[UIApplication sharedApplication].delegate; + [app.window makeToast:[NSString stringWithFormat:@"收到答复:%@", result]]; } [self.loopTimer invalidate]; return YES; diff --git a/Ifish/controllers/leftcontrollers/IFishUDPHelperBackMsgModel.h b/Ifish/controllers/leftcontrollers/IFishUDPHelperBackMsgModel.h new file mode 100644 index 0000000..a38be29 --- /dev/null +++ b/Ifish/controllers/leftcontrollers/IFishUDPHelperBackMsgModel.h @@ -0,0 +1,19 @@ +// +// IFishUDPHelperBackMsgModel.h +// Ifish +// +// Created by Minghao Xue on 2018/8/6. +// Copyright © 2018年 lianlian. All rights reserved. +// + +#import + +@interface IFishUDPHelperBackMsgModel : NSObject + +@property (nonatomic, copy) NSString *result; +@property (nonatomic, copy) NSString *changshang; +@property (nonatomic, copy) NSString *device; + +- (instancetype)initWithData:(NSData *)data; + +@end diff --git a/Ifish/controllers/leftcontrollers/IFishUDPHelperBackMsgModel.m b/Ifish/controllers/leftcontrollers/IFishUDPHelperBackMsgModel.m new file mode 100644 index 0000000..4c3b23d --- /dev/null +++ b/Ifish/controllers/leftcontrollers/IFishUDPHelperBackMsgModel.m @@ -0,0 +1,23 @@ +// +// IFishUDPHelperBackMsgModel.m +// Ifish +// +// Created by Minghao Xue on 2018/8/6. +// Copyright © 2018年 lianlian. All rights reserved. +// + +#import "IFishUDPHelperBackMsgModel.h" + +@implementation IFishUDPHelperBackMsgModel + +- (instancetype)initWithData:(NSData *)data { + if (self = [super init]) { + NSString*totalString=[dataContorl dataToHexString:data]; + self.result = [totalString substringWithRange:NSMakeRange(30, 2)]; + self.changshang = [totalString substringWithRange:NSMakeRange(32, 2)]; + self.device = [totalString substringWithRange:NSMakeRange(34, 2)]; + } + return self; +} + +@end