summaryrefslogtreecommitdiffstats
path: root/src/android
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@qt.io>2017-01-04 11:14:30 +0100
committerAlex Blasche <alexander.blasche@qt.io>2017-01-23 11:09:26 +0000
commiteaec158cf7ea2a62e79afd87701384830dee599d (patch)
tree7a56c42df37391a5e752a8e05e490dce8c4fbf01 /src/android
parentd66b34100ad3e5ddd226ba85c4e974ad08e22205 (diff)
Android: Keep track of peripheral advertisement errors
If advertisement fails then we drop back into the unconnected state and provide a more detailed error message for individual advertisement errors. Change-Id: Ic9de02b456409cd1a2dec11e53c884fe368ae267 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'src/android')
-rw-r--r--src/android/bluetooth/src/org/qtproject/qt5/android/bluetooth/QtBluetoothLEServer.java24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/android/bluetooth/src/org/qtproject/qt5/android/bluetooth/QtBluetoothLEServer.java b/src/android/bluetooth/src/org/qtproject/qt5/android/bluetooth/QtBluetoothLEServer.java
index 685b9161..43e44c86 100644
--- a/src/android/bluetooth/src/org/qtproject/qt5/android/bluetooth/QtBluetoothLEServer.java
+++ b/src/android/bluetooth/src/org/qtproject/qt5/android/bluetooth/QtBluetoothLEServer.java
@@ -237,9 +237,33 @@ public class QtBluetoothLEServer {
public void onStartFailure(int errorCode) {
Log.e(TAG, "Advertising failure: " + errorCode);
super.onStartFailure(errorCode);
+
+ // changing errorCode here implies changes to errorCode handling on Qt side
+ int qtErrorCode = 0;
+ switch (errorCode) {
+ case AdvertiseCallback.ADVERTISE_FAILED_ALREADY_STARTED:
+ return; // ignore -> noop
+ case AdvertiseCallback.ADVERTISE_FAILED_DATA_TOO_LARGE:
+ qtErrorCode = 1;
+ break;
+ case AdvertiseCallback.ADVERTISE_FAILED_FEATURE_UNSUPPORTED:
+ qtErrorCode = 2;
+ break;
+ default: // default maps to internal error
+ case AdvertiseCallback.ADVERTISE_FAILED_INTERNAL_ERROR:
+ qtErrorCode = 3;
+ break;
+ case AdvertiseCallback.ADVERTISE_FAILED_TOO_MANY_ADVERTISERS:
+ qtErrorCode = 4;
+ break;
+ }
+
+ if (qtErrorCode > 0)
+ leServerAdvertisementError(qtObject, qtErrorCode);
}
};
public native void leServerConnectionStateChange(long qtObject, int errorCode, int newState);
+ public native void leServerAdvertisementError(long qtObject, int status);
}