Bläddra i källkod

06.15 ble wifi none 인 경우 비번입력 없이 바로 연결

eunmi.kim 8 år sedan
förälder
incheckning
545883d3de

+ 8 - 2
OneCable/Base.lproj/HomeHub.storyboard

@@ -1692,6 +1692,9 @@
                                                 <state key="normal" title="다음" backgroundImage="common_button_left_bg">
                                                     <color key="titleColor" red="0.011764705882352941" green="0.60392156862745094" blue="0.87450980392156863" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                                                 </state>
+                                                <state key="disabled">
+                                                    <color key="titleColor" red="0.79215686269999996" green="0.80784313730000001" blue="0.84705882349999995" alpha="1" colorSpace="calibratedRGB"/>
+                                                </state>
                                                 <state key="highlighted" backgroundImage="common_button_bg_press"/>
                                                 <userDefinedRuntimeAttributes>
                                                     <userDefinedRuntimeAttribute type="color" keyPath="placeHolderColor">
@@ -1699,7 +1702,7 @@
                                                     </userDefinedRuntimeAttribute>
                                                 </userDefinedRuntimeAttributes>
                                                 <connections>
-                                                    <action selector="btnNextTouched:" destination="4WK-51-lVX" eventType="touchUpInside" id="3pH-uB-1Wr"/>
+                                                    <action selector="btnNextTouched:" destination="4WK-51-lVX" eventType="touchUpInside" id="EJJ-yZ-n52"/>
                                                 </connections>
                                             </button>
                                         </subviews>
@@ -2931,6 +2934,9 @@
                                                 <state key="normal" title="다음" backgroundImage="common_button_left_bg">
                                                     <color key="titleColor" red="0.01176470588" green="0.60392156860000001" blue="0.87450980389999999" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                                                 </state>
+                                                <state key="disabled">
+                                                    <color key="titleColor" red="0.79215686269999996" green="0.80784313730000001" blue="0.84705882349999995" alpha="1" colorSpace="calibratedRGB"/>
+                                                </state>
                                                 <state key="highlighted" backgroundImage="common_button_bg_press"/>
                                                 <userDefinedRuntimeAttributes>
                                                     <userDefinedRuntimeAttribute type="color" keyPath="placeHolderColor">
@@ -2938,7 +2944,7 @@
                                                     </userDefinedRuntimeAttribute>
                                                 </userDefinedRuntimeAttributes>
                                                 <connections>
-                                                    <action selector="btnNextTouched:" destination="Vaf-fi-ogY" eventType="touchUpInside" id="t2C-er-1OZ"/>
+                                                    <action selector="btnNextTouched:" destination="Vaf-fi-ogY" eventType="touchUpInside" id="gya-5D-7BJ"/>
                                                 </connections>
                                             </button>
                                         </subviews>

+ 1 - 1
OneCable/Classes/Handler/BLEServiceHandler.m

@@ -552,7 +552,7 @@
     
     //_conDevice.peripheralRef = peripheral;
     
-    NSLog(@"didWriteValueForCharacteristic %@", [self getChrName:characteristic]) ;
+    NSLog(@"didWriteValueForCharacteristic [%@]", [self getChrName:characteristic]) ;
 
 }
 

+ 1 - 1
OneCable/Classes/ViewControllers/HomeHubScreens/HomeHubConnectWifiViewController.h

@@ -8,7 +8,7 @@
 
 #import "JDViewController.h"
 
-@interface HomeHubConnectWifiViewController : JDViewController <BLEServiceHandlerDelegate>
+@interface HomeHubConnectWifiViewController : JDViewController
 
 @property (weak, nonatomic) IBOutlet UILabel *lbTitle;
 @property (weak, nonatomic) IBOutlet CustomLabel *lblSSID;  // SSID 명

+ 13 - 3
OneCable/Classes/ViewControllers/HomeHubScreens/HomeHubSearchSuccessViewController.m

@@ -41,6 +41,18 @@
 
 }
 
+- (void)viewWillAppear:(BOOL)animated{
+    [super viewWillAppear:animated];
+    
+    bleService.delegate = self;
+}
+
+- (void)viewWillDisappear:(BOOL)animated {
+    [super viewWillDisappear:animated];
+ 
+    bleService.delegate = nil;
+}
+
 - (void)initUI {
 
     _btnNext.enabled = NO;
@@ -49,11 +61,8 @@
 
 - (void)prepareViewDidLoad {
     
-    devices = [NSMutableArray new];
-    
     //ble
     bleService = [BLEServiceHandler sharedManager];
-    bleService.delegate = self;
     
     devices = [bleService getDeviceList];
     
@@ -96,6 +105,7 @@
     [super tableView:tableView didSelectRowAtIndexPath:indexPath];
     
     selectedModel = [devices objectAtIndex:indexPath.row];
+    _btnNext.enabled = YES;
     [tableView reloadData];
 }
 

+ 9 - 8
OneCable/Classes/ViewControllers/HomeHubScreens/HomeHubSearchViewController.m

@@ -32,12 +32,19 @@
     
 }
 
-- (void)viewWillAppear:(BOOL)animated {
+- (void)viewWillAppear:(BOOL)animated{
     [super viewWillAppear:animated];
     
+    bleService.delegate = self;
     [self initUI];
 }
 
+- (void)viewWillDisappear:(BOOL)animated {
+    [super viewWillDisappear:animated];
+    
+    bleService.delegate = nil;
+}
+
 
 - (void)initUI {
     
@@ -47,15 +54,11 @@
 
 - (void)prepareViewDidLoad {
     
-    
     //ble
     bleService = [BLEServiceHandler sharedManager];
-    bleService.delegate = self;
     
 }
 
-
-
 -(void)startLoading:(BOOL)isStart {
     
     _lblTimer.hidden = !isStart;
@@ -115,9 +118,7 @@
 - (void)BLEEndScan:(NSMutableArray *)devices {
     
     [self startLoading:NO];
-    
-    
-    NSLog(@"");
+
     
     UIViewController *vc = [CommonUtil instantiateViewControllerWithIdentifier:@"HomeHubSearchSuccessViewController" storyboardName:@"HomeHub"];
     

+ 9 - 2
OneCable/Classes/ViewControllers/HomeHubScreens/HomeHubViewController.m

@@ -38,6 +38,7 @@
     
     BOOL bleState;
     DeviceModel *hubInfo;
+    BLEServiceHandler *bleService;
 }
 @end
 
@@ -59,9 +60,16 @@
 - (void)viewWillAppear:(BOOL)animated {
     [super viewWillAppear:animated];
     
+    bleService.delegate = self;
     bleState = [[BLEServiceHandler sharedManager] checkBLEStatus];
 }
 
+- (void)viewWillDisappear:(BOOL)animated {
+    [super viewWillDisappear:animated];
+    
+    bleService.delegate = nil;
+}
+
 
 - (void)initUI {
 
@@ -78,8 +86,7 @@
 
     //ble
     bleState = NO;
-    BLEServiceHandler *bleService = [BLEServiceHandler sharedManager];
-    bleService.delegate = self;
+    bleService = [BLEServiceHandler sharedManager];
     
     if (_selectHub == nil) {
         hubInfo = [[JDFacade facade].loginUser getHomeHub];

+ 12 - 1
OneCable/Classes/ViewControllers/HomeHubScreens/HomeHubWifiPasswdInputViewController.m

@@ -36,6 +36,18 @@
     
 }
 
+- (void)viewWillAppear:(BOOL)animated {
+    [super viewWillAppear:animated];
+    
+    bleService.delegate = self;
+}
+
+- (void)viewWillDisappear:(BOOL)animated {
+    [super viewWillDisappear:animated];
+    
+    bleService.delegate = nil;
+}
+
 - (void)initUI {
     
     _lblSSID.text = [NSString stringWithFormat:@"SSID : %@", _selectedWLanModel.ssid];
@@ -47,7 +59,6 @@
     
     //ble
     bleService = [BLEServiceHandler sharedManager];
-    bleService.delegate = self;
     
     updateSSID = updateBSSID = updateIPSet = updateIPAddr = NO;
     

+ 48 - 26
OneCable/Classes/ViewControllers/HomeHubScreens/HomeHubWifiSearchSuccessViewController.m

@@ -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

+ 9 - 3
OneCable/Classes/ViewControllers/HomeHubScreens/HomeHubWifiSearchViewController.m

@@ -41,8 +41,9 @@
     
     [self initUI];
 
+    bleService.delegate = self;
     [bleService connect:bleService.conDevice];
-    
+
 //    if (!bleService.isConnected) {
 //        
 //        
@@ -52,6 +53,12 @@
 //    }
 }
 
+- (void)viewWillDisappear:(BOOL)animated {
+    [super viewWillDisappear:animated];
+    
+    bleService.delegate = nil;
+}
+
 
 - (void)initUI {
     
@@ -65,10 +72,9 @@
     
     //ble
     bleService = [BLEServiceHandler sharedManager];
-    bleService.delegate = self;
+
     startScan = NO;
 
-    
 }
 
 -(void)startLoading:(BOOL)isStart {