// // HomeHubWifiSearchSuccessViewController.m // OneCable // // Created by nComz on 2017. 5. 11.. // Copyright © 2017년 ntels. All rights reserved. // #import "HomeHubWifiSearchSuccessViewController.h" #import "HomeHubWifiPasswdInputViewController.h" @interface HomeHubWifiSearchSuccessViewController () { BLEServiceHandler *bleService; BLEWLanModel *selectedWLanModel; } @end @implementation HomeHubWifiSearchTableViewCell @end @implementation HomeHubWifiSearchSuccessViewController - (void)viewDidLoad { [super viewDidLoad]; [self initUI]; [self prepareViewDidLoad]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; } - (void)initUI { _btnNext.enabled = NO; [self initTableViewAsDefaultStyle:_tableView]; } - (void)prepareViewDidLoad { //ble bleService = [BLEServiceHandler sharedManager]; bleService.delegate = self; [_tableView reloadData]; } #pragma mark - UITableView DataSource & Delegate - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return _wifiList.count; } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { return 101.0f; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { HomeHubWifiSearchTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"WifiSearchCellIdentifier"]; BLEWLanModel *model = [_wifiList objectAtIndex:indexPath.row]; cell.lblHubName.text = model.ssid; cell.chkBtn.delegate = self; cell.chkBtn.value = model; cell.chkBtn.checked = [cell.chkBtn getCheckStatusFromValue]; return cell; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [super tableView:tableView didSelectRowAtIndexPath:indexPath]; } #pragma mark - CustomCheckBox Delegate { - (void)didCheckBoxClicked:(id)sender { CustomCheckBox *btn = sender; btn.selected = !btn.selected; selectedWLanModel = btn.value; _btnNext.enabled = YES ; } #pragma mark - ble delegate - (void)BLEWiFiSSIDRead:(NSString*)ssid { NSLog(@"selectedWLanModel.ssid : %@", selectedWLanModel.ssid); NSLog(@"ssid : %@", ssid); if (EQUALS(selectedWLanModel.ssid, ssid)) { HomeHubWifiPasswdInputViewController *vc = [CommonUtil instantiateViewControllerWithIdentifier:@"HomeHubWifiPasswdInputViewController" storyboardName:@"HomeHub"]; vc.selectedWLanModel = selectedWLanModel; [self presentViewController:vc animated:YES completion:nil]; } } #pragma mark - user Event - (IBAction)btnNextTouched:(id)sender { if (selectedWLanModel != nil) { [bleService setWiFiSSID:selectedWLanModel.ssid]; [bleService readAndNotifyCharacteristicUUID:kBLEChrStSSIDArg isNotify:NO]; } } - (IBAction)btnCancelTouched:(id)sender { [self dismissViewControllerAnimated:YES completion:nil]; } @end