private async void AttemptOnboardingAsync(string ssid, string password, short authType) { if (string.IsNullOrWhiteSpace(ssid)) { UpdateStatusAsync("No SSID selected. Please select a network or manually enter SSID.", NotifyType.ErrorMessage); } else { UpdateStatusAsync("Attempting to configure onboardee...", NotifyType.StatusMessage); OnboardingConfigureWiFiResult configureWifiResult = await m_consumer.ConfigureWiFiAsync(ssid, ConvertUtf8ToHex(password), authType); if (configureWifiResult.Status == AllJoynStatus.Ok) { UpdateStatusAsync("Onboardee sucessfully configured.", NotifyType.StatusMessage); if (configureWifiResult.Status2 == (short)ConfigureWiFiResultStatus.Concurrent) { // The Onboardee has indicated that it will attempt to connect to the desired AP concurrently, while the SoftAP is enabled. In this case, // the Onboarder application must wait for the ConnectionResult signal to arrive over the AllJoyn session established over the SoftAP link. // If the Onboardee does not connect to the desired AP concurrently, then there is no guaranteed way for the Onboarder application to find // out if the connection attempt was successful or not. In the NotConcurrent connection attempt, if the Onboardee fails to connect to // the desired AP, the Onboarder application will have to again start over with scanning and connecting to the Onboardee SoftAP. // For more information please visit http://go.microsoft.com/fwlink/?LinkId=817239 m_consumer.Signals.ConnectionResultReceived += Signals_ConnectionResultReceived; } AttemptConnectionAsync(); } else { UpdateStatusAsync(string.Format("Attempt to configure WiFi failed with AllJoyn error: 0x{0:X}.", configureWifiResult.Status), NotifyType.ErrorMessage); } } ClearPasswords(); }
private async void AttemptOnboardingAsync(string ssid, string password, short authType) { if (string.IsNullOrWhiteSpace(ssid)) { UpdateStatusAsync("No SSID selected. Please select a network or manually enter SSID.", NotifyType.ErrorMessage); } else { UpdateStatusAsync("Attempting to configure onboardee...", NotifyType.StatusMessage); // WiFi password must be converted to hex representation of the UTF-8 string. OnboardingConfigureWiFiResult configureWifiResult = await m_consumer.ConfigureWiFiAsync(ssid, ConvertUtf8ToHex(password), authType); if (configureWifiResult.Status == AllJoynStatus.Ok) { UpdateStatusAsync("Onboardee sucessfully configured.", NotifyType.StatusMessage); if (configureWifiResult.Status2 == (short)ConfigureWiFiResultStatus.Concurrent) { // Concurrent step used to validate the personal AP connection. In this case, the Onboarder application must // wait for the ConnectionResult signal to arrive over the AllJoyn session established over the SoftAP link. m_consumer.Signals.ConnectionResultReceived += Signals_ConnectionResultReceived; } AttemptConnectionAsync(); } else { UpdateStatusAsync(string.Format("Attempt to configure WiFi failed with AllJoyn error: 0x{0:X}.", configureWifiResult.Status), NotifyType.ErrorMessage); } } ClearPasswords(); }