Please do not post the same thing multiple times. The board software automatically flags certain posts as needing moderator attention. This happens the most often for new users. I'm pretty sure this is made clear at the time you attempt to post. Posting the same thing over and over again just makes that many more posts the moderators have to weed through later. This makes us sad. Don't make us sad. If your post/thread doesn't appear, just wait a while. Don't post it again. If it hasn't shown up by the next day, then you can try again. I normally go through posts in the mornings, and try to check a few times throughout the day, but I'm not here 24/7. There will typically be a significant delay before posts are approved. Just be patient.
Thanks 4 the quick reply but that tutorial (which was indeed the one I followed to learn something about bluetooth connection in the iPhone) uses GKPeerPickerController. The problem is that the vast majority of the tutorials related to bluetooth use that picker (but is up to you whether use it or not)
I want to connect to or more pickers without using that interface.
I can't think why you wouldn't want to use that one, it makes things easier.
I may be understanding things wrong. With that dialog you can see all the peers available for connecting. When you click in one of them, you connect with that peer, and to see again all the peers available you need to show again that dialog in order to connect to other one. Is this that way or you can select all the peers you want to connect with? I don´t think so...
So the reason why I do not want to use that dialog is because I want to connect to several peers available at the same time without having to show that dialog every time I want to connect to a peer.
I hope with "several" you mean less than 4. Bluetooth on the iPhone can't handle any more than that (see here.).
Anyways, here's a step by step guide: 1. Init the session, just like you did. 2. Set the delegate and the isAvailable property. 3. Set the data receiver.
// Set data handler. [self.curSession setDataReceiveHandler:self withContext:nil];
4. Fire up a second device. 5. Wait. 6. The delegates method "didChangeState" should be called. The state should be "GKPeerStateAvailable". Once there, connect to that peer, using the GKSession's "connect" method.
// Do stuff depending on state. switch (state) { case GKPeerStateAvailable: [session connectToPeer:peerID withTimeout:0]; break; } }
7. Wait (the first connection can take up to 30 seconds, your bluetooth icon should be blinking in the process). 8. The delegates method "didReceiveConnectionRequestFromPeer" should be called. Accept the connection there using the sessions "acceptConnectionFromPeer" method.
9. Again, "didChangeState" will be called, this time with "GKPeerStateConnected". 10. Boom, you are done.
Don't forget to handle the other delgates methods, e.g. disconnecting the peer in "connectionToPeerFailed". Also, disconnect all peers and release the Bluetooth session before quitting the app.
And, if for the love of god you just can't get it to work, try restarting the device. Sometimes BT just stopped working for me.
Thanks a lot. I am really impressed that you have taken a little bit out of your time to get this solved 4 me. I am a bit new posting in forums an all this stuff and when I come across people as helpful as you really blows me away :-).
One more question by the way...
How can I get the name of the iPhone whoose peerID is X? I mean...the only info I have about the iPhone I am hooked up with is the peerID, isn´t it? I would like to show the iPhone name as usual...
I have some problems when connecting more than two devices. Imagine three iPhones (1, 2 and 3).
- I fire up 1. - I fire up 2. Then method didChangeState is called into GKPeerStateAvailable case. As I call connectToPeer, then didChangeState is called again into GKPeerStateConnected this time. Everything is OK. Two devices connected.
The problem is when I fire up 3. didChangeState is always called into GKPeerStateAvailable but sometimes it connects (didChangeState is called again into GKPeerStateConnected) once and then when I fire it up again it never connects.... But if I switched off devicew 2, then 1 and 3 can connect.
¿is it only possible to connect to devices with Gamekit? I don't think so...
I've got bluetooth working just fine. Am I correct in assuming that this doesn't work over WIFI? I do all the same with my interface with BT turned off, and I do not see any available peers.
In order to connect over WIFI, must I then use Bonjour directly? Any suggestions are appreciated. Thanks in advance.
Now I have the same question, but it has been years since the discussion. I want to know if you still work with it. I don't like the GKPeerPickerController default UI. But without it, I can't detect weather the bluetooth is open, because I want to communication just with bluetooth other than wifi. How can I implement it. Using BT, we know the found people is around, while he can be anywhere by wifi. Thank you!!
iPhoneSpain;172376 said:
Hi!
This time I´ll try to post my question very clear because I think I messed up last time.
1 - I want to connect several iPhones using Gamekit via Bluetooth.
2 - I don´t want to use GKPeerPickerController (I want to implement a custom picker myself). Thus, I have to use GKSession and GKSessionDelegate.
3 - I´ve tried (with no result) with this methods:
Now I have the same question, but it has been years since the discussion. I want to know if you still work with it. I don't like the GKPeerPickerController default UI. But without it, I can't detect weather the bluetooth is open, because I want to communication just with bluetooth other than wifi. How can I implement it. Using BT, we know the found people is around, while he can be anywhere by wifi. or there is any API to open bluetooth and communicate with BT? Thank you!!
Regnits;172834 said:
I hope with "several" you mean less than 4. Bluetooth on the iPhone can't handle any more than that (see here.).
Anyways, here's a step by step guide: 1. Init the session, just like you did. 2. Set the delegate and the isAvailable property. 3. Set the data receiver.
// Set data handler. [self.curSession setDataReceiveHandler:self withContext:nil];
4. Fire up a second device. 5. Wait. 6. The delegates method "didChangeState" should be called. The state should be "GKPeerStateAvailable". Once there, connect to that peer, using the GKSession's "connect" method.
// Do stuff depending on state. switch (state) { case GKPeerStateAvailable: [session connectToPeer:peerID withTimeout:0]; break; } }
7. Wait (the first connection can take up to 30 seconds, your bluetooth icon should be blinking in the process). 8. The delegates method "didReceiveConnectionRequestFromPeer" should be called. Accept the connection there using the sessions "acceptConnectionFromPeer" method.
9. Again, "didChangeState" will be called, this time with "GKPeerStateConnected". 10. Boom, you are done.
Don't forget to handle the other delgates methods, e.g. disconnecting the peer in "connectionToPeerFailed". Also, disconnect all peers and release the Bluetooth session before quitting the app.
And, if for the love of god you just can't get it to work, try restarting the device. Sometimes BT just stopped working for me.
Also, do all your devices have BT turned on? Do you have more than 1 device?
I have used GameKit on 3 devices and I've gotten it to work fine.
HTH
lxx719;328710 said:
Now I have the same question, but it has been years since the discussion. I want to know if you still work with it. I don't like the GKPeerPickerController default UI. But without it, I can't detect weather the bluetooth is open, because I want to communication just with bluetooth other than wifi. How can I implement it. Using BT, we know the found people is around, while he can be anywhere by wifi. or there is any API to open bluetooth and communicate with BT? Thank you!!
GKSessionDelegate is used to create a session and communicate. I just want to open the BT in the code and search people around. or let the user to open BT by GKPeerController. When BT is close, the iOS will show a default dialog to allow the user to open the BT, and then the default pick and connect dialog appears. I don't want to select a user to connect. How could I design the dialog and just let the user to open BT? This is a APP, so I can't open every BT in every device! Thank you every much.
intomo;328939 said:
Did you implement the class that you are doing that in as a GKSessionDelegate? Otherwise your delegate methods aren't going to fire.
I don't think the SDK allows you to turn on BT except manually via the Settings panel on each device. This is or security. You certainly can't do it through GameKit. And GameKit will not be able to see any devices where BT is not turned on.
HTH
lxx719;329263 said:
GKSessionDelegate is used to create a session and communicate. I just want to open the BT in the code and search people around. or let the user to open BT by GKPeerController. When BT is close, the iOS will show a default dialog to allow the user to open the BT, and then the default pick and connect dialog appears. I don't want to select a user to connect. How could I design the dialog and just let the user to open BT? This is a APP, so I can't open every BT in every device! Thank you every much.
I don't think the SDK allows you to turn on BT except manually via the Settings panel on each device. This is or security. You certainly can't do it through GameKit. And GameKit will not be able to see any devices where BT is not turned on.
I hope with "several" you mean less than 4. Bluetooth on the iPhone can't handle any more than that (see here.).
Anyways, here's a step by step guide: 1. Init the session, just like you did. 2. Set the delegate and the isAvailable property. 3. Set the data receiver.
// Set data handler. [self.curSession setDataReceiveHandler:self withContext:nil];
4. Fire up a second device. 5. Wait. 6. The delegates method "didChangeState" should be called. The state should be "GKPeerStateAvailable". Once there, connect to that peer, using the GKSession's "connect" method.
// Do stuff depending on state. switch (state) { case GKPeerStateAvailable: [session connectToPeer:peerID withTimeout:0]; break; } }
7. Wait (the first connection can take up to 30 seconds, your bluetooth icon should be blinking in the process). 8. The delegates method "didReceiveConnectionRequestFromPeer" should be called. Accept the connection there using the sessions "acceptConnectionFromPeer" method.
9. Again, "didChangeState" will be called, this time with "GKPeerStateConnected". 10. Boom, you are done.
Don't forget to handle the other delgates methods, e.g. disconnecting the peer in "connectionToPeerFailed". Also, disconnect all peers and release the Bluetooth session before quitting the app.
And, if for the love of god you just can't get it to work, try restarting the device. Sometimes BT just stopped working for me.
Hi,
very interesting thread. I've my own piece of code in a test app that make only voice chat. It works very well also in backgroud, but if i receive a call when it finish voice chat is not funcitionally I've notice that GKStateDisconnet is not be called during the call. I must work on didEnterFore/Background method? Or there are some other optional delegate method of GKSession that may help me?
I was having issues with this kind of Bluetooth connection. I came across this thread. Here's my situation:
I have these methods written into my app delegate. I also have the GKPeerPickerController in a viewController.
It worked well when I used an older version of my app that did not have the app delegate with the code from this forum. As soon as I used two devices with the same version of my app (with the app delegate having the code from this forum), the GKPeerPickerController says "waiting for /Device name" for five minutes. No connection dialogue.
How can I: make the code from this forum (when implemented in the AppDelegate) work with a GKPeerPickerController that is in one of my view controllers?
Replies
iPhone Bluetooth Programming
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeI want to connect to or more pickers without using that interface.
Help! :-)
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeSo the reason why I do not want to use that dialog is because I want to connect to several peers available at the same time without having to show that dialog every time I want to connect to a peer.
I don't know if I am explaining myself... :-)
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeAnyways, here's a step by step guide:
1. Init the session, just like you did.
2. Set the delegate and the isAvailable property.
3. Set the data receiver.
4. Fire up a second device.
5. Wait.
6. The delegates method "didChangeState" should be called. The state should be "GKPeerStateAvailable". Once there, connect to that peer, using the GKSession's "connect" method.
7. Wait (the first connection can take up to 30 seconds, your bluetooth icon should be blinking in the process).
8. The delegates method "didReceiveConnectionRequestFromPeer" should be called. Accept the connection there using the sessions "acceptConnectionFromPeer" method.
9. Again, "didChangeState" will be called, this time with "GKPeerStateConnected".
10. Boom, you are done.
Don't forget to handle the other delgates methods, e.g. disconnecting the peer in "connectionToPeerFailed". Also, disconnect all peers and release the Bluetooth session before quitting the app.
And, if for the love of god you just can't get it to work, try restarting the device. Sometimes BT just stopped working for me.
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeThanks a lot. I am really impressed that you have taken a little bit out of your time to get this solved 4 me. I am a bit new posting in forums an all this stuff and when I come across people as helpful as you really blows me away :-).
One more question by the way...
How can I get the name of the iPhone whoose peerID is X? I mean...the only info I have about the iPhone I am hooked up with is the peerID, isn´t it? I would like to show the iPhone name as usual...
You know something about this?
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeThanks one more time :-)
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeI have some problems when connecting more than two devices. Imagine three iPhones (1, 2 and 3).
- I fire up 1.
- I fire up 2. Then method didChangeState is called into GKPeerStateAvailable case. As I call connectToPeer, then didChangeState is called again into GKPeerStateConnected this time. Everything is OK. Two devices connected.
The problem is when I fire up 3. didChangeState is always called into GKPeerStateAvailable but sometimes it connects (didChangeState is called again into GKPeerStateConnected) once and then when I fire it up again it never connects.... But if I switched off devicew 2, then 1 and 3 can connect.
¿is it only possible to connect to devices with Gamekit? I don't think so...
So somebody can figure out what's happening?
Thanks again
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeI've got bluetooth working just fine.
Am I correct in assuming that this doesn't work over WIFI?
I do all the same with my interface with BT turned off, and I do not see any available peers.
In order to connect over WIFI, must I then use Bonjour directly?
Any suggestions are appreciated.
Thanks in advance.
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeI want to know if you still work with it.
I don't like the GKPeerPickerController default UI. But without it, I can't detect weather the bluetooth is open, because I want to communication just with bluetooth other than wifi. How can I implement it. Using BT, we know the found people is around, while he can be anywhere by wifi.
Thank you!!
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeI want to know if you still work with it.
I don't like the GKPeerPickerController default UI. But without it, I can't detect weather the bluetooth is open, because I want to communication just with bluetooth other than wifi. How can I implement it. Using BT, we know the found people is around, while he can be anywhere by wifi. or there is any API to open bluetooth and communicate with BT?
Thank you!!
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeAlso, do all your devices have BT turned on?
Do you have more than 1 device?
I have used GameKit on 3 devices and I've gotten it to work fine.
HTH
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeThank you every much.
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeThis is or security.
You certainly can't do it through GameKit.
And GameKit will not be able to see any devices where BT is not turned on.
HTH
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesomevery interesting thread.
I've my own piece of code in a test app that make only voice chat.
It works very well also in backgroud, but if i receive a call when it finish voice chat is not funcitionally
I've notice that GKStateDisconnet is not be called during the call.
I must work on didEnterFore/Background method?
Or there are some other optional delegate method of GKSession that may help me?
Thank's.
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeI have these methods written into my app delegate. I also have the GKPeerPickerController in a viewController.
It worked well when I used an older version of my app that did not have the app delegate with the code from this forum. As soon as I used two devices with the same version of my app (with the app delegate having the code from this forum), the GKPeerPickerController says "waiting for /Device name" for five minutes. No connection dialogue.
How can I: make the code from this forum (when implemented in the AppDelegate) work with a GKPeerPickerController that is in one of my view controllers?
Rest Counter - Count bars of rest in orchestra with ease!!!
<a href="http://itunes.apple.com/us/app/swiftload/id4697629
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome