当前位置: 首页>>代码示例>>Java>>正文


Java ServiceRecord类代码示例

本文整理汇总了Java中javax.bluetooth.ServiceRecord的典型用法代码示例。如果您正苦于以下问题:Java ServiceRecord类的具体用法?Java ServiceRecord怎么用?Java ServiceRecord使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ServiceRecord类属于javax.bluetooth包,在下文中一共展示了ServiceRecord类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: serviceSearchCompleted

import javax.bluetooth.ServiceRecord; //导入依赖的package包/类
@Override
public void serviceSearchCompleted(int arg0, int arg1) {
	
	Map<String, ServiceRecord> ports = new HashMap<String, ServiceRecord>();
	
	for (Entry<RemoteDevice, ServiceRecord[]> entry : services.entrySet()) {
		RemoteDevice remoteDevice = entry.getKey();
		ServiceRecord service = findService(entry.getValue());
		if (service != null) {
			String name = "noname";
			try {
				name = remoteDevice.getFriendlyName(false);
			} catch (Exception e) {
			}

			name += " " + remoteDevice.getBluetoothAddress();
			ports.put(name, service);
		}
	}
	
	bluetoothConnection.setPorts(ports);
	
       synchronized (lock) {
           lock.notify();
       }
}
 
开发者ID:Ardulink,项目名称:Ardulink-1,代码行数:27,代码来源:ArdulinkDiscoveryListener.java

示例2: servicesDiscovered

import javax.bluetooth.ServiceRecord; //导入依赖的package包/类
@Override
public void servicesDiscovered(int transaction, ServiceRecord[] services) {
	for (ServiceRecord record : services) {
		// Does this service have a URL?
		String serviceUrl = record.getConnectionURL(
				ServiceRecord.NOAUTHENTICATE_NOENCRYPT, false);
		if (serviceUrl == null) continue;
		// Does this service have the UUID we're looking for?
		Collection<String> uuids = new TreeSet<>();
		findNestedClassIds(record.getAttributeValue(0x1), uuids);
		for (String u : uuids) {
			if (uuid.equalsIgnoreCase(u)) {
				// The UUID matches - store the URL
				url = serviceUrl;
				finished.countDown();
				return;
			}
		}
	}
}
 
开发者ID:rafjordao,项目名称:Nird2,代码行数:21,代码来源:InvitationListener.java

示例3: PAKBluetoothPairingHandler

import javax.bluetooth.ServiceRecord; //导入依赖的package包/类
public PAKBluetoothPairingHandler(String password, String eMail,
		String firstName, String lastName, String deviceName,
		X509Certificate ownerCertEnc, X509Certificate ownerCertSign,
		Map<String, X509Certificate> knownDevices,
		Collection<VCard> knownContacts) throws IOException {
	super(PairingType.SLAVE, password, eMail, firstName, lastName,
			deviceName, ownerCertEnc, ownerCertSign, knownDevices,
			knownContacts);
	UUID uuid = new UUID(0x1101); // TODO: Create new unique UUID
	String connectionString = "btspp://localhost:" + uuid
			+ ";name=PanboxImportListener;encrypt=false;authenticate=false";
	streamConnNotifier = (StreamConnectionNotifier) Connector.open(
			connectionString, Connector.READ_WRITE);
	ServiceRecord record = LocalDevice.getLocalDevice().getRecord(
			streamConnNotifier);
	logger.debug("PAKBluetoothPairingHandler : connection is up at: "
			+ record.getConnectionURL(0, false));
}
 
开发者ID:Rohde-Schwarz-Cybersecurity,项目名称:PanBox,代码行数:19,代码来源:PAKBluetoothPairingHandler.java

示例4: servicesDiscovered

import javax.bluetooth.ServiceRecord; //导入依赖的package包/类
public void servicesDiscovered(int transaction, ServiceRecord[] services) {
	for(ServiceRecord record : services) {
		// Does this service have a URL?
		String serviceUrl = record.getConnectionURL(
				ServiceRecord.NOAUTHENTICATE_NOENCRYPT, false);
		if(serviceUrl == null) continue;
		// Does this service have the UUID we're looking for?
		Collection<String> uuids = new TreeSet<String>();
		findNestedClassIds(record.getAttributeValue(0x1), uuids);
		for(String u : uuids) {
			if(uuid.equalsIgnoreCase(u)) {
				// The UUID matches - store the URL
				url = serviceUrl;
				finished.countDown();
				return;
			}
		}
	}
}
 
开发者ID:kiggundu,项目名称:briar,代码行数:20,代码来源:InvitationListener.java

示例5: serialize

import javax.bluetooth.ServiceRecord; //导入依赖的package包/类
public static synchronized byte[] serialize(ServiceRecord record) {
    DataElement seq = new DataElement(DataElement.DATSEQ);
    int[] attrIDs = record.getAttributeIDs();
    for (int i = 0; i < attrIDs.length; i++) {
        DataElement attrID = new DataElement(DataElement.U_INT_2,
                attrIDs[i]);
        DataElement attrValue = record.getAttributeValue(attrIDs[i]);
        if (attrValue != null) {
            seq.addElement(attrID);
            seq.addElement(attrValue);
        }
    }
    try {
        return des.serialize(seq);
    } catch (IOException e) {
        return null;
    }
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:19,代码来源:ServiceRecordSerializer.java

示例6: getRecord

import javax.bluetooth.ServiceRecord; //导入依赖的package包/类
public ServiceRecord getRecord(Connection notifier) {
    if (notifier == null) {
        throw new NullPointerException("Null notifier specified.");
    }
    if (!(notifier instanceof BluetoothNotifier)) {
        if (!(notifier instanceof SessionNotifierImpl)) {
            throw new IllegalArgumentException("Invalid notifier class.");
        }
        Connection transport =
            ((SessionNotifierImpl)notifier).getTransport();
        if (!(transport instanceof BluetoothNotifier)) {
            throw new IllegalArgumentException("Invalid notifier class.");
        }
        return ((BluetoothNotifier)transport).getServiceRecord();
    }
    return ((BluetoothNotifier)notifier).getServiceRecord();
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:18,代码来源:LocalDeviceImpl.java

示例7: updateRecord

import javax.bluetooth.ServiceRecord; //导入依赖的package包/类
public void updateRecord(ServiceRecord srvRecord)
        throws ServiceRegistrationException {
    if (DEBUG) {
        System.out.println("LocalDeviceImpl.updateRecord");
    }
    if (srvRecord == null) {
        throw new NullPointerException("Null record specified.");
    }
    if (!(srvRecord instanceof ServiceRecordImpl)) {
        throw new IllegalArgumentException("Invalid service record class.");
    }
    ServiceRecordImpl record = (ServiceRecordImpl)srvRecord;
    BluetoothNotifier notifier = record.getNotifier();
    if (notifier == null) {
        throw new IllegalArgumentException(
                "Service record is not from local SDDB.");
    }
    notifier.updateServiceRecord(record);
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:20,代码来源:LocalDeviceImpl.java

示例8: servicesFoundCallback

import javax.bluetooth.ServiceRecord; //导入依赖的package包/类
public void servicesFoundCallback(SearchServicesThread startedNotify, DiscoveryListener listener,
		RemoteDevice device, String serviceName, byte[] uuidValue, int channel, long recordHanlde) {

	ServiceRecordImpl record = new ServiceRecordImpl(this, device, 0);

	UUID uuid = new UUID(Utils.UUIDByteArrayToString(uuidValue), false);

	record.populateRFCOMMAttributes(recordHanlde, channel, uuid, serviceName, BluetoothConsts.obexUUIDs
			.contains(uuid));
	DebugLog.debug("servicesFoundCallback", record);

	RemoteDevice listedDevice = RemoteDeviceHelper.createRemoteDevice(this, device);
	RemoteDeviceHelper.setStackAttributes(this, listedDevice, "RFCOMM_channel" + channel, uuid);

	ServiceRecord[] records = new ServiceRecordImpl[1];
	records[0] = record;
	listener.servicesDiscovered(startedNotify.getTransID(), records);
}
 
开发者ID:empeeoh,项目名称:bluecove-osx,代码行数:19,代码来源:BluetoothStackBlueSoleil.java

示例9: isAuthenticated

import javax.bluetooth.ServiceRecord; //导入依赖的package包/类
public boolean isAuthenticated() {
	if (!hasConnections()) {
		DebugLog.debug("no connections, Authenticated = false");
		return false;
	}
	Boolean authenticated = bluetoothStack.isRemoteDeviceAuthenticated(addressLong);
	if (authenticated != null) {
		return authenticated.booleanValue();
	}
	synchronized (connections) {
		// Find first authenticated connection
		for (Enumeration en = connections.elements(); en.hasMoreElements();) {
			BluetoothConnectionAccess c = (BluetoothConnectionAccess) en.nextElement();
			if (c.getSecurityOpt() != ServiceRecord.NOAUTHENTICATE_NOENCRYPT) {
				return true;
			}
		}
	}
	return false;
}
 
开发者ID:empeeoh,项目名称:bluecove-osx,代码行数:21,代码来源:RemoteDeviceHelper.java

示例10: getFromServiceCache

import javax.bluetooth.ServiceRecord; //导入依赖的package包/类
public ServiceRecord getFromServiceCache( String btAddr, String uuidStr )
{
	ServiceRecord r = null;
	try {
		r = serviceCache.get( btAddr ).get( uuidStr );
	} catch( NullPointerException e ) {}
	return r;
}
 
开发者ID:jolie,项目名称:jolie,代码行数:9,代码来源:BTL2CapChannelFactory.java

示例11: putInServiceCache

import javax.bluetooth.ServiceRecord; //导入依赖的package包/类
public void putInServiceCache( String btAddr, String uuidStr, ServiceRecord record )
{
	if ( serviceCache.size() > cacheLimit ) {
		serviceCache.remove( serviceCache.keySet().iterator().next() );
	}
	Map< String, ServiceRecord > map = serviceCache.get( btAddr );
	if ( map == null ) {
		map = new HashMap< String, ServiceRecord > ();
		serviceCache.put( btAddr, map );
	}
	if ( map.size() > cacheLimit ) {
		map.remove( map.keySet().iterator().next() );
	}
	map.put( uuidStr, record);
}
 
开发者ID:jolie,项目名称:jolie,代码行数:16,代码来源:BTL2CapChannelFactory.java

示例12: getResult

import javax.bluetooth.ServiceRecord; //导入依赖的package包/类
public ServiceRecord getResult()
{
	synchronized ( this ) {
		while ( !completed ) {
			try {
				this.wait();
			} catch ( InterruptedException e ) {
			}
		}
	}
	return serviceRecord;
}
 
开发者ID:jolie,项目名称:jolie,代码行数:13,代码来源:BTServiceDiscoveryListener.java

示例13: servicesDiscovered

import javax.bluetooth.ServiceRecord; //导入依赖的package包/类
public void servicesDiscovered( int transID, ServiceRecord[] serviceRecords )
{
	DataElement e;
	ServiceRecord r;
	Enumeration< DataElement > en;
	boolean keepRun = true;
	for( int i = 0; i < serviceRecords.length && keepRun; i++ ) {
		r = serviceRecords[ i ];
		// Search for the desired UUID
		if( (e=r.getAttributeValue( 0x0001 )) != null ) {
			if ( e.getDataType() == DataElement.DATSEQ ) {
				en = (Enumeration< DataElement >)e.getValue();
				Object o;
				while( en.hasMoreElements() ) {
					o = en.nextElement().getValue();
					if ( o instanceof UUID ) {
						if ( ((UUID)o).equals( uuid ) ) {
							serviceRecord = r;
							keepRun = false;
						}
					}
				}
			} else if ( e.getDataType() == DataElement.UUID ) {
				if ( ((UUID)e.getValue()).equals( uuid ) ) {
					serviceRecord = r;
					keepRun = false;
				}
			}
		}
	}
}
 
开发者ID:jolie,项目名称:jolie,代码行数:32,代码来源:BTServiceDiscoveryListener.java

示例14: servicesDiscovered

import javax.bluetooth.ServiceRecord; //导入依赖的package包/类
public void servicesDiscovered( int transID, ServiceRecord[] serviceRecords )
{
	ValueVector vec = value.getChildren( "service" );
	Value v;
	for( ServiceRecord record : serviceRecords) {
		v = Value.create();
		v.getFirstChild( "location" ).setValue(
			record.getConnectionURL( ServiceRecord.NOAUTHENTICATE_NOENCRYPT, false )
		);
		vec.add( v );
	}
}
 
开发者ID:jolie,项目名称:jolie,代码行数:13,代码来源:BluetoothService.java

示例15: servicesDiscovered

import javax.bluetooth.ServiceRecord; //导入依赖的package包/类
public void servicesDiscovered(int transID, ServiceRecord[] servRecord) {
	logger.info("Device discovered: "+ servRecord[0].getConnectionURL(ServiceRecord.NOAUTHENTICATE_NOENCRYPT, false));
	if (servRecord != null && servRecord.length > 0) {
		deviceURL = servRecord[0].getConnectionURL(ServiceRecord.AUTHENTICATE_ENCRYPT, false);
	}
	synchronized (waitMutex) {
		waitMutex.notify();
	}
}
 
开发者ID:matthesrieke,项目名称:OBDig,代码行数:10,代码来源:OBDTestClient.java


注:本文中的javax.bluetooth.ServiceRecord类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。