【问题标题】:Android bluetooth connection with bluetooth rs232 adapterAndroid蓝牙连接蓝牙rs232适配器
【发布时间】:2014-07-15 10:58:00
【问题描述】:

我一直在计划制作一个可以与这个蓝牙 rs232 适配器通信的 Android 应用程序

http://www.nordfield.com/wireless-serial-rs232-bluetooth-adapter

我不确定在这种情况下我应该如何处理 UUID?我是否能够开始与应用程序的连接,该应用程序看起来像 Google 的 BluetoothChat 示例应用程序?

https://android.googlesource.com/platform/development/+/25b6aed7b2e01ce7bdc0dfa1a79eaf009ad178fe/samples/BluetoothChat/

【问题讨论】:

  • 有什么工作要做吗?

标签: android bluetooth android-bluetooth


【解决方案1】:

嗯,我已经解决了这个问题。实际上有可能在不知道设备的 UUID 的情况下创建蓝牙连接。是通过这段代码实现的:

public ConnectThread(BluetoothDevice device) {
        mmDevice = device;
        BluetoothSocket tmp = null;

        try {               
            Method method;

            method = device.getClass().getMethod("createRfcommSocket", new Class[] { int.class } );
            tmp = (BluetoothSocket) method.invoke(device, 1);  

        } catch (Exception e) { }

        mmSocket = tmp;
    }    

所有其余的连接管理都与 Google 的 BluetoothChat 示例应用程序相同。

【讨论】:

    猜你喜欢
    • 2010-12-29
    • 1970-01-01
    • 2014-12-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多