diff options
Diffstat (limited to 'sampleclient')
| -rwxr-xr-x | sampleclient/ConnectionController.h | 2 | ||||
| -rwxr-xr-x | sampleclient/ConnectionController.m | 56 | ||||
| -rwxr-xr-x | sampleclient/MainStoryboard.storyboard | 27 |
3 files changed, 76 insertions, 9 deletions
diff --git a/sampleclient/ConnectionController.h b/sampleclient/ConnectionController.h index d8a7755..31e217d 100755 --- a/sampleclient/ConnectionController.h +++ b/sampleclient/ConnectionController.h @@ -10,7 +10,7 @@ #import "AppDelegate.h" #import "Waydio.h" -@interface ConnectionController : UIViewController <UITextFieldDelegate, WaydioDelegate, CBCentralManagerDelegate> { +@interface ConnectionController : UIViewController <UITextFieldDelegate, WaydioDelegate> { UITextField *_inputText; NSMutableString *_outputText; //used as string data for textView to make string concatenations more efficient NSArray *_allCommands; //All commands sent by the get settings button 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 diff --git a/sampleclient/MainStoryboard.storyboard b/sampleclient/MainStoryboard.storyboard index 908994a..2ced530 100755 --- a/sampleclient/MainStoryboard.storyboard +++ b/sampleclient/MainStoryboard.storyboard @@ -98,7 +98,7 @@ <color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/> </state> <connections> - <action selector="getSettings:" destination="6Co-CY-QOi" eventType="touchUpInside" id="ul8-L4-zrT"/> + <action selector="disconnectButton:" destination="6Co-CY-QOi" eventType="touchUpInside" id="F4J-bI-SgR"/> </connections> </button> <textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" indicatorStyle="black" editable="NO" id="cGV-n4-9ji" userLabel="textView"> @@ -159,7 +159,6 @@ <connections> <outlet property="batteryLabel" destination="5km-Vi-7hx" id="zkS-Uk-m5d"/> <outlet property="batteryReading" destination="ydm-ls-dqM" id="FbC-49-5sj"/> - <outlet property="buttonGetSettings" destination="ecM-M5-w4n" id="V6s-Cg-nxq"/> <outlet property="buttonReading" destination="Ea1-A6-mdk" id="vab-Ze-c7Z"/> <outlet property="disconnectButton" destination="ecM-M5-w4n" id="xbP-mt-QDZ"/> <outlet property="textView" destination="cGV-n4-9ji" id="7k2-1Y-0W7"/> @@ -187,6 +186,30 @@ <point key="canvasLocation" x="33" y="-143"/> </scene> </scenes> + <classes> + <class className="ConnectionController" superclassName="UIViewController"> + <source key="sourceIdentifier" type="project" relativePath="./Classes/ConnectionController.h"/> + <relationships> + <relationship kind="action" name="disconnectButton:"/> + <relationship kind="outlet" name="batteryLabel" candidateClass="UILabel"/> + <relationship kind="outlet" name="batteryReading" candidateClass="UILabel"/> + <relationship kind="outlet" name="buttonReading" candidateClass="UILabel"/> + <relationship kind="outlet" name="disconnectButton" candidateClass="UIButton"/> + <relationship kind="outlet" name="textView" candidateClass="UITextView"/> + <relationship kind="outlet" name="weightLabel" candidateClass="UILabel"/> + <relationship kind="outlet" name="weightReading" candidateClass="UILabel"/> + </relationships> + </class> + <class className="ScanController" superclassName="UIViewController"> + <source key="sourceIdentifier" type="project" relativePath="./Classes/ScanController.h"/> + <relationships> + <relationship kind="action" name="startScanButton:"/> + <relationship kind="action" name="stopScanButton:"/> + <relationship kind="outlet" name="_deviceTableView" candidateClass="UITableView"/> + <relationship kind="outlet" name="_scanButton" candidateClass="UIButton"/> + </relationships> + </class> + </classes> <simulatedMetricsContainer key="defaultSimulatedMetrics"> <simulatedStatusBarMetrics key="statusBar"/> <simulatedOrientationMetrics key="orientation"/> |
