Managing Multiple Network Connections in Windows Embedded HH 6.5

Anonymous (not verified) -
5 MIN READ

Handheld devices in enterprise environments typically don't use a single network connection for communication.  The devices can be connected through wireless LAN, cellular, Bluetooth, and even wired Ethernet.  To add to that, these can be connected independent of each other or all at the same time.  Windows Embedded HH 6.5 allows multiple interfaces to be up simultaneously and will allow the device to have multiple IP addresses.  The Microsoft Connection Manager (http://msdn.microsoft.com/en-us/library/ms849587.aspx) is responsible for handling connection requests from applications and automatically deciding the "least cost" interface to use.  Typically it will prefer wired Ethernet to wireless LAN and wireless LAN to cellular.  This works well in most cases however there can be situations where the best suited connection for the customer is not the "least cost" connection as decided by Connection Manger.  There are also power considerations when dealing with multiple radios.  Leaving all radios active at all times can have a detrimental effect on battery performance with little to no gain.  In this blog I will explain some best practices when dealing with multiple connections and then provide some details on implementation.

 

Suggested Practices

 

  • Control power to radios that aren't needed or aren't in use.  By powering off the radios that you do not want to use, Connection Manager is forced to use only the connection that remains.  This method had the added benefit of saving battery power by turning off radios when they aren't needed.
  • Consider using power notifications to suggest that terminal is in or out of WiFi coverage.  In some situations, devices are out in cellular coverage during the day and are only in WiFi coverage when they are brought back to a central depot to charge following a shift.  In this case a notification that the device is charging could be a good indicator for the application to power on the WiFi radio.
  • Periodically power on the WiFi radio to check if a known network is available.  If no network is available, shut down the radio and increase the time until the next check to prevent frequent power cycles when out of WiFi coverage long periods of time.
  • Use Microsoft's Connection Manager when multiple connections exist.

 

Wireless LAN - Power Control

  • Use Fusion Public API (FAPI) to enable and disable radio power.
  • Call OpenFusionAPI() with COMMAND_MODE.
    • Note: Command mode can only be open by a single application at any given time.  It is recommended only to open command mode for the time necessary to send the command.  Applications should not hold an open command mode context for an extended period to ensure interoperability with other applications.
  • Call CommandFusionAPI()
    • POWER_CONTROL_WLAN_DISABLE_POWER
    • POWER_CONTROL_WLAN_ENABLE_POWER
  • Alternate Method
    • Call DevicePowerNotify(L"WLP1:", D0, 1);
      • D0 - On
      • D4 - Off

 

Wireless LAN - Getting Status

  • Use Fusion public API (FAPI) to get WLAN status
  • Call OpenFusionAPI() with STAT_MODE
  • Call CommandFusionAPI()
  • The following commands provide useful information from the WLAN radio:
    • ADAPTER_INFO_WLAN
    • RF_SIGNAL_STRENGTH_WLAN_GET
    • RF_SIGNAL_QUALITY_WLAN_GET
    • WLAN_ADAPTER_STATISTICS_GET
    • FUSION_DIAG_LOG_SAVE

 

Cellular - Power Management

  • Use Microsoft TAPI commands to Enable/Disable the WAN radio
  • lineSetEquipmentState with:
    • LINEEQUIPSTATE_FULL – On
    • LINEEQUIPSTATE_MINIMUM – Off
  • See WANSample in the Motorola Solutions EMDK for C for more information

 

Cellular - Getting Status

  • The following TAPI calls provide useful information from the WAN radio:
  • lineGetCurrentSystemType – GSM, CDMA, IDEN, etc
    • lineGetRegisterStatus – Registration status (roam, home)
    • lineGetLineDevStatus – Signal strength
  • See WANSample in the Motorola Solutions EMDK for C for more information

 

Bluetooth - Power Management

  • When using the Stonestreet One BT stack, the recommended way to enable/disable Bluetooth is by using the OEMBthSetMode exposed by SS1PWMGR.dll:

          hInstance = LoadLibrary(L"SS1PWMGR.dll");

          // If the lib was found, try and find the OEMBthGetMode/OEMBthSetMode functions

          if(hInstance)

          {

                     pBthGetMode = (int (*)(DWORD *pdwMode))GetProcAddress( hInstance,    L"OEMGetBthPowerState");

                     pBthSetMode = (int (*)(DWORD dwMode))GetProcAddress( hInstance, L"OEMSetBthPowerState");

                     if(pBthGetMode) // be sure to check the ptr before using it

                     {

                         pBthGetMode (&pdwMode);

                     }

                     if(pBthSetMode)

                     {

                         pBthSetMode (dwNewState);

                     }

          };

 

  • Note:  For WM devices, the Microsoft API BthSetMode() will also work

 

Bluetooth - Getting Status (Stonestreet One stack)

  • Use BTExplorer (provisioning) API to enumerate connections:
    • BTPFindFirstConnection
    • BTPFindNextConnection
    • Use BTP_Connection_Query_t structure to filter types of connections to return (Active, All, etc.)

 

  • Returns BTP_Connection_Info_t structure:

typedef struct

{

          BTP_Connection_ID            ConnectionID;

          BD_ADDR_t                            BD_ADDR;

          unsigned int                         RFCOMMPort;

          int                                       LocalCOMPort;

          unsigned char                       MajorVersion;

          unsigned char                       MinorVersion;

          Word_t                                ConnectionAttributes;

          BTP_Profile_Type               ProfileType;

} BTP_Connection_Info_t;

 

Using Microsoft Connection Manager

  • Connection Manager exposes functionality to explicitly request a certain interface be used for the requested connection:
    • ConnMgrMapConRef() will return a destination network GUID when given the name of a network connection (ex. My Connection).
    • Calling ConnMgrEstablishConnectionSync() with the GUID from ConnMgrMapConRef() will ensure the supplied connection path is used even if it is not the “least cost”
  • If a cellular connection had an entry in the "Connections" settings applet, it can be referred to by its name when calling ConnMgrMapConRef.  Other adapters (like WiFi or ethernet) must be added to Connection Manager by means of XML provisioning.  The following example shows how to add a network connection called "Wifi Connection" that will correspond to the Wifi adapter named "NPME\JEDI10_1".  Note that the adapter name will change based on the specific WiFi adapter in the device.  You can use GetAdaptersInfo() to retrieve all of the adapter names in the system.

 

         

                   

                             

                             

                   

         

 

Additional Information

Additional information on using Connection Manager can be found here: http://msdn.microsoft.com/en-us/library/bb840031.aspx .

profile

Anonymous (not verified)

Dfghjkjjn

Please register or login to post a reply

1 Replies

B Bo Nielsen

A C# version using standard Windows Mobile 6.5 API BthSetMode can be found on MSDN here:

<a href="http://msdn.microsoft.com/en-us/library/bb416244.aspx">Changing the Bluetooth Radio Mode</a>

Note: I was unable to get BthGetMode to work on the latest SS1 stack but BthSetMode works fine.

One could wonder why Symbol.WPAN.Bluetooth RadioMode is read only on SS1 stack... refer to Bluetooth Programmer’s Guide in EMDK 2.8