Read contacts using bluetooth

送分小仙女□ 提交于 2020-01-05 04:00:27

问题


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();

});

I dont know if there are another ways to get the contacts using OBEX.


回答1:


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 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.



来源:https://stackoverflow.com/questions/48872112/read-contacts-using-bluetooth

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!