HomeHubWifiSearchSuccessViewController.m 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. //
  2. // HomeHubWifiSearchSuccessViewController.m
  3. // OneCable
  4. //
  5. // Created by nComz on 2017. 5. 11..
  6. // Copyright © 2017년 ntels. All rights reserved.
  7. //
  8. #import "HomeHubWifiSearchSuccessViewController.h"
  9. #import "HomeHubWifiPasswdInputViewController.h"
  10. @interface HomeHubWifiSearchSuccessViewController () <CustomCheckBoxDelegate> {
  11. BLEServiceHandler *bleService;
  12. BLEWLanModel *selectedWLanModel;
  13. }
  14. @end
  15. @implementation HomeHubWifiSearchTableViewCell
  16. @end
  17. @implementation HomeHubWifiSearchSuccessViewController
  18. - (void)viewDidLoad {
  19. [super viewDidLoad];
  20. [self initUI];
  21. [self prepareViewDidLoad];
  22. }
  23. - (void)didReceiveMemoryWarning {
  24. [super didReceiveMemoryWarning];
  25. }
  26. - (void)initUI {
  27. _btnNext.enabled = NO;
  28. [self initTableViewAsDefaultStyle:_tableView];
  29. }
  30. - (void)prepareViewDidLoad {
  31. //ble
  32. bleService = [BLEServiceHandler sharedManager];
  33. bleService.delegate = self;
  34. [_tableView reloadData];
  35. }
  36. #pragma mark - UITableView DataSource & Delegate
  37. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  38. return 1;
  39. }
  40. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  41. return _wifiList.count;
  42. }
  43. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  44. return 101.0f;
  45. }
  46. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  47. HomeHubWifiSearchTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"WifiSearchCellIdentifier"];
  48. BLEWLanModel *model = [_wifiList objectAtIndex:indexPath.row];
  49. cell.lblHubName.text = model.ssid;
  50. cell.chkBtn.delegate = self;
  51. cell.chkBtn.value = model;
  52. cell.chkBtn.checked = [cell.chkBtn getCheckStatusFromValue];
  53. return cell;
  54. }
  55. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  56. [super tableView:tableView didSelectRowAtIndexPath:indexPath];
  57. }
  58. #pragma mark - CustomCheckBox Delegate {
  59. - (void)didCheckBoxClicked:(id)sender {
  60. CustomCheckBox *btn = sender;
  61. btn.selected = !btn.selected;
  62. selectedWLanModel = btn.value;
  63. _btnNext.enabled = YES ;
  64. }
  65. #pragma mark - ble delegate
  66. - (void)BLEWiFiSSIDRead:(NSString*)ssid {
  67. NSLog(@"selectedWLanModel.ssid : %@", selectedWLanModel.ssid);
  68. NSLog(@"ssid : %@", ssid);
  69. if (EQUALS(selectedWLanModel.ssid, ssid)) {
  70. HomeHubWifiPasswdInputViewController *vc = [CommonUtil instantiateViewControllerWithIdentifier:@"HomeHubWifiPasswdInputViewController" storyboardName:@"HomeHub"];
  71. vc.selectedWLanModel = selectedWLanModel;
  72. [self presentViewController:vc animated:YES completion:nil];
  73. }
  74. }
  75. #pragma mark - user Event
  76. - (IBAction)btnNextTouched:(id)sender {
  77. if (selectedWLanModel != nil) {
  78. [bleService setWiFiSSID:selectedWLanModel.ssid];
  79. [bleService readAndNotifyCharacteristicUUID:kBLEChrStSSIDArg
  80. isNotify:NO];
  81. }
  82. }
  83. - (IBAction)btnCancelTouched:(id)sender {
  84. [self dismissViewControllerAnimated:YES completion:nil];
  85. }
  86. @end