首页 文章

某些手机不支持C#32feet obex bluetooth

提问于
浏览
1

我有一个项目,卡拉OK机器记录用户,然后让用户通过蓝牙与他/她的手机连接到机器并下载他们的录音 . 经过大量阅读,示例,文档我尝试使用 32feet (卡拉OK是用 C# .NET 编写的),但我找到发送文件的唯一方法是使用 ObexWebResponse ,有些手机没有这项服务:

http://oi62.tinypic.com/153s8p5.jpg(来自蓝牙OBEX文件传输的图片)

这会导致程序抛出异常 (this code is a sample I took from an answer here to just test sending video files before taking the dialogs out of the way and make it more automatic once the user pairs itself to the karaoke machine)

private void sendfile()
    {
        SelectBluetoothDeviceDialog dialog = new SelectBluetoothDeviceDialog();
        dialog.ShowAuthenticated = true;
        dialog.ShowRemembered = true;
        dialog.ShowUnknown = true;
        OpenFileDialog ofd = new OpenFileDialog();
        ofd.Title = "Select File";
        if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
        {
            string m_pin = "";
            Console.WriteLine(BluetoothSecurity.PairRequest(dialog.SelectedDevice.DeviceAddress, m_pin));

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                var uri = new Uri("obex://" + dialog.SelectedDevice.ToString() + "/" + ofd.FileName);
                var request = new ObexWebRequest(uri);
                request.ReadFile(ofd.FileName);
                var response = (ObexWebResponse)request.GetResponse(); // << THIS THROWS AN EXCEPTION WITH THE ADDITIONAL INFORMATION: CONNECT FAILED.
                response.Close();
            }
            else
            {
                MessageBox.Show("File Not Selected");
            }
        }
        else
        {
            MessageBox.Show("Device Not Selected");
        }
    }

Debbuger也显示:http://oi62.tinypic.com/e6rpkg.jpg

OBEX有替代品吗?与每部手机兼容的东西,或者与不兼容的设备混合使用OBEX的方法 .

我使用本机Windows应用程序 (control panel > Devices and printers > Bluetooth devices > 'device name' > send file) 发送文件,因此这不是一个与硬件相关的问题,如果有任何解决方案,即使在其他语言或库中,请给我一个指导如何实现这一点 .

提前谢谢您的阅读时间!

1 回答

相关问题