mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-25 16:43:28 +00:00
add Logging toggle, store value in ch.ringwald.btstack mobile preferences
This commit is contained in:
parent
89cc05c52d
commit
4764045067
@ -37,7 +37,8 @@
|
|||||||
@interface BluetoothTableViewAdapter : NSObject<UITableViewDelegate, UITableViewDataSource, BluetoothControllerListener> {
|
@interface BluetoothTableViewAdapter : NSObject<UITableViewDelegate, UITableViewDataSource, BluetoothControllerListener> {
|
||||||
UIActivityIndicatorView *bluetoothActivity;
|
UIActivityIndicatorView *bluetoothActivity;
|
||||||
UITableView *_tableView;
|
UITableView *_tableView;
|
||||||
UISwitch *discoverableSwitch;
|
UISwitch *loggingSwitch;
|
||||||
}
|
}
|
||||||
-(id) initWithTableView:(UITableView *) tableView;
|
-(id) initWithTableView:(UITableView *) tableView;
|
||||||
|
@property (nonatomic, retain) UISwitch *loggingSwitch;
|
||||||
@end
|
@end
|
||||||
|
@ -30,13 +30,20 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#import "BluetoothTableViewAdapter.h"
|
#import "BluetoothTableViewAdapter.h"
|
||||||
|
#include <notify.h>
|
||||||
|
|
||||||
|
#define BTstackID "ch.ringwald.btstack"
|
||||||
|
|
||||||
@implementation BluetoothTableViewAdapter
|
@implementation BluetoothTableViewAdapter
|
||||||
|
@synthesize loggingSwitch;
|
||||||
|
|
||||||
-(id) initWithTableView:(UITableView *) tableView {
|
-(id) initWithTableView:(UITableView *) tableView {
|
||||||
bluetoothActivity = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
|
bluetoothActivity = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
|
||||||
[bluetoothActivity startAnimating];
|
[bluetoothActivity startAnimating];
|
||||||
_tableView = tableView;
|
_tableView = tableView;
|
||||||
|
CGRect dummy;
|
||||||
|
self.loggingSwitch = [[UISwitch alloc] initWithFrame:dummy];
|
||||||
|
[loggingSwitch addTarget:self action:@selector(loggingSwitchToggled) forControlEvents:UIControlEventValueChanged];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,6 +54,19 @@
|
|||||||
[_tableView reloadData];
|
[_tableView reloadData];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-(void) loggingSwitchToggled {
|
||||||
|
NSLog(@"Logging: %u", loggingSwitch.on);
|
||||||
|
CFPropertyListRef on;
|
||||||
|
if (loggingSwitch.on){
|
||||||
|
on = kCFBooleanTrue;
|
||||||
|
} else {
|
||||||
|
on = kCFBooleanFalse;
|
||||||
|
}
|
||||||
|
CFPreferencesSetValue(CFSTR("Logging"), on, CFSTR("ch.ringwald.btstack"), kCFPreferencesCurrentUser, kCFPreferencesCurrentHost);
|
||||||
|
CFPreferencesSynchronize(CFSTR(BTstackID), kCFPreferencesCurrentUser, kCFPreferencesCurrentHost);
|
||||||
|
// send notification
|
||||||
|
notify_post("ch.ringwald.btstack.logging");
|
||||||
|
}
|
||||||
|
|
||||||
#pragma mark Table view delegate methods
|
#pragma mark Table view delegate methods
|
||||||
|
|
||||||
@ -99,8 +119,8 @@
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
theLabel = @"Discoverable";
|
theLabel = @"Logging";
|
||||||
cell.accessoryView = discoverableSwitch;
|
cell.accessoryView = loggingSwitch;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -139,6 +159,10 @@
|
|||||||
|
|
||||||
#pragma mark Table view data source methods
|
#pragma mark Table view data source methods
|
||||||
|
|
||||||
|
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
|
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
|
||||||
switch (section){
|
switch (section){
|
||||||
case 0:
|
case 0:
|
||||||
@ -146,6 +170,8 @@
|
|||||||
return @"Internal BTstack Error";
|
return @"Internal BTstack Error";
|
||||||
}
|
}
|
||||||
return @"Active Bluetooth Stack";
|
return @"Active Bluetooth Stack";
|
||||||
|
case 1:
|
||||||
|
return @"BTstack Config";
|
||||||
default:
|
default:
|
||||||
return @"BTstack Config";
|
return @"BTstack Config";
|
||||||
}
|
}
|
||||||
@ -156,19 +182,18 @@
|
|||||||
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 BTstack package and/or make "
|
||||||
"sure that /Library/LaunchDaemons/ is owned by user 'root' and group 'wheel' (root:wheel)!";
|
"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 @"Enabling iOS Bluetooth after BTstack was used can take up to 30 seconds. Please be patient.";
|
||||||
|
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:
|
default:
|
||||||
return nil;
|
return nil;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
|
|
||||||
return 1; // without discoverable
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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){
|
switch (section){
|
||||||
@ -177,6 +202,8 @@
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return 3;
|
return 3;
|
||||||
|
case 1:
|
||||||
|
return 1;
|
||||||
default:
|
default:
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user