summaryrefslogtreecommitdiff
path: root/sampleclient/ConnectionController.m
diff options
context:
space:
mode:
authorTim Redfern <tim@Adaptics.local>2013-10-11 17:46:32 -0700
committerTim Redfern <tim@Adaptics.local>2013-10-11 17:46:32 -0700
commite89f9947ae51eee20902432c4758b2d8e24185ea (patch)
tree3b4661b0277019e568648ce6ab44592494e552e7 /sampleclient/ConnectionController.m
parentcb75fd2a2f258a1a4e9f307840842f582838250b (diff)
talking to the deviceHEADmaster
Diffstat (limited to 'sampleclient/ConnectionController.m')
-rwxr-xr-xsampleclient/ConnectionController.m56
1 files changed, 50 insertions, 6 deletions
diff --git a/sampleclient/ConnectionController.m b/sampleclient/ConnectionController.m
index b56f898..c14ca97 100755
--- a/sampleclient/ConnectionController.m
+++ b/sampleclient/ConnectionController.m
@@ -13,6 +13,13 @@
@implementation ConnectionController
+@synthesize textView;
+//@synthesize inputText = _inputText;
+//@synthesize buttonChangeMode;
+//@synthesize buttonSend100;
+//@synthesize buttonGetSettings;
+@synthesize waydioObject;
+
#pragma mark waydioDelegate
- (void)waydio:(Waydio*)waydio OpenStatusChanged:(BOOL)isOpen {
@@ -42,7 +49,7 @@
- (void)waydio:(Waydio*)waydio ButtonChanged:(BOOL)isPressed {
}
-
+/*
#pragma mark CBCentralManagerDelegate
- (void)centralManagerDidUpdateState:(CBCentralManager *)central {
@@ -57,6 +64,7 @@
[self.waydioObject close];
[self.navigationController popViewControllerAnimated:YES];
}
+ */
- (void)viewDidLoad {
[super viewDidLoad];
@@ -119,17 +127,20 @@
- (void)viewWillAppear:(BOOL)animated {
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
//[self disableButtons];
- [AppDelegate app].cbCentral.delegate = self;
+ //-------->[AppDelegate app].cbCentral.delegate = self;
//init the object with default buffer sizes of 1024 bytes
-// self.brspObject = [[Brsp alloc] initWithPeripheral:[AppDelegate app].activePeripheral];
+ //self.brspObject = [[Brsp alloc] initWithPeripheral:[AppDelegate app].activePeripheral];
//init with custom buffer sizes
//self.brspObject = [[Brsp alloc] initWithPeripheral:[AppDelegate app].activePeripheral InputBufferSize:512 OutputBufferSize:512];
+ self.waydioObject = [[Waydio alloc] initWithPeripheral:[AppDelegate app].activePeripheral];
+ //[self.waydioObject open];
+
//It is important to set this delegate before calling [Brsp open]
//self.brspObject.delegate = self;
//Use CBCentral Manager to connect this peripheral
- [[AppDelegate app].cbCentral connectPeripheral:[AppDelegate app].activePeripheral options:nil];
+ //--------->[[AppDelegate app].cbCentral connectPeripheral:[AppDelegate app].activePeripheral options:nil];
_outputText = [NSMutableString stringWithCapacity:MAX_TEXT_VIEW_CHARACTERS];
[super viewWillAppear:animated];
@@ -142,9 +153,9 @@
- (void)viewWillDisappear:(BOOL)animated {
//call close to disable notifications etc (Not required)
- //[brspObject close];
+ [waydioObject close];
//Use CBCentralManager to close the connection to this peripheral
- [[AppDelegate app].cbCentral cancelPeripheralConnection:[AppDelegate app].activePeripheral];
+ //[[AppDelegate app].cbCentral cancelPeripheralConnection:[AppDelegate app].activePeripheral];
[super viewWillDisappear:animated];
}
@@ -160,6 +171,38 @@
}
}
+#pragma mark - UITextFieldDelegate methods
+-(BOOL) textFieldShouldReturn:(UITextField *)textField {
+ //Write whatever user typed in textfield to brsp peripheral
+ //NSError *error = [self.brspObject writeString:[NSString stringWithFormat:@"%@\r", textField.text]];
+ //if (error)
+ /// NSLog(@"%@", error.description);
+ //textField.text = @"";
+ //[textField resignFirstResponder];
+ return YES;
+}
+
+- (void)textFieldDidBeginEditing:(UITextField *)textField {
+ [self animateTextField:textField up: YES];
+}
+
+- (void)textFieldDidEndEditing:(UITextField *)textField {
+ [self animateTextField:textField up: NO];
+}
+
+- (void) animateTextField:(UITextField*)textField up:(BOOL)up {
+ const int movementDistance = 170; //will only work on iPhones
+ const float movementDuration = 0.3f; //
+
+ int movement = (up ? -movementDistance : movementDistance);
+
+ [UIView beginAnimations: @"anim" context: nil];
+ [UIView setAnimationBeginsFromCurrentState: YES];
+ [UIView setAnimationDuration: movementDuration];
+ self.view.frame = CGRectOffset(self.view.frame, 0, movement);
+ [UIView commitAnimations];
+}
+
#pragma mark - UI
- (IBAction)disconnectButton:(id)sender {
@@ -175,6 +218,7 @@
NSLog(@"%@", error.description);
}
*/
+ NSLog(@"disconnecting");
}
@end