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