使用bluecove接收来自蓝牙设备的数据

时间:2018-10-16 07:19:15

标签: java bluetooth bluecove

我的问题很简单。我正在笔记本电脑中的Eclipse中使用bluecove来获取蓝牙地址列表。我想要的是从这些列出的蓝牙地址之一接收数据。以下是我的简单代码:

import javax.bluetooth.DiscoveryAgent;
import javax.bluetooth.LocalDevice;
import javax.bluetooth.RemoteDevice;

public class interactor
{
    public interactor()
    {
        try
        {
            LocalDevice device = LocalDevice.getLocalDevice();

            RemoteDevice[] remotedevice = device.getDiscoveryAgent().retrieveDevices(DiscoveryAgent.PREKNOWN);

            for(RemoteDevice btDevice : remotedevice)
            {
                System.out.println("Device Name : " + btDevice.getFriendlyName(false));
                System.out.println("Bluetooth Address : " + btDevice.getBluetoothAddress()+"\n");

            }   
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
    }
}

0 个答案:

没有答案