Stop
This content is outdated and preserved only for posterities sake; I rewrote it for the Moblin SDK documentation: A developers introduction to ConnMan. However even that revised and edited version is likely of little use with modern ConnMan.
There was an accompanying tutorial: D-Bus – An overview, for those not familiar with D-Bus.
Writing connectivity user interfaces for the ConnMan daemon is about as easy
such a task can be.
ConnMan can be controlled entirely via its D-Bus interface.
This is just a stripped down set of notes towards some documention for the ConnMan website.
The [overview](http://git.kernel.org/?p=network/connman/connman.git;a=blob;f=doc/overview-api.txt) is probably a better starter for now.
## Manager
The entry point for the ConnMan D-Bus API is the manager interface.
[org.moblin.connman.Manager](http://git.kernel.org/?p=network/connman/connman.git;a=blob;f=doc/manager-api.txt)
From here you should be able to perform most of the operations required by a
connectivity UI.
### Interesting properties
The Manager object has several properties of interest:
State (RO): Global state of the system (online, connected or offline)
AvailableTechnologies (RO): Array of technologies available on the system
(wifi, ethernet, wimax, cellular, bluetooth)
EnabledTechnologies (RO): Array of enabled technologies
ConnectedTechnologies (RO): Array of technologies with an active connection
OfflineMode (RW): Boolean representing whether offline mode is enabled
Services (RO): Sorted array of object paths of available Services objects
### Useful methods
Useful methods on the Manager object include:
GetState (): If you want to know the daemon state but don’t care about the rest
of the properties
RequestScan (string type): Triggers a network scan. Argument is the type of
technology you’d like to scan on.
An empty string triggers all scannable technologies.
EnableTechnology (string type):
DisableTechnology (string type): Methods used to enable/disable technologies.
String argument is the type of technology to
enable/disable.
This method will appropriately set the powered
state of the device.
ConnectService (dict network): Connect to a service as specified by the
properties in the network dictionary.
Typically used for connecting to hidden
networks.
For connecting to a hidden WiFi network the
dict might look as follows:
{‘Type’:’wifi’,
‘Mode’:’managed’,
‘SSID’:’ssid’,
‘Security’:’WEP’,
‘Passphrase’:’secret’}
## Service
Services are ConnMan’s abstract interface for all available connection options.
[org.moblin.connman.Service](http://git.kernel.org/?p=network/connman/connman.git;a=blob;f=doc/service-api.txt)
The Service property of the Manger is a sorted list of available services.
For more information on service sorting see the [overview](http://git.kernel.org/?p=network/connman/connman.git;a=blob;f=doc/overview-api.txt).
### Interesting properties
A Service object has many properties, some of the more interesting ones:
State (RO): The status of the service as a string. Valid values are:
idle, failure, association, configuration and ready.
Obviously ready is when the service is usable for connectivity.
Error (RO): When the service state is failure this property may contain a string
explaining why this is the case.
Security (RO): The type of security for a wireless network. Possible values are
none, wep, wpa, rsn.
Passphrase (RW): The passphrase of the service.
### Useful methods
SetProperty (string name, variant value):
ClearProperty (string name): Setting and clearing RW properties. Passphrase
being the most obvious candidate.
Connect ():
Disconnect (): Do as expected. For a secure service the Passphrase property
should be set before the Connect method is called.
Remove (): Disconnects the network, clears the favourite flag and clears any
stored passphrase.
MoveBefore (object service): To prioritise one connected Service over another
call the MoveBefore method with the object path of
the Service to prioritise over as argument.
## Example code
There are a few places in the wild to see examples of using ConnMan’s D-Bus interface.
1. Test scripts: Several Python scripts exist in the test directory of ConnMan.
[ConnMan repo](http://git.kernel.org/?p=network/connman/connman.git;a=summary)
2. connman-gnome: A Gtk+ UI for ConnMan. Mostly a test-area for the API.
The common directory is the best place to start looking.
One comment
Comments are closed.