correct address of result field in CONNECTION_RESPONSE (really)

This commit is contained in:
matthias.ringwald 2009-10-23 21:38:30 +00:00
parent cd56f93151
commit 141679a411
5 changed files with 41 additions and 21 deletions

View File

@ -109,18 +109,7 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
remoteNameIndex++;
[self getNextRemoteName];
break;
case L2CAP_EVENT_CHANNEL_OPENED:
// inform about new l2cap connection
bt_flip_addr(event_addr, &packet[2]);
uint16_t psm = READ_BT_16(packet, 10);
uint16_t source_cid = READ_BT_16(packet, 12);
printf("Channel successfully opened: ");
print_bd_addr(event_addr);
printf(", handle 0x%02x, psm 0x%02x, source cid 0x%02x, dest cid 0x%02x\n",
READ_BT_16(packet, 8), psm, source_cid, READ_BT_16(packet, 14));
break;
case HCI_EVENT_COMMAND_COMPLETE:
break;
@ -357,8 +346,9 @@ 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 && inquiryState == kInquiryInactive && idx < [devices count]){
if (delegate && [delegate respondsTo:@selector(deviceChoosen:device:)]){
[delegate deviceChoosen:self device:[devices objectAtIndex:idx]];
// if (delegate && [delegate conformsTo:@protocol(BTInquiryDelegate)]){
if (delegate) {
[delegate deviceChoosen:self device:[devices objectAtIndex:idx]];
}
} else {
[tableView deselectRowAtIndexPath:indexPath animated:TRUE];

View File

@ -2,8 +2,16 @@
NEXT:
- prepare WiiMoteDemo for release
- integrate new inquiry code
- use navigation controller to switch views
- on device select:
- if name != WiiMote
- show alert: need wiimote
- stop inquiry
- set flag to connecting for wiimote
- on connect, switch view
- improve user experience of BTstack Inquiry View
- shorter inquiry interval
- repeat inquiry while BT on
- allow to select device and stop inquiry
- figure out why stack doesn't shut Bluetooth off when in sleep for a while/after wakeup
- provide test version by setting up APT repository within BTstack SVN
- instructions: http://www.saurik.com/id/7

View File

@ -18,9 +18,13 @@
UILabel *status;
}
- (void)startDemo:(id) arg;
@property (nonatomic, retain) UIWindow *window;
@property (nonatomic, retain) UINavigationController *navControl;
@property (nonatomic, retain) UIViewController *glViewControl;
@property (nonatomic, retain) BTInquiryViewController *inqViewControl;
@property (nonatomic, retain) EAGLView *glView;
@end

View File

@ -16,7 +16,7 @@
#define USE_BLUETOOTH
bd_addr_t addr = {0x00, 0x19, 0x1d, 0x90, 0x44, 0x68 }; // WiiMote
BTDevice *device;
WiiMoteOpenGLDemoAppDelegate * theMainApp;
@ -26,6 +26,7 @@ WiiMoteOpenGLDemoAppDelegate * theMainApp;
@synthesize glView;
@synthesize navControl;
@synthesize glViewControl;
@synthesize inqViewControl;
#define SIZE 5
static void bt_data_cb(uint8_t x, uint8_t y, uint8_t z){
@ -88,13 +89,23 @@ void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint
// interupt channel openedn succesfully, now open control channel, too.
bt_send_cmd(&l2cap_create_channel, event_addr, 0x11);
} else {
// request acceleration data.. probably has to be sent to control channel 0x11 instead of 0x13
uint8_t setMode31[] = { 0x52, 0x12, 0x00, 0x31 };
bt_send_l2cap( source_cid, setMode31, sizeof(setMode31));
uint8_t setLEDs[] = { 0x52, 0x11, 0x10 };
bt_send_l2cap( source_cid, setLEDs, sizeof(setLEDs));
// (*state_cb)("WiiMote connected");
// start GL demo
// [device setConnectionState:kBluetoothConnectionConnected];
// [[[theMainApp inqViewControl] tableView] reloadData];
// do perform on main thread stuff
// [[theMainApp navControl] pushViewController:[theMainApp glViewControl] animated:YES];
[theMainApp performSelectorOnMainThread:@selector(startDemo:)
withObject:nil waitUntilDone:false];
}
break;
default:
break;
@ -104,6 +115,10 @@ void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint
break;
}
}
- (void)startDemo:(id) arg {
NSLog(@"startDemo");
[navControl pushViewController:glViewControl animated:YES];
}
- (void)applicationDidFinishLaunching:(UIApplication *)application {
NSLog(@"Started");
@ -154,10 +169,13 @@ void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint
glView.animationInterval = 1.0 / 60.0;
}
-(void) deviceChoosen:(BTInquiryViewController *) inqView device:(BTDevice*) device{
-(void) deviceChoosen:(BTInquiryViewController *) inqView device:(BTDevice*) selectedDevice{
NSLog(@"deviceChoosen %@", [device toString]);
[navControl pushViewController:glViewControl animated:YES];
device = selectedDevice;
[device setConnectionState:kBluetoothConnectionConnecting];
[[inqView tableView] reloadData];
bt_send_cmd(&l2cap_create_channel, [device address], 0x13);
}

View File

@ -180,7 +180,7 @@ void l2cap_signaling_handler(l2cap_channel_t *channel, uint8_t *packet, uint16_t
case L2CAP_STATE_WAIT_CONNECT_RSP:
switch (code){
case CONNECTION_RESPONSE:
result = READ_BT_16 (packet, L2CAP_SIGNALING_DATA_OFFSET+8);
result = READ_BT_16 (packet, L2CAP_SIGNALING_DATA_OFFSET+4);
switch (result) {
case 0:
// successfull connection