iPhone sometimes fails connecting to cc2564 (Bluetooth Low Energy) - iphone

We are developing an application where an iPhone should connect to an cc2564 device (Specifically cc2564+msp430f5438), the application should make quick and short connections to send some data. We need reliability in the connection so we need to know if the connection was really successfully or not, and we need a way to connect to the device with assurance.
The iPhone connects correctly to de device most times, it discovers services and works as expected, but sometimes the iphone makes the connection but the callback of discovered services is never called.
We used a sniffer to look at the communication packages and we saw that in those cases the connection package was send but there wasn't any response from the device, the phone tries to retry some version request messages and then stops, as you can see in the image:
The problem seems to be on the device, we are using the SPPLEDemo sample provided by Texas, and the first function that is called when the connection is established is GAP_LE_Evenet_Callback, and when the problem occurs it's never called. We don't know if somewhere inside the GAP API the device receive the connection message.
Is there some way to debug it or to know if the connection message is received by the device when the error occurs?
Is it a problem on the iPhone (unlikely), or is a problem on the device?

You quoted that
..the first function that is called when the connection is established is GAP_LE_Evenet_Callback, and when the problem occurs it's never called..
I'd recommend tweaking (playing) a bit with connection timeouts and Link Supervision Timeouts before consulting the experts who have developed the BLE Device firmware if that is possible for you.
Be assured that whenever a connection is made, the BLE device gets an event (callback) from the BLE stack that the connection has been established.
If that event is not handled the way it should be, then you can conclude that BLE device has some implementation issue.

Related

CoreBluetooth APIMISUSE (send command - peripheral not connected)

The system i'm working with uses the following scenario:
Connecting to bluetooth LE device
Discover Services & Characteristics
Write command to TX characteristic and receive response
Above works fine 90% of time. Now and then the system gets into a state where 3rd step constantly fails (there is no response from device whatsoever even though step 1 and 2 succeeded. Restarting the app / phone / BLE device DOES not remedy this. Block is constant. What does resolve the problem is manually unpairing the device from iOS system settings. Looking at BLE diagnostic logs i get this:
"pon. mar 7 21:27:30 Preferences[380]: [CoreBluetooth] API MISUSE: can only accept commands while in the connected state"
However prior to sending the commands i've debugged the app and i'm 100% the connection is established and services&characteristics have been discovered. Any Idea? Anybody facing similiar problems?
Did you implement centralManager:didDisconnectPeripheral:error: in your central manager delegate?
It will notify you when a peripheral disconnects. Could be that the peripheral disconnected or there was a connection error. You should always make sure to only do read/write operations while in the connected state.
Maybe also have a look at this method: centralManager:didFailToConnectPeripheral:error:

Sending a contact from an iOS app via bluetooth

I am trying to allow a user, who is running my app, to send a contacts vcard (vcf) via bluetooth to another iOS device.
The problem is, that the receiving device should not be required to run the same app.
Is there a possibiliy to accomplish this?
If there is not - is it at least possible to have Gamekit to establish a session, when the receiving device is running the same app, but without requiring the (receiving) user to start the peerPicker-dialog?
Any help and hints are appreciated!
First option: seems to be impossible.
Second option: Works. I implemented a GKSessionDelegate for receiving incoming connections. This session is startet together with the app.
For establishing the connection with a receiver, I used the well known GKPeerPickerControllerDelegate.
One remainig problem is, that the sender sees itself in the list of available peers (because it has also a receiver running in the background). My solution for this is to set its GKSession.available=NO, as soon as the sender starts its GKPeerPickerController.

How can i know when i have connection with my server using Reachability?

i need to Implement in my app Error report. i have already have this error report but the problem is that i use the grabURLInBackground to send the error and it's not a good Idea because i need to save those error's in array and ONLY when i have connection with the server i need to send all of those error's together. so my Question is how do i "listen" to a server connection?
how can i know when to send my error's ( Connection is Available ) ? do i need to do it in background? with what?
i hope you guy's Understood me :)
You will get a lot of example code code with Reachability. In fact you can google it.
I didn't found a solution which completely works for me as desired.
Here is a similar question, maybe.
And here is my test cases:
Connect your device to a WI-FI router, and unplug the WLAN from router, so has connection to WI-FI , but no connection to internet.
Case2:
Insert a SIM card, turn on the Allow data at setting via 3G, but the card has no 3G dataplan.
All of Reachability will say there is internet connection and all api calls are fake...

Is it possible to have two instances of GKSession on the same device when using Bluetooth?

I am writing mutliplayer game and thought I would create two instances of GKSession. One session set to GKSessionModeServer and the other to GKSessionModeClient. The server is properly reported when I call peersWithConnectionState: on the client peer and each session has different peer ids. But when I try to connect to the server I receive the message session:connectionWithPeerFailed:withError: with the error description "Failed while pending outgoing invitation.".
Using two GKSessions works when Wi-Fi is available. I am afraid that there is some limitation with Bluetooth that disallows this but I am not sure. I could rewrite the code to use a single GKSession on the server but I would rather not code special cases if I know that someone else got it working with two instances.
If I turn off both Wi-Fi and Bluetooth i get the error "Network not available." which I don't get if either is turned on. This makes me believe it won't work when there is another iPhone is nearby either.
I rewrote the code so I only create one GKSession on the hosting device and send data between the server and the local client directly without using the GKSession. I could finally test this with two devices and they properly connect to each other. So the lesson is to have only one GKSession on the host and it will work with Bluetooth as well as Wi-Fi.

Delay in receiving APN on iPhone

Sometimes I am experiecing a delay while receiving APN , while at other times its working absolutely fine.
I am also connecting to the feedback server at ssl://feedback.sandbox.push.apple.com , but its not showing any data.
What are the possible reasons for the delay?
Thanks
Delay can happen if you've got a bad connection on 3G or Edge (iPhones use those, not wifi, for push unless they're totally unavailable). If the connection is dropped but the device doesn't know it, it'll wait until it does a heartbeat and realizes the connection is closed.
Also, if you're using an iPod Touch, the connection to the push servers will only be maintained while the backlight is on or you're plugged in via USB; otherwise the wifi connection will be dropped when the backlight goes off to save power, and it'll poll for new notifications every half an hour.