0

I'm trying to create a hotspot. One option I found online was to use the HotspotAuthtication library for windows. I loaded to sample from Microsoft's Universal Samples and ran it but it doesn't lead to any noticeable results.

I read the READ ME.md as well and that didn't provide a clear enough explanation of what it actually does.

Deeswoc
  • 159
  • 1
  • 13

1 Answers1

0

How are the HotspotAuthentication group of classes to be used

Currently, We have fewer documents on this. I have discuss with product team about this. I checked official code sample, it looks easy to understand. We use xml file to store hotspot configuration. And it contains ssid encryption protocol HotspotProfile etc.

<CarrierProvisioning xmlns="http://www.microsoft.com/networking/CarrierControl/v1">
  <Global>
    <!-- Adjust the Carrier ID to fit your own ID. Refer to the MSDN documentation about Carrier ID's. -->
    <CarrierId>{11111111-1111-1111-1111-111111111111}</CarrierId>
    <!-- Adjust the Susbscriber ID. Refer to the MSDN documentation about Subscriber ID's. -->
    <SubscriberId>1234567890</SubscriberId>
  </Global>
  <WLANProfiles>
    <WLANProfile xmlns="http://www.microsoft.com/networking/CarrierControl/WLAN/v1">
      <!-- Adjust the profile name to have a human readable network name. By default this equals the SSID. -->
      <name>Contoso Wi-Fi</name>
      <SSIDConfig>
        <SSID>
          <!-- Adjust the SSID name to fit the SSID of the hotspot. -->
          <name>contosowifi</name>
        </SSID>
      </SSIDConfig>
      <MSM>
        <security>
          <authEncryption>
            <authentication>open</authentication>
            <encryption>none</encryption>
            <useOneX>false</useOneX>
          </authEncryption>
          <HotspotProfile xmlns="http://www.microsoft.com/networking/WLAN/HotspotProfile/v1">
            <ExtAuth>
              <!-- Adjust the extension ID to match the package family name of the application running the background task handler. -->
              <ExtensionId>Microsoft.SDKSamples.HotspotAuthentication.CS_8wekyb3d8bbwe</ExtensionId>
            </ExtAuth>
          </HotspotProfile>
        </security>
      </MSM>
    </WLANProfile>
  </WLANProfiles>
</CarrierProvisioning>

And then, we call ProvisionFromXmlDocumentAsync to load xml info and create hotspot.

private async void ProvisionButton_Click(object sender, RoutedEventArgs e)
{
    ProvisionButton.IsEnabled = false;

    // Open the installation folder
    var installLocation = Windows.ApplicationModel.Package.Current.InstalledLocation;

    // Access the provisioning file
    var provisioningFile = await installLocation.GetFileAsync("ProvisioningData.xml");

    // Load with XML parser
    var xmlDocument = await XmlDocument.LoadFromFileAsync(provisioningFile);

    // Get raw XML
    var provisioningXml = xmlDocument.GetXml();

    // Create ProvisiongAgent Object
    var provisioningAgent = new ProvisioningAgent();

    try
    {
        // Create ProvisionFromXmlDocumentResults Object
        var result = await provisioningAgent.ProvisionFromXmlDocumentAsync(provisioningXml);

        if (result.AllElementsProvisioned)
        {
            rootPage.NotifyUser("Provisioning was successful", NotifyType.StatusMessage);
        }
        else
        {
            rootPage.NotifyUser("Provisioning result: " + result.ProvisionResultsXml, NotifyType.ErrorMessage);
        }
    }
    catch (System.Exception ex)
    {
        // See https://learn.microsoft.com/en-us/uwp/api/windows.networking.networkoperators.provisioningagent.provisionfromxmldocumentasync
        // for list of possible exceptions.
        rootPage.NotifyUser($"Unable to provision: {ex}", NotifyType.ErrorMessage);
    }

    ProvisionButton.IsEnabled = true;
}

Please note, if you want to use HotspotAuthentication in the uwp application, you need add networkConnectionManagerProvisioning before. And the ExtensionId is the app's package family name.

xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
IgnorableNamespaces="uap mp rescap"

 .......

<rescap:Capability Name="networkConnectionManagerProvisioning"/>
Nico Zhu
  • 32,367
  • 2
  • 15
  • 36
  • 1
    I can really see where the hotspot is being created. It doesn't seem immediately obvious where its creating said hotspot. If its done after provisioning then why do I need to register? I also can't see where its getting the ssid and key because the sample application only starts where it calls "scenario 1" i.e. where it initializes by provisioning and registering something. – Deeswoc Aug 31 '19 at 04:19