Qt Bluetooth on iOS

匆匆过客 提交于 2021-02-10 06:31:09

问题


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

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.

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

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


回答1:


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

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.

Many thanks to Paulw11 for this input.



来源:https://stackoverflow.com/questions/40258183/qt-bluetooth-on-ios

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