在C#中使用Obex读取联系人 [英] Read contacts using obex in c#

查看:196
本文介绍了在C#中使用Obex读取联系人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用32feet库读取C#的联系人.我正在通过蓝牙将PC连接到移动设备,而当我尝试执行此代码时,总是会出现错误的请求错误

I'm trying to read contacts using 32feet library for c#. I'm connecting my PC to mobile device via bluetooth, and when I try to execute this code always give me bad request error

LocalInfo.SetServiceState(BluetoothService.PhonebookAccessPce, true);
BluetoothAddress addr = BluetoothAddress.Parse("00:00:00:00:00:00");
BluetoothEndPoint rep = new BluetoothEndPoint(addr, BluetoothService.PhonebookAccessPse);
BluetoothClient cli = new BluetoothClient();
cli.Connect(rep);

Uri uri = new Uri(ObexUri.UriSchemeObex + "://" + addr + "/telecom/pb.vcf");
ObexWebRequest request = new ObexWebRequest(uri);
request.Method = "GET";
request.ContentType = "text/x-vCard";
ObexWebResponse resp = (ObexWebResponse)request.GetResponse();

在构造函数中:

private BluetoothDeviceInfo localinfo = null;
public BluetoothDeviceInfo LocalInfo
    {
        get
        {
            return localinfo = (localinfo ?? new BluetoothDeviceInfo(BluetoothRadio.PrimaryRadio.LocalAddress));
        }
    }

我做错了什么? URI是否错误,或者我需要其他蓝牙?

What I'm doing wrong? Is the URI wrong, or I need a different Bluetooth?

推荐答案

尽管我不是32feet的专家,但我知道GET请求检索vcard的Name Header应该是null.为什么不尝试使用空或null URI?

Though I am not an expert in 32feet, I know that the Name Header of the GET request retrieving vcard should be null. Why don't you try using empty or null URI?

编辑,我发现一些要求您使用obex-ftp而不是obex的语句.

Edit I found some statements that requires you to use obex-ftp instead of obex.

备注

对于对象交换,方法代码映射到等效的HTTP 样式方法.例如"PUT","GET"等."PUT"是默认设置 价值.从2.5版开始,对GET有了新的支持.

For Object Exchange the method code is mapped to the equivalent HTTP style method. For example "PUT", "GET" etc. "PUT" is the default value. There is new support for GET as of version 2.5.

要使用GET,请将方法"更改为"GET",并且还必须使用scheme 网址中的"obex-ftp",而不是通常的"obex"-除非您 知道您要连接的默认OBEX服务器支持GET.

To use GET change the Method to " GET " and you must also use scheme " obex-ftp " in the URL instead of the usual " obex " -- unless you know that the default OBEX server you are connecting supports GET.

它从这里.

修改

电话簿访问与文件传输类似,但使用目标{0x79, 0x61、0x35、0xF0、0xF0、0xC5、0x11、0xD8、0x09、0x66、0x08、0x00, 0x20、0x0C,0x9A,0x66};可以列出电话簿条目(带有各种 可能的排序和过滤器)并从某些目录中检索 在telecom/下,使用GET和SETPATH

Phonebook Access Similar to file transfer, but uses a target {0x79, 0x61, 0x35, 0xF0, 0xF0, 0xC5, 0x11, 0xD8, 0x09, 0x66, 0x08, 0x00, 0x20, 0x0C, 0x9A, 0x66}; phonebook entries can be listed (with various possible orderings and filters) and retrieved from certain directories under telecom/ using GET and SETPATH

-根据Wikipedia,当您连接到phonebook access时,应在TARGET标头中放置一些特定的UUID.

--according to wikipedia you should put some specific UUID to TARGET header when you connect to phonebook access.

类似于在此,您不仅应该在RFCOMM级别上指定PBAP服务UUID 0000112f-0000-1000-8000-00805f9b34fb,而且还必须在OBEX级别上的类型标头中指定目标标头UUID 0x79, 0x61, 0x35, (byte) 0xf0, (byte) 0xf0, (byte) 0xc5, 0x11, (byte) 0xd8, 0x09, 0x66, 0x08, 0x00, 0x20, 0x0c, (byte) 0x9a, 0x66.

Like codes from here, you should not only specify PBAP Service UUID 0000112f-0000-1000-8000-00805f9b34fb on RFCOMM level, but also have to specify target header UUID 0x79, 0x61, 0x35, (byte) 0xf0, (byte) 0xf0, (byte) 0xc5, 0x11, (byte) 0xd8, 0x09, 0x66, 0x08, 0x00, 0x20, 0x0c, (byte) 0x9a, 0x66 on OBEX level in type header.

这篇关于在C#中使用Obex读取联系人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆