no message

This commit is contained in:
wbzhan
2019-10-10 17:35:35 +08:00
parent 79fc0ce36b
commit 347a774be9
2 changed files with 50 additions and 11 deletions
@@ -54,15 +54,14 @@ Copy NSString *deviceId;
[self.progressView updatePercent:100 animation:YES];
[self.progressView endProgressWithString:@"设备连接中..."];
self.HUD.labelText = @"正在绑定设备";
//AP模式配网
[[GWP2PDeviceLinker shareInstance] p2pAPLinkDeviceWithWiFiSSID:self.wifiName wifiPassword:self.wifiPassword devicePassword:@"123" deviceReceive:^(NSString *deviceId, BOOL isSupport) {
//已经连接到设备,此处回调之后,会断开热点,重新连接到路由器wifi
NSLog(@"设备%@收到WiFi,isSupport:%d",deviceId,isSupport);
self.deviceId = deviceId;
} deviceLinkIn:^(NSDictionary *deviceDict) {
//AP模式配网成功//连接到路由器wifi成功之后,会走此回调方法
[self bindDeviceWithDeviceId:self.deviceId];
}];
if ( [GWP2PClient sharedClient].linkStatus==P2PLinkStatusOK) {
[self connectDevice];
}else{
UserModel *model=[dataContorl getUserInfo];
[self loginGewellWith:model];
}
//传入设备要连接的wifi名称和密码
// [self sendToDeviceWithSSIDName:self.wifiName andSSIDPWD:self.wifiPassword];
// // Do any additional setup after loading the view.
@@ -70,6 +69,46 @@ Copy NSString *deviceId;
self.timer = [NSTimer timerWithTimeInterval:1 target:self selector:@selector(timerAction) userInfo:nil repeats:YES];
[[NSRunLoop currentRunLoop] addTimer:self.timer forMode:NSRunLoopCommonModes];
}
//AP模式配网
-(void)connectDevice{
[[GWP2PDeviceLinker shareInstance] p2pAPLinkDeviceWithWiFiSSID:self.wifiName wifiPassword:self.wifiPassword devicePassword:@"123" deviceReceive:^(NSString *deviceId, BOOL isSupport) {
//已经连接到设备,此处回调之后,会断开热点,重新连接到路由器wifi
NSLog(@"设备%@收到WiFi,isSupport:%d",deviceId,isSupport);
self.HUD.labelText = @"设备WiFi配置成功,之后会断开设备热点,连接设备到路由器";
self.deviceId = deviceId;
} deviceLinkIn:^(NSDictionary *deviceDict) {
//AP模式配网成功//连接到路由器wifi成功之后,会走此回调方法
if (IsEmptyStr(self.deviceId)) {
[self bindDeviceWithDeviceId:self.deviceId];
}
}];
}
//P2P连线
-(void)loginGewellWith:(UserModel *)model
{
NSString *accountId =[NSString stringWithFormat:@"%d",(int)[model.gwellUserID integerValue]&0x7fffffff];
if ([accountId isEqualToString:@"0"]) {
[self.view makeToast:@"暂未检测到设备"];
return;
}
if ([model.P2PVerifyCode1 isEqualToString:@""]) {
[self.view makeToast:@"暂未检测到设备"];
return;
}
if ([model.P2PVerifyCode2 isEqualToString:@""]) {
[self.view makeToast:@"暂未检测到设备"];
return;
}
if ([GWP2PClient sharedClient]!=P2PLinkStatusOK) {
[[GWP2PClient sharedClient] connectWithAccount:accountId codeStr1:model.P2PVerifyCode1 codeStr2:model.P2PVerifyCode2 sessionID1:model.sessionID sessionID2:model.sessionID2 customerIDs:nil];
[self connectDevice];
}
//loginResult.contactId 用户ID号
NSLog(@"%@%@%@",accountId,model.P2PVerifyCode1,model.P2PVerifyCode2,model.sessionID,model.sessionID2);
}
-(void)bindDeviceWithDeviceId:(NSString*)deviceId{
NSLog(@"设备bssid_%@",deviceId);