From 979044ba98a3a205cc8aa7560d50870cc3662610 Mon Sep 17 00:00:00 2001 From: "matthias.ringwald" Date: Sat, 24 Oct 2009 16:31:40 +0000 Subject: [PATCH] on applicationWillResignActive: just disconnect, power off and push 'don't know yet' --- TODO.txt | 4 +- .../Classes/WiiMoteOpenGLDemoAppDelegate.m | 40 +++++++++++++------ 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/TODO.txt b/TODO.txt index c301dc1d9..c0d864751 100644 --- a/TODO.txt +++ b/TODO.txt @@ -1,14 +1,14 @@ /* new todo file for BTstack */ NEXT: -- on applicationWillResignActive: just disconnect, power off and push "Not clear yet" - - 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 == Release Version 0.1 +- figure out how to receive iPhone System Power IONotifications to detect, + when phone gets locked - create - add timeouts to cocoa run loop - implement rest of L2CAP state machine diff --git a/example/WiiMoteOpenGLDemo/Classes/WiiMoteOpenGLDemoAppDelegate.m b/example/WiiMoteOpenGLDemo/Classes/WiiMoteOpenGLDemoAppDelegate.m index 01da72b2a..245024978 100644 --- a/example/WiiMoteOpenGLDemo/Classes/WiiMoteOpenGLDemoAppDelegate.m +++ b/example/WiiMoteOpenGLDemo/Classes/WiiMoteOpenGLDemoAppDelegate.m @@ -151,18 +151,18 @@ void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint inqViewControl = [[BTInquiryViewController alloc] init]; [inqViewControl setTitle:@"BTstack Device Selector"]; [inqViewControl setAllowSelection:NO]; - - // UILabel *footer = [[UILabel alloc] initWithFrame:CGRectMake(10,0,300,30)]; - // footer.text = @"Please press the 1+2 buttons\nof your WiiMote at the same time\nto make it discoverable"; - UITextView *footer = [[UITextView alloc] initWithFrame:CGRectMake(10,00,300,85)]; - footer.text = @"Please make your WiiMote discoverable by pressing the 1+2 buttons at the same time"; - footer.textColor = [UIColor blackColor]; - footer.font = [UIFont fontWithName:@"Arial" size:18]; - // footer.textAlignment = UITextAlignmentCenter; - footer.backgroundColor = [UIColor whiteColor]; - footer.autoresizingMask = UIViewAutoresizingFlexibleWidth; - footer.editable = false; - [[inqViewControl tableView] setTableFooterView:footer]; + + if (btOK) { + UITextView *footer = [[UITextView alloc] initWithFrame:CGRectMake(10,00,300,85)]; + footer.text = @"Please make your WiiMote discoverable by pressing the 1+2 buttons at the same time."; + footer.textColor = [UIColor blackColor]; + footer.font = [UIFont fontWithName:@"Arial" size:18]; + // footer.textAlignment = UITextAlignmentCenter; + footer.backgroundColor = [UIColor whiteColor]; + footer.autoresizingMask = UIViewAutoresizingFlexibleWidth; + footer.editable = false; + [[inqViewControl tableView] setTableFooterView:footer]; + } // create nav view controller navControl = [[UINavigationController alloc] initWithRootViewController:inqViewControl]; @@ -186,7 +186,21 @@ void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint - (void)applicationWillResignActive:(UIApplication *)application { - glView.animationInterval = 1.0 / 5.0; + // glView.animationInterval = 1.0 / 5.0; + + // if (wiiMoteConHandle) { + // bt_send_cmd(&hci_disconnect, wiiMoteConHandle, 0x13); // remote closed connection + // } + bt_send_cmd(&btstack_set_power_mode, HCI_POWER_OFF ); + + UIAlertView* alertView = [[UIAlertView alloc] init]; + alertView.title = @"Power Management ?"; + alertView.message = @"Don't know yet, what to do when\n" + "phone gets locked.\n" + "Turning Bluetooth off for now. :)\n"; + NSLog(@"Alert: %@ - %@", alertView.title, alertView.message); + // [alertView addButtonWithTitle:@"Dismiss"]; + [alertView show]; }