Unable to connect to Wifi AP with AccessorySetupKit

Hi,

I'm trying to connect to a Wifi access point with the new AccessorySetupKit framework.

At first i thought that ASK would establish the connection to the access point but then it was mentioned in the session that I need to do that myself with NEHotspotConfigurationManager.

I tried to do that but every time I get this error:

NEHotspotConfigurationErrorDomain Code=17 "system denied configuration of the accessory network."

My AP is just a small ESP32 but I get the same results with any other AP.

Looking at the logs in Console.app for my device, I see some interesting logs such as these:

Subsystem: com.apple.AccessorySetup, Category: ASAccessorySession

Received event: DADeviceEvent: type DeviceChangedDADeviceEvent: device DADevice: ID D0A7B5FB-6800-4B73-9DC4-697DDE791D2B, name 'Printer Emulator', flags AccessorySetup, SSID 'ESP32-AP', type Hi-Fi Speaker, { DADeviceAppAccessInfo: com.criboe.GBPE, ID D0A7B5FB-6800-4B73-9DC4-697DDE791D2B, state Authorized, < WiFi >, Time 2024-07-10-11:16:40.389, disConfig asID 6CC66EF2-9D12-4071-92E4-7038D741D5E5, btSv [], com.criboe.GBPE, flags 0x8 < RenameSSID >, hSPs [ "ESP32" ] }

Subsystem: com.apple.DeviceAccess, Category: DADaemonServer

[WiFi] profile not found for SSID = 'ESP32-AP'
[WiFi] profile not found for SSID = 'ESP32-AP'
[WiFi] profile not found for SSID = 'ESP32-AP'

...and many more...

Subsystem: --, Category: <Missing Description> (wifid)

WiFiManagerAddNetworkAsync: Request to add network with content: ESP32-AP: isHidden=0, isEAP=0, isSAE=0, isWPA=0, isWEP=0, WAPI=0, type=0, enabled=(null), saveData=(null), responsiveness=(null) ((null)) isHome=Unknown, isForceFixed=0, transitionDisabledFlags=(null), foundNanIe=0, isPH=0, isPublicAirPlayNetwork=0, is6EDisabled=0, hs20=0, Channel=0
WiFiManagerAddNetworkAsync: adding ssid='ESP32-AP' bundleId='com.criboe.GBPE' appName='Camera Boy' originator='3rd Party' HS20=0
__GetNetworkWithSameSsid: network ESP32-AP not found
WiFiManagerAddNetworkAsync: 'com.criboe.GBPE' is authorized to join 'ESP32-AP: isHidden=0, isEAP=0, isSAE=0, isWPA=0, isWEP=0, WAPI=0, type=0, enabled=(null), saveData=(null), responsiveness=(null) ((null)) isHome=Unknown, isForceFixed=0, transitionDisabledFlags=(null), foundNanIe=0, isPH=0, isPublicAirPlayNetwork=0, is6EDisabled=0, hs20=0, Channel=0'

What is weird is that if I don't use ASK to first find my accessory and simply call NEHotspotConfigurationManager.shared.apply(_: ) I can connect to the AP just fine.

Any suggestions to what might be wrong here?

Answered by Engineer in 794892022

Hello, for accessories, you will need to use one of these new methods on NEHotspotConfigurationManager to connect:

 */
- (void)joinAccessoryHotspot:(nonnull ASAccessory *)accessory
				passphrase:(nonnull NSString *)passphrase
				completionHandler:(void (^ __nullable)(NSError * __nullable error))completionHandler API_AVAILABLE(ios(18.0)) API_UNAVAILABLE(macos, watchos, tvos);

- (void)joinAccessoryHotspotWithoutSecurity:(nonnull ASAccessory *)accessory
				completionHandler:(void (^ __nullable)(NSError * __nullable error))completionHandler API_AVAILABLE(ios(18.0)) API_UNAVAILABLE(macos, watchos, tvos);


Accepted Answer

Hello, for accessories, you will need to use one of these new methods on NEHotspotConfigurationManager to connect:

 */
- (void)joinAccessoryHotspot:(nonnull ASAccessory *)accessory
				passphrase:(nonnull NSString *)passphrase
				completionHandler:(void (^ __nullable)(NSError * __nullable error))completionHandler API_AVAILABLE(ios(18.0)) API_UNAVAILABLE(macos, watchos, tvos);

- (void)joinAccessoryHotspotWithoutSecurity:(nonnull ASAccessory *)accessory
				completionHandler:(void (^ __nullable)(NSError * __nullable error))completionHandler API_AVAILABLE(ios(18.0)) API_UNAVAILABLE(macos, watchos, tvos);


@Engineer Is it possible to disconnect from the Wi-Fi AP after it was connected using one of these new methods?

Neither removing accessory in ASAccessorySession nor removing configuration in NEHotspotConfigurationManager seem to be helping.

In my tests, calling NEHotspotConfigurationManager.removeConfiguration(forSSID:) disconnected from the accessory's AP again.

Unable to connect to Wifi AP with AccessorySetupKit
 
 
Q