⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 findservices.java

📁 服务器端源文件:btServer-20050819.zip
💻 JAVA
字号:
/*  * Description : Bluetooth Service Discovery Protocol Helper Class *  * Notes :  *  * Assigned Numbers - Service Discovery Protocol  * https://www.bluetooth.org/foundry/assignnumb/document/service_discovery * * SDP										0x0001			16-bit * RFCOMM									0x0003			16-bit * OBEX										0x0008			16-bit * HTTP										0x000C			16-bit * L2CAP									0x0100			16-bit * BNEP										0x000F			16-bit * Serial Port								0x1101			16-bit * ServiceDiscoveryServerServiceClassID		0x1000 			16-bit * OBEX Object Push Profile					0x1105			16-bit * OBEX File Transfer Profile				0x1106			16-bit *  * ServiceRecordHandle						0x0000 	32-bit unsigned integer * ServiceClassIDList						0x0001 	DATSEQ of UUIDs * ServiceRecordState						0x0002 	32-bit unsigned integer * ServiceID								0x0003 	UUID * ProtocolDescriptorList					0x0004 	DATSEQ of DATSEQ of UUID and optional parameters * BrowseGroupList							0x0005 	DATSEQ of UUIDs * LanguageBasedAttributeIDList				0x0006 	DATSEQ of DATSEQ triples * ServiceInfoTimeToLive					0x0007 	32-bit unsigned integer * ServiceAvailability						0x0008 	8-bit unsigned integer * BluetoothProfileDescriptorList			0x0009 	DATSEQ of DATSEQ pairs * DocumentationURL							0x000A 	URL * ClientExecutableURL						0x000B	URL * IconURL									0x000C	URL * VersionNumberList						0x0200 	DATSEQ of 16-bit unsigned integers * ServiceDatabaseState						0x0201 	32-bit unsigned integer * * LICENSE : This code is licensed under GPL. (See http://www.gnu.org/copyleft/gpl.html) *  * findService.java @version 1.0 * Created on Jun 13, 2005 *  * This class is modified from the class clientTest from the aveTest package.  * aveTest are the source code examples that came with avetanaBluetooth package. *  * Hacked by renyi, allows find services by uuid. *  */package btServer;import javax.bluetooth.DeviceClass;import javax.bluetooth.DiscoveryListener;import javax.bluetooth.RemoteDevice;import javax.bluetooth.UUID;import javax.bluetooth.DiscoveryAgent;import javax.bluetooth.LocalDevice;import javax.bluetooth.ServiceRecord;import javax.bluetooth.BluetoothStateException;/** * @author renyi *  * @param * @return * */public class findServices implements DiscoveryListener {             private String url = null;    private int transID;    private boolean searchCompleted = false; 	public void deviceDiscovered(RemoteDevice btDevice, DeviceClass cod) {	}			public void inquiryCompleted(int discType) {	}		public void serviceSearchCompleted(int transID, int respCode) {  	    searchCompleted = true; 	    }		public void servicesDiscovered(int transID, ServiceRecord[] servRecord) {	    url = servRecord[0].getConnectionURL(ServiceRecord.NOAUTHENTICATE_NOENCRYPT, false );  	}    public findServices (String addr, String uuid, UUID[] uuids) {				try {		DiscoveryAgent da = LocalDevice.getLocalDevice().getDiscoveryAgent();					        // Look for OBEX FTP		//UUID[] uuids = { new UUID(0x1105), new UUID(0x1106) };		//UUID[] uuids = { new UUID(0x1105) };				transID = da.searchServices(null, uuids, new RemoteDevice (addr), this);		while (!searchCompleted) {			synchronized (this) { wait(100); }		}				} 		catch (BluetoothStateException be) {}		catch (InterruptedException ie) {}		    }        public String getUrl () {        return url;    }        public int getTransID () {        return transID;    }          /*     * Testing only     */    public static void main(String[] args) {        //findServices f = new findServices("000A2874B063","102030405060708090A0B0C0D0E0F010");        //findServices f = new findServices("000EEDF4ADD4","102030405060708090A0B0C0D0E0F010");                //System.out.println(f.getUrl());    }}        

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -