From 95ce7742574d0e63c4a8f0edac467592ba00beed Mon Sep 17 00:00:00 2001 From: "matthias.ringwald" Date: Sat, 24 Oct 2009 15:30:14 +0000 Subject: [PATCH] check bt_open and show alert if not accessible --- TODO.txt | 5 +--- .../Classes/WiiMoteOpenGLDemoAppDelegate.m | 25 +++++++++++++------ 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/TODO.txt b/TODO.txt index 72a7c73b5..fe9eea4fb 100644 --- a/TODO.txt +++ b/TODO.txt @@ -1,14 +1,11 @@ /* new todo file for BTstack */ NEXT: +- on applicationWillResignActive: just disconnect, power off and push "Not clear yet" - improve user experience of BTstack Inquiry View - shorter inquiry interval - repeat inquiry while BT on -- CocoaTouch user interface - - on iPhone sleep, just turn off Bluetooth and disconnect all connections -- and figure out why stack doesn't shut Bluetooth off when in sleep for a while/after wakeup - - prepend all source files with 'new BSD' copyright header - provide test version by setting up APT repository within BTstack SVN - instructions: http://www.saurik.com/id/7 diff --git a/example/WiiMoteOpenGLDemo/Classes/WiiMoteOpenGLDemoAppDelegate.m b/example/WiiMoteOpenGLDemo/Classes/WiiMoteOpenGLDemoAppDelegate.m index 27c64b874..2272bdb1a 100644 --- a/example/WiiMoteOpenGLDemo/Classes/WiiMoteOpenGLDemoAppDelegate.m +++ b/example/WiiMoteOpenGLDemo/Classes/WiiMoteOpenGLDemoAppDelegate.m @@ -122,11 +122,22 @@ void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint - (void)applicationDidFinishLaunching:(UIApplication *)application { NSLog(@"Started"); - + bool btOK = false; + #ifdef USE_BLUETOOTH run_loop_init(RUN_LOOP_COCOA); - bt_open(); - bt_register_packet_handler(packet_handler); + if ( bt_open() ){ + UIAlertView* alertView = [[UIAlertView alloc] init]; + alertView.title = @"Bluetooth not accessible!"; + alertView.message = @"Connection to BTstack failed!\n" + "Please make sure that BTstack is installed correctly."; + NSLog(@"Alert: %@ - %@", alertView.title, alertView.message); + [alertView addButtonWithTitle:@"Dismiss"]; + [alertView show]; + } else { + bt_register_packet_handler(packet_handler); + btOK = true; + } #endif // create window @@ -149,10 +160,10 @@ void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint theMainApp = self; -#ifdef USE_BLUETOOTH - [inqViewControl setDelegate:self]; - [inqViewControl startInquiry]; -#endif + if (btOK) { + [inqViewControl setDelegate:self]; + [inqViewControl startInquiry]; + } glView = (EAGLView *) [glViewControl view]; glView.animationInterval = 1.0 / 60.0;