forked from BLEduino/bleduino-ios
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKeyboardModuleTableViewController.m
More file actions
67 lines (52 loc) · 1.68 KB
/
Copy pathKeyboardModuleTableViewController.m
File metadata and controls
67 lines (52 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//
// KeyboardModuleTableViewController.m
// BLEduino
//
// Created by Ramon Gonzalez on 10/1/13.
// Copyright (c) 2013 Kytelabs. All rights reserved.
//
#import "KeyboardModuleTableViewController.h"
#import "UARTService.h"
#import "LeDiscoveryManager.h"
@interface KeyboardModuleTableViewController ()
@end
@implementation KeyboardModuleTableViewController
- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
UIBarButtonItem *dissmissButton = [[UIBarButtonItem alloc] initWithTitle:@"Modules" style:UIBarButtonItemStylePlain target:self action:@selector(dismissModule:)];
self.navigationItem.leftBarButtonItem = dissmissButton;
self.messageView.delegate = self;
[self.messageView becomeFirstResponder];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - Table view data source
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
{
if([text isEqualToString:@"\n"])
{
LeDiscoveryManager *leManager = [LeDiscoveryManager sharedLeManager];
CBPeripheral *bleduino = [leManager.connectedBleduinos lastObject];
NSString *message = self.messageView.text;
UARTService *messageService = [[UARTService alloc] initWithPeripheral:bleduino controller:self];
[messageService writeMessage:message];
}
return YES;
}
- (void)dismissModule:(id)sender
{
[self.delegate keyboardModuleTableViewControllerDismissed:self];
}
@end