Cleanup
This commit is contained in:
@ -35,21 +35,21 @@
|
||||
// Dispose of any resources that can be recreated.
|
||||
}
|
||||
|
||||
|
||||
//############ Connection Handling
|
||||
|
||||
- (IBAction)connect:(id)sender {
|
||||
|
||||
[btControl findHMSoftPeripherals:8];
|
||||
[NSTimer scheduledTimerWithTimeInterval:8 target:self selector:@selector(scanTimer:) userInfo:nil repeats:NO];
|
||||
}
|
||||
|
||||
-(void) scanTimer:(NSTimer *)timer
|
||||
{
|
||||
-(void) scanTimer:(NSTimer *)timer {
|
||||
|
||||
if(box == nil) [[[UIAlertView alloc] initWithTitle:@"Error" message:@"BeerBox not found!" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:nil] show];
|
||||
}
|
||||
|
||||
|
||||
-(void) peripheralFound:(CBPeripheral *)peripheral
|
||||
{
|
||||
-(void) peripheralFound:(CBPeripheral *)peripheral {
|
||||
if([peripheral.name isEqual: @"LBsKeys"])
|
||||
{
|
||||
box = peripheral;
|
||||
@ -57,14 +57,19 @@
|
||||
}
|
||||
}
|
||||
|
||||
-(void) serialGATTCharValueUpdated:(NSString *)UUID value:(NSData *)data
|
||||
{
|
||||
-(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];
|
||||
|
||||
}
|
||||
|
||||
- (IBAction)sendMsgToArduino:(id)sender {
|
||||
- (IBAction)listDrinks:(id)sender {
|
||||
}
|
||||
|
||||
- (IBAction)listUsers:(id)sender {
|
||||
}
|
||||
|
||||
- (IBAction)createUser:(id)sender {
|
||||
|
||||
NSString *sendString = [NSString stringWithFormat:@"!%@;",_nameEntry.text];
|
||||
NSData *data = [sendString dataUsingEncoding:[NSString defaultCStringEncoding]];
|
||||
@ -95,15 +100,10 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (IBAction)removeUser:(id)sender {
|
||||
}
|
||||
|
||||
- (IBAction)listUsers:(id)sender {
|
||||
}
|
||||
|
||||
|
||||
- (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;
|
||||
[alert show];
|
||||
@ -112,8 +112,6 @@
|
||||
[[alert textFieldAtIndex:0] resignFirstResponder];
|
||||
[[alert textFieldAtIndex:0] setKeyboardType:UIKeyboardTypePhonePad];
|
||||
[[alert textFieldAtIndex:0] becomeFirstResponder];
|
||||
|
||||
|
||||
}
|
||||
|
||||
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
|
||||
@ -127,43 +125,9 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (IBAction)revokeFinger:(id)sender {
|
||||
}
|
||||
|
||||
|
||||
|
||||
- (IBAction)checkCount:(id)sender {
|
||||
|
||||
NSString *sendString = [NSString stringWithFormat:@"!%@;",_nameEntry.text];
|
||||
NSData *data = [sendString dataUsingEncoding:[NSString defaultCStringEncoding]];
|
||||
|
||||
if(data.length > 20)
|
||||
{
|
||||
int i = 0;
|
||||
int nIndex = 0;
|
||||
while ((i + 1) * 20 <= data.length) {
|
||||
nIndex = i * 20;
|
||||
if(nIndex > 0)
|
||||
nIndex--;
|
||||
NSData *dataSend = [data subdataWithRange:NSMakeRange(nIndex, 20)];
|
||||
[btControl write:box data:dataSend];
|
||||
i++;
|
||||
}
|
||||
i = data.length % 20;
|
||||
if(i > 0)
|
||||
{
|
||||
NSData *dataSend = [data subdataWithRange:NSMakeRange(data.length - i, i)];
|
||||
[btControl write:box data:dataSend];
|
||||
}
|
||||
|
||||
}else
|
||||
{
|
||||
//NSData *data = [MsgToArduino.text dataUsingEncoding:[NSString defaultCStringEncoding]];
|
||||
[btControl write:box data:data];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
-(void)setConnect
|
||||
{
|
||||
|
Reference in New Issue
Block a user