mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-02-13 15:41:17 +00:00
provide Disconnect button in inquiry view, allow to restart inquiry when not connected
This commit is contained in:
parent
a836342cf7
commit
5c1cf5ec46
@ -64,7 +64,8 @@ typedef enum {
|
||||
bool stopRemoteNameGathering;
|
||||
bool restartInquiry;
|
||||
BTDevice *remoteNameDevice; // device for which remote name request is pending
|
||||
BTDevice *remoteDevice;
|
||||
BTDevice *remoteDevice; // device for which connection is pending
|
||||
BTDevice *connectedDevice; // device to which we're connected
|
||||
bool notifyDelegateOnInquiryStopped;
|
||||
}
|
||||
|
||||
@ -72,6 +73,7 @@ typedef enum {
|
||||
- (void) stopInquiry;
|
||||
|
||||
- (void) showConnecting:(BTDevice *) device;
|
||||
- (void) showConnected:(BTDevice *) device;
|
||||
|
||||
@property (nonatomic, assign) bool allowSelection;
|
||||
@property (nonatomic, retain) NSMutableArray *devices;
|
||||
@ -81,5 +83,6 @@ typedef enum {
|
||||
@protocol BTInquiryDelegate
|
||||
- (void) deviceChoosen:(BTInquiryViewController *) inqView device:(BTDevice*) device;
|
||||
- (void) deviceDetected:(BTInquiryViewController *) inqView device:(BTDevice*) device;
|
||||
- (void) disconnectDevice:(BTInquiryViewController *) inqView device:(BTDevice*) device;
|
||||
- (void) inquiryStopped;
|
||||
@end
|
||||
|
@ -93,6 +93,10 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
|
||||
return;
|
||||
}
|
||||
NSLog(@"Inquiry started");
|
||||
|
||||
stopRemoteNameGathering = false;
|
||||
restartInquiry = true;
|
||||
|
||||
inquiryState = kInquiryActive;
|
||||
[[self tableView] reloadData];
|
||||
|
||||
@ -328,6 +332,11 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
|
||||
[[self tableView] reloadData];
|
||||
}
|
||||
|
||||
- (void) showConnected:(BTDevice *) device {
|
||||
connectedDevice = device;
|
||||
[[self tableView] reloadData];
|
||||
}
|
||||
|
||||
/*
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
@ -427,7 +436,10 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
|
||||
label = @"Bluetooth not accessible!";
|
||||
cell.accessoryView = nil;
|
||||
} else {
|
||||
if (remoteDevice) {
|
||||
if (connectedDevice) {
|
||||
label = @"Disconnect";
|
||||
cell.accessoryView = nil;
|
||||
} else if (remoteDevice) {
|
||||
label = @"Connecting...";
|
||||
cell.accessoryView = bluetoothActivity;
|
||||
} else {
|
||||
@ -484,9 +496,19 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
|
||||
|
||||
// valid selection?
|
||||
int idx = [indexPath indexAtPosition:1];
|
||||
if (bluetoothState == HCI_STATE_WORKING && idx < [devices count]){
|
||||
if (delegate) {
|
||||
[delegate deviceChoosen:self device:[devices objectAtIndex:idx]];
|
||||
if (bluetoothState == HCI_STATE_WORKING) {
|
||||
if (delegate) {
|
||||
if (idx < [devices count]){
|
||||
[delegate deviceChoosen:self device:[devices objectAtIndex:idx]];
|
||||
} else if (idx == [devices count]) {
|
||||
if (connectedDevice) {
|
||||
// DISCONNECT button
|
||||
[delegate disconnectDevice:self device:connectedDevice];
|
||||
} else {
|
||||
// Find more devices
|
||||
[self myStartInquiry];
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
[tableView deselectRowAtIndexPath:indexPath animated:TRUE];
|
||||
|
@ -348,6 +348,9 @@ void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint
|
||||
NSLog(@"inquiryStopped");
|
||||
}
|
||||
|
||||
- (void) disconnectDevice:(BTInquiryViewController *) inqView device:(BTDevice*) selectedDevice {
|
||||
}
|
||||
|
||||
- (void)applicationWillTerminate:(UIApplication *)application {
|
||||
// disconnect
|
||||
if (wiiMoteConHandle) {
|
||||
|
@ -28,7 +28,6 @@
|
||||
9C7ECB840FCC85650085DAC5 /* bt_control_iphone.c in Sources */ = {isa = PBXBuildFile; fileRef = 9C7ECB820FCC85650085DAC5 /* bt_control_iphone.c */; };
|
||||
9C7ECBB50FCC95DD0085DAC5 /* hci_dump.c in Sources */ = {isa = PBXBuildFile; fileRef = 9C7ECBB40FCC95DD0085DAC5 /* hci_dump.c */; };
|
||||
9C88500E0FBF6702004980E4 /* l2cap.c in Sources */ = {isa = PBXBuildFile; fileRef = 9C88500C0FBF6702004980E4 /* l2cap.c */; };
|
||||
9CAA573710A5D87400D0E1A9 /* inquiry.c in Sources */ = {isa = PBXBuildFile; fileRef = 9CAA573610A5D87400D0E1A9 /* inquiry.c */; };
|
||||
9CC813A20FFC0774002816F9 /* btstack.c in Sources */ = {isa = PBXBuildFile; fileRef = 9CC813A10FFC0774002816F9 /* btstack.c */; };
|
||||
9CC813A50FFC0A51002816F9 /* daemon.c in Sources */ = {isa = PBXBuildFile; fileRef = 9CC813A40FFC0A51002816F9 /* daemon.c */; };
|
||||
9CCE6CEA1025BD0000FCE9F4 /* hci.c in Sources */ = {isa = PBXBuildFile; fileRef = 9C46FC340FA906F700ABEF05 /* hci.c */; };
|
||||
@ -267,9 +266,9 @@
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
8DD76FA90486AB0100D96B5E /* project */ = {
|
||||
8DD76FA90486AB0100D96B5E /* BTdaemon */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 1DEB928508733DD80010E9CD /* Build configuration list for PBXNativeTarget "project" */;
|
||||
buildConfigurationList = 1DEB928508733DD80010E9CD /* Build configuration list for PBXNativeTarget "BTdaemon" */;
|
||||
buildPhases = (
|
||||
8DD76FAB0486AB0100D96B5E /* Sources */,
|
||||
8DD76FAD0486AB0100D96B5E /* Frameworks */,
|
||||
@ -279,7 +278,7 @@
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = project;
|
||||
name = BTdaemon;
|
||||
productInstallPath = "$(HOME)/bin";
|
||||
productName = project;
|
||||
productReference = 8DD76FB20486AB0100D96B5E /* project */;
|
||||
@ -313,7 +312,7 @@
|
||||
projectDirPath = "";
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
8DD76FA90486AB0100D96B5E /* project */,
|
||||
8DD76FA90486AB0100D96B5E /* BTdaemon */,
|
||||
9C7B5CF5100FC96A0065D87E /* clientTest */,
|
||||
);
|
||||
};
|
||||
@ -341,7 +340,6 @@
|
||||
9CEB4F17107AAAEF00DD5720 /* run_loop_posix.c in Sources */,
|
||||
9C04B826107D1CED002A63D0 /* run_loop.c in Sources */,
|
||||
9C04B876107D2B7C002A63D0 /* run_loop_cocoa.m in Sources */,
|
||||
9CAA573710A5D87400D0E1A9 /* inquiry.c in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@ -501,7 +499,7 @@
|
||||
/* End XCBuildConfiguration section */
|
||||
|
||||
/* Begin XCConfigurationList section */
|
||||
1DEB928508733DD80010E9CD /* Build configuration list for PBXNativeTarget "project" */ = {
|
||||
1DEB928508733DD80010E9CD /* Build configuration list for PBXNativeTarget "BTdaemon" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
1DEB928608733DD80010E9CD /* Debug */,
|
||||
|
Loading…
x
Reference in New Issue
Block a user