| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- //
- // HomeHubWifiSearchSuccessViewController.m
- // OneCable
- //
- // Created by nComz on 2017. 5. 11..
- // Copyright © 2017년 ntels. All rights reserved.
- //
- #import "HomeHubWifiSearchSuccessViewController.h"
- #import "HomeHubWifiPasswdInputViewController.h"
- @interface HomeHubWifiSearchSuccessViewController () <CustomCheckBoxDelegate> {
- 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
|