Associating an application with a connection in Connection Manager


Consider a scenario where a connection exposes some service to be used by a service-specific application, or collection of such applications.  For example, consider some set of “Premium Services” that are used by an application allowing user to interact with these services.  In Connection Manager (CM), there are two options in associating an application with a connection:


1.     Association by connection name.  If the name of the connection is known, the application can ask for it explicitly using ConnMgrMapConRef().  The application can obtain the connection name by having the name configured in application.


2.     Association by meta-network.  If the meta-network that the connection leads to is known, the application can ask for the meta-network by its GUID.  The application can obtain the GUID by:


a.     GUID configured in the application.


b.    Name of meta-network, such as “Premium Services Network”, configured in application, and mapping the name of the meta-network to GUID using ConnMgrEnumDestinations().


 


The above approaches require that the service-specific connection is provisioned to lead to a custom destination meta-network that is unlikely to be requested by other applications.  Custom networks can be created using CM_Networks configuration service provider.  If a service-specific connection points to a well known network is, such as “The Internet” or “Work”, then CM may connect applications such as Mobile Internet Explorer (IE) over the connection even in the presence of other more appropriate connections.  If the service-specific connection is not able to honor Mobile IE’s HTTP requests then this misconfiguration will lead to failures in many applications and a bad user experience.


 


Option 1 is simple to implement, but has limitations.  First, since the application is specifically asking for the one connection, CM will be forced to use that connection by itself without any proxies that may be required to access the service.  In this case, the application will need to be also configured with the proxy information.  Second, if the service is accessible using more than one connection, then CM will not be able to select the best connection for the given moment, and the application will need to know about the different options and implement the selection logic.


 


The preferred option in associating an application to a connection is option 2, association by meta-network.  Although this option requires more configuration, it is flexible and doesn’t have the limitations associated with the first option.  For example, consider a Premium Service available as a custom network “Premium Service Network” and exposed by:


·         A WiFi connection:  PREMIUM à “Premium Services Network”


·         Across a HTTP proxy over any connection connecting to the Internet:  “The Internet” à Premium Services HTTP Proxy à “Premium Service Network”


 


With this configuration, an application wanting to access the Premium Service Network could find it in list of ConnMgrEnumDestinations and have CM choose the best connection for the application to connect.  The XML configuration that supports this example follows.


 


<wap-provisioningdoc>


 


   <characteristic type="CM_Networks">


      <characteristic type="Premium Services Network">


         <parm name="DestId" value="{275abb2d-829f-420e-9533-256651e04a66}"/>


      </characteristic>


   </characteristic>


 


   <characteristic type="Wi-Fi">


      <characteristic type="access-point">


         <characteristic type="PREMIUM">


            <parm name="DestId" value="{275abb2d-829f-420e-9533-256651e04a66}"/>


         </characteristic>


      </characteristic>


   </characteristic>


 


   <characteristic type="CM_ProxyEntries">


      <characteristic type="Premium Services HTTP Proxy">


         <parm name="SrcId" value="{436EF144-B4FB-4863-A041-8F905A62C572}" />


         <parm name="DestId" value="{275abb2d-829f-420e-9533-256651e04a66}" />


         <parm name="Proxy" value="proxyservername:80" />


         <parm name="Type" value="1" />


      </characteristic>


   </characteristic>


 


</wap-provisioningdoc>


 


References:


·         Meta-networks Configuration Service Provider @ http://msdn.microsoft.com/library/default.asp?url=/library/en-us/mobilesdk5/html/wce51grfcm_proxyentriescsp.asp


·         WiFi Configuration Service Provider @ http://msdn.microsoft.com/library/default.asp?url=/library/en-us/mobilesdk5/html/wce51grfcm_proxyentriescsp.asp


·         Proxy Configuration Service Provider @ http://msdn.microsoft.com/library/default.asp?url=/library/en-us/mobilesdk5/html/wce51grfcm_proxyentriescsp.asp


 


[Author: Adam Dyba]

Comments (7)

  1. vagrant says:

    I enjoyed the article, but have a few questions about the provisioning. In my app I will need to connect via GPRS and Wifi. (most likely wifi during the morning and evening, and GPRS during the day. The traffic will be FTP. I want to be able to force the connection type (Wifi or GPRS). I understand how to provision a wifi connection to connect to “The Internet”.

    <wap-provisioningdoc>

      <characteristic type=”Wi-Fi”>

         <characteristic type=”access-point”>

            <characteristic type=”TESTAP”>

               <parm name=”DestId” value=”{436EF144-B4FB-4863-A041-8F905A62C572}”/>

            </characteristic>

         </characteristic>

      </characteristic>

    </wap-provisioningdoc>

    How would I use this in the call to ConnMgrMapConRef()? From other reading it looks as if I would need to pass a connection name to the call to ConnMgrMapConref()?? Also what is the difference in the two values of the first parameter?

    Do I need to have the WLAN radio powered on before the call to ConnMgrMapConRef()?

    Also, how did you come up with the destId guid values in your example above for CM_Networks and Wi-Fi??

    Pretty new to connection manager as you can probably tell from the questions.

    Dev env: Smartphone WM 5.0, C++

    Thanks for any info on this.

  2. vagrant says:

    How would you scan for available wireless networks within an application? I am developing an app that will upload images over GPRS and WLAN. In our network we have quite a few access points, some with different security than others. I would like to be able to scan of wireless access points and based on name and security, provide the correct credentials to connect via WLAN. Thanks for any input on this

  3. cenet says:

    vagrant:  answers to your questions follow.

    1.  When the WiFi connection (TESTAP) is connected it should be accessible using ConnMgrMapConRef / ConnMgrEstablishConnection by its SSID "TESTAP".

    2.  Yes, the WiFi adapter needs to be powered-on and it needs to be associated with an AP prior to calling ConnMgrMapConRef.  You can listen for connection status change notifications by registering with ConnMgrRegisterForStatusChangeNotification, see MSDN for more info.

    3.  To create a GUID for a new meta-network, you can use guidgen.exe, see MSDN for more info.

    4.  The WiFi Zero Config (WZC) automatically takes care of scanning for available SSIDs and will connect on the most preferred one (in WZC preference list) that is in range.  On WM, WiFi Configuration Service Provider or UI can be used to populate the WZC preference list.  In your scenario, you could populate this list such that more secure SSIDs are listed first followed by less secure ones.  [Author:  Adam Dyba]

  4. vagrant says:

    cenet thanks for your reply.

    In your reply #2 you mentioned the Wifi adapter needs to be powered up. I am using SetDevicePower() to set the adapter to power state D0. And this is working fine. You then mentioned it needs to be associated with an AP. What call do I use to perform the assoication?? What interface layer??

    In my current app I am powering up WiFi but the connection is not coming up. I am assuming that this is because I have not performed the association.

    Thanks!

  5. cenet says:

    vagrant:  I tried to cover this in the earlier response to 4., more details follow.  The WZC preference list needs to be populated with the SSID(s) that you would like the WiFi interface to associate with (when the interface is up and the SSID is in range).  You can populate the preference list using the "Wi-Fi" configuration service provider, see http://msdn2.microsoft.com/en-us/library/aa455986.aspx for more info.  [Author:  Adam Dyba]

  6. adam_right says:

    is it possible to use only gprs connection ? How can determine the active connection is gprs or not ?

    Thanks…

  7. cenet says:

    adam_right:  Yes, it is possible to choose a GPRS connection using ConnMgrMapConRef API.  The connection can be selected amongst those that are available/configured from the list returned by ConnMgrQueryDetailedStatus API.  [Author:  Adam Dyba]

Skip to main content