【问题标题】:Get listed bluetooth devices uuid with out pairing在不配对的情况下获取列出的蓝牙设备 uuid
【发布时间】:2013-12-13 13:04:04
【问题描述】:

我可以列出可用的bluetoothdevices,但我没有得到服务器bluetoothdevice 的UUID。 我的目的是列出可用的bluetooth server(另一个安卓设备)的数量。我什至不确定如何从所有可用的bluetoothdevices 中识别我的服务器设备。

  • 对于第一个提到的问题,我也使用了 fetchUuidsWithSdp(),但我在 UUID broadcast receiver 中得到了 nullvalue。有人请帮忙, 提前致谢。

【问题讨论】:

  • 你能在不配对的情况下获得 UUID..???
  • Get listed bluetooth devices uuid with out pairing - 你的意思是不需要连接到设备,仍然可以获得UUID?这种情况需要设备支持此功能,例如 Beacon。如果信标已经支持,您可以通过 BLE 扫描并获取 UUID。

标签: android bluetooth uuid android-broadcast android-bluetooth


【解决方案1】:
bluetooth = BluetoothAdapter.getDefaultAdapter();

if(bluetooth != null)
    {
        String status;
        if (bluetooth.isEnabled()) {
            String mydeviceaddress = bluetooth.getAddress();
            String mydevicename = bluetooth.getName();
            status = mydevicename + " : " + mydeviceaddress;
            bluetooth.startDiscovery();
        }
        else
        {
            status = "Bluetooth is not Enabled.";
        }
    }

在广播接收器中

public class Receiver extends BroadcastReceiver
{
    @Override
    public void onReceive(Context context, Intent intent) 
    {               
        if (BluetoothDevice.ACTION_FOUND.equals(intent.getAction())) 
        {
            BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
            String uuid = intent.getStringExtra(BluetoothDevice.EXTRA);

        }
}

【讨论】:

  • 我也是这样做的,但是当我得到 BluetoothDevice.ACTION_FOUND 时,uuid 为空
  • 我的理解:对等设备使用SDP获取UUID列表,可能需要SDP设备配对。
猜你喜欢
  • 2011-06-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多