|
|
@@ -41,6 +41,17 @@
|
|
|
[self prepareViewDidLoad];
|
|
|
}
|
|
|
|
|
|
+- (void)viewWillAppear:(BOOL)animated {
|
|
|
+ [super viewWillAppear:animated];
|
|
|
+
|
|
|
+ bleService.delegate = self;
|
|
|
+}
|
|
|
+
|
|
|
+- (void)viewWillDisappear:(BOOL)animated {
|
|
|
+ [super viewWillDisappear:animated];
|
|
|
+
|
|
|
+ bleService.delegate = nil;
|
|
|
+}
|
|
|
|
|
|
- (void)didReceiveMemoryWarning {
|
|
|
[super didReceiveMemoryWarning];
|
|
|
@@ -51,6 +62,7 @@
|
|
|
|
|
|
_imgvLoading.hidden = YES;
|
|
|
_btnNext.enabled = NO;
|
|
|
+
|
|
|
[self initTableViewAsDefaultStyle:_tableView];
|
|
|
}
|
|
|
|
|
|
@@ -58,7 +70,6 @@
|
|
|
|
|
|
//ble
|
|
|
bleService = [BLEServiceHandler sharedManager];
|
|
|
- bleService.delegate = self;
|
|
|
|
|
|
updateSSID = updateBSSID = updateIPSet = updateIPAddr = NO;
|
|
|
|
|
|
@@ -155,7 +166,8 @@
|
|
|
[super tableView:tableView didSelectRowAtIndexPath:indexPath];
|
|
|
|
|
|
BLEWLanModel *model = [_wifiList objectAtIndex:indexPath.row];
|
|
|
-// selectedWLanModel = model;
|
|
|
+ selectedWLanModel = model;
|
|
|
+ _btnNext.enabled = YES;
|
|
|
[_tableView reloadData];
|
|
|
}
|
|
|
|
|
|
@@ -182,23 +194,13 @@
|
|
|
|
|
|
- (IBAction)btnNextTouched:(id)sender {
|
|
|
|
|
|
+ NSLog(@"selectedWLanModel : %@", selectedWLanModel);
|
|
|
+
|
|
|
if (selectedWLanModel != nil) {
|
|
|
|
|
|
- if (EQUALS(selectedWLanModel.security, @"none")) {
|
|
|
-
|
|
|
- [self startLoading:YES];
|
|
|
- [bleService enableDHCP];
|
|
|
- [bleService readAndNotifyCharacteristicUUID:kBLEChrStDHCPArg isNotify:NO];
|
|
|
-
|
|
|
- updateSSID = updateBSSID = updateIPSet = updateIPAddr = NO;
|
|
|
-
|
|
|
- }
|
|
|
- else {
|
|
|
-
|
|
|
- [bleService setWiFiSSID:selectedWLanModel.ssid];
|
|
|
- [bleService readAndNotifyCharacteristicUUID:kBLEChrStSSIDArg
|
|
|
- isNotify:NO];
|
|
|
- }
|
|
|
+ [bleService setWiFiSSID:selectedWLanModel.ssid];
|
|
|
+ [bleService readAndNotifyCharacteristicUUID:kBLEChrStSSIDArg
|
|
|
+ isNotify:NO];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -206,15 +208,27 @@
|
|
|
#pragma mark - ble delegate
|
|
|
- (void)BLEWiFiSSIDUpdate:(NSString*)ssid {
|
|
|
|
|
|
- NSLog(@"selectedWLanModel.ssid : %@", selectedWLanModel.ssid);
|
|
|
+ NSLog(@"\nwifi search seccess BLEWiFiSSIDUpdate ssid : %@", selectedWLanModel.ssid);
|
|
|
NSLog(@"ssid : %@", ssid);
|
|
|
|
|
|
if (EQUALS(selectedWLanModel.ssid, ssid)) {
|
|
|
|
|
|
- HomeHubWifiPasswdInputViewController *vc = [CommonUtil instantiateViewControllerWithIdentifier:@"HomeHubWifiPasswdInputViewController" storyboardName:@"HomeHub"];
|
|
|
- vc.selectedWLanModel = selectedWLanModel;
|
|
|
-
|
|
|
- [self.navigationController pushViewController:vc animated:YES];
|
|
|
+ if (EQUALS(selectedWLanModel.security, @"none")) {
|
|
|
+
|
|
|
+ [self startLoading:YES];
|
|
|
+ [bleService enableDHCP];
|
|
|
+ [bleService readAndNotifyCharacteristicUUID:kBLEChrStDHCPArg isNotify:NO];
|
|
|
+
|
|
|
+ updateSSID = updateBSSID = updateIPSet = updateIPAddr = NO;
|
|
|
+
|
|
|
+ }
|
|
|
+ else {
|
|
|
+
|
|
|
+ HomeHubWifiPasswdInputViewController *vc = [CommonUtil instantiateViewControllerWithIdentifier:@"HomeHubWifiPasswdInputViewController" storyboardName:@"HomeHub"];
|
|
|
+ vc.selectedWLanModel = selectedWLanModel;
|
|
|
+
|
|
|
+ [self.navigationController pushViewController:vc animated:YES];
|
|
|
+ }
|
|
|
}
|
|
|
else {
|
|
|
|
|
|
@@ -226,18 +240,26 @@
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
//enableDHCP
|
|
|
- (void)BLEWiFiDHCPUpdate:(id)data {
|
|
|
|
|
|
+ NSLog(@"\nwifi search seccess BLEWiFiDHCPUpdate!");
|
|
|
+
|
|
|
[bleService applyWiFiSettingInfo];
|
|
|
- [bleService readAndNotifyCharacteristicUUID:kBLEChrRdConInfo isNotify:YES];
|
|
|
+ [self performSelector:@selector(afterApplyNotifyConnect) withObject:nil afterDelay:0.5];
|
|
|
|
|
|
}
|
|
|
|
|
|
+- (void)afterApplyNotifyConnect {
|
|
|
+
|
|
|
+ [bleService readAndNotifyCharacteristicUUID:kBLEChrRdConInfo isNotify:YES];
|
|
|
+}
|
|
|
+
|
|
|
//kBLEChrRdConInfo
|
|
|
- (void)BLEWiFiConnectionUpdate:(CBCharacteristic *)info {
|
|
|
|
|
|
- NSLog(@"Connection Update!");
|
|
|
+ NSLog(@"\nwifi search seccess BLEWiFiConnectionUpdate!");
|
|
|
|
|
|
NSString *value = [bleService hexStringValue:info] ;
|
|
|
|
|
|
@@ -246,14 +268,13 @@
|
|
|
|
|
|
[bleService readConnectionWiFiInfo];
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
//readConnectionWiFiInfo
|
|
|
- (void)BLEWiFiConnectionInfoUpdateWithKey:(NSString *)kBLEChr
|
|
|
result:(NSString *)result {
|
|
|
|
|
|
- NSLog(@"Connection Info Update!") ;
|
|
|
+ NSLog(@"\nwifi search seccess BLEWiFiConnectionInfoUpdateWithKey") ;
|
|
|
|
|
|
if (EQUALS(kBLEChr, kBLEChrRdSSID)) {
|
|
|
updateSSID = YES;
|
|
|
@@ -280,4 +301,5 @@
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
@end
|