DJI iOS SDK (Swift) - App cannot connect to aircraft when iPhone is connected to the Mavic remote controller via USB - ios

I have made the simplest app possible to connect to a Mavic Pro (basically the Swift version of this code (which comes from the Aircraft Binding and Activation demo on DJI's website.
My setup is as follows: iPhone running the App is connected via lightning cable to the main USB port on the RC (between the two joysticks on the bottom). The switch on the Mavic is set to "RC" (not Wifi).
When I run the app, the aircraft binding state is unknown and the DJISDKManager.product() returns nil, even though registration of the app completed successfully.
Here are some strange but helpful pieces of information:
With the same setup as above, running the DJI Go App from the same device works perfectly.
Using either the wireless bridge app or the wifi connections works perfectly and I'm able to connect with the aircraft no problem.
Is there some setting I'm missing? I looked at all of DJI's documentation very carefully, and have found no solutions.

The hardware accessory (the remote controller) may be associated with DJI Go now. With your app open, un-plug the lightening cable, and plug it back in. Now it will be associated with your app. With iOS 11 apps sharing hardware devices got a bit challenging.
(but thanks for mentioning DJI Go did work, then we don't have to worry the microUSB in the upper left corner of the RC was activated. Leaving the pigtail connector in will block the USB port you are using.)

I almost had the same problem. Here is the fix that worked for me.
Make sure in your info.plist file you have the following.
DJI-SDK
Also I am assuming that you calling DJISDKManager.startConnectionToProduct() after appRegisteredWithError(_ error: Error?) is called.

Related

Not able to connect to apple tv !! "Making apple tv ready for development" dialog shown

I'm trying to connect apple tv with my xcode to debug my app. But I'm getting below dialog and it will never go. So I tried following steps to fix but no use.
Waited for 10 mins and checked but still the same.
I restarted/reset apple tv and checked but no use.
Tried with different versions of xcode but no use.
Tried using wifi, mobile hotspot with different networks.
Some times I will get this dialog and it will never go.
If I try to run app in this state then I will get this alert in xcode
So I'm not understanding the why its behaving like this. And how to fix this issue ?
Wireless Debugging on Apple TV
Dive has some great recommendations about using Apple TV with your machine, connected via Ethernet. So far this is also my preferred way to connect, develop and deploy to Apple TV, however debugging on Wifi isn't the best experience.
Here are a few things you could try.
Remove current pairing by using Device and Simulator window.
Try downloading Apple Configurator 2 and use that to first pair your Apple TV to your machine. This is great tool to ensure you can connect to your iOS/tvOS devices for some super user type setup. ( Main Menu -> Paired Devices)
For this to work you have to be on a specific screen on your Apple TV.
Settings -> Remote and Devices -> Remote App and Devices ( This uses multipeer connectivity)
If you are successful pairing your TV using apple configurator then it's a good sign as you can rule our networking issues with your Wifi.
Try pairing with Xcode after it's paired with your machine in the step above. The dialog window you see above is expected and takes some time ( longer in some cases) but should eventually complete.
If step 3 wasn't a success, unpair from Xcode and Apple Configurator ( if they show as connected but not aren't really paired), restart your machine and Apple TV and start the same steps again.
Lan Set up :
You can connect to your Apple TV via a switch or usually Modem/Routers have inbuilt switch ( extra ethernet ports).
Try the same steps and you should be able to pair with Xcode.
Troubleshooting: Try using Console app on your machine if you still can not figure out the root cause and this should help you debug the pairing issue.
There is a helpful instruction from Apple - Pair a wireless device with Xcode (iOS, tvOS) and I assume that you did as they recommend.
Such issues usually appear due to the following reasons:
Something is wrong with your network configuration. The easiest way to check is to try to wirelessly connect your iPhone to be sure that you do not have the same problem. If this is the case then try to white-list the IP address for the Apple TV on your router and open necessary ports;
About port, Apple recommends the following configuration: Communication to network devices uses port 62078. Some networks block specific ports. You may need to check your network settings or ask your system administrator to open this port;
Your Xcode version has to be in sync with tvOS. From the screenshots, I see that you have tvOS 13.3.1. It means that it is better to use Xcode 11.3.1 in this configuration. But you mentioned that you already tried this.
The option that always works to me is to use an Ethernet connection. I connect my AppleTV via the ethernet cable to my router and access it from my MacBook without problems:
Connect the device to the same network using an Ethernet cable.
For an Apple TV, connect using the Ethernet port in the back of the device.

How to debug an app on iPhone without internet

I'm using Xcode 10.1, and I don't have a checkbox whether I want to connect through network or not on my device page (which was there in Xcode 9 and Xcode 10 beta). Search "connect via network xcode" on google images if you don't know what I mean.
However, I must debug the offline flow of my app (which is written in React-Native btw). Not just no-internet-connection, but turning off wifi and mobile-data, which will trigger a status change. By using the developer settings of the iPhone, I can make every call fail (100% loss), but cannot change the internet-status of the phone.
So I want the debugger to stay connected and either be able to:
debug the old-school way through the cable (if I turn off internet now, I get a red error screen and nothing is possible anymore), so I can disable wifi and mobile-data,
or simulating that status change on the phone.
Btw, I cannot use a simulator, since the app requires Bluetooth.
Thanks in advance!
Edit:
The checkbox is not there for older iPhone devices. With iPhone 7s, I do see the checkbox "connect via network". But enabling or disabling does not change the fact that your iPhone needs internet to debug. If I disable internet on the phone I get the following error:
Ok, I've found the problem. We are testing on a iPhone5, which is no longer officially supported by Apple. Which means that Apple has decided to cut features for iPhone5 so you would buy a new one (wonderful strategy =/). Hence debugging with a cable is no longer supported on iPhone5.
We tested with a iPhone6 from a colleague, and everything works fine.
Edit:
Altough the checkbox is there, and I can disable wifi for connection... The moment I turn off internet on the phone, the app crashes and says: "Runtime is not ready for debugging: make sure packager runtime is running"... so no solution yet...

Bluetooth Transmitting Legacy Name

I am working on an mbed powered Bluetooth Low Energy project. I have been developing various GATT services, however, I have now found my project has got "stuck" on a previous service. What ever program I download onto the device, a Service is broadcast with the name "HRM_SEC". I have repeatedly changed the name from this.
I have installed known working examples of default Heart Rate Monitor Example. I have installed blank programs without bluetooth service definition etc.
However, the name of this prior service is persisting.
I have reinstalled my ios app - LightBlue - incase it was a casheing thing. By reinstalled I mean deleted and then downloaded from app store.
I can't connect to these services. New programs are being installed, as I am getting the expected serial feedback.
Why is this happening and What can I do?
I have just tried using the LightBlue app on a different iPhone and I am getting the expected behaviour. How can I purge the stored data from the LightBlue app. I have tried deleting it, then doing a reset (holing lock and home button), then when it has rebooted I re-downloaded the app from the app store. What else can I do to clear which ever info is being stored by LightBlue?
This seems to be an underlying iOS issue, as my other apps are also now using this legacy name. I have tried disabling and then enabling Bluetooth, but this hasn't worked. Any other ideas?
I have submitted an iOS bug report. This is really annoying, as I cannot use my iPhone to test an app I am working on. Any ideas for workarounds?

Bonjour not advertising over BT

I've been banging my head against this for the last week or so. I've already gone through the following resources:
StackOverflow: Bonjour over bluetooth WITHOUT Gamekit ? (3844189)
StackOverflow: How does Bonjour Over Bluetooth Work (3350094)
StackOverflow: Using iOS GameKit's “Bluetooth Bonjour” with other platforms (8070998)
Technical Q&A QA1753 -- Apple Developer
WiTap sample application
SRVResolver sample application
DNSSDObjects sample application
I'm using Mac OS 10.7, Xcode 4.5, an iPhone 4 with iOS 6, and an iPad 1 with iOS 5.1.1.
My problem is this: I am modifying an application that currently uses GameKit's peer picker to connect between an iPad and a iP{hone|od touch}. We want to modify this to use Bonjour over Bluetooth instead because we've had issues with reconnecting the devices using Gamekit if the connection is lost. I've used dns_sd.h API to some success and have gotten the service to advertise and resolve over wifi, but even though I am passing kDNSServiceFlagsIncludeP2P I am not getting any success over bluetooth.
I thought possibly Bluetooth Bonjour need a PAN established between devices already, but even pairing the iPad to the iMac and browsing for DNS-SD services gives me nothing...and the iPhone won't pair to the iPad anyway.
I just finished solving this in my own app in the last 24 hours. I used the core classes from the OS X sample app DNSSDObjects. I only had to change three lines of code to add support for bluetooth. This works great in my iOS app.
In DNSSDBrowser.m, the call to DNSServiceBrowse needs to have kDNSServiceFlagsIncludeP2P passed in for the 2nd parameter.
In DNSSDRegister.m, the call to DNSServiceRegister needs the same change.
In DNSSDService.m, the call to DNSServiceResolve also needs the same change.
If you want to limit yourself to just bluetooth, and not WiFi, then the same three lines of code should be updated so the 3rd parameter is kDNSServiceInterfaceIndexP2P instead of kDNSServiceInterfaceIndexAny.
Indeed, it looks like the kDNSServiceInterfaceIndexP2P flag won't work on OSX.
If you run the code on IOS, you'll notice that Bonjour will publish two IP Adresses: one for your local WiFi network, and an 169.xx.xx.xx adress for Bluetooth.
The same code on OSX never publishes the 169.xx.xx.xx adress, so it's only found over WiFi.

AIR mobile debug - "Enter ip address or hostname"

I'm developing a mobile app using Flash Builder 4.6/AIR. I've been able to debug on the device (an iPhone 4s) just fine until now. I connect my iPhone to my mac with the USB corad, and debug.
All of a sudden I'm getting a black screen for close to a minute. Then I see the "Enter ip address or hostname" dialog. If I enter the ip address of my machine it doesn't matter. The window goes away for about 15 seconds, then comes back. Meanwhile, Flash Builder on my mac times out. The only way I can actually see the program running is if I hit 'Cancel' on that dialog. The app then launches, but I cannot set any breakpoints, cannot debug.
Everything I've found on the internet around this issue mentions it in reference to AIR for android -- not iOs. But I'm seeing it with iOs.
Anyone know what's going on here?
Thanks.
To make it easier for future readers, the official answer to this issue;
With the current (official) version of the AIR SKD (3.2) USB debugging is not supported on iOS devices. This is going to change with the future 3.3 release which (amongst others) adds USB debugging support:
"USB debugging for AIR iOS
This new feature allows the iOS developer to connect to the desktop via USB while debugging their mobile applications instead of relying on network connectivity."
With version 3.2, iOS debugging works over the local network, so both devices (the machine the debugger runs on and the iOS device) have to be in the same network so that they can communicate with each other.
See also the reply to What is the address of my Flash debugger?, it really helped me to resolve similar issue. Using 'ios-debug' mode was the way to go.
If you still have this problem using Android with the device connected to same wifi, try checking firewall rules. In my case FlashDevelop was blocked and I didn't suspected because of updates worked perfectly.

Resources