28,20 → 28,37 |
|
public final int MAX_DEVICES=10; |
|
public RemoteDevice[] remote_devices; |
|
public int remote_device_count=0; |
public String[] remote_device_name; |
public String[] remote_device_mac; |
|
|
public void search_again() |
{ |
try |
{ |
remote_device_count=0; |
searching=true; |
m_DscrAgent.startInquiry(DiscoveryAgent.GIAC,this); |
} |
catch (BluetoothStateException ex) |
{ |
error=true; |
err_log+="Problem in searching the blue tooth devices\n" + ex; |
|
} |
|
|
} |
|
public BTSearcher() |
{ |
|
remote_devices=new RemoteDevice[MAX_DEVICES]; |
remote_device_name=new String[MAX_DEVICES]; |
remote_device_mac=new String[MAX_DEVICES]; |
|
remote_device_count=0; |
|
try |
{ |
//First get the local device and obtain the discovery agent. |
48,7 → 65,6 |
m_LclDevice = LocalDevice.getLocalDevice(); |
m_DscrAgent= m_LclDevice.getDiscoveryAgent(); |
|
m_DscrAgent.startInquiry(DiscoveryAgent.GIAC,this); |
} |
catch (BluetoothStateException ex) |
{ |
56,24 → 72,13 |
err_log+="Problem in searching the blue tooth devices\n" + ex; |
|
} |
|
search_again(); |
} |
|
|
public void inquiryCompleted(int transID) { |
|
try { |
for(int i=0;i<remote_device_count;i++) |
{ |
remote_device_name[i]=remote_devices[i].getFriendlyName(true); |
remote_device_mac[i]=remote_devices[i].getBluetoothAddress(); |
|
} |
} |
catch (Exception e) |
{ |
err_log+="Problem in searching the blue tooth devices"; |
} |
searching=false; |
} |
|
85,7 → 90,9 |
{ |
if (remote_device_count!=(MAX_DEVICES-1)) |
{ |
remote_devices[remote_device_count]=btDevice; |
|
remote_device_name[remote_device_count]=btDevice.getFriendlyName(true); |
remote_device_mac[remote_device_count]=btDevice.getBluetoothAddress(); |
remote_device_count++; |
} |
} |