This commit is contained in:
Lukas Bachschwell 2016-07-25 13:09:05 +02:00
parent ee6dabccc6
commit ab093d66f5
4 changed files with 46 additions and 105 deletions

View File

@ -23,10 +23,10 @@
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
@ -48,17 +48,21 @@
ReferencedContainer = "container:BeerBox.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable>
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "2BBC018A1981879400D0BAE0"
@ -71,12 +75,13 @@
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<BuildableProductRunnable>
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "2BBC018A1981879400D0BAE0"

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="8191" systemVersion="15A284" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="vXZ-lx-hvc">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10116" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="vXZ-lx-hvc">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8154"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
</dependencies>
<scenes>
<!--View Controller-->
@ -19,7 +19,6 @@
<subviews>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="RzV-q3-whK">
<rect key="frame" x="20" y="28" width="140" height="30"/>
<animations/>
<state key="normal" title="Connect to BeerBox">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
@ -28,80 +27,53 @@
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="n2u-Pj-bkX">
<rect key="frame" x="86" y="194" width="149" height="30"/>
<animations/>
<state key="normal" title="Create">
<rect key="frame" x="86" y="395" width="149" height="30"/>
<state key="normal" title="Create User">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="sendMsgToArduino:" destination="vXZ-lx-hvc" eventType="touchUpInside" id="j24-Kf-P4X"/>
<action selector="createUser:" destination="vXZ-lx-hvc" eventType="touchUpInside" id="Dxc-IU-yJN"/>
</connections>
</button>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Create a new User:" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="gdW-7D-K7k">
<rect key="frame" x="85" y="94" width="146" height="21"/>
<animations/>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Debug and old stuff" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="gdW-7D-K7k">
<rect key="frame" x="84" y="320" width="152" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="Y0c-XX-now">
<rect key="frame" x="110" y="123" width="97" height="30"/>
<animations/>
<rect key="frame" x="110" y="357" width="97" height="30"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits"/>
<connections>
<action selector="dismiss:" destination="vXZ-lx-hvc" eventType="touchCancel" id="2tJ-ro-nvC"/>
</connections>
</textField>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="I56-eg-l11">
<rect key="frame" x="69" y="223" width="179" height="30"/>
<animations/>
<state key="normal" title="Check one User"/>
<connections>
<action selector="checkCount:" destination="vXZ-lx-hvc" eventType="touchUpInside" id="Yjh-px-8Zf"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="zej-Tp-avG">
<rect key="frame" x="115" y="251" width="92" height="30"/>
<animations/>
<state key="normal" title="Remove User"/>
<connections>
<action selector="removeUser:" destination="vXZ-lx-hvc" eventType="touchUpInside" id="MBp-Ad-5nQ"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="q10-Wt-zCw">
<rect key="frame" x="113" y="365" width="97" height="30"/>
<animations/>
<state key="normal" title="Revoke Finger"/>
<connections>
<action selector="revokeFinger:" destination="vXZ-lx-hvc" eventType="touchUpInside" id="Qoc-9A-pkM"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Ega-iL-c02">
<rect key="frame" x="124" y="284" width="69" height="30"/>
<animations/>
<state key="normal" title="List Users"/>
<rect key="frame" x="126" y="102" width="65" height="30"/>
<state key="normal" title="Drink List"/>
<connections>
<action selector="listUsers:" destination="vXZ-lx-hvc" eventType="touchUpInside" id="KYv-By-fPM"/>
<action selector="listDrinks:" destination="vXZ-lx-hvc" eventType="touchUpInside" id="xBK-LE-APk"/>
</connections>
</button>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="not Connected" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="8HX-K5-jdU">
<rect key="frame" x="186" y="32" width="114" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="lHu-Pd-1h1">
<rect key="frame" x="126" y="140" width="61" height="30"/>
<state key="normal" title="User List"/>
</button>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="6Lh-Ga-6ln">
<rect key="frame" x="100" y="339" width="122" height="30"/>
<animations/>
<rect key="frame" x="99" y="454" width="122" height="30"/>
<state key="normal" title="Revoke RFID Chip"/>
<connections>
<action selector="revokeRFID:" destination="vXZ-lx-hvc" eventType="touchUpInside" id="U06-XH-32h"/>
</connections>
</button>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="not Connected" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="8HX-K5-jdU">
<rect key="frame" x="186" y="32" width="114" height="21"/>
<animations/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<animations/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
</view>
<simulatedScreenMetrics key="simulatedDestinationMetrics" type="retina4"/>

View File

@ -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
{