Example #1
0
        public OnboardingService()
        {
            _state     = OnboardingState.NotConfigured;
            _stateLock = new object();

            var settings = ApplicationData.Current.LocalSettings.Values;

            // If an Oboarding Instance ID has already been established, then just use it
            if (settings.ContainsKey(_onboardingDeviceIdSettingName))
            {
                var deviceIdString = settings[_onboardingDeviceIdSettingName] as string;
                _onboardingDeviceId = new Guid(deviceIdString);
            }
            // Otherwise, we need to have some kind of unique identifier for the SoftAP and AllJoyn Onboarding ID
            else
            {
                var guid = Guid.NewGuid();
                settings[_onboardingDeviceIdSettingName] = guid.ToString();
                _onboardingDeviceId = guid;
            }

            // Obtain the WiFi MAC address if this device has a WiFi interface
            _mac = MACFinder.GetWiFiAdapterMAC();

            // If there isn't a MAC, then this device doesn't have a WiFi interface, so dummy-up a MAC address
            // The AllJoyn Onboarding Interface will still appear on a wired network.
            if (String.IsNullOrEmpty(_mac))
            {
                _mac = _onboardingDeviceId.GetHashCode().ToString("X8");
            }
        }
        private static void InitAccessPoint()
        {
            string mac = MACFinder.GetWiFiAdapterMAC();

            if (_AccessPoint != null)
            {
                StopAccessPoint();
            }
            _AccessPoint = new OnboardingAccessPoint($"{SecretManager.AccessPointSsid}_{mac}", SecretManager.AccessPointPassword, AccessPointId);
        }