java—设备的服务发现

7nbnzgx9  于 2021-07-03  发布在  Java
关注(0)|答案(0)|浏览(314)

我正在研究raspberry pi,并尝试使用蓝牙将dell pc与raspberry pi连接起来。我的类正在实现覆盖四个端口的discoverylistenermethods:devicediscovered,inquirycompleted,servicesdiscovered和servicesearchcompleted。但是ServiceDiscovery方法不仅仅是执行的..这是我的ServiceDiscovery代码:

@Override
public void servicesDiscovered(int transID, ServiceRecord[] servRecord)
{
    System.out.println("hiii");
    for (int i = 0; i < servRecord.length; i++)
    {
        String url =
                servRecord[i].getConnectionURL(ServiceRecord.NOAUTHENTICATE_NOENCRYPT, false);
        if (url == null)
        {
            continue;
        }
        DataElement serviceName = servRecord[i].getAttributeValue(0x0100);
        if (serviceName != null)
        {
            System.out.println("service " + serviceName.getValue() + " found " + url);

            if (serviceName.getValue().equals("OBEX Object Push"))
            {
                sendMessageToDevice(url);
            }
        }
        else
        {
            System.out.println("service found " + url);
        }
    }
}

我能知道这背后的原因吗?谢谢

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题