使用蓝牙读取联系人



我正在尝试使用 32feet 库从移动设备读取联系人,并且尝试时我的请求错误很差。该设备与我的应用程序配对。这是我的代码:

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获得联系。

也许当您必须为请求发送空名称时犯了一个错误。变量tName应为null,而不是"",因为""是字节中的0x00,而不是空名称标题。该库将将名称标头的大小发送为0x0004而不是0x0003,这是您的VCARD请求所需的。这是一个常见的错误,我也承诺了:(

为什么要提供tFileContents参数?我不需要。您可能必须删除参数。根据IRDA规格,不需要。

对不起,英语不好,我希望这个答案对此有所帮助。

最新更新