diff --git a/platforms/ios/PrefsBundle/BluetoothTableViewAdapter.h b/platforms/ios/PrefsBundle/BluetoothTableViewAdapter.h index 7a0d6ffd0..e287897dd 100644 --- a/platforms/ios/PrefsBundle/BluetoothTableViewAdapter.h +++ b/platforms/ios/PrefsBundle/BluetoothTableViewAdapter.h @@ -38,7 +38,9 @@ UIActivityIndicatorView *bluetoothActivity; UITableView *_tableView; UISwitch *loggingSwitch; + UIButton *offButton; } -(id) initWithTableView:(UITableView *) tableView; @property (nonatomic, retain) UISwitch *loggingSwitch; +@property (nonatomic, retain) UIButton *offButton; @end diff --git a/platforms/ios/PrefsBundle/BluetoothTableViewAdapter.m b/platforms/ios/PrefsBundle/BluetoothTableViewAdapter.m index 9621bb3cc..c13c75a90 100644 --- a/platforms/ios/PrefsBundle/BluetoothTableViewAdapter.m +++ b/platforms/ios/PrefsBundle/BluetoothTableViewAdapter.m @@ -36,6 +36,7 @@ @implementation BluetoothTableViewAdapter @synthesize loggingSwitch; +@synthesize offButton; -(id) initWithTableView:(UITableView *) tableView { bluetoothActivity = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]; @@ -43,7 +44,12 @@ _tableView = tableView; self.loggingSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(0,0, 100, 20)]; // size will be ignored anyway [loggingSwitch addTarget:self action:@selector(loggingSwitchToggled) forControlEvents:UIControlEventValueChanged]; - + self.offButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; + self.offButton.frame = CGRectMake(0.0f, 0.0f, 80.0f, 20.0f); + // self.offButton.backgroundColor = [UIColor redColor]; + [self.offButton setTitle:@"Force Off" forState:UIControlStateNormal]; + [offButton addTarget:self action:@selector(offTapped) forControlEvents:UIControlEventTouchUpInside]; + // get old value Boolean valid; Boolean loggingOn = CFPreferencesGetAppBooleanValue(CFSTR("Logging"), CFSTR("ch.ringwald.btstack"), &valid); @@ -73,6 +79,11 @@ notify_post("ch.ringwald.btstack.preferences"); } +-(void)offTapped { + NSLog(@"BTstack 'Force off' tapped"); + [[BluetoothController sharedInstance] requestType:BluetoothTypeNone]; +} + #pragma mark Table view delegate methods - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { @@ -93,34 +104,31 @@ cell.accessoryType = UITableViewCellAccessoryNone; cell.accessoryView = nil; - BOOL hasAccessory; BluetoothType_t bluetoothType = [[BluetoothController sharedInstance] targetType]; BOOL activity = [[BluetoothController sharedInstance] isActive]; - // NSLog(@"tableView update: type %u, active %u", bluetoothType, activity); + NSLog(@"tableView update: type %u, active %u", bluetoothType, activity); switch ([indexPath section]) { case 0: - switch ([indexPath row]) { - case 0: - theLabel = @"BTstack"; - hasAccessory = bluetoothType == BluetoothTypeBTstack; - break; - case 1: - theLabel = @"iOS"; - hasAccessory = bluetoothType == BluetoothTypeApple; - break; - default: - theLabel = @"None"; - hasAccessory = bluetoothType == BluetoothTypeNone; - break; - } - if (hasAccessory) { - if (activity){ - cell.accessoryView = bluetoothActivity; - } else { - cell.accessoryType = UITableViewCellAccessoryCheckmark; + if ([[BluetoothController sharedInstance] isConnected]){ + switch (bluetoothType){ + case BluetoothTypeBTstack: + theLabel = @"Bluetooth Stack: BTstack"; + cell.accessoryView = offButton; + break; + case BluetoothTypeApple: + theLabel = @"Bluetooth Stack: iOS"; + break; + case BluetoothTypeNone: + theLabel = @"Bluetooth Stack: None"; + break; } + } else { + theLabel = @"Bluetooth Stack: Unknown"; + } + if (activity){ + cell.accessoryView = bluetoothActivity; } break; case 1: @@ -141,25 +149,8 @@ } - (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath { - if([indexPath section] != 0) return nil; - - BluetoothType_t newType; - switch ([indexPath row]) { - case 0: - newType = BluetoothTypeBTstack; - break; - case 1: - newType = BluetoothTypeApple; - break; - default: - newType = BluetoothTypeNone; - break; - } - - [[BluetoothController sharedInstance] requestType:newType]; - [_tableView reloadData]; - - return nil; + // avoid selecting a row + return nil; } #pragma mark Table view data source methods @@ -171,12 +162,7 @@ - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{ switch (section){ case 0: - if (![[BluetoothController sharedInstance] isConnected]){ - return @"Internal BTstack Error"; - } - return @"Active Bluetooth Stack"; - case 1: - return @"BTstack Config"; + return @"Bluetooth Config"; default: return @"BTstack Config"; } @@ -186,11 +172,10 @@ switch (section) { case 0: if (![[BluetoothController sharedInstance] isConnected]){ - return @"Cannot connect to BTstack daemon.\n\nPlease re-install BTstack package and/or make " - "sure that /Library/LaunchDaemons/ is owned by user 'root' and group 'wheel' (root:wheel).\n" - "If you're on 5.x, pleaes install latest version of 'Corona 5.0.1 Untether' package, reboot and try again."; + return @"Cannot connect to BTstack daemon.\n\nPlease re-install the BTstack package."; } - return @"Enabling iOS Bluetooth after BTstack was used can take up to 30 seconds. Please be patient."; + return @"BTstack-compatible applications automatically enable BTstack on start and disable it on exit. " + "Otherwise, you can force BTstack off here."; case 1: return @"Turn on logging, if you experience problems with BTstack-based software and add /tmp/hci_dump.pklg to your support mail."; default: @@ -201,17 +186,7 @@ // Customize the number of rows in the table view. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { - switch (section){ - case 0: - if (![[BluetoothController sharedInstance] isConnected]){ - return 0; - } - return 3; - case 1: - return 1; - default: - return 1; - } + return 1; } diff --git a/platforms/ios/README.md b/platforms/ios/README.md new file mode 100644 index 000000000..cb37d2a5d --- /dev/null +++ b/platforms/ios/README.md @@ -0,0 +1,16 @@ +=== BTstack for iOS === + +BTstack for iOS provides an alternative Bluetooth stack for iOS devices with a public and complete API. + +It supports the following protocols: +- L2CAP +- RFCOMM +- SDP + +Based on these protocols, applications or daemons can implement various Bluetooth profiles. +You need to install other packages like BTstack GPS, Blutrol, or WeBe++ to make use of +BTstack. + +Note: As BTstack directly uses the Bluetooth hardware, the iOS Bluetooth is automatically disabled for BTstack applications & services. + +Please visit the [project page at GitHub](https://github.com/bluekitchen/btstack/) for technical information. diff --git a/platforms/ios/layout/DEBIAN/control b/platforms/ios/layout/DEBIAN/control index 8788312d2..7ff5cd521 100644 --- a/platforms/ios/layout/DEBIAN/control +++ b/platforms/ios/layout/DEBIAN/control @@ -9,5 +9,4 @@ Depends: firmware (>= 3.0), ch.ringwald.springboardaccess (>= 0.3), preferencelo Author: Mattthias Ringwald Maintainer: Mattthias Ringwald Section: Development -Tag: role::developer -Version: 0.9 +Version: 1.0