macOS: Broadcast Wi-Fi Direct Hotspot - Host AP Mode

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!

Answered by DTS Engineer in 795097022
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"

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"

Thanks for letting me know, Quinn!

Do you think a user-level feature or API for this will ever be added in the future?

For context, my use-case is low-latency network communication for realtime musical performance. My Mac hosts music software which is controlled by other musical instrument devices over the Wi-Fi network. Having a router as the connection point between my Mac and these devices causes jitter and adds latency that can be detrimental to a musical performance. Using a router also requires me to carry additional hardware. A peer-to-peer Wi-Fi connection between my Mac and these devices is ideal for latency and mobility.

I understand this is a niche use-case but products and users do exist which would benefit from a "Wi-Fi Direct"-like solution on macOS. People use the TouchOSC (https://hexler.net/touchosc) app on their iOS device to control Logic Pro on their Mac. I make a product called MoveMusic (https://movemusic.com) which allows people to control music software on Mac from a Meta Quest VR headset. Instead of relying on USB connections, the consumer market of MIDI Controller hardware products could rely on Wi-Fi as a primary connection method if it were straightforward for users to establish a direct Wi-Fi connection with their computers. Mac is the favored computer in the music software market, so the impact of macOS adding this feature would be highly impactful for the music tech space.

It seems other developers have been interested in Wi-Fi Direct on Apple platforms in the past:

If it is helpful, I submitted an Enhancement Request, FB12291606, on this topic in 2023.

Do you think a user-level feature or API for this will ever be added in the future?

I can’t predict the future, alas.

If it is helpful, I submitted an Enhancement Request, FB12291606, on this topic in 2023.

Thanks for that.

I had a quick look and it’s in the right place but I’ve no info to share beyond that.


Oh, and a quick note on terminology. You’re not talking about Wi-Fi Direct here. Wi-Fi Direct is a point-to-point protocol and that’s not the case for Apple’s peer-to-peer Wi-Fi, Personal Hotspot, and Internet Sharing.

Note I’m gonna terms from my Wi-Fi Fundamentals post.

The latter two are infrastructure Wi-Fi, with the device on which you enable the feature acting as both a AP and a STA. In infrastructure Wi-Fi, normal STA-to-STA traffic goes via the AP, so if the peer STA is on the AP then, yep, that’s only one hop. However, that’s not the same as Wi-Fi Direct.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

macOS: Broadcast Wi-Fi Direct Hotspot - Host AP Mode
 
 
Q