HomeHubWifiPasswdInputViewController.m 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. //
  2. // HomeHubWifiPasswdInputViewController.m
  3. // OneCable
  4. //
  5. // Created by nComz on 2017. 5. 11..
  6. // Copyright © 2017년 ntels. All rights reserved.
  7. //
  8. #import "HomeHubWifiPasswdInputViewController.h"
  9. @interface HomeHubWifiPasswdInputViewController () {
  10. BLEServiceHandler *bleService;
  11. }
  12. @end
  13. @implementation HomeHubWifiPasswdInputViewController
  14. - (void)viewDidLoad {
  15. [super viewDidLoad];
  16. [self initUI];
  17. [self prepareViewDidLoad];
  18. }
  19. - (void)initUI {
  20. _lblSSID.text = [NSString stringWithFormat:@"SSID : %@", _selectedWLanModel.ssid];
  21. }
  22. - (void)prepareViewDidLoad {
  23. //ble
  24. bleService = [BLEServiceHandler sharedManager];
  25. bleService.delegate = self;
  26. }
  27. - (void)didReceiveMemoryWarning {
  28. [super didReceiveMemoryWarning];
  29. }
  30. #pragma mark - User Event
  31. - (IBAction)btnAgainTouched:(id)sender {
  32. UIViewController *vc = [CommonUtil instantiateViewControllerWithIdentifier:@"HomeHubConnectWifiViewController" storyboardName:@"HomeHub"];
  33. [self presentViewController:vc animated:YES completion:nil];
  34. }
  35. - (IBAction)btnConnectTouched:(id)sender {
  36. NSString *pass = _txtInputPasswd.text.trim;
  37. if (pass.length == 0) {
  38. return;
  39. }
  40. NSLog(@"pass : %@", pass);
  41. [bleService setWiFiPwd:pass];
  42. [bleService enableDHCP];
  43. [bleService readAndNotifyCharacteristicUUID:kBLEChrStDHCPArg isNotify:NO];
  44. }
  45. - (IBAction)btnCancelTouched:(id)sender {
  46. [self dismissViewControllerAnimated:YES completion:nil];
  47. }
  48. #pragma mark - ble delegate
  49. - (void)BLEWiFiDHCPRead:(id)data {
  50. NSLog(@"BLEWiFiDHCPRead") ;
  51. [bleService applyWiFiSettingInfo];
  52. [bleService readAndNotifyCharacteristicUUID:kBLEChrRdConInfo isNotify:YES];
  53. }
  54. @end