diff options
Diffstat (limited to 'sampleclient')
| -rwxr-xr-x | sampleclient/.DS_Store | bin | 0 -> 6148 bytes | |||
| -rwxr-xr-x | sampleclient/AppDelegate.h | 21 | ||||
| -rwxr-xr-x | sampleclient/AppDelegate.m | 66 | ||||
| -rwxr-xr-x | sampleclient/ConnectionController.h | 32 | ||||
| -rwxr-xr-x | sampleclient/ConnectionController.m | 180 | ||||
| -rwxr-xr-x | sampleclient/MainStoryboard.storyboard | 195 | ||||
| -rwxr-xr-x | sampleclient/ScanController.h | 27 | ||||
| -rwxr-xr-x | sampleclient/ScanController.m | 158 | ||||
| -rwxr-xr-x | sampleclient/en.lproj/InfoPlist.strings | 2 | ||||
| -rwxr-xr-x | sampleclient/main.m | 15 | ||||
| -rw-r--r-- | sampleclient/waydio_comms_demo-Info.plist | 58 | ||||
| -rw-r--r-- | sampleclient/waydio_comms_demo-Prefix.pch | 15 |
12 files changed, 769 insertions, 0 deletions
diff --git a/sampleclient/.DS_Store b/sampleclient/.DS_Store Binary files differnew file mode 100755 index 0000000..5008ddf --- /dev/null +++ b/sampleclient/.DS_Store diff --git a/sampleclient/AppDelegate.h b/sampleclient/AppDelegate.h new file mode 100755 index 0000000..262717d --- /dev/null +++ b/sampleclient/AppDelegate.h @@ -0,0 +1,21 @@ +// +// AppDelegate.h +// sampleterm +// +// Created by Michael Testa on 11/1/12. +// Copyright (c) Blueradios, Inc. All rights reserved. +// + +#import <UIKit/UIKit.h> +#import <CoreBluetooth/CoreBluetooth.h> + +@interface AppDelegate : UIResponder <UIApplicationDelegate> + +@property (strong, nonatomic) UIWindow *window; +@property (strong, nonatomic) CBCentralManager *cbCentral; +@property (strong, nonatomic) CBPeripheral *activePeripheral; + +//Returns a pointer to the shared AppDelegate ++(AppDelegate*)app; + +@end diff --git a/sampleclient/AppDelegate.m b/sampleclient/AppDelegate.m new file mode 100755 index 0000000..1e46e92 --- /dev/null +++ b/sampleclient/AppDelegate.m @@ -0,0 +1,66 @@ +// +// AppDelegate.m +// sampleterm +// +// Created by Michael Testa on 11/1/12. +// Copyright (c) Blueradios, Inc. All rights reserved. +// + +#import "AppDelegate.h" + +@implementation AppDelegate + +@synthesize window = _window; +@synthesize cbCentral; +@synthesize activePeripheral; + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions +{ + return YES; +} + +- (void)applicationWillResignActive:(UIApplication *)application +{ + /* + Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. + Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. + */ +} + +- (void)applicationDidEnterBackground:(UIApplication *)application +{ + /* + Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. + If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. + */ +} + +- (void)applicationWillEnterForeground:(UIApplication *)application +{ + /* + Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. + */ +} + +- (void)applicationDidBecomeActive:(UIApplication *)application +{ + /* + Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. + */ +} + +- (void)applicationWillTerminate:(UIApplication *)application +{ + /* + Called when the application is about to terminate. + Save data if appropriate. + See also applicationDidEnterBackground:. + */ +} + ++(AppDelegate*)app { + return (AppDelegate*)[[UIApplication sharedApplication] delegate]; +} + + +@end diff --git a/sampleclient/ConnectionController.h b/sampleclient/ConnectionController.h new file mode 100755 index 0000000..d8a7755 --- /dev/null +++ b/sampleclient/ConnectionController.h @@ -0,0 +1,32 @@ +// +// ConnectionController.h +// sampleterm +// +// Created by Michael Testa on 11/1/12. +// Copyright (c) Blueradios, Inc. All rights reserved. +// + +#import <UIKit/UIKit.h> +#import "AppDelegate.h" +#import "Waydio.h" + +@interface ConnectionController : UIViewController <UITextFieldDelegate, WaydioDelegate, CBCentralManagerDelegate> { + 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 + NSMutableArray *_commandQueue; //An array of commands queued for sending +} + +@property (strong, nonatomic) Waydio *waydioObject; +@property (strong, nonatomic) IBOutlet UITextView *textView; + +@property (strong, nonatomic) IBOutlet UIButton *disconnectButton; + +@property (weak, nonatomic) IBOutlet UILabel *weightLabel; +@property (weak, nonatomic) IBOutlet UILabel *weightReading; +@property (weak, nonatomic) IBOutlet UILabel *batteryLabel; +@property (weak, nonatomic) IBOutlet UILabel *batteryReading; + +@property (weak, nonatomic) IBOutlet UILabel *buttonReading; + +@end diff --git a/sampleclient/ConnectionController.m b/sampleclient/ConnectionController.m new file mode 100755 index 0000000..170b0a0 --- /dev/null +++ b/sampleclient/ConnectionController.m @@ -0,0 +1,180 @@ +// +// ConnectionController.m +// sampleterm +// +// Created by Michael Testa on 11/1/12. +// Copyright (c) Blueradios, Inc. All rights reserved. +// + +#import "ConnectionController.h" + +//Make this number larger or smaller to see more or less output in the textview +#define MAX_TEXT_VIEW_CHARACTERS 800 + +@implementation ConnectionController + +#pragma mark waydioDelegate + +- (void)waydio:(Waydio*)waydio OpenStatusChanged:(BOOL)isOpen { + +} +/** + Called when the measured weight changes + @param waydio The Waydio object generating this event + @param weight + */ +- (void)waydio:(Waydio*)waydio WeightChanged:(Float32)weight { + +} +/** + Called when the battery level changes + @param waydio The Waydio object generating this event + @param batteryPercent + */ +- (void)waydio:(Waydio*)waydio BatteryChanged:(Float32)batteryPercent { + +} +/** + Called when the isSending changes + @param waydio The Waydio object generating this event + @param isOpen YES == Pressed + */ +- (void)waydio:(Waydio*)waydio ButtonChanged:(BOOL)isPressed { + +} + +#pragma mark CBCentralManagerDelegate +- (void)centralManagerDidUpdateState:(CBCentralManager *)central { + +} + +- (void)centralManager:(CBCentralManager *)central didConnectPeripheral:(CBPeripheral *)peripheral { + //call the open function to prepare the brsp service + //[self.brspObject open]; +} + +- (void)centralManager:(CBCentralManager *)central didDisconnectPeripheral:(CBPeripheral *)peripheral error:(NSError *)error { + //[self.brspObject close]; + [self.navigationController popViewControllerAnimated:YES]; +} + +- (void)viewDidLoad { + [super viewDidLoad]; + self.navigationItem.title = [AppDelegate app].activePeripheral.name; + [_inputText setDelegate:self]; + _allCommands = [NSMutableArray new]; + [self loadCommandArray]; + //_lastMode = BrspModeData; //Default brsp mode +} + +-(void)loadCommandArray { + _allCommands = [NSArray arrayWithObjects: + @"ATMT?", + @"ATV?", + @"ATA?", + @"ATSN?", + @"ATSZ?", + @"ATSFC?", + @"ATSCL?", + @"ATSRM?", + @"ATSDIF?", + @"ATSPL?", + @"ATSUART?", + @"ATSPIO?,0", + @"ATSPIO?,1", + @"ATSPIO?,2", + @"ATSPIO?,3", + @"ATSPIO?,4", + @"ATSPIO?,5", + @"ATSPIO?,6", + @"ATSPIO?,7", + @"ATSPIO?,8", + @"ATSPIO?,9", + @"ATSPIO?,10", + @"ATSPIO?,11", + @"ATSPIO?,12", + @"ATSPIO?,13", + @"ATSPIO?,14", + @"ATSLED?,0", + @"ATSLED?,1", + @"ATSSP?", + @"ATSPK?", + @"ATSDBLE?", + @"ATSBRSP?", + @"ATSDSLE?", + @"ATSDSTLE?", + @"ATSDILE?", + @"ATSDITLE?", + @"ATSDMTLE?", + @"ATSDCP?", + @"ATSPLE?", + //D2 Modules only +// @"ATS?", +// @"ATLCA?", +// @"ATSP?", +// @"ATSCOD?", + nil]; +} + +- (void)viewWillAppear:(BOOL)animated { + [UIApplication sharedApplication].networkActivityIndicatorVisible = YES; + //[self disableButtons]; + [AppDelegate app].cbCentral.delegate = self; + + //init the object with default buffer sizes of 1024 bytes +// 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]; + + //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]; + _outputText = [NSMutableString stringWithCapacity:MAX_TEXT_VIEW_CHARACTERS]; + [super viewWillAppear:animated]; + + //_presses=0; +} + +- (void)viewDidUnload { + [super viewDidUnload]; +} + +- (void)viewWillDisappear:(BOOL)animated { + //call close to disable notifications etc (Not required) + //[brspObject close]; + //Use CBCentralManager to close the connection to this peripheral + [[AppDelegate app].cbCentral cancelPeripheralConnection:[AppDelegate app].activePeripheral]; + [super viewWillDisappear:animated]; +} + +- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { + switch(interfaceOrientation) + { + case UIInterfaceOrientationLandscapeLeft: + return NO; + case UIInterfaceOrientationLandscapeRight: + return NO; + default: + return YES; + } +} + + +#pragma mark - UI +- (IBAction)disconnectButton:(id)sender { + /* + //Save the brsp mode so it can be switched back when this process is complete + _lastMode = self.brspObject.brspMode; + if (brspObject.brspMode != BrspModeData) + [self.brspObject changeBrspMode:BrspModeData]; //change brsp mode to data + for (int i=1; i <= 10; i++) { + //Write numbers 1-10 to the device + NSError *error = [self.brspObject writeString:[NSString stringWithFormat:@"%i\r\n", i%10]]; + if (error) + NSLog(@"%@", error.description); + } + */ +} + +@end diff --git a/sampleclient/MainStoryboard.storyboard b/sampleclient/MainStoryboard.storyboard new file mode 100755 index 0000000..908994a --- /dev/null +++ b/sampleclient/MainStoryboard.storyboard @@ -0,0 +1,195 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="2.0" toolsVersion="3084" systemVersion="12D78" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" initialViewController="chw-46-jAo"> + <dependencies> + <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="2083"/> + </dependencies> + <scenes> + <!--Scan Controller - Select Device--> + <scene sceneID="IfQ-sd-xu9"> + <objects> + <viewController id="hDM-Al-XXx" customClass="ScanController" sceneMemberID="viewController"> + <view key="view" contentMode="scaleToFill" id="e7o-wp-2MY"> + <rect key="frame" x="0.0" y="64" width="320" height="416"/> + <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> + <subviews> + <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" id="kd5-hv-IOF"> + <rect key="frame" x="0.0" y="0.0" width="320" height="355"/> + <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> + <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/> + <prototypes> + <tableViewCell contentMode="scaleToFill" selectionStyle="blue" accessoryType="disclosureIndicator" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="Reuse Identifier" id="Czi-yq-CF3"> + <rect key="frame" x="0.0" y="22" width="320" height="44"/> + <autoresizingMask key="autoresizingMask"/> + <view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center"> + <rect key="frame" x="0.0" y="0.0" width="300" height="43"/> + <autoresizingMask key="autoresizingMask"/> + <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/> + </view> + <connections> + <segue destination="6Co-CY-QOi" kind="push" identifier="cellSegue" id="96p-O4-0cc"/> + </connections> + </tableViewCell> + </prototypes> + <connections> + <outlet property="dataSource" destination="hDM-Al-XXx" id="ZMe-u1-iMV"/> + <outlet property="delegate" destination="hDM-Al-XXx" id="E2h-qb-9lG"/> + </connections> + </tableView> + <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="NdL-GX-MJW"> + <rect key="frame" x="20" y="368" width="120" height="37"/> + <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> + <fontDescription key="fontDescription" type="boldSystem" pointSize="15"/> + <state key="normal" title="Scan"> + <color key="titleColor" red="0.19607843459999999" green="0.30980393290000002" blue="0.52156865600000002" alpha="1" colorSpace="calibratedRGB"/> + <color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/> + </state> + <state key="highlighted"> + <color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/> + </state> + <connections> + <action selector="startScanButton:" destination="hDM-Al-XXx" eventType="touchUpInside" id="cU9-KC-SXC"/> + </connections> + </button> + <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="dUj-0w-c6F"> + <rect key="frame" x="180" y="368" width="120" height="37"/> + <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> + <fontDescription key="fontDescription" type="boldSystem" pointSize="15"/> + <state key="normal" title="Stop Scan"> + <color key="titleColor" red="0.19607843459999999" green="0.30980393290000002" blue="0.52156865600000002" alpha="1" colorSpace="calibratedRGB"/> + <color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/> + </state> + <state key="highlighted"> + <color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/> + </state> + <connections> + <action selector="stopScanButton:" destination="hDM-Al-XXx" eventType="touchUpInside" id="Ppt-sS-SNt"/> + </connections> + </button> + </subviews> + <color key="backgroundColor" cocoaTouchSystemColor="scrollViewTexturedBackgroundColor"/> + </view> + <navigationItem key="navigationItem" title="Select Device" id="3Jc-oH-x5M"/> + <connections> + <outlet property="_deviceTableView" destination="kd5-hv-IOF" id="qJw-EN-Buo"/> + <outlet property="_scanButton" destination="NdL-GX-MJW" id="1AQ-Ik-LGI"/> + </connections> + </viewController> + <placeholder placeholderIdentifier="IBFirstResponder" id="C8G-bR-zgH" userLabel="First Responder" sceneMemberID="firstResponder"/> + </objects> + <point key="canvasLocation" x="492" y="-143"/> + </scene> + <!--Connection Controller--> + <scene sceneID="sXX-xB-gIc"> + <objects> + <viewController id="6Co-CY-QOi" customClass="ConnectionController" sceneMemberID="viewController"> + <view key="view" contentMode="scaleToFill" id="gwo-2B-OZu"> + <rect key="frame" x="0.0" y="64" width="320" height="416"/> + <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> + <subviews> + <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="ecM-M5-w4n"> + <rect key="frame" x="108" y="369" width="105" height="44"/> + <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> + <fontDescription key="fontDescription" type="boldSystem" pointSize="15"/> + <state key="normal" title="Disconnect"> + <color key="titleColor" red="0.19607843459999999" green="0.30980393290000002" blue="0.52156865600000002" alpha="1" colorSpace="calibratedRGB"/> + <color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/> + </state> + <state key="highlighted"> + <color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/> + </state> + <connections> + <action selector="getSettings:" destination="6Co-CY-QOi" eventType="touchUpInside" id="ul8-L4-zrT"/> + </connections> + </button> + <textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" indicatorStyle="black" editable="NO" id="cGV-n4-9ji" userLabel="textView"> + <rect key="frame" x="5" y="5" width="310" height="205"/> + <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> + <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/> + <fontDescription key="fontDescription" type="system" pointSize="14"/> + <textInputTraits key="textInputTraits" autocapitalizationType="sentences"/> + <connections> + <outlet property="delegate" destination="6Co-CY-QOi" id="HUH-im-eDb"/> + </connections> + </textView> + <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Weight:" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="OZ5-9M-I1x" userLabel="label1"> + <rect key="frame" x="20" y="246" width="58" height="21"/> + <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> + <fontDescription key="fontDescription" type="system" pointSize="17"/> + <color key="textColor" cocoaTouchSystemColor="darkTextColor"/> + <nil key="highlightedColor"/> + </label> + <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Battery:" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="5km-Vi-7hx" userLabel="label3"> + <rect key="frame" x="20" y="275" width="59" height="21"/> + <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> + <fontDescription key="fontDescription" type="system" pointSize="17"/> + <color key="textColor" cocoaTouchSystemColor="darkTextColor"/> + <nil key="highlightedColor"/> + </label> + <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Label" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="zKS-cw-AQg" userLabel="label2"> + <rect key="frame" x="86" y="246" width="42" height="21"/> + <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> + <fontDescription key="fontDescription" type="system" pointSize="17"/> + <color key="textColor" cocoaTouchSystemColor="darkTextColor"/> + <nil key="highlightedColor"/> + </label> + <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Label" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="ydm-ls-dqM" userLabel="label4"> + <rect key="frame" x="86" y="275" width="42" height="21"/> + <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> + <fontDescription key="fontDescription" type="system" pointSize="17"/> + <color key="textColor" cocoaTouchSystemColor="darkTextColor"/> + <nil key="highlightedColor"/> + </label> + <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Label" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="Ea1-A6-mdk" userLabel="label5"> + <rect key="frame" x="192" y="258" width="42" height="21"/> + <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> + <accessibility key="accessibilityConfiguration"> + <accessibilityTraits key="traits" none="YES"/> + </accessibility> + <fontDescription key="fontDescription" type="system" pointSize="17"/> + <color key="textColor" cocoaTouchSystemColor="darkTextColor"/> + <nil key="highlightedColor"/> + </label> + </subviews> + <color key="backgroundColor" cocoaTouchSystemColor="scrollViewTexturedBackgroundColor"/> + <gestureRecognizers/> + </view> + <toolbarItems/> + <navigationItem key="navigationItem" id="uLf-vX-Maj"/> + <simulatedNavigationBarMetrics key="simulatedTopBarMetrics" prompted="NO"/> + <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"/> + <outlet property="weightLabel" destination="OZ5-9M-I1x" id="Mx0-RN-hxL"/> + <outlet property="weightReading" destination="zKS-cw-AQg" id="w9R-mm-pFy"/> + </connections> + </viewController> + <placeholder placeholderIdentifier="IBFirstResponder" id="iyI-Bn-xs0" userLabel="First Responder" sceneMemberID="firstResponder"/> + </objects> + <point key="canvasLocation" x="938" y="-143"/> + </scene> + <!--Navigation Controller--> + <scene sceneID="iv5-3O-T2y"> + <objects> + <navigationController definesPresentationContext="YES" id="chw-46-jAo" sceneMemberID="viewController"> + <navigationBar key="navigationBar" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" id="s8h-iY-QXM"> + <autoresizingMask key="autoresizingMask"/> + </navigationBar> + <connections> + <segue destination="hDM-Al-XXx" kind="relationship" relationship="rootViewController" id="rCK-kI-det"/> + </connections> + </navigationController> + <placeholder placeholderIdentifier="IBFirstResponder" id="d7B-fr-BOp" userLabel="First Responder" sceneMemberID="firstResponder"/> + </objects> + <point key="canvasLocation" x="33" y="-143"/> + </scene> + </scenes> + <simulatedMetricsContainer key="defaultSimulatedMetrics"> + <simulatedStatusBarMetrics key="statusBar"/> + <simulatedOrientationMetrics key="orientation"/> + <simulatedScreenMetrics key="destination"/> + </simulatedMetricsContainer> +</document>
\ No newline at end of file diff --git a/sampleclient/ScanController.h b/sampleclient/ScanController.h new file mode 100755 index 0000000..4d3538b --- /dev/null +++ b/sampleclient/ScanController.h @@ -0,0 +1,27 @@ +// +// ScanController.h +// sampleterm +// +// Created by Michael Testa on 11/1/12. +// Copyright (c) Blueradios, Inc. All rights reserved. +// + +#import <UIKit/UIKit.h> +#import "AppDelegate.h" +#import "ConnectionController.h" +#import "Waydio.h" + +@interface ScanController : UIViewController <UITableViewDelegate, UITableViewDataSource, CBCentralManagerDelegate> { + IBOutlet UITableView *_deviceTableView; + IBOutlet UIButton *_scanButton; + NSMutableArray *_peripherals; +} + +@property (strong, nonatomic) UITableView* deviceTableView; + +//UI Elements +- (IBAction)startScanButton:(id)sender; +- (IBAction)stopScanButton:(id)sender; +- (void)enableButton:(UIButton*)butt; +- (void)disableButton:(UIButton*)butt; +@end diff --git a/sampleclient/ScanController.m b/sampleclient/ScanController.m new file mode 100755 index 0000000..7d59c2e --- /dev/null +++ b/sampleclient/ScanController.m @@ -0,0 +1,158 @@ +// +// ScanController.m +// sampleterm +// +// Created by Michael Testa on 11/1/12. +// Copyright (c) Blueradios, Inc. All rights reserved. +// + +#import "ScanController.h" + +@implementation ScanController + +@synthesize deviceTableView = _deviceTableView; + +- (void)didReceiveMemoryWarning +{ + [super didReceiveMemoryWarning]; +} + +#pragma mark - View lifecycle + +- (void)viewDidLoad +{ + [super viewDidLoad]; + _peripherals = [NSMutableArray new]; + self.navigationItem.title = @"Select Device"; + [self disableButton:_scanButton]; + [AppDelegate app].cbCentral = [[CBCentralManager alloc] initWithDelegate:self queue:nil]; +} + +- (void)viewDidUnload +{ + [super viewDidUnload]; +} + +- (void)viewWillAppear:(BOOL)animated +{ + [AppDelegate app].cbCentral.delegate = self; + [super viewWillAppear:animated]; +} + +- (void)viewDidAppear:(BOOL)animated +{ + [super viewDidAppear:animated]; +} + +- (void)viewWillDisappear:(BOOL)animated +{ + [super viewWillDisappear:animated]; +} + +- (void)viewDidDisappear:(BOOL)animated +{ + [super viewDidDisappear:animated]; +} + +#pragma mark - Table options + +//********************************************************************************************************************************************************** +//Table Options +//********************************************************************************************************************************************************** +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { + return 1; +} + +- (NSInteger)tableView:(UITableView *)TableView numberOfRowsInSection:(NSInteger)section { + return _peripherals.count; +} + +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { + + static NSString *CellIdentifier = @"Cell"; + + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; + if (cell == nil) { + cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; + } + // Configure the cell. + + CBPeripheral *peripheral = [_peripherals objectAtIndex:indexPath.row]; + + cell.textLabel.text = peripheral.name; + cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; + + return cell; +} + +- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { + [self performSegueWithIdentifier:@"cellSegue" sender:self]; +} + +- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{ + if ([[segue identifier] isEqualToString:@"cellSegue"]) { + [self stopScanButton:nil]; + NSIndexPath *indexPath = [self.deviceTableView indexPathForSelectedRow]; + + [AppDelegate app].activePeripheral = [_peripherals objectAtIndex:indexPath.row]; + [self.deviceTableView deselectRowAtIndexPath:indexPath animated:YES]; + } +} +- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {return NO;} + +#pragma mark - UI + +- (void) startScanButton:(id)sender { + [UIApplication sharedApplication].networkActivityIndicatorVisible = YES; + [_peripherals removeAllObjects]; + [self.deviceTableView reloadData]; + [self disableButton:_scanButton]; + [[AppDelegate app].cbCentral scanForPeripheralsWithServices:[NSArray arrayWithObject:[Waydio brspServiceUUID]] options:nil]; +} + +- (void) stopScanButton:(id)sender { + [[AppDelegate app].cbCentral stopScan]; + [self enableButton:_scanButton]; + [UIApplication sharedApplication].networkActivityIndicatorVisible = NO; +} + +- (void)enableButton:(UIButton*)butt { + butt.enabled = YES; + butt.alpha = 1.0; +} + +- (void)disableButton:(UIButton*)butt { + butt.enabled = NO; + butt.alpha = 0.5; +} + +#pragma mark - CBCentralManagerDelegate + +- (void)centralManager:(CBCentralManager *)central didConnectPeripheral:(CBPeripheral *)peripheral { +} +- (void)centralManager:(CBCentralManager *)central didDisconnectPeripheral:(CBPeripheral *)peripheral error:(NSError *)error { +} +- (void)centralManager:(CBCentralManager *)central didFailToConnectPeripheral:(CBPeripheral *)peripheral error:(NSError *)error { +} +- (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI { + if (![_peripherals containsObject:peripheral]) { + [_peripherals addObject:peripheral]; + [self.deviceTableView reloadData]; + } +} +-(void)retrieveConnectedPeripherals { +} + +- (void)centralManager:(CBCentralManager *)central didRetrieveConnectedPeripherals:(NSArray *)peripheralslist { +} + +- (void)centralManager:(CBCentralManager *)central didRetrievePeripherals:(NSArray *)peripherals { +} + +- (void)centralManagerDidUpdateState:(CBCentralManager *)central { + printf("Status of CoreBluetooth central manager changed %d \r\n",central.state); + if (central.state==CBCentralManagerStatePoweredOn) { + [self enableButton:_scanButton]; + } +} +@end diff --git a/sampleclient/en.lproj/InfoPlist.strings b/sampleclient/en.lproj/InfoPlist.strings new file mode 100755 index 0000000..477b28f --- /dev/null +++ b/sampleclient/en.lproj/InfoPlist.strings @@ -0,0 +1,2 @@ +/* Localized versions of Info.plist keys */ + diff --git a/sampleclient/main.m b/sampleclient/main.m new file mode 100755 index 0000000..1f1654c --- /dev/null +++ b/sampleclient/main.m @@ -0,0 +1,15 @@ +// +// main.m +// sampleclient + + +#import <UIKit/UIKit.h> + +#import "AppDelegate.h" + +int main(int argc, char *argv[]) +{ + @autoreleasepool { + return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); + } +} diff --git a/sampleclient/waydio_comms_demo-Info.plist b/sampleclient/waydio_comms_demo-Info.plist new file mode 100644 index 0000000..9ad6ac8 --- /dev/null +++ b/sampleclient/waydio_comms_demo-Info.plist @@ -0,0 +1,58 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>CFBundleDevelopmentRegion</key> + <string>en</string> + <key>CFBundleDisplayName</key> + <string>waydio</string> + <key>CFBundleExecutable</key> + <string>${EXECUTABLE_NAME}</string> + <key>CFBundleIconFiles</key> + <array> + <string>icon.png</string> + <string>icon@2x.png</string> + </array> + <key>CFBundleIcons</key> + <dict> + <key>CFBundlePrimaryIcon</key> + <dict> + <key>CFBundleIconFiles</key> + <array> + <string>icon.png</string> + <string>icon@2x.png</string> + </array> + <key>UIPrerenderedIcon</key> + <false/> + </dict> + </dict> + <key>CFBundleIdentifier</key> + <string>${PRODUCT_NAME:rfc1034identifier}</string> + <key>CFBundleInfoDictionaryVersion</key> + <string>6.0</string> + <key>CFBundleName</key> + <string>${PRODUCT_NAME}</string> + <key>CFBundlePackageType</key> + <string>APPL</string> + <key>CFBundleShortVersionString</key> + <string>1.0</string> + <key>CFBundleSignature</key> + <string>????</string> + <key>CFBundleVersion</key> + <string>1.0</string> + <key>LSRequiresIPhoneOS</key> + <true/> + <key>UIMainStoryboardFile</key> + <string>MainStoryboard</string> + <key>UIRequiredDeviceCapabilities</key> + <array> + <string>armv7</string> + <string>bluetooth-le</string> + </array> + <key>UISupportedInterfaceOrientations</key> + <array> + <string>UIInterfaceOrientationPortrait</string> + <string>UIInterfaceOrientationPortraitUpsideDown</string> + </array> +</dict> +</plist> diff --git a/sampleclient/waydio_comms_demo-Prefix.pch b/sampleclient/waydio_comms_demo-Prefix.pch new file mode 100644 index 0000000..e172fd8 --- /dev/null +++ b/sampleclient/waydio_comms_demo-Prefix.pch @@ -0,0 +1,15 @@ +// +// Prefix header for all source files of the 'sampleclient' target in the 'sampleclient' project +// + +#import <Availability.h> + +#ifndef __IPHONE_3_0 +#warning "This project uses features only available in iOS SDK 3.0 and later." +#endif + +#ifdef __OBJC__ + #import <UIKit/UIKit.h> + #import <Foundation/Foundation.h> +#endif + |
