private static void addObex(int uuid) {
UUID u = new UUID(uuid);
obexUUIDs.put(u, u);
public List<ServiceRecord> findServices(LocalDevice localDevice, RemoteDevice device, int serviceIndex) throws InterruptedException, BluetoothStateException {
ServicesDiscoveryListener listener = new ServicesDiscoveryListener();
int tryRound = 0;
while (tryRound < maximumNumberOfTryToConnect && serviceRecords.isEmpty()) {
synchronized (lock) {
int[] attrIDs = new int[]{
0x0100 // Service name
if (log.isInfoEnabled()) {
log.info("Trying to get services (try " + tryRound + ")");
localDevice.getDiscoveryAgent().searchServices(attrIDs,
new UUID[]{new UUID(serviceIndex)},
device,
listener);
lock.wait();
tryRound++;
return serviceRecords;
public void connect(Device device) {
UUID[] uuidSet = new UUID[1];
uuidSet[0] = new UUID(SECURE_UUID, false);
try {
mDiscoveryAgent.searchServices(null, uuidSet, device.getRemoteDevice(), mClient);
} catch (BluetoothStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
notifierParams = new BluetoothConnectionNotifierParams(new UUID(portORuuid, false), paramBoolean(
values, AUTHENTICATE), paramBoolean(values, ENCRYPT), paramBoolean(values, AUTHORIZE),
(String) values.get(NAME), paramBoolean(values, MASTER));
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);