Methods Summary |
---|
private void | addTransaction(int transactionID)
for (int i = 0; i < transactions.length; i++) {
if (transactions[i] == -1) {
transactions[i] = transactionID;
return;
}
}
|
public void | deviceDiscovered(RemoteDevice device, DeviceClass type)
devices.addElement(device);
|
public static java.lang.String | getConnectionURL(java.lang.String uuid)
BluetoothServiceFinder finder
= new BluetoothServiceFinder(BluetoothReceiver.UUID);
return finder.getFirstURL();
|
private java.lang.String | getFirstURL()
try {
agent.startInquiry(DiscoveryAgent.GIAC, this);
synchronized (this) {
try {
this.wait();
}
catch (InterruptedException ex) {
}
}
}
catch (BluetoothStateException ex) {
System.out.println("No devices in range");
}
if (devices.size() > 0) {
RemoteDevice[] remotes = new RemoteDevice[devices.size()];
devices.copyInto(remotes);
if (searchServices(remotes)) {
return record.getConnectionURL(
ServiceRecord.NOAUTHENTICATE_NOENCRYPT, false);
}
}
return null;
|
public void | inquiryCompleted(int discType)
synchronized (this) {
this.notifyAll();
}
|
private void | removeTransaction(int transactionID)
for (int i = 0; i < transactions.length; i++) {
if (transactions[i] == transactionID) {
transactions[i] = -1;
return;
}
}
|
private boolean | searchServices(RemoteDevice[] devices)
UUID[] searchList = { new UUID(uuid, false) };
for (int i = 0; i < devices.length; i++) {
if (record != null) {
return true;
}
try {
// don't care about attributes
int transactionID = agent.searchServices(null, searchList, devices[i], this);
addTransaction(transactionID);
}
catch (BluetoothStateException ex) {
}
synchronized (this) {
serviceSearchCount++;
if (serviceSearchCount == transactions.length) {
try {
this.wait();
}
catch (InterruptedException ex) {
// continue
}
}
}
}
while (serviceSearchCount > 0) { // unfinished searches
synchronized (this) {
try {
this.wait();
}
catch (InterruptedException ex) {
// continue
}
}
}
if (record != null) return true;
else return false;
|
public void | serviceSearchCompleted(int transactionID, int responseCode)
removeTransaction(transactionID);
serviceSearchCount--;
synchronized (this) {
this.notifyAll();
}
|
public void | servicesDiscovered(int transactionID, ServiceRecord[] records)
if (record == null) {
record = records[0];
for (int i = 0; i < transactions.length; i++) {
if (transactions[i] != -1) {
agent.cancelServiceSearch(transactions[i]);
}
}
}
|