[Interest] Qt, mobile and bearer management

Federico Buti bacarozzo at gmail.com
Fri Jun 19 12:04:47 CEST 2015


Hi list,

I've an application which connects to a custom WiFi device with hotspot
capability, collects some data and send the latter to some webservices
(both SOAP and REST). I've implemented SOAP requests via KDSoap and REST
via simple QNetworkRequests.

On desktop, WIFI is used with the device whereas cabled connection is used
for server interaction (trasparently w.r.t. my code). To ease user life
also on mobile devices, in our idea, the app must use WiFi connection to
communicate with the custom WiFi device and mobile data connection to
communicate with the servers. Unfortunately, It is not clear if this is
feasible or not and to what extent. I remember that there were some
limitations on network management on Android/iOS and I'm not sure if I can
still open/force a session with mobile data connection. At the same time,
it seems like the native ConnectivityManager
<http://developer.android.com/reference/android/net/ConnectivityManager.html>
provides
the right API for that.

In my REST class I've added the following code to force the
QNetworkConfigurationManager to use mobile data configuration:

    QNetworkConfigurationManager mgr;

    QList<QNetworkConfiguration> configs =
mgr.allConfigurations(QNetworkConfiguration::Discovered);

    foreach (QNetworkConfiguration conf, configs)

    {

        if(conf.bearerTypeFamily() == QNetworkConfiguration::Bearer3G
|| conf.bearerTypeFamily() == QNetworkConfiguration::Bearer4G ||

                conf.bearerTypeFamily() == QNetworkConfiguration::Bearer2G) {

            if(conf.state() >= QNetworkConfiguration::Discovered)

            {

                manager->setConfiguration(conf);

                break;

            }

    }


Unfortunately this does not change the common behaviour: as long as WiFi is
active and connected to the custom device, communication with the server is
not possible. If WiFi is turned off data is correctly sent. I've the
following permission in my manifest (pertinent to this issue):
ACCESS_NETWORK_STATE, ACCESS_WIFI_STATE, CHANGE_NETWORK_STATE,
CHANGE_WIFI_STATE, INTERNET.

First and foremost, I've missed something about Qt bearer management?
Secondly, if I enable mobile data from ConnectivityManager (by extending
QtActivity), can the above code work properly? Summing up, is there a way
to use the connections independently, as described above (with or without
native code)? Finally, if the answer to the previous question is "yes",
does the same can be done in iOS? I fear that the answer to this last
question is a big NO-NO...

Thanks in advance, at least for the time spent reading my question.
Cheers,
F.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20150619/9e473b10/attachment.html>


More information about the Interest mailing list