first take on an Bluetooth Inquiry dialog for the iPhone

This commit is contained in:
matthias.ringwald 2009-10-08 22:18:54 +00:00
parent e29adc1159
commit 7826510afc
10 changed files with 711 additions and 0 deletions

View File

@ -0,0 +1,28 @@
<?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>English</string>
<key>CFBundleDisplayName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIconFile</key>
<string>logo.png</string>
<key>CFBundleIdentifier</key>
<string>com.yourcompany.${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>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>LSRequiresIPhoneOS</key>
<true/>
</dict>
</plist>

View File

@ -0,0 +1,251 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 45;
objects = {
/* Begin PBXBuildFile section */
1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; };
1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */; };
288765FD0DF74451002DB57D /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 288765FC0DF74451002DB57D /* CoreGraphics.framework */; };
9C04BB16107E9AD8002A63D0 /* BTDevice.m in Sources */ = {isa = PBXBuildFile; fileRef = 9C04BB12107E9AD8002A63D0 /* BTDevice.m */; };
9C04BB17107E9AD8002A63D0 /* BTInquiryViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9C04BB13107E9AD8002A63D0 /* BTInquiryViewController.m */; };
9C04BB18107E9AD8002A63D0 /* BTstackCocoaAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 9C04BB15107E9AD8002A63D0 /* BTstackCocoaAppDelegate.m */; };
9C04BB1F107E9B05002A63D0 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 9C04BB1E107E9B05002A63D0 /* main.m */; };
9C04BB2B107E9BF1002A63D0 /* logo.png in Resources */ = {isa = PBXBuildFile; fileRef = 9C04BB2A107E9BF1002A63D0 /* logo.png */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
1D30AB110D05D00D00671497 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
1D6058910D05DD3D006BFB54 /* BTstackCocoa.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = BTstackCocoa.app; sourceTree = BUILT_PRODUCTS_DIR; };
1DF5F4DF0D08C38300B7A737 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
288765FC0DF74451002DB57D /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
32CA4F630368D1EE00C91783 /* BTstackCocoa_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BTstackCocoa_Prefix.pch; sourceTree = "<group>"; };
8D1107310486CEB800E47090 /* BTstackCocoa-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "BTstackCocoa-Info.plist"; plistStructureDefinitionIdentifier = "com.apple.xcode.plist.structure-definition.iphone.info-plist"; sourceTree = "<group>"; };
9C04BB12107E9AD8002A63D0 /* BTDevice.m */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = sourcecode.c.objc; name = BTDevice.m; path = src/BTDevice.m; sourceTree = "<group>"; };
9C04BB13107E9AD8002A63D0 /* BTInquiryViewController.m */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = sourcecode.c.objc; name = BTInquiryViewController.m; path = src/BTInquiryViewController.m; sourceTree = "<group>"; };
9C04BB14107E9AD8002A63D0 /* BTstackCocoaAppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = sourcecode.c.h; name = BTstackCocoaAppDelegate.h; path = src/BTstackCocoaAppDelegate.h; sourceTree = "<group>"; };
9C04BB15107E9AD8002A63D0 /* BTstackCocoaAppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = sourcecode.c.objc; name = BTstackCocoaAppDelegate.m; path = src/BTstackCocoaAppDelegate.m; sourceTree = "<group>"; };
9C04BB19107E9AEF002A63D0 /* BTDevice.h */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = sourcecode.c.h; name = BTDevice.h; path = include/BTstack/BTDevice.h; sourceTree = "<group>"; };
9C04BB1A107E9AEF002A63D0 /* BTInquiryViewController.h */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = sourcecode.c.h; name = BTInquiryViewController.h; path = include/BTstack/BTInquiryViewController.h; sourceTree = "<group>"; };
9C04BB1E107E9B05002A63D0 /* main.m */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = sourcecode.c.objc; name = main.m; path = src/main.m; sourceTree = "<group>"; };
9C04BB2A107E9BF1002A63D0 /* logo.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = logo.png; path = ../resources/logo.png; sourceTree = SOURCE_ROOT; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
1D60588F0D05DD3D006BFB54 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */,
1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */,
288765FD0DF74451002DB57D /* CoreGraphics.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
19C28FACFE9D520D11CA2CBB /* Products */ = {
isa = PBXGroup;
children = (
1D6058910D05DD3D006BFB54 /* BTstackCocoa.app */,
);
name = Products;
sourceTree = "<group>";
};
29B97314FDCFA39411CA2CEA /* CustomTemplate */ = {
isa = PBXGroup;
children = (
9C04BB11107E9AC0002A63D0 /* Classes */,
29B97315FDCFA39411CA2CEA /* Other Sources */,
29B97317FDCFA39411CA2CEA /* Resources */,
29B97323FDCFA39411CA2CEA /* Frameworks */,
19C28FACFE9D520D11CA2CBB /* Products */,
);
name = CustomTemplate;
sourceTree = "<group>";
};
29B97315FDCFA39411CA2CEA /* Other Sources */ = {
isa = PBXGroup;
children = (
9C04BB1E107E9B05002A63D0 /* main.m */,
32CA4F630368D1EE00C91783 /* BTstackCocoa_Prefix.pch */,
);
name = "Other Sources";
sourceTree = "<group>";
};
29B97317FDCFA39411CA2CEA /* Resources */ = {
isa = PBXGroup;
children = (
9C04BB2A107E9BF1002A63D0 /* logo.png */,
8D1107310486CEB800E47090 /* BTstackCocoa-Info.plist */,
);
name = Resources;
sourceTree = "<group>";
};
29B97323FDCFA39411CA2CEA /* Frameworks */ = {
isa = PBXGroup;
children = (
1DF5F4DF0D08C38300B7A737 /* UIKit.framework */,
1D30AB110D05D00D00671497 /* Foundation.framework */,
288765FC0DF74451002DB57D /* CoreGraphics.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
9C04BB11107E9AC0002A63D0 /* Classes */ = {
isa = PBXGroup;
children = (
9C04BB19107E9AEF002A63D0 /* BTDevice.h */,
9C04BB1A107E9AEF002A63D0 /* BTInquiryViewController.h */,
9C04BB12107E9AD8002A63D0 /* BTDevice.m */,
9C04BB13107E9AD8002A63D0 /* BTInquiryViewController.m */,
9C04BB14107E9AD8002A63D0 /* BTstackCocoaAppDelegate.h */,
9C04BB15107E9AD8002A63D0 /* BTstackCocoaAppDelegate.m */,
);
name = Classes;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
1D6058900D05DD3D006BFB54 /* BTstackCocoa */ = {
isa = PBXNativeTarget;
buildConfigurationList = 1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "BTstackCocoa" */;
buildPhases = (
1D60588D0D05DD3D006BFB54 /* Resources */,
1D60588E0D05DD3D006BFB54 /* Sources */,
1D60588F0D05DD3D006BFB54 /* Frameworks */,
);
buildRules = (
);
dependencies = (
);
name = BTstackCocoa;
productName = BTstackCocoa;
productReference = 1D6058910D05DD3D006BFB54 /* BTstackCocoa.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
29B97313FDCFA39411CA2CEA /* Project object */ = {
isa = PBXProject;
buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "BTstackCocoa" */;
compatibilityVersion = "Xcode 3.1";
hasScannedForEncodings = 1;
mainGroup = 29B97314FDCFA39411CA2CEA /* CustomTemplate */;
projectDirPath = "";
projectRoot = "";
targets = (
1D6058900D05DD3D006BFB54 /* BTstackCocoa */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
1D60588D0D05DD3D006BFB54 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
9C04BB2B107E9BF1002A63D0 /* logo.png in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
1D60588E0D05DD3D006BFB54 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
9C04BB16107E9AD8002A63D0 /* BTDevice.m in Sources */,
9C04BB17107E9AD8002A63D0 /* BTInquiryViewController.m in Sources */,
9C04BB18107E9AD8002A63D0 /* BTstackCocoaAppDelegate.m in Sources */,
9C04BB1F107E9B05002A63D0 /* main.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin XCBuildConfiguration section */
1D6058940D05DD3E006BFB54 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
COPY_PHASE_STRIP = NO;
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = BTstackCocoa_Prefix.pch;
INFOPLIST_FILE = "BTstackCocoa-Info.plist";
PRODUCT_NAME = BTstackCocoa;
};
name = Debug;
};
1D6058950D05DD3E006BFB54 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
COPY_PHASE_STRIP = YES;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = BTstackCocoa_Prefix.pch;
INFOPLIST_FILE = "BTstackCocoa-Info.plist";
PRODUCT_NAME = BTstackCocoa;
};
name = Release;
};
C01FCF4F08A954540054247B /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
GCC_C_LANGUAGE_STANDARD = c99;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
PREBINDING = NO;
SDKROOT = iphoneos3.0;
};
name = Debug;
};
C01FCF5008A954540054247B /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
GCC_C_LANGUAGE_STANDARD = c99;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
PREBINDING = NO;
SDKROOT = iphoneos3.0;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "BTstackCocoa" */ = {
isa = XCConfigurationList;
buildConfigurations = (
1D6058940D05DD3E006BFB54 /* Debug */,
1D6058950D05DD3E006BFB54 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
C01FCF4E08A954540054247B /* Build configuration list for PBXProject "BTstackCocoa" */ = {
isa = XCConfigurationList;
buildConfigurations = (
C01FCF4F08A954540054247B /* Debug */,
C01FCF5008A954540054247B /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 29B97313FDCFA39411CA2CEA /* Project object */;
}

View File

@ -0,0 +1,8 @@
//
// Prefix header for all source files of the 'BTstackCocoa' target in the 'BTstackCocoa' project
//
#ifdef __OBJC__
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#endif

View File

@ -0,0 +1,43 @@
//
// BTDevice.h
// BT-Keyboard
//
// Created by Matthias Ringwald on 3/30/09.
//
#import <Foundation/Foundation.h>
#define kCODHID 0x2540
#define kCODZeeMote 0x584
#define kCODInvalid 0xffff
typedef enum {
kBluetoothDeviceTypeGeneric = 0,
kBluetoothDeviceTypeHID,
kBluetoothDeviceTypeMobilePhone,
kBluetoothDeviceTypeSmartPhone,
kBluetoothDeviceTypeZeeMote,
} BluetoothDeviceType;
typedef enum {
kBluetoothConnectionNotConnected = 0,
kBluetoothConnectionRemoteName,
kBluetoothConnectionConnecting,
kBluetoothConnectionConnected
} BluetoothConnectionState;
@interface BTDevice : NSObject {
NSString * address;
NSString * name;
uint32_t classOfDevice;
BluetoothConnectionState connectionState;
}
@property (readonly) BluetoothDeviceType deviceType;
@property (readonly) NSString * nameOrAddress;
@property (nonatomic, copy) NSString * address;
@property (nonatomic, copy) NSString * name;
@property (nonatomic, assign) uint32_t classOfDevice;
@property (nonatomic, assign) BluetoothConnectionState connectionState;
@end

View File

@ -0,0 +1,32 @@
//
// BTInquiryViewController.h
//
// Created by Matthias Ringwald on 10/8/09.
//
#import <UIKit/UIKit.h>
typedef enum {
kBluetoothStateUnknown,
kBluetoothStateOn,
kBluetoothStateOff,
kBluetoothStateInitializing,
kBluetoothStateStopping
} BluetoothState;
typedef enum {
kInquiryInactive,
kInquiryActive,
kInquiryRemoteName
} InquiryState;
@interface BTInquiryViewController : UITableViewController {
NSMutableArray *devices;
BluetoothState bluetoothState;
InquiryState inquiryState;
UIActivityIndicatorView *deviceActivity;
}
@property (nonatomic, retain) NSMutableArray *devices;
@property (nonatomic, assign) BluetoothState bluetoothState;
@property (nonatomic, assign) InquiryState inquiryState;
@end

46
CocoaTouch/src/BTDevice.m Normal file
View File

@ -0,0 +1,46 @@
//
// BTDevice.m
//
// Created by Matthias Ringwald on 3/30/09.
//
#import "BTDevice.h"
@implementation BTDevice
@synthesize name;
@synthesize address;
@synthesize classOfDevice;
@synthesize connectionState;
- (BTDevice *)init {
name = NULL;
address = @"00:00:00:00:00:00";
classOfDevice = kCODInvalid;
connectionState = kBluetoothConnectionNotConnected;
return self;
}
- (NSString *) nameOrAddress{
if (name) return name;
return address;
}
- (BluetoothDeviceType) deviceType{
switch (classOfDevice) {
case kCODHID:
return kBluetoothDeviceTypeHID;
case kCODZeeMote:
return kBluetoothDeviceTypeZeeMote;
default:
return kBluetoothDeviceTypeGeneric;
}
}
- (void)dealloc {
[name release];
[address release];
[super dealloc];
}
@end

View File

@ -0,0 +1,226 @@
//
// BTInquiryViewController.m
//
// Created by Matthias Ringwald on 10/8/09.
//
#import "BTInquiryViewController.h"
#import "BTDevice.h"
@implementation BTInquiryViewController
@synthesize devices;
@synthesize bluetoothState;
@synthesize inquiryState;
#define MOCKUP
int mock_state = 0;
- (id) init {
self = [super initWithStyle:UITableViewStyleGrouped];
bluetoothState = kBluetoothStateUnknown;
inquiryState = kInquiryInactive;
deviceActivity = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
[deviceActivity startAnimating];
return self;
}
/*
- (void)viewDidLoad {
[super viewDidLoad];
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem;
}
*/
/*
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
}
*/
/*
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
}
*/
/*
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
}
*/
/*
- (void)viewDidDisappear:(BOOL)animated {
[super viewDidDisappear:animated];
}
*/
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;
}
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
- (void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
#pragma mark Table view methods
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
return @"Devices";
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
// Customize the number of rows in the table view.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
int rows = 1; // 1 for status line
if (bluetoothState == kBluetoothStateOn) {
rows += [devices count];
}
return rows;
}
// Customize the appearance of table view cells.
- (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] autorelease];
// cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
// Set up the cell...
NSString *label = nil;
int idx = [indexPath indexAtPosition:1];
if (bluetoothState != kBluetoothStateOn || idx >= [devices count]) {
if (bluetoothState == kBluetoothStateInitializing){
label = @"Activating BTstack...";
cell.accessoryView = deviceActivity;
} else {
switch (inquiryState){
case kInquiryInactive:
if ([devices count] > 0){
label = @"Find more devices...";
} else {
label = @"Find devices...";
}
cell.accessoryView = nil;
break;
case kInquiryActive:
label = @"Searching...";
cell.accessoryView = deviceActivity;
break;
case kInquiryRemoteName:
label = @"Query device names...";
cell.accessoryView = deviceActivity;
break;
}
}
} else {
BTDevice *dev = [devices objectAtIndex:idx];
label = [dev nameOrAddress];
switch ([dev connectionState]) {
case kBluetoothConnectionNotConnected:
case kBluetoothConnectionConnected:
cell.accessoryView = nil;
break;
case kBluetoothConnectionConnecting:
case kBluetoothConnectionRemoteName:
cell.accessoryView = deviceActivity;
break;
}
}
[cell.textLabel setText:label];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSLog(@"didSelectRowAtIndexPath %@", indexPath);
// Navigation logic may go here. Create and push another view controller.
// AnotherViewController *anotherViewController = [[AnotherViewController alloc] initWithNibName:@"AnotherView" bundle:nil];
// [self.navigationController pushViewController:anotherViewController];
// [anotherViewController release];
#ifdef MOCKUP
switch (mock_state) {
case 0:
bluetoothState = kBluetoothStateOn;
[tableView reloadData];
mock_state++;
break;
case 1:
inquiryState = kInquiryActive;
[tableView reloadData];
mock_state++;
case 2:
case 3: {
BTDevice * dev = [[BTDevice alloc] init];
[dev setAddress:[NSString stringWithFormat:@"%02x:%02x:%02x:%02x:%02x:%02x:", mock_state, mock_state, mock_state, mock_state, mock_state, mock_state]];
[devices addObject:dev];
[tableView reloadData];
mock_state++;
break;
}
case 4: {
inquiryState = kInquiryRemoteName;
BTDevice * dev;
dev = [devices objectAtIndex:0];
// [dev setConnectionState:kBluetoothConnectionRemoteName];
dev = [devices objectAtIndex:1];
// [dev setConnectionState:kBluetoothConnectionRemoteName];
[tableView reloadData];
mock_state++;
break;
}
case 5: {
BTDevice * dev;
dev = [devices objectAtIndex:0];
[dev setName:@"Fake Device 1"];
[dev setConnectionState:kBluetoothConnectionNotConnected];
[tableView reloadData];
mock_state++;
break;
}
case 6: {
inquiryState = kInquiryInactive;
BTDevice * dev;
dev = [devices objectAtIndex:1];
[dev setConnectionState:kBluetoothConnectionNotConnected];
[dev setName:@"Fake Device 2"];
[tableView reloadData];
mock_state = 1;
break;
}
}
#endif
}
- (void)dealloc {
[super dealloc];
}
@end

View File

@ -0,0 +1,18 @@
//
// BTstackCocoaAppDelegate.h
// BTstackCocoa
//
// Created by Matthias Ringwald on 10/8/09.
// Copyright Dybuster AG 2009. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface BTstackCocoaAppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@end

View File

@ -0,0 +1,42 @@
//
// BTstackCocoaAppDelegate.m
// BTstackCocoa
//
// Created by Matthias Ringwald on 10/8/09.
// Copyright Dybuster AG 2009. All rights reserved.
//
#import "BTstackCocoaAppDelegate.h"
#import "BTInquiryViewController.h"
#import "BTDevice.h"
@implementation BTstackCocoaAppDelegate
@synthesize window;
- (void)applicationDidFinishLaunching:(UIApplication *)application {
// Override point for customization after application launch
window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// create BTInquiryView
BTInquiryViewController *inqView = [[BTInquiryViewController alloc] init];
[inqView setBluetoothState:kBluetoothStateInitializing];
NSMutableArray *devices = [[NSMutableArray alloc] init];
[inqView setDevices:devices];
[window addSubview:[inqView view]];
// show
[window makeKeyAndVisible];
}
- (void)dealloc {
[window release];
[super dealloc];
}
@end

17
CocoaTouch/src/main.m Normal file
View File

@ -0,0 +1,17 @@
//
// main.m
// BTstackCocoa
//
// Created by Matthias Ringwald on 10/8/09.
// Copyright Dybuster AG 2009. All rights reserved.
//
#import <UIKit/UIKit.h>
int main(int argc, char *argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, @"BTstackCocoaAppDelegate");
[pool release];
return retVal;
}