📄 linkprotocoltest.java
字号:
/*
Copyright (c) 2008, Intel Corporation.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.
* Neither the name of Intel Corporation nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/import java.util.*;import com.intel.mobile.base.IntelMobileException;import com.intel.mobile.network.*;/** * <class or interface desc> */public class LinkProtocolTest{ private LinkProtocolClass myClass; private Protocol802_3Class my802_3Class; private Protocol802_11Class my802_11Class; private ProtocolWwanClass myWwanClass; private ProtocolGprsClass myGprsClass; private ProtocolCdmaClass myCdmaClass; private ProtocolBluetoothPanClass myBluetoothClass; public LinkProtocolTest(LinkProtocolClass myClass, Protocol802_3Class my802_3Class, Protocol802_11Class my802_11Class, ProtocolWwanClass myWwanClass, ProtocolGprsClass myGprsClass, ProtocolCdmaClass myCdmaClass, ProtocolBluetoothPanClass myBluetoothClass) { this.myClass = myClass; this.my802_3Class = my802_3Class; this.my802_11Class = my802_11Class; this.myWwanClass = myWwanClass; this.myGprsClass = myGprsClass; this.myCdmaClass = myCdmaClass; this.myBluetoothClass = myBluetoothClass; } public void printInfo() throws IntelMobileException { LinkProtocolCollection myCollection = (LinkProtocolCollection)myClass.GetInstances(); myCollection.Reset(); LinkProtocolInstance myInstance = null; while ( myCollection.HasNext() ) { myInstance = (LinkProtocolInstance)myCollection.Next(); StringBuffer strBuf = new StringBuffer(); strBuf.append("\n------------ Output Link Protocol Properties ------------\n"); String type = myInstance.GetType(); strBuf.append("Type: ").append(type).append("\n"); String key = myInstance.GetKey(); strBuf.append("Key: ").append(key).append("\n"); strBuf.append(ConsoleTestHelper.printp(myInstance.DataRateRx, "DataRateRx")); if (!myInstance.DataRateRx.IsNull()) strBuf.append("DataRateRx = ").append(myInstance.DataRateRx.GetValue()).append("\n"); //strBuf.append(ConsoleTestHelper.printp(myInstance.DataRateTx, "")) if ( !myInstance.IpAddress.IsNull() ) { String value = myInstance.IpAddress.GetValue(); strBuf.append("IpAddress: ").append(value).append("\n"); } if ( !myInstance.Enabled.IsNull() ) { boolean value = myInstance.Enabled.GetValue(); strBuf.append("Enabled: ").append(value).append("\n"); } if ( !myInstance.TxPower.IsNull() ) { int value = myInstance.TxPower.GetValue(); strBuf.append("TxPower: ").append(value).append("\n"); } if ( !myInstance.DataRateRx.IsNull() ) { long value = myInstance.DataRateRx.GetValue(); strBuf.append("DataRateRx: ").append(value).append("\n"); } if ( !myInstance.DataRateTx.IsNull() ) { long value = myInstance.DataRateTx.GetValue(); strBuf.append("DataRateTx: ").append(value).append("\n"); } if ( !myInstance.Id.IsNull() ) { String value = myInstance.Id.GetValue(); strBuf.append("Id: ").append(value).append("\n"); } if ( !myInstance.MaxLinkSpeed.IsNull() ) { long value = myInstance.MaxLinkSpeed.GetValue(); strBuf.append("MaxLinkSpeed: ").append(value).append("\n"); } if ( !myInstance.MediaPresent.IsNull() ) { boolean value = myInstance.MediaPresent.GetValue(); strBuf.append("MediaPresent: ").append(value).append("\n"); } if ( !myInstance.State.IsNull() ) { ProtocolStateEnum value = myInstance.State.GetValue(); strBuf.append("State: ").append(value).append("\n"); } if ( !myInstance.DataRatesRx.IsNull() ) { int size = myInstance.DataRatesRx.GetSize(); for (int i = 0; i < size; i++) { long value = myInstance.DataRatesRx.GetValue(i); strBuf.append("DataRatesRx.[").append(i).append("]: ") .append(value).append("\n"); } } if ( !myInstance.DataRatesTx.IsNull() ) { int size = myInstance.DataRatesTx.GetSize(); for (int i = 0; i < size; i++) { long value = myInstance.DataRatesTx.GetValue(i); strBuf.append("DataRatesTx.[").append(i).append("]: ") .append(value).append("\n"); } } //strBuf.append("------------ Link Protocol Properties ------------\n\n"); System.out.print( strBuf.toString() ); if ( type.equals("Protocol802_3") ) { print802_3Info(key); } else if ( type.equals("Protocol802_11") ) { print802_11Info(key); } else if ( type.equals("ProtocolBluetoothPan") ) { printBluetoothInfo(key); } else if ( (type.equals("ProtocolWwan")) || (type.equals("ProtocolGprs")) || (type.equals("ProtocolCdma")) ) { printWwanInfo(key); if (type.equals("ProtocolGprs")) printGprsInfo(key); else if (type.equals("ProtocolCdma")) printCdmaInfo(key); } } } public void queryInfo() { } private void print802_3Info(String sKey) throws IntelMobileException { Protocol802_3Instance my802_3Instance = (Protocol802_3Instance)my802_3Class.GetInstance(sKey); StringBuffer strBuf = new StringBuffer(); strBuf.append("\n------------ Output Protocol 802.3 Properties ------------\n"); String type = my802_3Instance.GetType(); strBuf.append("Type: ").append(type).append("\n"); String key = my802_3Instance.GetKey(); strBuf.append("Key: ").append(key).append("\n"); if ( !my802_3Instance.MacAddress.IsNull() ) { //String value = my802_3Instance.MacAddress.GetValue(); //strBuf.append("MacAddress: ").append(value).append("\n"); int size = my802_3Instance.MacAddress.GetSize(); for (int i = 0; i < size; i++) { byte value = my802_3Instance.MacAddress.GetValue(i); strBuf.append("MacAddress[").append(i).append("]: ") .append(value).append("\n"); } } /*if ( !my802_3Instance.PermanentAddress.IsNull() ) { String value = my802_3Instance.PermanentAddress.GetValue(); strBuf.append("PermanentAddress: ").append(value).append("\n"); }*/ if ( !my802_3Instance.MulticastAddresses.IsNull() ) { int size = my802_3Instance.MulticastAddresses.GetSize(); for (int i = 0; i < size; i++) { String value = my802_3Instance.MulticastAddresses.GetValue(i); strBuf.append("MulticastAddresses[").append(i).append("]: ") .append(value).append("\n"); } } strBuf.append("------------ Protocol 802.3 Properties ------------\n\n"); System.out.print( strBuf.toString() ); } private void print802_11Info(String sKey) throws IntelMobileException { Protocol802_11Instance my802_11Instance = (Protocol802_11Instance)my802_11Class.GetInstance(sKey); StringBuffer strBuf = new StringBuffer(); strBuf.append("\n------------ Output Protocol 802.11 Properties ------------\n"); String type = my802_11Instance.GetType(); strBuf.append("Type: ").append(type).append("\n"); String key = my802_11Instance.GetKey(); strBuf.append("Key: ").append(key).append("\n"); //scan ap List apList = my802_11Instance.ScanAps(); printInfo( apList ); if ( !my802_11Instance.MacAddress.IsNull() ) { //String value = my802_11Instance.MacAddress.GetValue(); //strBuf.append("MacAddress: ").append(value).append("\n"); int size = my802_11Instance.MacAddress.GetSize(); for (int i = 0; i < size; i++) { byte value = my802_11Instance.MacAddress.GetValue(i); strBuf.append("MacAddress[").append(i).append("]: ") .append(value).append("\n"); } }// if ( !my802_11Instance.PermanentAddress.IsNull() )// {// String value = my802_11Instance.PermanentAddress.GetValue();// strBuf.append("PermanentAddress: ").append(value).append("\n");// } if ( !my802_11Instance.MulticastAddresses.IsNull() ) { int size = my802_11Instance.MulticastAddresses.GetSize(); for (int i = 0; i < size; i++) { String value = my802_11Instance.MulticastAddresses.GetValue(i); strBuf.append("MulticastAddresses[").append(i).append("]: ") .append(value).append("\n"); } } if ( !my802_11Instance.AtimWindow.IsNull() ) { int value = my802_11Instance.AtimWindow.GetValue(); strBuf.append("AtimWindow: ").append(value).append("\n"); } if ( !my802_11Instance.BeaconPeriod.IsNull() ) { int value = my802_11Instance.BeaconPeriod.GetValue(); strBuf.append("BeaconPeriod: ").append(value).append("\n"); } if ( !my802_11Instance.Bssid.IsNull() ) { //String value = my802_11Instance.BssId.GetValue(); //strBuf.append("BssId: ").append(value).append("\n"); int size = my802_11Instance.Bssid.GetSize(); for (int i = 0; i < size; i++) { byte value = my802_11Instance.Bssid.GetValue(i); strBuf.append("Bssid[").append(i).append("]: ") .append(value).append("\n"); } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -