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

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <?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> <dependencies>
<deployment identifier="iOS"/> <deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8154"/> <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
</dependencies> </dependencies>
<scenes> <scenes>
<!--View Controller--> <!--View Controller-->
@ -19,7 +19,6 @@
<subviews> <subviews>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="RzV-q3-whK"> <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"/> <rect key="frame" x="20" y="28" width="140" height="30"/>
<animations/>
<state key="normal" title="Connect to BeerBox"> <state key="normal" title="Connect to BeerBox">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/> <color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state> </state>
@ -28,80 +27,53 @@
</connections> </connections>
</button> </button>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="n2u-Pj-bkX"> <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"/> <rect key="frame" x="86" y="395" width="149" height="30"/>
<animations/> <state key="normal" title="Create User">
<state key="normal" title="Create">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/> <color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state> </state>
<connections> <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> </connections>
</button> </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"> <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="85" y="94" width="146" height="21"/> <rect key="frame" x="84" y="320" width="152" height="21"/>
<animations/>
<fontDescription key="fontDescription" type="system" pointSize="17"/> <fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/> <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/> <nil key="highlightedColor"/>
</label> </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"> <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"/> <rect key="frame" x="110" y="357" width="97" height="30"/>
<animations/>
<fontDescription key="fontDescription" type="system" pointSize="14"/> <fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits"/> <textInputTraits key="textInputTraits"/>
<connections> <connections>
<action selector="dismiss:" destination="vXZ-lx-hvc" eventType="touchCancel" id="2tJ-ro-nvC"/> <action selector="dismiss:" destination="vXZ-lx-hvc" eventType="touchCancel" id="2tJ-ro-nvC"/>
</connections> </connections>
</textField> </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"> <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"/> <rect key="frame" x="126" y="102" width="65" height="30"/>
<animations/> <state key="normal" title="Drink List"/>
<state key="normal" title="List Users"/>
<connections> <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> </connections>
</button> </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"> <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"/> <rect key="frame" x="99" y="454" width="122" height="30"/>
<animations/>
<state key="normal" title="Revoke RFID Chip"/> <state key="normal" title="Revoke RFID Chip"/>
<connections> <connections>
<action selector="revokeRFID:" destination="vXZ-lx-hvc" eventType="touchUpInside" id="U06-XH-32h"/> <action selector="revokeRFID:" destination="vXZ-lx-hvc" eventType="touchUpInside" id="U06-XH-32h"/>
</connections> </connections>
</button> </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> </subviews>
<animations/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/> <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
</view> </view>
<simulatedScreenMetrics key="simulatedDestinationMetrics" type="retina4"/> <simulatedScreenMetrics key="simulatedDestinationMetrics" type="retina4"/>

View File

@ -35,21 +35,21 @@
// Dispose of any resources that can be recreated. // Dispose of any resources that can be recreated.
} }
//############ Connection Handling
- (IBAction)connect:(id)sender { - (IBAction)connect:(id)sender {
[btControl findHMSoftPeripherals:8]; [btControl findHMSoftPeripherals:8];
[NSTimer scheduledTimerWithTimeInterval:8 target:self selector:@selector(scanTimer:) userInfo:nil repeats:NO]; [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]; 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"]) if([peripheral.name isEqual: @"LBsKeys"])
{ {
box = peripheral; 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]; NSString *value = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
[[[UIAlertView alloc] initWithTitle:@"RCV!" message:value delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:nil] show]; [[[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]; NSString *sendString = [NSString stringWithFormat:@"!%@;",_nameEntry.text];
NSData *data = [sendString dataUsingEncoding:[NSString defaultCStringEncoding]]; NSData *data = [sendString dataUsingEncoding:[NSString defaultCStringEncoding]];
@ -95,15 +100,10 @@
} }
} }
- (IBAction)removeUser:(id)sender {
}
- (IBAction)listUsers:(id)sender {
}
- (IBAction)revokeRFID:(id)sender { - (IBAction)revokeRFID:(id)sender {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Revoke RFID" message:@"Enter an ID" delegate:nil cancelButtonTitle:@"Cancel" otherButtonTitles:@"Add", nil]; UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Revoke RFID" message:@"Enter an ID" delegate:nil cancelButtonTitle:@"Cancel" otherButtonTitles:@"Add", nil];
alert.alertViewStyle = UIAlertViewStylePlainTextInput; alert.alertViewStyle = UIAlertViewStylePlainTextInput;
[alert show]; [alert show];
@ -112,8 +112,6 @@
[[alert textFieldAtIndex:0] resignFirstResponder]; [[alert textFieldAtIndex:0] resignFirstResponder];
[[alert textFieldAtIndex:0] setKeyboardType:UIKeyboardTypePhonePad]; [[alert textFieldAtIndex:0] setKeyboardType:UIKeyboardTypePhonePad];
[[alert textFieldAtIndex:0] becomeFirstResponder]; [[alert textFieldAtIndex:0] becomeFirstResponder];
} }
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{ - (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 -(void)setConnect
{ {