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:
Related
I am trying to reverse engineer the API of an IoT device using mitmproxy. My setup is an iphone, computer running on MacOS 10.14, and an IoT device (watering pump) that can only access the wireless network after being plugged into the computer via USB connection, i.e. a not genuinely WiFi device. My phone is configured to point to the computer, which is running mitmproxy on a standard configuration.
When I send instructions from the app controlling the device on my phone to the device itself, presumably these instructions are sent to the computer, to the device cloud server, and then to the device. With these assumptions, one would think that they would see the flow of POST requests in mitmproxy before observing the results of those instructions. That is, if you send an instruction to turn on the pump, you'd think you'd see POST request containing that instruction show up in the mitmproxy flows before you see the pump turn on.
However that is not the case here. What happens is that, when I send instructions from the app, I observe the expected behavior from the IoT device, and then the flow of requests appear on the mitmproxy console seemingly at random. There seems to be no determinate relationship between the instructions I send and the requests that appear; they show up 5 seconds later, 5 minutes later, or 30 minutes later. Is this an intentional security feature? To somehow jam MITMproxies so that hackers cannot easily isolate the knowledge of which packet is performing which instruction? Or is it just something that I am doing wrong? Does anyone have any ideas as to what could be happening hear and potential solutions for making the flow of requests appear in real time? Ty
I want to track my iPhone 6s device for the probe requests it is sending to connect to the WiFi router.
This is my current setup:
I have kept the WiFi on and have forgotten the network, in the phone so that it probes new APs.
1.The location and services is disabled.
2.The Mobile-Data is also On.
3.I am using Aircrack-ng to trace the probe requests to the router.
4.I ran the setup to get the probe requests for 1 hour, but still couldn't get the entry for the iPhone.
5.I also used wireshark and a different router to detect the iPhone but still it is not available. The capture duration was 1 hour.
6.The phone screen was randomly on and off.
I have read that from iOS8 Apple uses MAC randomization for the user safety so that they can't be tracked, but now I have a clear insight of what are the conditions when the randomization occurs(location disabled and packet data disabled and phone in sleep mode.)
I want to know that is the randomization actually happening and even if it is happening, how do I know the new Locally Randomized address of my device to trace it on Aircrack-ng/Wireshark.
And If the randomization process is actually not happening then why can't I see my iPhone in the list.
Some articles I followed:
http://blog.mojonetworks.com/ios8-mac-randomization-analyzed/.
http://www.cisco.com/c/en/us/td/docs/wireless/controller/technotes/8-0/iPhone_roam/b_iPhone-roaming.html#concept_79EB523637BD49F3AE876F9C1C95DD69
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.
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.
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.