I want to make a program which configures my Mac to broadcast a Wi-Fi Direct hotspot: a peer-to-peer network without an internet connection which is joinable by other devices including non-Apple devices (e.g. Android devices). This connection would allow for low latency comunication between external devices and my Mac without the need for extra Wi-Fi router hardware.
From my understanding, the Mac network interface must be configured to be in Host AP (Access Point) mode so that it can host other connections.
How can I write a program which enables Host AP mode and broadcasts a Wi-Fi hotspot from my Mac?
Note: I do not want to create an Ad-Hoc (IBSS) connection because Android devices do not support joining this kind of Wi-Fi connection.
Many years ago, it was possible to set the Mac Wi-Fi interface to Host AP mode via a function in CoreWLAN
: CWInterface.startHostAPModeWithSSID
. You can see this function referenced in this gist. But sadly, this function is no longer accessible.
At this point in time, I see no way in the CoreWLAN
library to set a CWInterface
to be in hostAP
interface mode, although the CWInterfaceMode.hostAP
enumeration suggests this is possible.
It is possible to enable Host AP mode via the Settings app > Sharing > Internet Sharing settings. But this requires a legitimate internet connection to be present. For my use case, I do not want a connection to the internet. I simply want to allow devices to communicate with my Mac directly, peer-to-peer over Wi-Fi.
Is there any alternative? Could I implement this functionality in a Network Extension or Kernel Extension?
Thank you all for any help you can provide!
How can I write a program which enables Host AP mode and broadcasts a Wi-Fi hotspot from my Mac?
There’s no supported way to do this. As you’ve noted, a bunch of infrastructure related to this is visible on our system, but it’s all there to support Internet Sharing. The interaction between that user-level feature and this infrastructure is an implementation detail, not an API.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"