check bt_open and show alert if not accessible

This commit is contained in:
matthias.ringwald 2009-10-24 15:30:14 +00:00
parent 6bc81084c3
commit 95ce774257
2 changed files with 19 additions and 11 deletions

View File

@ -1,14 +1,11 @@
/* new todo file for BTstack */ /* new todo file for BTstack */
NEXT: NEXT:
- on applicationWillResignActive: just disconnect, power off and push "Not clear yet"
- improve user experience of BTstack Inquiry View - improve user experience of BTstack Inquiry View
- shorter inquiry interval - shorter inquiry interval
- repeat inquiry while BT on - 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 - prepend all source files with 'new BSD' copyright header
- provide test version by setting up APT repository within BTstack SVN - provide test version by setting up APT repository within BTstack SVN
- instructions: http://www.saurik.com/id/7 - instructions: http://www.saurik.com/id/7

View File

@ -122,11 +122,22 @@ void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint
- (void)applicationDidFinishLaunching:(UIApplication *)application { - (void)applicationDidFinishLaunching:(UIApplication *)application {
NSLog(@"Started"); NSLog(@"Started");
bool btOK = false;
#ifdef USE_BLUETOOTH #ifdef USE_BLUETOOTH
run_loop_init(RUN_LOOP_COCOA); run_loop_init(RUN_LOOP_COCOA);
bt_open(); if ( bt_open() ){
bt_register_packet_handler(packet_handler); 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 #endif
// create window // create window
@ -149,10 +160,10 @@ void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint
theMainApp = self; theMainApp = self;
#ifdef USE_BLUETOOTH if (btOK) {
[inqViewControl setDelegate:self]; [inqViewControl setDelegate:self];
[inqViewControl startInquiry]; [inqViewControl startInquiry];
#endif }
glView = (EAGLView *) [glViewControl view]; glView = (EAGLView *) [glViewControl view];
glView.animationInterval = 1.0 / 60.0; glView.animationInterval = 1.0 / 60.0;