【问题标题】:How to connect to the bluetooth server and discover a service?如何连接到蓝牙服务器并发现服务?
【发布时间】:2019-10-03 06:10:11
【问题描述】:

我无法连接到我的蓝牙服务器,在 rpi 上设置。我需要一个connectionUrl,大概是从ServiceRecord 中获取的。但我似乎无法让它工作。

我已经使用 bluecove 设置了它,并且有一个正在运行的服务器,可以发现。但是,我在设备上找不到任何服务。 服务器:

UUID uuid = new UUID("446118f08b1e11e29e960800200c9a66", false);
String connectionString = "btspp://localhost:" + uuid + ";name=Mine";
StreamConnectionNotifier streamConnNotifier = (StreamConnectionNotifier) Connector.open(connectionString);

客户:

UUID[] uuidSet = new UUID[1];
uuidSet[0] = new UUID("446118f08b1e11e29e960800200c9a66", false);
agent.searchServices(null, uuidSet, remoteDevice, client);

public void servicesDiscovered(int transID, ServiceRecord[] servRecord) {
System.out.println("service discovered");

但是没有发现服务。如果我在服务器中执行以下操作:

ServiceRecord sr = local.getRecord(streamConnNotifier);
System.out.println(sr);

..除此之外,我明白了:

0x1:
    DATSEQ {
UUID 446118f08b1e11e29e960800200c9a66
UUID 0000110100001000800000805f9b34fb
}

我猜我可以通过 url 连接到服务 btspp://b827ebe97e0e:446118f08b1e11e29e960800200c9a66,但我不能,我得到IllegalArgumentException: channel 446118f08b1e11e29e960800200c9a66

【问题讨论】:

    标签: java bluetooth bluecove


    【解决方案1】:

    有人吗?我用的是java,服务器设置在树莓派上,客户端是我的macbook笔记本。

    将 UUID 用作“端口”是否正确(如果我们说的是 http)?

    【讨论】:

    • 我的蓝牙体验:知者勿言。说话的人不知道。
    猜你喜欢
    • 2012-08-18
    • 1970-01-01
    • 2018-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多