summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorOliver Wolff <oliver.wolff@qt.io>2017-11-02 14:26:21 +0100
committerOliver Wolff <oliver.wolff@qt.io>2017-11-03 08:30:05 +0000
commit2a5f325733fa43961d785bf9a0d5c209bd8c5c76 (patch)
tree7434fdfe36fd6cc4b86b3c1f2eabeccfb7d85b46 /src
parent6029bad7d1007aecd155985ba13d6c23a01015b8 (diff)
winrt: Reflect unsupported state of peripheral role of lowenergycontroller
There currently is no API for supporting the peripheral role on winrt, but there is no way to reflect that inside our API. If a user tries to set up a low energy peripheral device, the application should not crash though. The crash occurred, when the controller was set up in a perihperal role and the application tried to read or write a descriptor or characteristic. In this case the functions should just return early. Task-number: QTBUG-63709 Change-Id: I30b277788d822f869743e1f294ee1402abd36309 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/bluetooth/qlowenergycontroller_winrt.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/bluetooth/qlowenergycontroller_winrt.cpp b/src/bluetooth/qlowenergycontroller_winrt.cpp
index e4ae76b0..8517a942 100644
--- a/src/bluetooth/qlowenergycontroller_winrt.cpp
+++ b/src/bluetooth/qlowenergycontroller_winrt.cpp
@@ -651,6 +651,7 @@ void QLowEnergyControllerPrivate::discoverServiceDetails(const QBluetoothUuid &s
void QLowEnergyControllerPrivate::startAdvertising(const QLowEnergyAdvertisingParameters &, const QLowEnergyAdvertisingData &, const QLowEnergyAdvertisingData &)
{
+ setError(QLowEnergyController::AdvertisingError);
Q_UNIMPLEMENTED();
}
@@ -669,6 +670,12 @@ void QLowEnergyControllerPrivate::readCharacteristic(const QSharedPointer<QLowEn
{
qCDebug(QT_BT_WINRT) << __FUNCTION__ << service << charHandle;
Q_ASSERT(!service.isNull());
+ if (role == QLowEnergyController::PeripheralRole) {
+ service->setError(QLowEnergyService::CharacteristicReadError);
+ Q_UNIMPLEMENTED();
+ return;
+ }
+
if (!service->characteristicList.contains(charHandle)) {
qCDebug(QT_BT_WINRT) << charHandle << "could not be found in service" << service->uuid;
service->setError(QLowEnergyService::CharacteristicReadError);
@@ -728,6 +735,12 @@ void QLowEnergyControllerPrivate::readDescriptor(const QSharedPointer<QLowEnergy
{
qCDebug(QT_BT_WINRT) << __FUNCTION__ << service << charHandle << descHandle;
Q_ASSERT(!service.isNull());
+ if (role == QLowEnergyController::PeripheralRole) {
+ service->setError(QLowEnergyService::DescriptorReadError);
+ Q_UNIMPLEMENTED();
+ return;
+ }
+
if (!service->characteristicList.contains(charHandle)) {
qCDebug(QT_BT_WINRT) << "Descriptor" << descHandle << "in characteristic" << charHandle
<< "cannot be found in service" << service->uuid;
@@ -854,6 +867,11 @@ void QLowEnergyControllerPrivate::writeCharacteristic(const QSharedPointer<QLowE
{
qCDebug(QT_BT_WINRT) << __FUNCTION__ << service << charHandle << newValue << mode;
Q_ASSERT(!service.isNull());
+ if (role == QLowEnergyController::PeripheralRole) {
+ service->setError(QLowEnergyService::CharacteristicWriteError);
+ Q_UNIMPLEMENTED();
+ return;
+ }
if (!service->characteristicList.contains(charHandle)) {
qCDebug(QT_BT_WINRT) << "Characteristic" << charHandle << "cannot be found in service" << service->uuid;
service->setError(QLowEnergyService::CharacteristicWriteError);
@@ -938,6 +956,12 @@ void QLowEnergyControllerPrivate::writeDescriptor(
{
qCDebug(QT_BT_WINRT) << __FUNCTION__ << service << charHandle << descHandle << newValue;
Q_ASSERT(!service.isNull());
+ if (role == QLowEnergyController::PeripheralRole) {
+ service->setError(QLowEnergyService::DescriptorWriteError);
+ Q_UNIMPLEMENTED();
+ return;
+ }
+
if (!service->characteristicList.contains(charHandle)) {
qCDebug(QT_BT_WINRT) << "Descriptor" << descHandle << "in characteristic" << charHandle
<< "could not be found in service" << service->uuid;