diff --git a/BeerBox.xcodeproj/project.pbxproj b/BeerBox.xcodeproj/project.pbxproj index d96b75c..a7d9f70 100755 --- a/BeerBox.xcodeproj/project.pbxproj +++ b/BeerBox.xcodeproj/project.pbxproj @@ -7,7 +7,7 @@ objects = { /* Begin PBXBuildFile section */ - 2B08A22F1BB48CF300B0B8B1 /* Main_iPhone.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 2B08A22D1BB48CF300B0B8B1 /* Main_iPhone.storyboard */; settings = {ASSET_TAGS = (); }; }; + 2B08A22F1BB48CF300B0B8B1 /* Main_iPhone.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 2B08A22D1BB48CF300B0B8B1 /* Main_iPhone.storyboard */; }; 2BBC018F1981879400D0BAE0 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2BBC018E1981879400D0BAE0 /* Foundation.framework */; }; 2BBC01911981879400D0BAE0 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2BBC01901981879400D0BAE0 /* CoreGraphics.framework */; }; 2BBC01931981879400D0BAE0 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2BBC01921981879400D0BAE0 /* UIKit.framework */; }; @@ -24,8 +24,8 @@ 2BBC01C7198187B600D0BAE0 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2BBC01C6198187B600D0BAE0 /* AudioToolbox.framework */; }; 2BBC01C9198187C300D0BAE0 /* CoreBluetooth.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2BBC01C8198187C300D0BAE0 /* CoreBluetooth.framework */; }; 2BBC01CC198187EB00D0BAE0 /* SerialGATT.m in Sources */ = {isa = PBXBuildFile; fileRef = 2BBC01CA198187EB00D0BAE0 /* SerialGATT.m */; }; - 2BC70F0D1BD2242800330A1F /* Icon@2x copy.png in Resources */ = {isa = PBXBuildFile; fileRef = 2BC70F0C1BD2242800330A1F /* Icon@2x copy.png */; settings = {ASSET_TAGS = (); }; }; - 2BEEF2401BD7FAAB00003449 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 2BEEF23F1BD7FAAB00003449 /* LaunchScreen.storyboard */; settings = {ASSET_TAGS = (); }; }; + 2BC70F0D1BD2242800330A1F /* Icon@2x copy.png in Resources */ = {isa = PBXBuildFile; fileRef = 2BC70F0C1BD2242800330A1F /* Icon@2x copy.png */; }; + 2BEEF2401BD7FAAB00003449 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 2BEEF23F1BD7FAAB00003449 /* LaunchScreen.storyboard */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ diff --git a/BeerBox.xcodeproj/project.xcworkspace/xcuserdata/LB.xcuserdatad/UserInterfaceState.xcuserstate b/BeerBox.xcodeproj/project.xcworkspace/xcuserdata/LB.xcuserdatad/UserInterfaceState.xcuserstate index 3d703c2..5f4772d 100755 Binary files a/BeerBox.xcodeproj/project.xcworkspace/xcuserdata/LB.xcuserdatad/UserInterfaceState.xcuserstate and b/BeerBox.xcodeproj/project.xcworkspace/xcuserdata/LB.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/BeerBox/Base.lproj/Main_iPhone.storyboard b/BeerBox/Base.lproj/Main_iPhone.storyboard index d1d1b2e..2e7206b 100755 --- a/BeerBox/Base.lproj/Main_iPhone.storyboard +++ b/BeerBox/Base.lproj/Main_iPhone.storyboard @@ -1,5 +1,5 @@ - + @@ -14,7 +14,7 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - + - - + + - + - + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/BeerBox/Images.xcassets/AppIcon.appiconset/Contents.json b/BeerBox/Images.xcassets/AppIcon.appiconset/Contents.json index 72875c4..a7fe4fc 100644 --- a/BeerBox/Images.xcassets/AppIcon.appiconset/Contents.json +++ b/BeerBox/Images.xcassets/AppIcon.appiconset/Contents.json @@ -71,6 +71,11 @@ "idiom" : "ipad", "filename" : "Icon-76@2x.png", "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "83.5x83.5", + "scale" : "2x" } ], "info" : { diff --git a/BeerBox/LaunchScreen.storyboard b/BeerBox/LaunchScreen.storyboard index f2afbe5..0b34d93 100644 --- a/BeerBox/LaunchScreen.storyboard +++ b/BeerBox/LaunchScreen.storyboard @@ -1,8 +1,8 @@ - + - + @@ -16,7 +16,6 @@ - diff --git a/BeerBox/ViewController.h b/BeerBox/ViewController.h index 3649426..19a61b0 100755 --- a/BeerBox/ViewController.h +++ b/BeerBox/ViewController.h @@ -10,23 +10,32 @@ #import "SerialGATT.h" -@interface ViewController : UIViewController +@interface ViewController : UIViewController @property (strong, nonatomic) SerialGATT *btControl; @property (strong, nonatomic) CBPeripheral *box; +@property Boolean connected; - (IBAction)connect:(id)sender; -- (IBAction)sendMsgToArduino:(id)sender; -- (IBAction)checkCount:(id)sender; -- (IBAction)removeUser:(id)sender; - (IBAction)listUsers:(id)sender; +- (IBAction)listDrinks:(id)sender; +- (IBAction)startScan:(id)sender; - +- (IBAction)getUser:(id)sender; - (IBAction)revokeRFID:(id)sender; - (IBAction)revokeFinger:(id)sender; +- (IBAction)setCredits:(id)sender; +- (IBAction)setName:(id)sender; +- (IBAction)removeUser:(id)sender; + +- (IBAction)clearOutput:(id)sender; @property (weak, nonatomic) IBOutlet UILabel *status; -@property (weak, nonatomic) IBOutlet UITextField *nameEntry; + +@property (weak, nonatomic) IBOutlet UITextField *fileEntry; +@property (weak, nonatomic) IBOutlet UITextField *dataEntry; + +@property (weak, nonatomic) IBOutlet UITextView *output; @end diff --git a/BeerBox/ViewController.m b/BeerBox/ViewController.m index 594eb1a..58727cb 100755 --- a/BeerBox/ViewController.m +++ b/BeerBox/ViewController.m @@ -14,7 +14,7 @@ @implementation ViewController -@synthesize btControl, box, status; +@synthesize btControl, box, status, connected; - (void)viewDidLoad { @@ -25,8 +25,8 @@ [btControl setup]; btControl.delegate = self; - [_nameEntry setDelegate:self]; - + [_dataEntry setDelegate:self]; + [_fileEntry setDelegate:self]; } - (void)didReceiveMemoryWarning @@ -58,20 +58,104 @@ } -(void) serialGATTCharValueUpdated:(NSString *)UUID value:(NSData *)data { - NSString *value = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding]; - [[[UIAlertView alloc] initWithTitle:@"RCV!" message:value delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:nil] show]; + NSString *retstring = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding]; + //[[[UIAlertView alloc] initWithTitle:@"RCV!" message:retstring delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:nil] show]; + //parseValue here + _output.text = [_output.text stringByAppendingString:retstring]; + /* + NSData *retdata = [retstring dataUsingEncoding:[NSString defaultCStringEncoding]]; + NSError *e = nil; + NSArray *jsonArray = [NSJSONSerialization JSONObjectWithData: retdata options: NSJSONReadingMutableContainers error: &e]; + + if (!jsonArray) { + NSLog(@"Error parsing JSON: %@", e); + } else { + for(NSDictionary *item in jsonArray) { + NSLog(@"Item: %@", item); + + } + } +*/ +} +- (IBAction)clearOutput:(id)sender{ + _output.text = @""; } - (IBAction)listDrinks:(id)sender { + + if(self.connected){ + //NSString *sendString = [NSString stringWithFormat:@"!%@;",_nameEntry.text]; + [self sendString:@"#1;"]; + + }else{ + [[[UIAlertView alloc] initWithTitle:@"Error" message:@"BeerBox not connected!" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:nil] show]; + } + } - (IBAction)listUsers:(id)sender { + if(self.connected){ + //NSString *sendString = [NSString stringWithFormat:@"!%@;",_nameEntry.text]; + [self sendString:@"#2;"]; + }else{ + [[[UIAlertView alloc] initWithTitle:@"Error" message:@"BeerBox not connected!" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:nil] show]; + } + + /* + UITableViewController* tab =[self.storyboard instantiateViewControllerWithIdentifier:@"tableView"]; + //tab.anotherString = self.originalString; + [tab.tableView setDelegate:self]; + [tab.tableView setDataSource:self]; + [self presentViewController:tab animated:YES completion:nil]; + */ +} + +- (IBAction)startScan:(id)sender{ + if(self.connected){ + //NSString *sendString = [NSString stringWithFormat:@"!%@;",_nameEntry.text]; + [self sendString:@"!3;"]; + }else{ + [[[UIAlertView alloc] initWithTitle:@"Error" message:@"BeerBox not connected!" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:nil] show]; + } +} + +- (IBAction)getUser:(id)sender { + NSString *sendString = [NSString stringWithFormat:@"!2%@;",_fileEntry.text]; + [self sendString:sendString]; } - (IBAction)createUser:(id)sender { - - NSString *sendString = [NSString stringWithFormat:@"!%@;",_nameEntry.text]; + NSString *sendString = [NSString stringWithFormat:@"!1%@;",_dataEntry.text]; + [self sendString:sendString]; +} + +- (IBAction)removeUser:(id)sender { + NSString *sendString = [NSString stringWithFormat:@"!6%@;",_fileEntry.text]; + [self sendString:sendString]; +} + +- (IBAction)setCredits:(id)sender { + NSString *sendString = [NSString stringWithFormat:@"!7%@;%@;",_fileEntry.text,_dataEntry.text]; + [self sendString:sendString]; +} +- (IBAction)setName:(id)sender { + NSString *sendString = [NSString stringWithFormat:@"!8%@;%@;",_fileEntry.text,_dataEntry.text]; + [self sendString:sendString]; +} + +- (IBAction)revokeRFID:(id)sender { + NSString *sendString = [NSString stringWithFormat:@"!5%@;",_fileEntry.text]; + [self sendString:sendString]; +} +- (IBAction)revokeFinger:(id)sender { + NSString *sendString = [NSString stringWithFormat:@"!4%@;",_fileEntry.text]; + [self sendString:sendString]; +} + + + +- (void) sendString:(NSString*)sendString{ NSData *data = [sendString dataUsingEncoding:[NSString defaultCStringEncoding]]; if(data.length > 20) @@ -98,11 +182,11 @@ //NSData *data = [MsgToArduino.text dataUsingEncoding:[NSString defaultCStringEncoding]]; [btControl write:box data:data]; } + } - - +/* - (IBAction)revokeRFID:(id)sender { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Revoke RFID" message:@"Enter an ID" delegate:nil cancelButtonTitle:@"Cancel" otherButtonTitles:@"Add", nil]; alert.alertViewStyle = UIAlertViewStylePlainTextInput; @@ -113,6 +197,7 @@ [[alert textFieldAtIndex:0] setKeyboardType:UIKeyboardTypePhonePad]; [[alert textFieldAtIndex:0] becomeFirstResponder]; } +*/ - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{ // The user created a new item, add it @@ -133,12 +218,14 @@ { [[[UIAlertView alloc] initWithTitle:@"Found!" message:@"BeerBox found!" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil] show]; status.text=@"Connected!"; + self.connected = true; } -(void)setDisconnect { [[[UIAlertView alloc] initWithTitle:@"Lost!" message:@"BeerBox lost :-(" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil] show]; status.text=@"not Connected"; + self.connected = false; } @@ -147,6 +234,22 @@ return NO; } +//####### Table View stuff + +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ + return 10; +} + +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ + NSString *protoID = @"userCell"; + + UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:protoID]; + cell.textLabel.text = @"Lol"; + + return cell; +} + + @end