本文整理汇总了Java中javax.bluetooth.UUID类的典型用法代码示例。如果您正苦于以下问题:Java UUID类的具体用法?Java UUID怎么用?Java UUID使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
UUID类属于javax.bluetooth包,在下文中一共展示了UUID类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: PAKBluetoothPairingHandler
import javax.bluetooth.UUID; //导入依赖的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));
}
示例2: init
import javax.bluetooth.UUID; //导入依赖的package包/类
/**
* Process the search/download requests.
*/
public void init() {
try {
// create/get a local device and discovery agent
LocalDevice localDevice = LocalDevice.getLocalDevice();
discoveryAgent = localDevice.getDiscoveryAgent();
} catch (Exception e) {
eventListener.errorOccured("Can't initialize bluetooth: ", e);
System.err.println("Can't initialize bluetooth: " + e);
}
// initialize some optimization variables
uuidSet = new UUID[2];
// ok, we are interesting in btspp services only
uuidSet[0] = new UUID(0x1101);
// and only known ones, that allows pictures
uuidSet[1] = SERVER_UUID;
}
示例3: startServiceSearch
import javax.bluetooth.UUID; //导入依赖的package包/类
/**
*
* This method is used to re-establish a connection to a device when we have the address.
*
* @param address The address to the device
*/
public void startServiceSearch(String address){
// Connects to a remote device with the given address
RemoteDeviceInstance remoteDevice = new RemoteDeviceInstance(address);
try{
localDevice = LocalDevice.getLocalDevice();
agent = localDevice.getDiscoveryAgent();
uuids[0] = new UUID(uuidString, false);
servicesFound = new Vector();
devicesFound = new Vector();
agent.searchServices(attributes,uuids,remoteDevice,this);
}catch(BluetoothStateException bse) {
log.logException("BluetoothServiceDiscovery.startServiceSearch()",bse, false);
// throw bse;
}
}
示例4: selectFromDevicesList
import javax.bluetooth.UUID; //导入依赖的package包/类
private String selectFromDevicesList(RemoteDevice[] devs, UUID uuid,
int security, boolean master, Hashtable disDevsHash) {
if (devs == null) {
return null;
}
for (int i = 0; i < devs.length; i++) {
if (disDevsHash.put(devs[i], devs[i]) != null) {
continue;
}
String url = selectService(devs[i], uuid, security, master);
if (url != null) {
if (DEBUG) {
System.out.println("\turl=" + url);
}
return url;
}
}
return null;
}
示例5: searchService
import javax.bluetooth.UUID; //导入依赖的package包/类
public int searchService(int[] attrSet, UUID[] uuidSet, RemoteDevice btDev,
DiscoveryListener discListener) throws BluetoothStateException,
IllegalArgumentException {
if (DEBUG) {
System.out.println("- serviceSearcher: initializing");
}
initialize(attrSet, uuidSet, btDev);
if (discListener == null) {
throw new NullPointerException("DiscoveryListener is null");
}
this.discListener = discListener;
return start();
}
示例6: ClientServiceSearchAttributeTransaction
import javax.bluetooth.UUID; //导入依赖的package包/类
public ClientServiceSearchAttributeTransaction(JavaSDPClient client, int transactionID,
SDPResponseListener listener, int[] attrSet,
UUID[] uuidSet) {
super(client, SDPClientTransaction.SDP_SERVICE_SEARCH_ATTRIBUTE_REQUEST, transactionID,
listener);
attrData = new DataElement(DataElement.DATSEQ);
uuidData = new DataElement(DataElement.DATSEQ);
for (int i = 0; i < attrSet.length; i++) {
attrData.addElement(new DataElement(DataElement.U_INT_2,
attrSet[i]));
}
for (int i = 0; i < uuidSet.length; i++) {
uuidData.addElement(new DataElement(DataElement.UUID,
uuidSet[i]));
}
parameterLength = super.client.getConnection().getReaderWriter().getDataSize(attrData) +
super.client.getConnection().getReaderWriter().getDataSize(uuidData) + 2;
}
示例7: hasProtocolClassUUID
import javax.bluetooth.UUID; //导入依赖的package包/类
boolean hasProtocolClassUUID(UUID uuid) {
DataElement protocolDescriptor = getAttributeValue(BluetoothConsts.ProtocolDescriptorList);
if ((protocolDescriptor == null) || (protocolDescriptor.getDataType() != DataElement.DATSEQ)) {
// DebugLog.debug("Bogus ProtocolDescriptorList");
return false;
}
for (Enumeration protocolsSeqEnum = (Enumeration) protocolDescriptor.getValue(); protocolsSeqEnum
.hasMoreElements();) {
DataElement elementSeq = (DataElement) protocolsSeqEnum.nextElement();
if (elementSeq.getDataType() == DataElement.DATSEQ) {
Enumeration elementSeqEnum = (Enumeration) elementSeq.getValue();
if (elementSeqEnum.hasMoreElements()) {
DataElement protocolElement = (DataElement) elementSeqEnum.nextElement();
if (protocolElement.getDataType() != DataElement.UUID) {
continue;
}
if (uuid.equals(protocolElement.getValue())) {
return true;
}
}
}
}
return false;
}
示例8: servicesFoundCallback
import javax.bluetooth.UUID; //导入依赖的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);
}
示例9: testDATSEQ
import javax.bluetooth.UUID; //导入依赖的package包/类
public void testDATSEQ() throws IOException {
DataElement seq1 = new DataElement(DataElement.DATSEQ);
seq1.addElement(new DataElement(DataElement.STRING, "BlueCove-seq1"));
seq1.addElement(new DataElement(DataElement.U_INT_1, 0x12));
seq1.addElement(new DataElement(DataElement.URL, "http://blueCove/"));
seq1.addElement(new DataElement(DataElement.STRING, stringUTFData));
seq1.addElement(new DataElement(DataElement.UUID, new UUID("B10C0BE1111111111111111111110001", false)));
DataElement seq2 = new DataElement(DataElement.DATSEQ);
seq2.addElement(new DataElement(DataElement.U_INT_8, new byte[] { 1, -2, 3, 4, -5, 6, 7, -8 }));
seq2.addElement(new DataElement(DataElement.STRING, getLongString(0x100 + 2)));
seq2.addElement(new DataElement(DataElement.U_INT_2, 0x14));
DataElement seq3 = new DataElement(DataElement.DATSEQ);
seq3.addElement(new DataElement(DataElement.U_INT_4, 0x15));
seq3.addElement(new DataElement(DataElement.STRING, stringUTFData));
seq3.addElement(new DataElement(DataElement.UUID, new UUID(0x1105)));
seq3.addElement(new DataElement(DataElement.INT_8, 0x16));
seq1.addElement(seq2);
seq1.addElement(seq3);
seq1.addElement(new DataElement(DataElement.INT_4, 0x1BCDEF35l));
validateConversion(seq1);
}
示例10: deviceDiscovered
import javax.bluetooth.UUID; //导入依赖的package包/类
@Override
public void deviceDiscovered(RemoteDevice device, DeviceClass deviceClass) {
UUID[] uuids = new UUID[] {new UUID(uuid, false)};
// Try to discover the services associated with the UUID
try {
discoveryAgent.searchServices(null, uuids, device, this);
searches.incrementAndGet();
} catch (BluetoothStateException e) {
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
}
}
示例11: findNestedClassIds
import javax.bluetooth.UUID; //导入依赖的package包/类
private void findNestedClassIds(Object o, Collection<String> ids) {
o = getDataElementValue(o);
if (o instanceof Enumeration<?>) {
for (Object o1 : Collections.list((Enumeration<?>) o))
findNestedClassIds(o1, ids);
} else if (o instanceof UUID) {
ids.add(o.toString());
}
}
示例12: bluetoothServer
import javax.bluetooth.UUID; //导入依赖的package包/类
/**
* start server creating an UUID and a connection String,
* then waiting for a device to connect
*/
private void bluetoothServer() {
if (sendReciveMessageThread.isAlive()) {
sendReciveMessageThread.interrupt();
}
try {
//Create a UUID for SPP
UUID uuid = new UUID("1101", true);
//Create the servicve url
String connectionString = "btspp://localhost:" + uuid + ";name=Sample SPP Server";
//open server url
streamConnNotifier = (StreamConnectionNotifier) Connector.open(connectionString);
//Wait for client connection
System.out.println("\nServer Started. Waiting for clients to connect...");
StreamConnection connection = streamConnNotifier.acceptAndOpen();
System.out.println("Remote device address: " + RemoteDevice.getRemoteDevice(connection).getBluetoothAddress());
System.out.println("Remote device name: " + RemoteDevice.getRemoteDevice(connection).getFriendlyName(true));
//the stream is opened both in and out
outStream = connection.openOutputStream();
inStream = connection.openInputStream();
connectionIsAvaible = true;
SingletonStaticGeneralStats.getInstance().setBluetoothServerCreated(true);
sendBluetoothMessage();
} catch (IOException e) {
e.printStackTrace();
//in case of problems, the connection is stopped
closeConnection();
}
}
示例13: servicesDiscovered
import javax.bluetooth.UUID; //导入依赖的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;
}
}
}
}
}
示例14: deviceDiscovered
import javax.bluetooth.UUID; //导入依赖的package包/类
public void deviceDiscovered(RemoteDevice device, DeviceClass deviceClass) {
UUID[] uuids = new UUID[] { new UUID(uuid, false) };
// Try to discover the services associated with the UUID
try {
discoveryAgent.searchServices(null, uuids, device, this);
searches.incrementAndGet();
} catch(BluetoothStateException e) {
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
}
}
示例15: findNestedClassIds
import javax.bluetooth.UUID; //导入依赖的package包/类
private void findNestedClassIds(Object o, Collection<String> ids) {
o = getDataElementValue(o);
if(o instanceof Enumeration<?>) {
for(Object o1 : Collections.list((Enumeration<?>) o))
findNestedClassIds(o1, ids);
} else if(o instanceof UUID) {
ids.add(o.toString());
}
}