How to control WiFi on the CN50
SmartSystems Settings
Using the SmartSystems API (Device Management Resource Kit, SSAPI) you can control
WiFi settings.
<?xml version="1.0" encoding="UTF-8"?>
<DevInfo Action="Set" Persist="true" SeqNo="135">
<Subsystem Name="Communications">
<Field Name="AdapterType" Path="\Communications\AdapterType">2</Field>
<Field Name="Disabled By Remote Policy" Path="\Device Settings\Features
Disabled by Policy\Wifi Disabled">0</Field>
<Group Name="802.11 Radio">
<Field Name="Funk Installed">0</Field>
<Field Name="ChangeSettingsAllowed">1</Field>
<Field Name="RadioBandsEnabled">3</Field>
<Field Name="Radio Bands">3</Field>
<Field Name="Radio Enabled">1</Field>
<Group Name="Microsoft Security">
<Field Name="Network name (SSID)">SOFTWARE</Field>
<Field Name="Infrastructure Mode">1</Field>
<Field Name="Network Authentication">1</Field>
<Field Name="Data Encryption">1</Field>
<Field Name="802.1X Authentication">0</Field>
<Field Name="Network Key Setting">0</Field>
<Field Name="Network Key Index">0</Field>
<Field Name="Radio Power Management">Disabled(CAM)</Field>
<Field Name="RTS Threshold (octets)">0</Field>
<Field Name="Hidden Network">0</Field>
</Group>
</Group>
<Group Name="IP Settings">
<Field Name="DHCP" Path="\Communications\802.11 Radio\IP
Settings\DHCP">1</Field>
<Field Name="DHCP Client Identifier" Path="\Communications\802.11 Radio\IP
Settings\DHCP Client Identifier"/>
<Field Name="IP Address" Path="\Communications\802.11 Radio\IP Settings\IP
Address" DeviceUnique="true">192.168.0.183</Field>
<Field Name="Subnet Mask" Path="\Communications\802.11 Radio\IP
Settings\Subnet Mask" DeviceUnique="true">255.255.255.0</Field>
<Field Name="Default Router" Path="\Communications\802.11 Radio\IP Settings\
Default Router" DeviceUnique="true">192.168.0.1</Field>
</Group>
<Group Name="Name Servers">
<Field Name="Primary DNS" Path="\Communications\802.11 Radio\IP
Settings\Primary DNS" DeviceUnique="true">192.168.0.1</Field>
<Field Name="Secondary DNS" Path="\Communications\802.11 Radio\IP
Settings\Secondary DNS" DeviceUnique="true"/>
<Field Name="Primary WINS" Path="\Communications\802.11 Radio\IP
Settings\Primary WINS" DeviceUnique="true">10.202.48.2</Field>
<Field Name="Secondary WINS" Path="\Communications\802.11 Radio\IP Settings\
Secondary WINS" DeviceUnique="true">10.10.1.157</Field>
</Group>
</Subsystem>
</DevInfo>
Disable notifications about new networks found
[HKEY_CURRENT_USER\ControlPanel\Notifications\{DDBD3B44-80B0-4b24-9DC4839FEA6E559E}]
"Default"="Wireless network detected"
"Options"=dword:00000000
Switch on/off WiFi (and other wireless)
Using ossvcs.dll in C++
WRLSPWR.h
//WRLSPWR.H
#pragma once
// Types of radio device
typedef enum _RADIODEVTYPE
{
RADIODEVICES_MANAGED = 1,
RADIODEVICES_PHONE,
RADIODEVICES_BLUETOOTH,
} RADIODEVTYPE;
// whether to save before or after changing state
typedef enum _SAVEACTION
{
RADIODEVICES_DONT_SAVE = 0,
RADIODEVICES_PRE_SAVE,
RADIODEVICES_POST_SAVE,
} SAVEACTION;
// Details of radio devices
struct RDD
{
RDD() : pszDeviceName(NULL), pNext(NULL), pszDisplayName(NULL) {}
~RDD()
{
LocalFree(pszDeviceName);
LocalFree(pszDisplayName);
}
LPTSTR pszDeviceName; // Device name for registry setting.
LPTSTR pszDisplayName; // Name to show the world
DWORD dwState; // ON/off/[Discoverable for BT]
DWORD dwDesired; // desired state - used for setting registry etc.
RADIODEVTYPE DeviceType; // Managed, phone, BT etc.
RDD * pNext; // Next device in list
}; //radio device details
wirelessdevices.h
//wirelessdevices.h
#pragma once
#include "wrlspwr.h"
#include "Wininet.h"
#include <service.h>
#pragma comment(lib, "Wininet.lib")
// WLAN Switch
#define _WLAN_SWITCH_OFF 0
#define _WLAN_SWITCH_ON 1
// Phone Switch
#define _PHONE_SWITCH_OFF 0
#define _PHONE_SWITCH_ON 1
// BT Switch
#define _BT_SWITCH_OFF 0
#define _BT_SWITCH_ON 1
//
#define GetWirelessDevice_ORDINAL 276
#define ChangeRadioState_ORDINAL 273
#define FreeDeviceList_ORDINAL 280
//imports from ossvcs.dll
typedef LRESULT (CALLBACK* _GetWirelessDevices)(RDD **pDevices, DWORD dwFlags);
typedef LRESULT (CALLBACK* _ChangeRadioState)(RDD* pDev, DWORD dwState, SAVEACTION
sa);
typedef LRESULT (CALLBACK* _FreeDeviceList)(RDD *pRoot);
//Header of further functions
DWORD GetWDevState(DWORD* bWifi, DWORD* bPhone, DWORD* bBT);
DWORD SetWDevState(DWORD dwDevice, DWORD dwState);
BOOL DeinitDLL();
BOOL InitDLL();
//
wirelessdevice.cpp
//wirelessdevice.cpp
#include "stdafx.h"
#include "WirelessDevices.h"
_GetWirelessDevices pGetWirelessDevices = NULL;
_ChangeRadioState pChangeRadioState = NULL;
_FreeDeviceList pFreeDeviceList = NULL;
HINSTANCE g_DllWrlspwr;
BOOL InitDLL()
{
g_DllWrlspwr = LoadLibrary(TEXT("ossvcs.dll"));
if (g_DllWrlspwr == NULL)
return FALSE;
pGetWirelessDevices =
(_GetWirelessDevices)GetProcAddress(g_DllWrlspwr,MAKEINTRESOURCE(GetWirelessDevice
_ORDINAL));
if (pGetWirelessDevices == NULL)
return FALSE;
pChangeRadioState =
(_ChangeRadioState)GetProcAddress(g_DllWrlspwr,MAKEINTRESOURCE(ChangeRadioState_OR
DINAL));
if (pChangeRadioState == NULL)
return FALSE;
pFreeDeviceList =
(_FreeDeviceList)GetProcAddress(g_DllWrlspwr,MAKEINTRESOURCE(FreeDeviceList_ORDINA
L));
if (pFreeDeviceList == NULL)
return FALSE;
return TRUE;
}
BOOL DeinitDLL()
{
return FreeLibrary(g_DllWrlspwr);
}
//set the status of the desired wireless device
DWORD SetWDevState(DWORD dwDevice, DWORD dwState)
{
RDD * pDevice = NULL;
RDD * pTD;
HRESULT hr;
DWORD retval = 0;
// InitDLL();
hr = pGetWirelessDevices(&pDevice, 0);
if(hr != S_OK) return -1;
if (pDevice)
{
pTD = pDevice;
// loop through the linked list of devices
while (pTD)
{
if (pTD->DeviceType == dwDevice)
{
hr = pChangeRadioState(pTD, dwState, RADIODEVICES_PRE_SAVE);
retval = 0;
}
pTD = pTD->pNext;
}
// Free the list of devices retrieved with
// GetWirelessDevices()
pFreeDeviceList(pDevice);
}
if(hr == S_OK)return retval;
return -2;
}
//*********pls see this is getWdevstate***********
//get status of all wireless devices at once
DWORD GetWDevState(DWORD* bWifi, DWORD* bPhone, DWORD* bBT)
{
RDD * pDevice = NULL;
RDD * pTD;
HRESULT hr;
DWORD retval = 0;
hr = pGetWirelessDevices(&pDevice, 0);
if(hr != S_OK) return -1;
if (pDevice)
{
pTD = pDevice;
// loop through the linked list of devices
while (pTD)
{
switch (pTD->DeviceType)
{
case RADIODEVICES_MANAGED:
*bWifi = pTD->dwState;
break;
case RADIODEVICES_PHONE:
*bPhone = pTD->dwState;
break;
case RADIODEVICES_BLUETOOTH:
*bBT = pTD->dwState;
break;
default:
break;
}
pTD = pTD->pNext;
}
// Free the list of devices retrieved with
// GetWirelessDevices()
pFreeDeviceList(pDevice);
}
if(hr == S_OK)
return retval;
return -2;
}
/*
//on initdialog add following code
InitDLL();
DWORD dwWifi;
UpdateData(TRUE);
GetWDevState(&dwWifi);
if(dwWifi == 1)
str=TEXT("ON");
//str is textbox varriable
else
str=TEXT("OFF");
UpdateData(FALSE);
//on clicking ON button following code will be executed
SetWDevState( RADIODEVICES_MANAGED, 1);
DWORD dwWifi;
GetWDevState(&dwWifi);
UpdateData(TRUE);
if(dwWifi == 1)
str=TEXT("ON");
else
str=TEXT("OFF");
UpdateData(FALSE);
//and on off button
SetWDevState( RADIODEVICES_MANAGED, 0);
DWORD dwWifi;
UpdateData(TRUE);
GetWDevState(&dwWifi);
if(dwWifi == 1)
str=TEXT("ON");
else
str=TEXT("OFF");
UpdateData(FALSE);
*/
C# class code: See RadioManager at
http://forum.xda-developers.com/showthread.php?t=413159
© Copyright 2025