Pages

Saturday, September 10, 2011

WiFi Radio Toggle in smart device (Symbol.Fusion dll)

I was working on to Enable/Disable it Wifi on Motorola MC17 device . After some effort I found the solution to enable/Disable it wifi Radio. I am Using Symbol.Fusion dll to get toggle wifi radio. there are some other ways also to Like P/invoke with .Net etc. here I will put both ways . you can take the reference of that. Here I am putting sourcecode for your reference.

public class WiFiRadio
{
    WLAN myCommandModeWlan = null;
    public WiFiRadio()
    {
        InitializeWiFi();
    }
    public void InitializeWiFi()
    {
        try
        {
            myCommandModeWlan = new WLAN(FusionAccessType.COMMAND_MODE);
        }
        catch (OperationFailureException ex)
        {
            System.Windows.Forms.MessageBox.Show("Command mode is in use", "WiFiMgr");
        }
    }
    public void ToggleWiFi(bool enableWiFi)
    {
        try
        {
            if (myCommandModeWlan != null)
            {
                if (enableWiFi)
                {
                    myCommandModeWlan.Adapters[0].PowerState = Adapter.PowerStates.ON;
                }
                else
                {
                    myCommandModeWlan.Adapters[0].PowerState = Adapter.PowerStates.OFF;
                }

            }

        }
        catch (OperationFailureException ex)
        {
            System.Windows.Forms.MessageBox.Show("Command mode is in use", "WiFiMgr");
        }
    }
    public bool GetCurrentStatus()
    {
        if (myCommandModeWlan.Adapters[0].PowerState == Adapter.PowerStates.ON)
        {
            return true;
        }
        else
        {
            return false;
        }
    }
}

Note: You Need To Take The Reference Of Symbol.fusion dll

3 comments: