This commit is contained in:
Milanka Ringwald 2015-07-01 17:05:11 +02:00
commit 7f159f85aa
4 changed files with 56 additions and 64 deletions

View File

@ -38,7 +38,9 @@
UIActivityIndicatorView *bluetoothActivity; UIActivityIndicatorView *bluetoothActivity;
UITableView *_tableView; UITableView *_tableView;
UISwitch *loggingSwitch; UISwitch *loggingSwitch;
UIButton *offButton;
} }
-(id) initWithTableView:(UITableView *) tableView; -(id) initWithTableView:(UITableView *) tableView;
@property (nonatomic, retain) UISwitch *loggingSwitch; @property (nonatomic, retain) UISwitch *loggingSwitch;
@property (nonatomic, retain) UIButton *offButton;
@end @end

View File

@ -36,6 +36,7 @@
@implementation BluetoothTableViewAdapter @implementation BluetoothTableViewAdapter
@synthesize loggingSwitch; @synthesize loggingSwitch;
@synthesize offButton;
-(id) initWithTableView:(UITableView *) tableView { -(id) initWithTableView:(UITableView *) tableView {
bluetoothActivity = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]; bluetoothActivity = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
@ -43,7 +44,12 @@
_tableView = tableView; _tableView = tableView;
self.loggingSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(0,0, 100, 20)]; // size will be ignored anyway self.loggingSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(0,0, 100, 20)]; // size will be ignored anyway
[loggingSwitch addTarget:self action:@selector(loggingSwitchToggled) forControlEvents:UIControlEventValueChanged]; [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 // get old value
Boolean valid; Boolean valid;
Boolean loggingOn = CFPreferencesGetAppBooleanValue(CFSTR("Logging"), CFSTR("ch.ringwald.btstack"), &valid); Boolean loggingOn = CFPreferencesGetAppBooleanValue(CFSTR("Logging"), CFSTR("ch.ringwald.btstack"), &valid);
@ -73,6 +79,11 @@
notify_post("ch.ringwald.btstack.preferences"); notify_post("ch.ringwald.btstack.preferences");
} }
-(void)offTapped {
NSLog(@"BTstack 'Force off' tapped");
[[BluetoothController sharedInstance] requestType:BluetoothTypeNone];
}
#pragma mark Table view delegate methods #pragma mark Table view delegate methods
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
@ -93,34 +104,31 @@
cell.accessoryType = UITableViewCellAccessoryNone; cell.accessoryType = UITableViewCellAccessoryNone;
cell.accessoryView = nil; cell.accessoryView = nil;
BOOL hasAccessory;
BluetoothType_t bluetoothType = [[BluetoothController sharedInstance] targetType]; BluetoothType_t bluetoothType = [[BluetoothController sharedInstance] targetType];
BOOL activity = [[BluetoothController sharedInstance] isActive]; 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]) { switch ([indexPath section]) {
case 0: case 0:
switch ([indexPath row]) { if ([[BluetoothController sharedInstance] isConnected]){
case 0: switch (bluetoothType){
theLabel = @"BTstack"; case BluetoothTypeBTstack:
hasAccessory = bluetoothType == BluetoothTypeBTstack; theLabel = @"Bluetooth Stack: BTstack";
break; cell.accessoryView = offButton;
case 1: break;
theLabel = @"iOS"; case BluetoothTypeApple:
hasAccessory = bluetoothType == BluetoothTypeApple; theLabel = @"Bluetooth Stack: iOS";
break; break;
default: case BluetoothTypeNone:
theLabel = @"None"; theLabel = @"Bluetooth Stack: None";
hasAccessory = bluetoothType == BluetoothTypeNone; break;
break;
}
if (hasAccessory) {
if (activity){
cell.accessoryView = bluetoothActivity;
} else {
cell.accessoryType = UITableViewCellAccessoryCheckmark;
} }
} else {
theLabel = @"Bluetooth Stack: Unknown";
}
if (activity){
cell.accessoryView = bluetoothActivity;
} }
break; break;
case 1: case 1:
@ -141,25 +149,8 @@
} }
- (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath { - (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if([indexPath section] != 0) return nil; // avoid selecting a row
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;
} }
#pragma mark Table view data source methods #pragma mark Table view data source methods
@ -171,12 +162,7 @@
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{ - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
switch (section){ switch (section){
case 0: case 0:
if (![[BluetoothController sharedInstance] isConnected]){ return @"Bluetooth Config";
return @"Internal BTstack Error";
}
return @"Active Bluetooth Stack";
case 1:
return @"BTstack Config";
default: default:
return @"BTstack Config"; return @"BTstack Config";
} }
@ -186,11 +172,10 @@
switch (section) { switch (section) {
case 0: case 0:
if (![[BluetoothController sharedInstance] isConnected]){ if (![[BluetoothController sharedInstance] isConnected]){
return @"Cannot connect to BTstack daemon.\n\nPlease re-install BTstack package and/or make " return @"Cannot connect to BTstack daemon.\n\nPlease re-install the BTstack package.";
"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 @"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: case 1:
return @"Turn on logging, if you experience problems with BTstack-based software and add /tmp/hci_dump.pklg to your support mail."; return @"Turn on logging, if you experience problems with BTstack-based software and add /tmp/hci_dump.pklg to your support mail.";
default: default:
@ -201,17 +186,7 @@
// Customize the number of rows in the table view. // Customize the number of rows in the table view.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
switch (section){ return 1;
case 0:
if (![[BluetoothController sharedInstance] isConnected]){
return 0;
}
return 3;
case 1:
return 1;
default:
return 1;
}
} }

16
platforms/ios/README.md Normal file
View File

@ -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.

View File

@ -9,5 +9,4 @@ Depends: firmware (>= 3.0), ch.ringwald.springboardaccess (>= 0.3), preferencelo
Author: Mattthias Ringwald <tickets@btstack.uservoice.com> Author: Mattthias Ringwald <tickets@btstack.uservoice.com>
Maintainer: Mattthias Ringwald <tickets@btstack.uservoice.com> Maintainer: Mattthias Ringwald <tickets@btstack.uservoice.com>
Section: Development Section: Development
Tag: role::developer Version: 1.0
Version: 0.9