Код: Выделить всё
import java.io.*;
import java.util.Vector;
import javax.bluetooth.*;
import javax.microedition.io.Connector;
import javax.microedition.io.StreamConnection;
import javax.swing.*;
public class elmbtooth implements DiscoveryListener
{
private static Object lock = new Object();
private static Vector remdevices = new Vector();
private static String connectionURL = null;
public static void main(String args[]) throws IOException
{
BufferedReader b = new BufferedReader(new InputStreamReader(System.in));
elmbtooth obj = new elmbtooth();
LocalDevice locdevice = LocalDevice.getLocalDevice();
String add = locdevice.getBluetoothAddress();
String friendly_name = locdevice.getFriendlyName();
System.out.println("Local Bluetooth Address: " + add);
System.out.println("" +
"" +
"Local Friendly name: " + friendly_name);
DiscoveryAgent dis_agent = locdevice.getDiscoveryAgent();
System.out.println("********Locating Devices******");
dis_agent.startInquiry(DiscoveryAgent.GIAC, obj);
try
{
synchronized (lock)
{
lock.wait();
}
}
catch(InterruptedException e)
{
e.printStackTrace();
}
if(remdevices.size()
Подробнее здесь: [url]https://stackoverflow.com/questions/18431424/unable-to-communicate-with-elm327-bluetooth[/url]