I have 2 iOS devices and I would like one of them to send data to the other
(1-way really). When I put the same app on the two iOS devices & used
GameKit, things worked great.



Recently I made a second app in the hopes to have it send data to the 1st
iOS device. I used the exact same GK code and I get this every time I try to
connect with the 2nd app:

BTM: attaching to BTServer
<<< Session >>> +[GKBluetoothSupport _determineBluetoothStatus]: BT
not available - try again later.
BTM: posting notification BluetoothAvailabilityChangedNotification



I don't know why when I try to connect with the second device (launch the
app on 2nd device 1st and hit a connect button) it won't work. This is how I
am invoking the picker:

-(IBAction) btnConnect:(id) sender {
    picker = [[GKPeerPickerController alloc] init];
    picker.delegate = self;
    picker.connectionTypesMask = GKPeerPickerConnectionTypeNearby;
    [connect setHidden:YES];
    [disconnect setHidden:NO];
    [picker show];
}

- (void)peerPickerController:(GKPeerPickerController *)picker
              didConnectPeer:(NSString *)peerID
                   toSession:(GKSession *) session {
    self.currentSession = session;
    session.delegate = self;
    [session setDataReceiveHandler:self withContext:nil];
    picker.delegate = nil;
    [picker dismiss];
    [picker autorelease];
}

- (void)session:(GKSession *)session
           peer:(NSString *)peerID
 didChangeState:(GKPeerConnectionState)state {
    switch (state)
    {
        case GKPeerStateConnected:
            NSLog(@"connected");
            break;
        case GKPeerStateDisconnected:
            NSLog(@"disconnected");
            [self.currentSession release];
            currentSession = nil;
            [connect setHidden:NO];
            [disconnect setHidden:YES];
            break;
        case GKPeerStateAvailable:
        case GKPeerStateConnecting:
        case GKPeerStateUnavailable:
            break;
    }
}



That's problem one. It doesn't seem to matter what iOS device (touch/iPhone)
I put it on, I get that weird BT not available in the console.



Problem two... since the apps are different and will have different ids,
does anything special need to be done to get them to communicate over BT?
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to