API Documentation

Documentation for developing SailfishOS applications

WLAN Provisioning

WLAN provisioning and network access control is handled through Connman connection manager.

Provisioning networks

You can add new networks using asynchronous createService() or synchronous createServiceSync() methods in NetworkManager API.

Add network

 NetworkManager *manager = NetworkManagerFactory::createInstance();

 auto createService = [manager] {
     QVariantMap settings;
     settings.insert("Name", "MyNetwork");
     settings.insert("Security", "ieee8021x");
     settings.insert("EAP", "peap");
     settings.insert("Hidden", "true");
     settings.insert("Identity", "myidentity");
     settings.insert("Passphrase", "mypassphrase");
     settings.insert("AutoConnect", "true");
     settings.insert("Access", "sailfish:1;*=deny;GetProperty(Access)=allow;user(sailfish-mdm)=allow");
     QString path = manager->createServiceSync(settings, "wifi");
     qInfo() << "Created network" << path;
 };

 if (manager->isAvailable()) {
     createService();
 } else {
     QObject::connect(manager, &NetworkManager::availabilityChanged, createService);
 }

where the fields are

  • SSID - 802.11 SSID in a hexadecimal form
  • Name - SSID in a string form
  • Security - Used security type "none", "web", "psk" (WPA/WPA2 PSK), "ieee8021x" (WPA EAP)
  • EAP - EAP authentication method, currently only "peap" is supported
  • Identity - Identity string for EAP
  • Passphrase - RSN/WPA/WPA2 Passphrase
  • Hidden - "true" if hidden
  • AutoConnect - "true" if the device should connect automatically when in range
  • Access - Access control rules

You can also define proxy settings and manual IPv4 address for the client.

Set automatic proxy

 settings.insert("Proxy.Method", "auto")
 settings.insert("Proxy.URL", "http://www.proxy.net")

Set manual proxy

 settings.insert("Proxy.Method", "manual")
 settings.insert("Proxy.Servers", "http://example.proxy.net:8080")
 settings.insert("Proxy.Excludes", "domain1.net;domain2.net")

Set manual IPv4 address

 settings.insert("IPv4.method", "manual")
 settings.insert("IPv4.netmask_prefixlen", "255")
 settings.insert("IPv4.local_address", "192.168.1.30")
 settings.insert("IPv4.gateway", "192.168.1.1")
 settings.insert("Nameservers", "nameserver1.net;nameserver2.net")
 settings.insert("Domains", "defaultdomain1.net;defaultdomain2.net")
 settings.insert("TimeServers", "10.2.3.4;192.168.1.99")

Access network object

You can access the service object of your provisioned network from the saved services list.

 NetworkManager *manager = NetworkManagerFactory::createInstance();
 QObject::connect(manager, &NetworkManager::servicesListChanged, [manager, &app] {
     QVector<NetworkService*> services = manager->getSavedServices("wifi");
     foreach (NetworkService *service, services) {
         if (service->name() == ssid) {
             qInfo() << "Found network" << service->name();
             break;
         }
     }
 };

NetworkService API provides methods to request connection, fetch information about the network, remove the network from saved services list, and so on. Services added by device management should have managed property set to true. See the Connman Service API documentation for more information about the supported methods.

We use cookies to improve your user experience and to help us to develop our services. By continuing to browse the site, you approve of our use of cookies.