Unable to suggest a hotspot due to invalid connection response

So I am working with some hardware that requires connecting to a wifi network before uploading the firmware file. However, I am not seeing any user permission prompt appear and the following error is logged:

2022-12-11 15:20:10.899927-0600 -[2054:22393] [] Failed to send a 9 message to nehelper: <dictionary: 0x213d2e530> { count = 1, transaction: 0, voucher = 0x0, contents = "XPCErrorDescription" => <string: 0x213d2e6c8> { length = 18, contents = "Connection invalid" } } 2022-12-11 15:20:10.899997-0600 -[2054:22393] [] NEHotspotConfigurationHelper failed to communicate to helper server. Hotspot switch failed: Error Domain=NEHotspotConfigurationErrorDomain Code=8 "internal error." UserInfo={NSLocalizedDescription=internal error.}

In short the process is:

  • Connect to BLE device
  • Tell device a firmware update will occur over wifi
  • The device opens a hotspot network (with a configurable SSID/PW)
  • The user is expected to connect to the BLE device's hotspot, but I am stuck here
  • The firmware update is continued and completed over wifi

My code more or less is:

import NetworkExtension
// ...
                NEHotspotConfigurationManager.shared.removeConfiguration(forSSID: deviceSerialNumber)
                
                let wifiConfig = NEHotspotConfiguration(ssid: deviceSerialNumber, passphrase: deviceSerialNumber, isWEP: false)
                // Not setting joinOnce or setting it to true does not change the bahavior
                wifiConfig.joinOnce = false
                wifiConfig.lifeTimeInDays = 1
                // Using a background thread did not change the behavior
                DispatchQueue.main.async {
                    NEHotspotConfigurationManager.shared.apply(wifiConfig) { error in
                        if (error != nil)
                        {
                            let alreadyConnected: Bool = (error! as NSError).domain == NEHotspotConfigurationErrorDomain && (error! as NSError).code == NEHotspotConfigurationError.alreadyAssociated.rawValue
                            if (!alreadyConnected)
                            {
                                AppLogger.log("Hotspot switch failed: \(error!)")
                                DispatchQueue.global(qos: .userInitiated).async {
                                    // ...
                                }
                                return
                            }
                        }
                        
                        DispatchQueue.global(qos: .userInitiated).async {
                            // ...
                        }
                    }
                }
// ...

I currently have the following capabilities defined via an imported provisioning file:

  • Access WiFi Information
  • Hotspot Configuration
  • In-App Purchase
  • Keychain Sharing
  • Media Device Discovery
  • Network Extensions
  • Wireless Accessory Configuration

Hardware tested on:

  • Mac Mini M1 - MacOS Monterey 12.6
  • iPhone X - iOS 15.7.1, same result with a different memory address for XPCError

I am very new to Apple development, so I'm probably missing something simple. Any advice will be appreciated.

Thank You!

Nevermind found my issue.

The Capabilities were defined in the provisioning profile, but they were not added as Capabilities in use under the Signature section of the target configuration. I also still needed to link the NetworkExtension.framework into the Build Phase. Those changes resolved the problem for iPhone.

I still see the issue with the Mac Mini M1, but I am guessing I need to add Mac Catalyst Capabilities for that device.

Glad to hear that you’re making progress.

I still see the issue with the Mac Mini M1, but I am guessing I need to add Mac Catalyst Capabilities for that device.

No. NEHotspotConfigurationManager is not going to work on the Mac [1].

If you need do do this sort of thing on the Mac, you need a different API: Core WLAN.

Share and Enjoy

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

[1] While the API is available to Mac Catalyst apps, that’s just to make it easier to get your app building.

Unable to suggest a hotspot due to invalid connection response
 
 
Q