Use Wifi Instead of Bluetooth in game development kit - wifi

I am using GameKit to connect 2 device (peer to peer) way.
I don't want to use bluetooth to connect the devices - I want to use the local wifi router.(the router does not have internet access).
I am able to do every thing using bluetooth but not wifi - I even modified this line:
picker.connectionTypesMask = GKPeerPickerConnectionTypeNearby;
to
picker.connectionTypesMask = GKPeerPickerConnectionTypeNearby | GKPeerPickerConnectionTypeOnline;
but this simple change added a tab saying online, when I tap it it does nothing and when I tap the other tab that says nearby it connects using bluetooth. What's the problem?

Related

Pair and Connecting to Bluetooth Classic Speaker iOS

I realise most of the searches are quite old on this topic and not after Core Bluetooth now supports more than just BLE connections (https://developer.apple.com/videos/play/wwdc2019/901?time=556).
Simply by running the RxBluetoothKit example app I am able to discover my speaker and inspect its services. However I am unsure how to actually get the speaker to pair with the phone, after a while the speaker disconnects. I am struggling to get information on the protocol and/or how to proceed.
Or is this still not possible: "And so if you're calling connect on a BR/EDR device, if your app is in foreground, then we'll try to make a connection out to that device for you." - it seems like querying and communication with an already paired device is what they were getting at in the talk.
Thanks in advance.

How to disconnect completely on BLE using iOS Core Bluetooth

When using CBCentralManager.cancelPeripheralConnection(peripheral) , disconnection is only for the application level. So can't connect again to the same device without turn off and on bluetooth.
I know that CBCentralManager?.retrieveConnectedPeripherals(withServices: ) function is there, but I need to connect to the exact same device( based on MAC address [ This I'm getting from advertising data ] ) not to any device with the specific service.
Is there any way to disconnect completely?
You don't need to disconnect completely.
You can just call connect(_:options:) within centralManager:didDisconnectPeripheral:error:. The device will be reconnected once it is visible again.

Can iOS application use cellular internet connection while doing "Wireless Accessory Configuration" through WiFi?

Is it possible to access internet (using cellular) during WiFi device configuration using Apple's "Wireless Accessory Configuration" feature?
This device would create the WiFi network and we would need to get data from the server while configurating the device.
Specifications:
Would iOS automatically use cellular to connect to the internet if there is no internet connection through WiFi? (But still keeps WiFi connection with device)
Or is it possible to programmatically switch between connections? For example: Get data from device through WiFi, send data to server through cellular, get data from server through cellular and then configurate device through WiFi.
Some other way to accomplish this?
From Apple Developers Forum:
eskimo:
"iOS keeps WWAN active even when Wi-Fi is fully functioning. That’s done because important system services, like push notifications, always run over WWAN where possible.
So, what you’re asking about is the switch of the default route. In general, iOS only switches the default route to Wi-Fi when the Wi-Fi is fully up and running. That means that WWAN should remain the default route during the WAC process."
https://forums.developer.apple.com/thread/46528

Transfer code from App to WiFi module

The app I am working on is to control model trains. The train manufacturer has provided the code that would operate the train (for example, ring bell, move forward, etc.).
The WiFi module I would use for the app broadcasts a WiFi Network. In the Settings section of the iPad, the WiFi network can be located and connected to without the need of a password.
I need to figure out how my app can connect to that same WiFi network. From there each button on the app would be programmed to the specific manufacturer provided code. For example, the bell button has a specific code that when pressed that code is sent from the iPad to the WiFi module by way of the WiFi network. The the WiFi module is connected to a Command Base by way of a serial port. So the WiFi module sends the code to the Command Base. The Command Base then sends the code through 2.4Ghz frequency to the train where in our example it will ring its bell.
Any suggestions to programming the buttons & connecting to the WiFi network is appreciated. Thanks!
Apple does not allow you to change system settings like wifi network with your app. You simply need to instruct the user. You CAN provide them a link to the settings page however:
NSURL* settingsURL = [NSURL URLWithString:#”prefs:root=WIFI”]]; // objective c
[[UIApplication sharedApplication] openURL:settingsURL];
let settingsURL = NSURL(string: "prefs:root=WIFI") // swift
UIApplication.sharedApplication().openURL(settingsURL)

"Internet connection is offline" when connecting to AP without internet access - WiFi off/on fixes

BACKGROUND
We're trying to use an iOS app running on iPhone/iPad to give WiFi credentials to an embedded device (using an ARM SoC running Linux). The embedded device starts an AP (access point), we instruct the user to connect to this AP and then the user submits their WiFi credentials. After WiFi credentials are received the device drops the AP and connects to the WiFi the user gave credentials for.
Initially, we try to hit a PHP page to get the list of WiFi networks the embedded device can see.
ISSUE
We instruct the user to join XYZ network (in iOS they must background the app, go into settings and switch to our WiFi network). We listen for an app resumed from background notification, check the devices current ESSID (ensure its our AP ESSID) and try to hit a PHP page to receive the list of WiFi networks. Often, this connection fails reports "The internet connection appears to be offline" (or something of that nature).
We currently have a stop gap when this happens telling the user to toggle their WiFi off and then back on (in settings). The device will reconnect to our AP as it's the most recently connected network. This ALWAYS fixes the issue, we've never had to toggle the WiFi twice in order to reach the PHP page on the device. Please tell me any possible way we can avoid having to instruct the user to toggle WiFi and still access PHP pages on the embedded device.
Note: when we're connected to the AP (whether this bug is active or fixed) the device DOES NOT show the WiFi icon in the status bar. We assume this is because the AP doesn't have a viable connection to the internet (can only access pages served by the embedded device). We've been testing on a device that has LTE cellular access, but the error still says "Internet connection appears to be offline".
Obviously we have a DHCP server running on the embedded device.
It's looking like this was caused by an omission in our dhcpd.conf file.
This omission was causing iOS to believe the connection was unviable.
We added the following line and are getting much better results:
option domain-name-servers 10.10.10.1;

Resources