使用蓝牙读取联系人 [英] Read contacts using bluetooth
问题描述
我正在尝试使用 32feet 库从移动设备中读取联系人,并且在尝试时遇到错误的请求错误.该设备已与我的应用配对.这是我的代码:
I'm trying to read contacts from my mobile device using 32feet library and i'm having a bad request error when I try. The device is paired with my app. This is my code:
var item = (BluetoothDeviceInfo)listBox.SelectedItem;
Task.Run(() =>
{
item.Update();
item.Refresh();
item.SetServiceState(BluetoothService.PhonebookAccess, true);
if (OBEXOpenStream(item.DeviceAddress.ToString()))
{
if (OBEXConnect())
{
string tName = "";
string tType = "text/x-vCard";
string tFileContent = "";
int result = OBEXRequest("GET", tName, tType, tFileContent);
item.ShowDialog();
}
}
OBEXCloseStream();
});
我不知道是否还有其他方法可以使用OBEX获取联系人.
I dont know if there are another ways to get the contacts using OBEX.
推荐答案
在您必须为请求发送空名称标头时,您可能犯了一个错误.变量 tName
应该为 null
,而不是"
,因为"
为 0x00
以字节为单位,而不是空的名称标头.库将发送名称标头的大小为 0x0004
,而不是 0x0003
,这是vCard请求所必需的.这是一个常见的错误,我也犯了这个错误:)
Maybe you made a mistake when you have to send a empty name header for the request. The variable tName
should be null
not ""
, as ""
is 0x00
in bytes, not empty name header. The library will send the size of the name header as0x0004
, not 0x0003
, which is required for your vCard request. This is a common mistake, and I commited it too :)
OR 为什么给 tFileContents
参数?据我所知,这是没有必要的.您可能必须删除该参数.根据IRDA规范,它不是必需的.
OR
Why do you give tFileContents
parameter? It is not necessary as I know. You may have to delete the parameter. According to IRDA spec, it is not needed.
对不起,英语不好,我希望这个答案能对您有所帮助.
Sorry for poor English and I hope this answer helped a lot.
这篇关于使用蓝牙读取联系人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!