HomeHubSearchSuccessViewController.m 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. //
  2. // HomeHubSearchSuccessViewController.m
  3. // OneCable
  4. //
  5. // Created by nComz on 2017. 5. 11..
  6. // Copyright © 2017년 ntels. All rights reserved.
  7. //
  8. #import "HomeHubSearchSuccessViewController.h"
  9. #import "CustomTableView.h"
  10. #import "CustomCheckBox.h"
  11. #import "HomeHubConnectWifiViewController.h"
  12. @interface HomeHubSearchSuccessViewController ()<CustomCheckBoxDelegate> {
  13. BLEServiceHandler *bleService;
  14. NSMutableArray *devices;
  15. NSArray *_tableZombieValues;
  16. BTLEDeivceModel *selectedModel;
  17. }
  18. @end
  19. @implementation HomeHubSearchTableViewCell
  20. @end
  21. @implementation HomeHubSearchSuccessViewController
  22. - (void)viewDidLoad {
  23. [super viewDidLoad];
  24. [self initUI];
  25. [self prepareViewDidLoad];
  26. }
  27. - (void)didReceiveMemoryWarning {
  28. [super didReceiveMemoryWarning];
  29. }
  30. - (void)initUI {
  31. _btnNext.enabled = NO;
  32. [self initTableViewAsDefaultStyle:_tableView];
  33. }
  34. - (void)prepareViewDidLoad {
  35. devices = [NSMutableArray new];
  36. //ble
  37. bleService = [BLEServiceHandler sharedManager];
  38. bleService.delegate = self;
  39. devices = [bleService getDeviceList];
  40. [_tableView reloadData];
  41. }
  42. #pragma mark - UITableView DataSource & Delegate
  43. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  44. return 1;
  45. }
  46. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  47. return devices.count;
  48. }
  49. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  50. return 108.0f;
  51. }
  52. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  53. HomeHubSearchTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"HubSearchCellIdentifier"];
  54. BTLEDeivceModel *bleModel = [devices objectAtIndex:indexPath.row];
  55. cell.lblHubName.text = bleModel.peripheralRef.name;
  56. cell.lblSerialNum.text = [NSString stringWithFormat:@"S/N : %@",bleModel.peripheralRef.identifier];
  57. cell.chkBtn.selected = [selectedModel isEqual:bleModel];
  58. return cell;
  59. }
  60. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  61. [super tableView:tableView didSelectRowAtIndexPath:indexPath];
  62. selectedModel = [devices objectAtIndex:indexPath.row];
  63. [tableView reloadData];
  64. }
  65. #pragma mark - User Event
  66. - (IBAction)btnNextTouched:(id)sender {
  67. NSLog(@"selectedModel : %@", selectedModel);
  68. if (selectedModel != nil) {
  69. [bleService setConDevice:selectedModel];
  70. HomeHubConnectWifiViewController *vc = [CommonUtil instantiateViewControllerWithIdentifier:@"HomeHubConnectWifiViewController" storyboardName:@"HomeHub"];
  71. [self.navigationController pushViewController:vc animated:YES];
  72. }
  73. }
  74. - (IBAction)btnCloseTouched:(id)sender {
  75. [self.navigationController popToRootViewControllerAnimated:YES];
  76. }
  77. @end