iOS上的Qt蓝牙 [英] Qt Bluetooth on iOS

查看:84
本文介绍了iOS上的Qt蓝牙的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图搜索查询答案.似乎微不足道,但我还找不到答案.

I tried to search for an answer for my query. It seems trivial, but I cant find an answer yet.

我正在尝试在iOS上使用Qt蓝牙运行程序.我可以在MacOS上成功使用它.

I am trying to run a program using Qt Bluetooth on iOS. I am able to use it successfully on MacOS.

但是,即使是最基本的代码功能,例如:

But even the most basic feature of code like :

QBluetoothLocalDevice localDevice;
QString localDeviceName;

// Check if Bluetooth is available on this device
 if (localDevice.isValid()) {

// Turn Bluetooth on
localDevice.powerOn();

// Read local device name
localDeviceName = localDevice.name();

// Make it visible to others
localDevice.setHostMode(QBluetoothLocalDevice::HostDiscoverable);

// Get connected devices
QList<QBluetoothAddress> remotes;
remotes = localDevice.connectedDevices();
ui->textBrowser->setText(localDevice.name() + "\n" + localDevice.address().toString());

}

给我一​​个空向量作为地址.

gives me a null vector as the address.

在iOS中运行它是否需要一些特定的设置.我需要在info.plist文件上添加某些标志吗?请提出.

Is there some specific settings needed to run it in iOS. Do I need to add certain flags on info.plist file? Kindly suggest.

有关信息,我正在使用Qt 5.7和xcode 8,在macOS Sierra MacBook上进行编程并为iOS10构建它.

For information, I am using Qt 5.7 and xcode 8, programming on a macOS Sierra macbook and building it for iOS10.

推荐答案

确实,Paulw11指出,只能在iOS设备上使用低功耗蓝牙版本.

As pointed out by Paulw11, indeed, it is only possible to use Bluetooth Low Energy version on iOS devices.

尽管Qt文档中没有特别提及,但我还是建议您尝试将iOS设备编程为与外围设备通信的BLE中央设备.

Although not specifically mentioned in the Qt Documentation, I would recommend you to try to program the iOS device as a BLE Central Device that communicates with a peripheral device.

非常感谢Paulw11的投入.

Many thanks to Paulw11 for this input.

这篇关于iOS上的Qt蓝牙的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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