V4.9.9测试版第一次提交 构建版本9.9.1
This commit is contained in:
@@ -51,18 +51,15 @@
|
||||
@interface IfishP2PMonitorController : UIViewController<
|
||||
AVCaptureVideoDataOutputSampleBufferDelegate,UIGestureRecognizerDelegate,TouchButtonDelegate,UIScrollViewDelegate,UIAlertViewDelegate,MonitorBottomCollcetionSelectDelegate,LxPopViewDelegate,CameraBottomHViewDelegate,IfishSegmentViewDelegate>
|
||||
|
||||
//@property (nonatomic, strong) OpenGLView *remoteView;
|
||||
@property (nonatomic, strong) GWP2PVideoPlayer *player;//摄像头页面
|
||||
@property (nonatomic) BOOL isReject;
|
||||
@property (nonatomic) BOOL isFullScreen4B3;
|
||||
@property (nonatomic) BOOL isShowControllerBar;
|
||||
@property (nonatomic) BOOL isShowVToolBar;
|
||||
@property (nonatomic) BOOL isVideoModeHD;
|
||||
//@property (strong, nonatomic) MBProgressHUD *progressAlert;
|
||||
@property (nonatomic,strong) IfishCameraModel *contact;
|
||||
@property (nonatomic,strong) UIScrollView *scrollView;//监控界面缩放
|
||||
@property (nonatomic) BOOL isScale;//监控界面缩放
|
||||
|
||||
@property (strong, nonatomic) UIView *bottomView;//重新调整监控画面
|
||||
@property (strong, nonatomic) UIView *pressView;
|
||||
@property (nonatomic) BOOL isTalking;
|
||||
@@ -113,7 +110,6 @@
|
||||
@property (nonatomic,strong) UIView *canvasView; //显示监控画面的载体
|
||||
@property (assign,nonatomic) CGRect canvasframe;
|
||||
@property (nonatomic,strong) UIButton *promptButton;
|
||||
@property (nonatomic,strong) UILabel *labelTip;
|
||||
@property (strong, nonatomic) ProgressImageView *yProgressView;
|
||||
@property (nonatomic,strong) UIView *midToolHView; //全屏时,隐藏
|
||||
@property (nonatomic,strong) CameraBottomHView *bottomToolHView; //全屏时,隐藏
|
||||
@@ -121,13 +117,7 @@
|
||||
|
||||
//YES表示当前处于监控中,且接收到推送,点击观看监控
|
||||
@property (assign,nonatomic) BOOL isIntoMonitorFromMonitor;
|
||||
|
||||
//分享工具栏 竖屏显示 全屏时,隐藏
|
||||
//@property (nonatomic,strong) UIView *midSecondToolHView;
|
||||
//@property (nonatomic,strong) UISegmentedControl *segmentControl;
|
||||
@property (nonatomic,strong) IifshSegmentView *segControl;
|
||||
|
||||
//@property (nonatomic,strong) UIButton *soundButtonH;
|
||||
@property (nonatomic,strong) UIButton *stopBtnH;
|
||||
@property (nonatomic,strong) UIImageView *stopImageViewH;
|
||||
@property (nonatomic,strong) UIButton *switchScreenButtonH;
|
||||
|
||||
+276
-557
File diff suppressed because it is too large
Load Diff
+147
-609
@@ -7,55 +7,34 @@
|
||||
//
|
||||
|
||||
#import "YooseeNextConnectViewController.h"
|
||||
#import "elian.h"
|
||||
#import "WaitingPageView.h"
|
||||
#define WAITING_CONTENT_VIEW_HEIGHT 300
|
||||
#define NAVIGATION_BAR_HEIGHT ([[[UIDevice currentDevice] systemVersion] floatValue] < 7.0 ? (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad ? 44:44):(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad ? 64:64))
|
||||
#import "AppDelegate.h"
|
||||
|
||||
#include <arpa/inet.h>
|
||||
#include <ifaddrs.h>
|
||||
#import <SystemConfiguration/CaptiveNetwork.h>
|
||||
#import "Toast+UIView.h"
|
||||
#import "ContactDAO.h"
|
||||
#import "Contact.h"
|
||||
#import "AppDelegate.h"
|
||||
|
||||
#import "Constants.h"
|
||||
#import "P2PClient.h"
|
||||
#import "FListManager.h"
|
||||
#import "Toast+UIView.h"
|
||||
|
||||
#import "MBProgressHUD.h"
|
||||
|
||||
#import "UDManager.h"
|
||||
#import "LoginResult.h"
|
||||
#import "Utils.h"
|
||||
#import <GWP2P/MD5Manager.h>
|
||||
#import "RightViewController.h"
|
||||
#import "LeftViewController.h"
|
||||
#import "ICSDrawerController.h"
|
||||
#import "UDPManager.h"
|
||||
#import "YooseeCenterViewController.h"
|
||||
#import "Socketsingleton.h"
|
||||
|
||||
#import "IfishCameraModel.h"
|
||||
#import "FListManager.h"
|
||||
#define GIWEI_INITPASS @"123"
|
||||
#import "IfishP2PMonitorController.h"
|
||||
#import "LSemTMFSet.h"
|
||||
#import "LXWaveProgressView.h"
|
||||
#import "IfishConnectingView.h"
|
||||
#import "PushMasssageWebViewController.h"
|
||||
#import "IfishUserObsever.h"
|
||||
|
||||
#import <GWP2P/GWP2P.h>
|
||||
typedef NS_ENUM(NSInteger,lodingViewdissMissStyle) {
|
||||
lodingViewdissMissSuccsess=0,// default is 0
|
||||
lodingViewdissMissfail,
|
||||
lodingViewdissMissAlreadyBinded
|
||||
};
|
||||
|
||||
@interface YooseeNextConnectViewController ()<UITextFieldDelegate,P2PClientDelegate,LSemTMFSetDelegate,UIAlertViewDelegate>
|
||||
@interface YooseeNextConnectViewController ()<UITextFieldDelegate,UIAlertViewDelegate>
|
||||
{
|
||||
void *_context;
|
||||
BOOL _bQuit;
|
||||
@@ -84,6 +63,8 @@ typedef NS_ENUM(NSInteger,lodingViewdissMissStyle) {
|
||||
@property(nonatomic,strong) LXWaveProgressView *waveProgressView;;
|
||||
@property(nonatomic,strong) IfishConnectingView *connectingView;
|
||||
|
||||
@property (copy, nonatomic) NSString *deviceID;//设备id
|
||||
@property (assign, nonatomic) BOOL isDeviceLinkIn;//是否已经连接智能设备
|
||||
|
||||
@end
|
||||
|
||||
@@ -93,18 +74,16 @@ typedef NS_ENUM(NSInteger,lodingViewdissMissStyle) {
|
||||
[super viewDidLoad];
|
||||
//智能联机
|
||||
_initPwSuc = NO;
|
||||
_isDeviceLinkIn = NO;
|
||||
self.conectType = conectType_Intelligent;
|
||||
self.addresses = [[NSMutableDictionary alloc] initWithCapacity:1];
|
||||
self.view.backgroundColor = [UIColor whiteColor];
|
||||
[self addTitleViewWithTitle:@"连接摄像头"];
|
||||
|
||||
[self initComponent];
|
||||
UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:nil];
|
||||
self.navigationItem.backBarButtonItem = item;
|
||||
//
|
||||
[self soundInit];
|
||||
_canDissMissController = YES;
|
||||
|
||||
//添加警告内容
|
||||
[self redTipLable];
|
||||
}
|
||||
|
||||
@@ -116,29 +95,12 @@ typedef NS_ENUM(NSInteger,lodingViewdissMissStyle) {
|
||||
_redTipLable.font=[UIFont systemFontOfSize:13];
|
||||
_redTipLable.textColor=[UIColor redColor];
|
||||
[_redTipLable sizeToFit];
|
||||
// _redTipLable.backgroundColor=[UIColor blackColor];
|
||||
[self.view addSubview:_redTipLable];
|
||||
[self.view bringSubviewToFront:_redTipLable];
|
||||
}
|
||||
return _redTipLable;
|
||||
}
|
||||
|
||||
#pragma mark - 声波SDK初始化
|
||||
-(void)soundInit{
|
||||
[[LSemTMFSet sharedInstance] setDelegate:self];
|
||||
|
||||
int soundCode=[[LSemTMFSet sharedInstance]initSDK:@"gwelltimes"
|
||||
client:@"gwelltimes"
|
||||
productModel:@"gm8135s-8136"
|
||||
license:@"11625ae8060111e6b5123e1d05defe78"];
|
||||
NSLog(@"声波初始化的结果码:%d",soundCode);
|
||||
_soundInitCode = soundCode;
|
||||
if (soundCode!=1) {//如果不能正常使用SDK,就不让发送SDK
|
||||
//
|
||||
[self.view makeToast:@"声波初始化失败"];
|
||||
}
|
||||
}
|
||||
|
||||
//获取WiFi信息
|
||||
- (id)fetchSSIDInfo
|
||||
{
|
||||
NSArray *ifs = (id)CFBridgingRelease(CNCopySupportedInterfaces());
|
||||
@@ -161,401 +123,22 @@ typedef NS_ENUM(NSInteger,lodingViewdissMissStyle) {
|
||||
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillShowNotification object:nil];
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillHideNotification object:nil];
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self name:RECEIVE_REMOTE_MESSAGE object:nil];
|
||||
|
||||
_bQuit = YES;
|
||||
|
||||
if (_context){
|
||||
elianStop(_context);
|
||||
elianDestroy(_context);
|
||||
_context = NULL;
|
||||
}
|
||||
|
||||
|
||||
self.isWaiting = NO;//isWaiting is NO
|
||||
self.isFinish = YES;
|
||||
self.isRun = NO;
|
||||
|
||||
if(self.socket){
|
||||
[self.socket close];
|
||||
self.socket=nil;
|
||||
}
|
||||
|
||||
[self soundExit];
|
||||
|
||||
[[GWP2PDeviceLinker shareInstance] p2pStopSmartLink];
|
||||
}
|
||||
|
||||
-(void)viewWillAppear:(BOOL)animated{
|
||||
[super viewWillAppear:animated];
|
||||
_bQuit = NO;
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveRemoteMessage:) name:RECEIVE_REMOTE_MESSAGE object:nil];
|
||||
//[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(wifiviewkeyboradWillShow:) name:UIKeyboardWillChangeFrameNotification object:nil];
|
||||
[self setSoket];
|
||||
|
||||
|
||||
|
||||
}
|
||||
- (void)receiveRemoteMessage:(NSNotification *)notification{
|
||||
|
||||
_initPwSuc = YES;
|
||||
NSDictionary *parameter = [notification userInfo];
|
||||
int key = [[parameter valueForKey:@"key"] intValue];
|
||||
NSString * contactName = [NSString stringWithFormat:@"Cam%@", self.contactID];
|
||||
switch(key){
|
||||
|
||||
case RET_SET_INIT_PASSWORD:
|
||||
{
|
||||
int result = [[parameter valueForKey:@"result"] intValue];
|
||||
if(result==0){
|
||||
ContactDAO *contactDAO = [[ContactDAO alloc] init];
|
||||
Contact *contact = [contactDAO isContact:self.contactID];
|
||||
|
||||
|
||||
if(contact!=nil){
|
||||
|
||||
contact.contactName = contactName;
|
||||
|
||||
contact.contactPassword = self.lastSetPassword;//updatepwd
|
||||
|
||||
[[FListManager sharedFList] updatee:contact];
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
|
||||
|
||||
// [self.view makeToast:NSLocalizedString(@"operator_success", nil)];
|
||||
|
||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
||||
usleep(800000);
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
//不同
|
||||
|
||||
//设置密码成功后爱鱼奇用户绑定摄像头
|
||||
//
|
||||
[self ifishUserBindcameraIdBy:self.contactID];
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
}else{
|
||||
Contact *contact = [[Contact alloc] init];
|
||||
contact.contactId = self.contactID;
|
||||
contact.contactName = contactName;
|
||||
|
||||
contact.contactPassword = self.lastSetPassword;
|
||||
contact.contactType = CONTACT_TYPE_UNKNOWN;
|
||||
[[FListManager sharedFList] insert:contact];
|
||||
|
||||
[[P2PClient sharedClient] getContactsStates:[NSArray arrayWithObject:contact.contactId]];
|
||||
[[P2PClient sharedClient] getDefenceState:contact.contactId password:contact.contactPassword];
|
||||
//contact 原始数据暂不动 现在摄像头数据 模型用IfishCameraModel
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
|
||||
// [self.view makeToast:NSLocalizedString(@"operator_success", nil)];
|
||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
||||
usleep(800000);
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
|
||||
//设置密码成功后爱鱼奇用户绑定摄像头
|
||||
[self ifishUserBindcameraIdBy:self.contactID];
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
}else if(result==43){
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
self.lodviewMissStyle =lodingViewdissMissSuccsess;
|
||||
[self mmPogressHUDdismiss];
|
||||
[self connectNormalView];
|
||||
_canDissMissController = YES;
|
||||
[self.view makeToast:NSLocalizedString(@"device_already_exist_password", nil)];
|
||||
});
|
||||
}else{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
//只为做 dissPogress处理并非成功
|
||||
self.lodviewMissStyle =lodingViewdissMissSuccsess;
|
||||
[self mmPogressHUDdismiss];
|
||||
[self connectNormalView];
|
||||
_canDissMissController = YES;
|
||||
|
||||
[self.view makeToast:NSLocalizedString(@"operator_failure", nil)];
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case RET_SET_DEVICE_PASSWORD:
|
||||
{
|
||||
|
||||
NSInteger result = [[parameter valueForKey:@"result"] intValue];
|
||||
|
||||
if(result==0){
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
//[self.view makeToast:NSLocalizedString(@"operator_success", nil)];
|
||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
||||
usleep(800000);
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
|
||||
[self ifishUserBindcameraIdBy:self.contactID];
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
}else{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
|
||||
self.lodviewMissStyle =lodingViewdissMissSuccsess;
|
||||
|
||||
[self mmPogressHUDdismiss];
|
||||
[self connectNormalView];
|
||||
_canDissMissController = YES;
|
||||
|
||||
[self.view makeToast:NSLocalizedString(@"operator_failure", nil)];
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
-(void)setWindowRootWith:(IfishCameraModel *)cameraMdel{
|
||||
|
||||
|
||||
Socketsingleton *soket=[Socketsingleton sharedInstance];
|
||||
if (soket.clientSocket.isConnected) {
|
||||
[soket cutOffSocket];
|
||||
}
|
||||
|
||||
IfishP2PMonitorController *monitorVC=[[IfishP2PMonitorController alloc] init];
|
||||
monitorVC.contact = cameraMdel;
|
||||
UINavigationController *nav=[[UINavigationController alloc] initWithRootViewController:monitorVC];
|
||||
|
||||
UIApplication*app=[UIApplication sharedApplication];
|
||||
AppDelegate*app1=(AppDelegate*)app.delegate;
|
||||
app1.window.rootViewController=nav;
|
||||
|
||||
//绑定成功 加 经验值
|
||||
[[IfishUserObsever sharedInstance] xinZengJingYanZhi:IFISHADDEXP_BIDCAMERA addType:IFISHADDEXPTYPE1];
|
||||
|
||||
}
|
||||
|
||||
-(void)viewDidAppear:(BOOL)animated{
|
||||
[super viewDidAppear:animated];
|
||||
|
||||
}
|
||||
|
||||
-(void)setSoket{
|
||||
|
||||
self.isRun = YES;
|
||||
self.isPrepared = NO;
|
||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
||||
while(self.isRun){//不断广播获取设置好WIFI的设备
|
||||
if(!self.isPrepared){
|
||||
[self prepareSocket];
|
||||
}
|
||||
usleep(1000000);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
-(BOOL)prepareSocket{
|
||||
|
||||
GCDAsyncUdpSocket *socket = [[GCDAsyncUdpSocket alloc] initWithDelegate:self delegateQueue:dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)];
|
||||
NSError *error = nil;
|
||||
|
||||
|
||||
if (![socket bindToPort:9988 error:&error])
|
||||
{
|
||||
//NSLog(@"Error binding: %@", [error localizedDescription]);
|
||||
return NO;
|
||||
}
|
||||
if (![socket beginReceiving:&error])
|
||||
{
|
||||
NSLog(@"Error receiving: %@", [error localizedDescription]);
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (![socket enableBroadcast:YES error:&error])
|
||||
{
|
||||
NSLog(@"Error enableBroadcast: %@", [error localizedDescription]);
|
||||
return NO;
|
||||
}
|
||||
|
||||
self.socket = socket;
|
||||
self.isPrepared = YES;
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#pragma mark - 空中发包,给设备设置wifi
|
||||
- (void)startSetWifiLoop
|
||||
{
|
||||
//ssid
|
||||
const char *ssid = [self.wifiName cStringUsingEncoding:NSUTF8StringEncoding];
|
||||
//authmode
|
||||
int authmode = 9;//delete
|
||||
//pwd
|
||||
const char *password = [self.wifiSecFiled.text cStringUsingEncoding:NSUTF8StringEncoding];//NSASCIIStringEncoding
|
||||
//target
|
||||
unsigned char target[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
|
||||
|
||||
|
||||
_context = elianNew(NULL, 0, target, ELIAN_SEND_V1 | ELIAN_SEND_V4);
|
||||
|
||||
elianPut(_context, TYPE_ID_AM, (char *)&authmode, 1);//delete
|
||||
|
||||
elianPut(_context, TYPE_ID_SSID, (char *)ssid, strlen(ssid));
|
||||
|
||||
elianPut(_context, TYPE_ID_PWD, (char *)password, strlen(password));
|
||||
|
||||
|
||||
elianStart(_context);
|
||||
}
|
||||
|
||||
#pragma mark - 使用90秒来进行空中发包,给设备设置wifi
|
||||
-(void)setWifiAniminte{
|
||||
|
||||
|
||||
self.isWaiting = YES;
|
||||
__weak typeof(self) weakself= self;
|
||||
|
||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
||||
|
||||
int index = 0;
|
||||
while(weakself.isWaiting){
|
||||
NSLog(@"%i",index);
|
||||
index++;
|
||||
if (weakself.conectType == conectType_Intelligent){
|
||||
//startSetWifiLoop
|
||||
if (index >= 21 && index <= 30)
|
||||
{
|
||||
if (index == 21)
|
||||
{
|
||||
elianStop(_context);
|
||||
}
|
||||
}
|
||||
else if (index >= 51 && index <= 60)
|
||||
{
|
||||
if (index == 51)
|
||||
{
|
||||
elianStop(_context);
|
||||
}
|
||||
}
|
||||
else if (index >= 81)
|
||||
{
|
||||
if (index == 81)
|
||||
{
|
||||
elianStop(_context);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (index==31 || index==61)
|
||||
{
|
||||
elianStart(_context);
|
||||
}
|
||||
}
|
||||
if(index>=90)
|
||||
{//90
|
||||
|
||||
[weakself soundSendStop];
|
||||
|
||||
NSLog(@"声波发送时间达上限,停止发送");
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(index>=60)
|
||||
{//60
|
||||
break;
|
||||
}
|
||||
}
|
||||
sleep(1.0);
|
||||
}
|
||||
|
||||
|
||||
if(!weakself.isFinish){
|
||||
if (weakself.conectType == conectType_Intelligent){//startSetWifiLoop
|
||||
if (_context){
|
||||
elianStop(_context);
|
||||
elianDestroy(_context);
|
||||
_context = NULL;
|
||||
|
||||
//dispatch_async(, <#^(void)block#>)
|
||||
[weakself connectNormalView];
|
||||
_canDissMissController = YES;
|
||||
weakself.lodviewMissStyle =lodingViewdissMissfail;
|
||||
[weakself mmPogressHUDdismiss];
|
||||
|
||||
NSLog(@"设置WIFI失败,停止");
|
||||
}//设置WIFI失败,停止
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
#pragma mark - 声波开始发送
|
||||
-(void)soundSendStart{
|
||||
NSLog(@"开始发送声波");
|
||||
NSString* strWiFiName=self.wifiName;
|
||||
NSString* strWiFiPwd=self.wifiSecFiled.text;
|
||||
NSLog(@"要发送的WiFi是:%@,其密码是:%@",self.wifiName,self.wifiSecFiled.text);
|
||||
[[LSemTMFSet sharedInstance] sendWiFiSet:strWiFiName password:strWiFiPwd];
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - 声波停止发送
|
||||
-(void)soundSendStop{
|
||||
NSLog(@"停止发送声波");
|
||||
|
||||
[[LSemTMFSet sharedInstance] stopSend];
|
||||
[[LSemTMFSet sharedInstance] cancleConnectTimer];
|
||||
}
|
||||
|
||||
#pragma mark - 声波SDK退出和释放
|
||||
-(void)soundExit{
|
||||
NSLog(@"退出声波SDK");
|
||||
[self soundSendStop];
|
||||
[[LSemTMFSet sharedInstance] exitEMTMFSDK];
|
||||
}
|
||||
#pragma mark - 声波的几个协议
|
||||
- (void)didSetWifiResultErrcode:(EMTMFErrcodeType*)errcode content:(NSString*)content{
|
||||
if (errcode==(EMTMFErrcodeType*)EMTMFErrcodeType_SUCESS){
|
||||
NSLog(@"声波配对成功");
|
||||
NSLog(@"content%@",content);
|
||||
[self soundSendStop];
|
||||
}else{
|
||||
NSLog(@"声波配对失败content%@,重新发送",content);
|
||||
[self soundSendStart];
|
||||
}
|
||||
}
|
||||
- (void)didFSKSendingComplete{
|
||||
[[LSemTMFSet sharedInstance] startConnectTimeOutListener:1];//暂停1秒,然后继续发送声波
|
||||
}
|
||||
-(void)didSDKErrcode:(int) errCode errMsg:(NSString*)errMsg{
|
||||
NSLog(@"声波初始化结果码:%d,结果码解释:%@",errCode,errMsg);
|
||||
}
|
||||
|
||||
-(void)dealloc{
|
||||
|
||||
[self soundExit];
|
||||
}
|
||||
- (void)didReceiveMemoryWarning {
|
||||
[super didReceiveMemoryWarning];
|
||||
// Dispose of any resources that can be recreated.
|
||||
@@ -704,72 +287,6 @@ typedef NS_ENUM(NSInteger,lodingViewdissMissStyle) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
-(void)initMMProgressHUD{
|
||||
|
||||
NSMutableArray *images = [[NSMutableArray alloc] init];
|
||||
|
||||
for (int i = 1; i <= 63; i ++) {
|
||||
|
||||
if (i < 10) {
|
||||
[images addObject:[UIImage imageNamed:[NSString stringWithFormat:@"neves000%d",i]]];
|
||||
|
||||
}else{
|
||||
[images addObject:[UIImage imageNamed:[NSString stringWithFormat:@"neves00%d",i]]];
|
||||
}
|
||||
|
||||
}
|
||||
_autodismiss = YES;//MMProgressHUDWindowOverlayModeLinear
|
||||
[MMProgressHUD setPresentationStyle:MMProgressHUDPresentationStyleNone];
|
||||
|
||||
/**
|
||||
* status: Custom Animated Image
|
||||
*/
|
||||
[MMProgressHUD showWithTitle:@"" status:@"" images:images];
|
||||
|
||||
|
||||
}
|
||||
-(void)mmPogressHUDdismiss{
|
||||
// if (_autodismiss == YES) {
|
||||
// double delayInSeconds = 2.0;
|
||||
// dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
|
||||
// dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
|
||||
[self setMMProgressHUDMissStayle:self.lodviewMissStyle];
|
||||
|
||||
// });
|
||||
// }
|
||||
}
|
||||
-(void)setMMProgressHUDMissStayle:(lodingViewdissMissStyle)missStyle{
|
||||
|
||||
switch (missStyle) {
|
||||
|
||||
case lodingViewdissMissSuccsess:
|
||||
{
|
||||
//[MMProgressHUD dismissWithSuccess:@""];
|
||||
//[self.view makeToast:NSLocalizedString(@"connect_success", nil)];
|
||||
|
||||
}
|
||||
break;
|
||||
case lodingViewdissMissfail:
|
||||
{
|
||||
//[MMProgressHUD dismissWithError:@""];
|
||||
|
||||
[self.view makeToast:@"再试一下!"];
|
||||
}
|
||||
break;
|
||||
case lodingViewdissMissAlreadyBinded:
|
||||
{
|
||||
|
||||
//[MMProgressHUD dismissWithSuccess:@""];
|
||||
[self.view makeToast:@"已经绑定过了!"];
|
||||
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
-(void)showTitle:(NSString*)title messsage:(NSString*)message{
|
||||
UIAlertView *alert=[[UIAlertView alloc]initWithTitle:title message:message delegate:nil cancelButtonTitle:nil otherButtonTitles:nil, nil];
|
||||
NSTimeInterval dismissSeconds=1.0;
|
||||
@@ -806,97 +323,11 @@ typedef NS_ENUM(NSInteger,lodingViewdissMissStyle) {
|
||||
CGSize sizeToFit = [value sizeWithFont:[UIFont systemFontOfSize:fontSize] constrainedToSize:CGSizeMake(width, CGFLOAT_MAX) lineBreakMode:NSLineBreakByCharWrapping];//此处的换行类型(lineBreakMode)可根据自己的实际情况进行设置
|
||||
return sizeToFit.height;
|
||||
}
|
||||
|
||||
#pragma mark - GCDAsyncUdpSocket
|
||||
- (void)udpSocket:(GCDAsyncUdpSocket *)sock didSendDataWithTag:(long)tag
|
||||
{
|
||||
NSLog(@"did send");
|
||||
}
|
||||
|
||||
- (void)udpSocketDidClose:(GCDAsyncUdpSocket *)sock withError:(NSError *)error
|
||||
{
|
||||
NSLog(@"error %@", error);
|
||||
}
|
||||
|
||||
#pragma mark 搜索设备
|
||||
- (void)udpSocket:(GCDAsyncUdpSocket *)sock didReceiveData:(NSData *)data
|
||||
fromAddress:(NSData *)address
|
||||
withFilterContext:(id)filterContext
|
||||
{
|
||||
|
||||
NSLog(@"data%@",data);
|
||||
//A buffer into which to copy the receiver's data. The buffer must be at least length bytes.
|
||||
if (data) {
|
||||
Byte receiveBuffer[1024];
|
||||
//Copies a range of bytes from the receiver’s data into a given buffer.
|
||||
[data getBytes:receiveBuffer length:1024];
|
||||
|
||||
if(receiveBuffer[0]==1){
|
||||
NSString *host = nil;
|
||||
uint16_t port = 0;
|
||||
[GCDAsyncUdpSocket getHost:&host port:&port fromAddress:address];
|
||||
|
||||
int contactId = *(int*)(&receiveBuffer[16]);
|
||||
int type = *(int*)(&receiveBuffer[20]);
|
||||
int flag = *(int*)(&receiveBuffer[24]);
|
||||
|
||||
self.contactID = [NSString stringWithFormat:@"%d",contactId];
|
||||
self.type = type;
|
||||
self.flag = flag;
|
||||
[self.addresses setObject:host forKey:[NSString stringWithFormat:@"%i",contactId]];
|
||||
|
||||
|
||||
if(self.isWaiting){
|
||||
|
||||
self.isWaiting = NO;//isWaiting is NO
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
self.isFinish = YES;
|
||||
|
||||
if (self.conectType == conectType_Intelligent){//startSetWifiLoop
|
||||
if (_context){
|
||||
elianStop(_context);
|
||||
elianDestroy(_context);
|
||||
_context = NULL;
|
||||
//设置WIFI成功
|
||||
}
|
||||
}
|
||||
|
||||
if (self.flag == 0){
|
||||
//没有初始化过密码
|
||||
[self initPaw];
|
||||
}else if (self.flag == 1){
|
||||
//设备默认已经初始化密码 有设备复位后会如此
|
||||
[self modifyPassW];
|
||||
}
|
||||
//声波停止发送 声波SDK退出和释放
|
||||
[self soundExit];
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//初始化设备密码
|
||||
-(void)initPaw{
|
||||
|
||||
NSString *newPassword = @"123";
|
||||
self.lastSetPassword = [Utils GetTreatedPassword:newPassword];
|
||||
//很容易设置失败?? 定时重发
|
||||
[[P2PClient sharedClient] setInitPasswordWithId:self.contactID initPassword:self.lastSetPassword];
|
||||
|
||||
}
|
||||
|
||||
//已初始化密码修改密码
|
||||
|
||||
-(void)modifyPassW{
|
||||
//密码
|
||||
-(void)resetPassWord{
|
||||
|
||||
NSString *newPassword = @"123";
|
||||
self.lastSetPassword = [Utils GetTreatedPassword:newPassword];
|
||||
//NSString *oldPass= [Utils GetTreatedPassword:@"123"];
|
||||
|
||||
[[P2PClient sharedClient] setDevicePasswordWithId:self.contactID password:GIWEI_INITPASS newPassword:self.lastSetPassword];
|
||||
|
||||
}
|
||||
|
||||
#pragma mark - 搜索到设备,弹出添加设备提示 暂不用
|
||||
@@ -918,7 +349,7 @@ withFilterContext:(id)filterContext
|
||||
NSString *newPassword = GIWEI_INITPASS;
|
||||
self.lastSetPassword = [Utils GetTreatedPassword:newPassword];;
|
||||
|
||||
[[P2PClient sharedClient] setInitPasswordWithId:self.contactID initPassword:self.lastSetPassword];
|
||||
// [[P2PClient sharedClient] setInitPasswordWithId:self.contactID initPassword:self.lastSetPassword];
|
||||
|
||||
}else{
|
||||
|
||||
@@ -929,51 +360,148 @@ withFilterContext:(id)filterContext
|
||||
if (buttonIndex ==1) {
|
||||
|
||||
[self.wifiSecFiled resignFirstResponder];
|
||||
//NSString *pwdString = self.wifiSecFiled.text;
|
||||
// if (!pwdString) {//ios<7.0
|
||||
// pwdString = @"";
|
||||
// }
|
||||
|
||||
if (self.wifiSecFiled.text.length<=0||[self.wifiName isEqualToString:@"无Wi-Fi"]) {
|
||||
//[self.view makeToast:NSLocalizedString(@"link_wifi", nil)];
|
||||
[self.view makeToast:@"请保证手机已连接wifi,且wifi密码不能为空"];
|
||||
return;
|
||||
}
|
||||
|
||||
// BOOL isRight =[dataContorl isIncludeSpecialCharact:self.wifiSecFiled.text];
|
||||
//
|
||||
// if (!isRight) {
|
||||
// [self.view makeToast:@"Wifi密码不能包含特殊字符,只能为数字字母下划线"];
|
||||
//
|
||||
// return;
|
||||
// }
|
||||
|
||||
|
||||
if (!self.wifiName) {
|
||||
|
||||
[self.view makeToast:@"未检测到wifi"];
|
||||
|
||||
return;
|
||||
}
|
||||
//旧连接效果已去
|
||||
//[self initMMProgressHUD];
|
||||
//最新连接效果
|
||||
self.wifiPwd = self.wifiSecFiled.text;
|
||||
//显示连接中效果
|
||||
[self connectNotNormalView];
|
||||
_canDissMissController = NO;
|
||||
//空中抓包方式
|
||||
self.conectType = conectType_Intelligent;
|
||||
[self savePassw];
|
||||
[self startSetWifiLoop];//给设备设置wifi
|
||||
[self setWifiAniminte];//直接调用,不用点击“听到了”按钮
|
||||
//声波智能联机
|
||||
[self smartLinkConnect];
|
||||
self.isFinish = NO;
|
||||
|
||||
//声波配置方式
|
||||
[self soundSendStart];
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
//智能联机
|
||||
-(void)smartLinkConnect{
|
||||
WEAK_SELF;
|
||||
[[GWP2PDeviceLinker shareInstance] p2pSmartLinkDeviceWithWiFiSSID:weakSelf.wifiName password:weakSelf.wifiPwd useSimpleConfig:YES deviceLinkIn:^(NSDictionary *deviceDict) {
|
||||
NSLog(@"声波配网成功,返回数据:%@",deviceDict);
|
||||
if (weakSelf.isDeviceLinkIn) {
|
||||
return;
|
||||
}
|
||||
weakSelf.isDeviceLinkIn = YES;
|
||||
[self.view makeToast:@"声波配网成功"];
|
||||
//如果智能联机,设备配网成功,就断开发送智能联机
|
||||
[[GWP2PDeviceLinker shareInstance] p2pStopSmartLink];
|
||||
|
||||
NSString *deviceID = [deviceDict[@"deviceID"] stringValue];
|
||||
NSString *deviceIP = deviceDict[@"deviceIP"];
|
||||
weakSelf.contactID = [NSString stringWithFormat:@"%d",deviceID];
|
||||
if (![deviceDict[@"isInitPassword"] boolValue]) { //设备没有初始化密码,设置密码
|
||||
[[GWP2PClient sharedClient] setDeviceInitialPassword:@"123" withDeviceID:deviceIP completionBlock:^(GWP2PClient *client, BOOL success, NSDictionary<NSString *,id> *dataDictionary) {
|
||||
NSLog(@"success:%i %@",success,dataDictionary);
|
||||
[weakSelf resetPassWord];//初始化密码
|
||||
if (success) {
|
||||
[weakSelf initPwdResault:dataDictionary];
|
||||
}else{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
//只为做 dissPogress处理并非成功
|
||||
weakSelf.lodviewMissStyle =lodingViewdissMissSuccsess;
|
||||
[weakSelf connectNormalView];
|
||||
_canDissMissController = YES;
|
||||
[weakSelf.view makeToast:NSLocalizedString(@"operator_failure", nil)];
|
||||
});
|
||||
}
|
||||
}];
|
||||
} else { //设备已经初始化密码,可以让用户输入正确的密码验证通过后加到本地列表,这里直接使用123
|
||||
|
||||
[[GWP2PClient sharedClient] getMultipleDeviceStatusWithDeviceID:deviceIP password:@"123" completionBlock:^(GWP2PClient *client, BOOL success, NSDictionary<NSString *,id> *dataDictionary) {
|
||||
NSLog(@"success:%i %@",success,dataDictionary);
|
||||
[weakSelf resetPassWord];//更新密码
|
||||
if (success) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
//[self.view makeToast:NSLocalizedString(@"operator_success", nil)];
|
||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
||||
usleep(800000);
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
|
||||
[weakSelf ifishUserBindcameraIdBy:self.contactID];
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
}else{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
|
||||
self.lodviewMissStyle =lodingViewdissMissSuccsess;
|
||||
[self connectNormalView];
|
||||
_canDissMissController = YES;
|
||||
[self.view makeToast:NSLocalizedString(@"operator_failure", nil)];
|
||||
|
||||
});
|
||||
}
|
||||
}];
|
||||
}
|
||||
}];
|
||||
}
|
||||
//初始化设备密码回调
|
||||
-(void)initPwdResault:(NSDictionary *)parameter{
|
||||
|
||||
NSString * contactName = [NSString stringWithFormat:@"Cam%@", self.contactID];
|
||||
|
||||
ContactDAO *contactDAO = [[ContactDAO alloc] init];
|
||||
Contact *contact = [contactDAO isContact:self.contactID];
|
||||
|
||||
if(contact!=nil){
|
||||
|
||||
contact.contactName = contactName;
|
||||
|
||||
contact.contactPassword = self.lastSetPassword;//updatepwd
|
||||
|
||||
[[FListManager sharedFList] updatee:contact];
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
|
||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
||||
usleep(800000);
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
//设置密码成功后爱鱼奇用户绑定摄像头
|
||||
[self ifishUserBindcameraIdBy:self.contactID];
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
}else{
|
||||
Contact *contact = [[Contact alloc] init];
|
||||
contact.contactId = self.contactID;
|
||||
contact.contactName = contactName;
|
||||
|
||||
contact.contactPassword = self.lastSetPassword;
|
||||
contact.contactType = CONTACT_TYPE_UNKNOWN;
|
||||
[[FListManager sharedFList] insert:contact];
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
|
||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
||||
usleep(800000);
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
|
||||
//设置密码成功后爱鱼奇用户绑定摄像头
|
||||
[self ifishUserBindcameraIdBy:self.contactID];
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
-(void)dealloc{
|
||||
[[GWP2PDeviceLinker shareInstance] p2pStopSmartLink];
|
||||
}
|
||||
#pragma mark - UI正常状态
|
||||
|
||||
-(void)connectNormalView
|
||||
@@ -1140,7 +668,6 @@ withFilterContext:(id)filterContext
|
||||
if ([resultDic[@"result"] isEqualToString:@"100"]) {
|
||||
self.lodviewMissStyle =lodingViewdissMissSuccsess;
|
||||
_canDissMissController = YES;
|
||||
[self mmPogressHUDdismiss];
|
||||
[self connectNormalView];
|
||||
|
||||
|
||||
@@ -1182,7 +709,6 @@ withFilterContext:(id)filterContext
|
||||
}else{
|
||||
//lodingViewdissMissSuccsess 只做移除loding效果
|
||||
self.lodviewMissStyle =lodingViewdissMissSuccsess;
|
||||
[self mmPogressHUDdismiss];
|
||||
[self connectNormalView];
|
||||
_canDissMissController = YES;
|
||||
[self.view makeToast:@"绑定失败错误码101"];
|
||||
@@ -1196,7 +722,19 @@ withFilterContext:(id)filterContext
|
||||
}];
|
||||
|
||||
}
|
||||
|
||||
|
||||
//绑定成功之后设置
|
||||
-(void)setWindowRootWith:(IfishCameraModel *)cameraMdel{
|
||||
|
||||
IfishP2PMonitorController *monitorVC=[[IfishP2PMonitorController alloc] init];
|
||||
monitorVC.contact = cameraMdel;
|
||||
UINavigationController *nav=[[UINavigationController alloc] initWithRootViewController:monitorVC];
|
||||
|
||||
UIApplication*app=[UIApplication sharedApplication];
|
||||
AppDelegate*app1=(AppDelegate*)app.delegate;
|
||||
app1.window.rootViewController=nav;
|
||||
//绑定成功 加 经验值
|
||||
[[IfishUserObsever sharedInstance] xinZengJingYanZhi:IFISHADDEXP_BIDCAMERA addType:IFISHADDEXPTYPE1];
|
||||
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -280,6 +280,7 @@
|
||||
|
||||
"cur_version_is" = "Current version is";
|
||||
"can_update_to" = "Will update to";
|
||||
"is_latest_version" = "Is the latest version";
|
||||
"can_update_sd" = "Will update from SD card";
|
||||
"start_update" = "Start to update";
|
||||
"update_failed" = "Update Failed";
|
||||
|
||||
@@ -280,6 +280,7 @@
|
||||
|
||||
"cur_version_is" = "当前版本为";
|
||||
"can_update_to" = "可升级至";
|
||||
"is_latest_version" = "为最新版本";
|
||||
"can_update_sd" = "能够从SD卡升级";
|
||||
"start_update" = "开始更新";
|
||||
"update_failed" = "更新失败";
|
||||
|
||||
Reference in New Issue
Block a user