1 Application programming interface
2 *********************************
8 Inside Connection Manager there exists one advanced interface to allow the
9 user interface an easy access to networking details and user chosen
10 preferences. This is the service list and interface.
12 The basic idea is that Connection Manager maintains a single flat and sorted
13 list of all available, preferred or previously used services. A service here
14 can be either a Ethernet device, a WiFi network, a WiMAX service provider
15 or a remote Bluetooth device (for example a mobile phone).
17 This list of service is sorted by Connection Manager and there is no need
18 for the user interface to implement its own sorting. User decisions will
19 need to be done via Connection Manager and it is then responsible to update
20 the order of services in this list.
22 +---------------------------------------+
24 +---------------------------------------+
26 +---------------------------------------+
27 | Guest (strength 90, none) |
28 +---------------------------------------+
29 | My WiFi AP (strength 80, rsn) |
30 +---------------------------------------+
31 | Clear WiMAX (strength 70) |
32 +---------------------------------------+
33 | Other AP (strength 70, rsn) |
34 +---------------------------------------+
35 | Friends AP (strength 70, wep) |
36 +---------------------------------------+
37 | Other WiMAX (strength 50) |
38 +---------------------------------------+
40 If none of the services has been used before the sorting order will be done
41 with these priorities:
43 1. Ethernet (lower index numbers first)
44 2. Bluetooth (last used devices first)
45 3. GSM/UTMS/3G (if SIM card is present, activated and not roaming)
46 3. WiFi/WiMAX (signal strength first, then prefer WiMAX over WiFi,
47 then more secure network first)
49 The Ethernet devices are always sorted first since they are physically built
50 into the system and will be always present. In cases they are switched off
51 manually they will not be showing in this list.
53 Since every Bluetooth device has to be configured/paired first, the user
54 already made a choice here that these are important. Connection Manager will
55 only show devices with PAN or DUN profile support. While Bluetooth devices
56 do have a signal strength, it is mostly unknown since background scanning
57 in Bluetooth is too expensive. The choice here is to sort the last used
58 Bluetooth device before the others.
60 The WiFi and WiMAX networks are treated equally since both provide signal
61 strength information and networks closer in the proximity should be shown
62 before others since it is more likely they are selected first. The signal
63 strength value is normalized to 0-100 (effectively a percentage) and allows
66 If the signal strength is identical then the WiMAX network should be shown
67 first since it is a licensed spectrum and more reliable. Also the number
68 of WiMAX networks will be smaller than the number of WiFi since that operates
69 in an unlicensed spectrum.
71 WiFi networks with the same signal strength are then sorted by their security
72 setting. WPA2 encrypted networks should be preferred over WPA/WEP and also
73 unencrypted ones. After that they will be sorted by the SSID in alphabetical
76 In the case the WiFi network uses WPS for setup and it is clearly detectable
77 that a network waits for Connection Manager to connect to it (for example via
78 a push-to-connect button press on the AP), then this network should be shown
79 first before any other WiFi or WiMAX network. The reason here is that the
80 user already made a choice via the access point. However this depends on
81 technical details if it is possible to detect these situations.
87 All unused services will have the internal order number of 0 and then will
88 be sorted according to the rules above. For Bluetooth the user already made
89 the decision to setup their device and by that means select it. However
90 until the first connection attempt it might have been setup for total
91 different reason (like audio usage) and thus it still counts as unused from
92 a networking point of view.
94 Selecting the "My WiFi AP" and successfully connecting to it makes it a
95 favorite device and it will become an order number bigger than 0. All
96 order numbers are internally. They are given only to service that are marked
97 as favorite. For WiFi, WiMAX and Bluetooth a successful connection attempt
98 makes these services automatically a favorite. For Ethernet the plugging
99 of a cable makes it a favorite. Disconnecting from a network doesn't remove
100 the favorite setting. It is a manual operation and is equal to users pressing
101 delete/remove button.
103 +---------------------------------------+
104 | My WiFi AP (strength 80, rsn) | order=1 - favorite=yes
105 +---------------------------------------+
107 +---------------------------------------+
108 | Guest (strength 90, none) | order=0
109 +---------------------------------------+
112 Ethernet is special here since the unplugging of the network cable will
113 remove the favorite selection.
115 +---------------------------------------+
116 | Ethernet with cable | order=1 - favorite=yes
117 +---------------------------------------+
118 | Ethernet without cable | order=0 - favorite=no
119 +---------------------------------------+
120 | Guest (strength 90, none) | order=0
121 +---------------------------------------+
124 This means that all services with an order > 0 have favorite=yes and all
125 others have favorite=no setting. The favorite setting is exposed via a
126 property over the service interface. As mentioned above, the order number
127 is only used internally.
129 Within Connection Manager many services can be connected at the same time and
130 also have an IP assignment. However only one can have the default route. The
131 service with the default route will always be sorted at the top of the
134 +---------------------------------------+
135 | Ethernet | order=2 - connected=yes
136 +---------------------------------------+
137 | My WiFi AP (strength 80, rsn) | order=1 - connected=yes
138 +---------------------------------------+
139 | Guest (strength 90, none) | order=0
140 +---------------------------------------+
143 To change the default connection to your access point, the user needs to
144 manually drag the access point service to the top of the list. Connection
145 Manager will not take down default routes if there is no reason to do so.
146 A working connection is considered top priority.
148 +---------------------------------------+
149 | My WiFi AP (strength 80, rsn) | order=2 - connected=yes
150 +---------------------------------------+
151 | Ethernet | order=1 - connected=yes
152 +---------------------------------------+
153 | Guest (strength 90, none) | order=0
154 +---------------------------------------+
157 Another possible user interaction would be to unplug the Ethernet cable and
158 in this case the favorite setting will be removed and the service falls back
161 +---------------------------------------+
162 | My WiFi AP (strength 80, rsn) | order=1 - connected=yes
163 +---------------------------------------+
165 +---------------------------------------+
166 | Guest (strength 90, none) | order=0
167 +---------------------------------------+
170 If the service on the top of the list changes the default route will be
171 automatically adjusted as needed. The user can trigger this by disconnecting
172 from a network, if the network becomes unavailable (out of range) or if the
173 cable gets unplugged.
175 As described above, the pure case of disconnecting from a network will not
176 remove the favorite setting. So previously selected networks are still present
177 and are sorted above all others.
179 +---------------------------------------+
180 | Ethernet | order=2 - connected=yes
181 +---------------------------------------+
182 | My WiFi AP (strength 80, rsn) | order=1 - connected=no
183 +---------------------------------------+
184 | Guest (strength 90, none) | order=0
185 +---------------------------------------+
188 Unplugging the Ethernet cable will remove the favorite setting, but due to
189 the basic ordering of services it will be at the top of the services with an
190 order number of 0 (directly after all favorite services).
192 +---------------------------------------+
193 | My WiFi AP (strength 80, rsn) | order=1 - connected=no
194 +---------------------------------------+
195 | Ethernet | order=0 - connected=no
196 +---------------------------------------+
197 | Guest (strength 90, none) | order=0
198 +---------------------------------------+
205 The interfaces of Connection Manager will always export all services that are
206 currently known. The Ethernet devices with no cable plugged are actually not
207 included in this list. They will only show up once a carrier is detected.
209 The service interface is not meant for basic device configuration task. So
210 switching a device on and off (via RFKILL for example) should be done via
211 the device interface.
213 Due to limited screen size of small devices and the big amount of WiFi
214 access points that are deployed right now it might be sensible to not show
215 certain WiFi networks in the user interface.
217 The choice to hide a WiFi network from the user interface should be purely
218 done by the signal strength. The optimal cut-off value here still has to be
219 determined, but in the end that is a user interface policy.
225 Every service will have a name property that allows the user interface to
226 display them directly. All names will be already converted into UTF-8. It
227 derives from the netork details.
229 In case of WiFi this will be the SSID value. The SSID is a binary array and
230 will be converted into printable form. Unprintable characters are replaced
233 For WiMAX networks the provider name like Clear or X-OHM will be used. This
234 name either comes directly from the network itself or from a provisioning
235 database of the WiMAX service.
237 For Bluetooth the device alias is used. The alias is different since it
238 can be overwritten by the user via the Bluetooth service. The identification
239 is still done based on its address, but the display name might change. In
240 most cases the alias is equal to the Bluetooth remote friendly name.
242 For Ethernet device no name will be provided. The type property will indicate
243 that this service is Ethernet and then it is up to the user interface to
244 provide a proper localized name for it.
250 Every service can have multiple states that indicate what is currently
251 going on with it. The choice to have multiple states instead of a simple
252 connected yes/no value comes from the fact that it is important to let the
253 user interface name if a service is in process of connecting/disconnecting.
255 The basic state of every service is "idle". This means that this service
256 is not in use at all at the moment. It also is not attempting to connect
259 The "association" state indicates that this service tries to establish a
260 low-level connection to the network. For example associating/connecting
261 with a WiFi access point.
263 With the "configuration" state the service indicates that it is trying
264 to retrieve/configure IP settings.
266 The "ready" state signals a successful connected device. This doesn't mean
267 it has the default route, but basic IP operations will succeed.
269 With the "disconnect" state a service indicates that it is going to terminate
270 the current connection and will return to the "idle" state.
272 In addition a "failure" state indicates a wrong behavior. It is similar to
273 the "idle" state since the service is not connected.
276 | idle |<-------------------------------+
280 +----------------------| failure | |
281 | service.Connect() +-------------+ |
283 +---------------+ | |
284 | association |-----------------+ |
285 +---------------+ error | |
289 +---------------+ | |
290 | configuration |-----------------+ |
291 +---------------+ error |
303 | online |<----------------+ |
304 +---------------+ | |
306 | service.Disconnect() | |
308 +---------------+ | |
309 | disconnect |-----------------+ |
310 +---------------+ error |
312 +------------------------------------------+
314 The different states should no be used by the user interface to trigger
315 advanced actions. The state transitions are provided for the sole purpose
316 to give the user feedback on what is currently going on. Especially in
317 cases where networks are flaky or DHCP servers take a long time these
318 information are helpful for the user.
320 Some services might require special authentication procedure like a web
321 based confirmation. The LoginRequired property should be used to check
328 All applications should use D-Bus to communicate with Connection Manager. The
329 main entry point is the manager object. Currently the manager object is
330 located at "/", but this might change to allow full namespacing of the API
331 in the future. The manager interface is documented in manager-api.txt and
332 contains a set of global properties and methods.
334 A simple way to retrieve all global properties looks like this:
336 bus = dbus.SystemBus()
338 manager = dbus.Interface(bus.get_object("net.connman", "/"),
339 "net.connman.Manager")
341 properties = manager.GetProperties()
343 Changing a global property is also pretty simple. For example enabling the
344 so called offline mode (aka flight mode) it is enough to just set that
347 manager.SetProperty("OfflineMode", dbus.Boolean(1))
349 The manager object contains references to profiles, devices, services and
350 connections. All these references represent other interfaces that allow
351 detailed control of Connection Manager. The profiles and devices interfaces
352 are more for advanced features and most applications don't need them at all.
354 The services are represented as a list of object paths. Every of these object
355 paths contains a service interface. A service is a global collection for
356 Ethernet devices, WiFi networks, Bluetooth services, WiMAX providers etc. and
357 all these different types are treated equally.
359 Every local Ethernet card will show up as exactly one service. WiFi networks
360 will be grouped by SSID, mode and security setting. Bluetooth PAN and DUN
361 service will show up per remote device. For WiMAX the provider name will
362 be used for grouping different base stations and access providers. This
363 creates a simple list that can be directly displayed to the users since these
364 are the exact details users should care about.
366 properties = manager.GetProperties()
368 for path in properties["Services"]:
369 service = dbus.Interface(bus.get_object("net.connman", path),
370 "net.connman.Service")
372 service_properties = service.GetProperties()
374 The service interface is documented in service-api.txt and contains common
375 properties valid for all services. It also contains method to connect or
376 disconnect a specific service. This allows users to select a specific service.
377 Connection Manager can also auto-connect services based on his policies or
378 via external events (like plugging in an Ethernet cable).
380 Connecting (or disconnecting) a specific service manually is as simple as
381 just telling it to actually connect:
383 service.Connect() or service.Disconnect()
385 It is possible to connect multiple services if the underlying technology
386 allows it. For example it would be possible to connect to a WiFi network
387 and a Bluetooth service at the same time. Trying to connect to a second WiFi
388 network with the same WiFi hardware would result in an automatic disconnect
389 of the currently connected network. Connection Manager handles all of this
390 for the applications in the background. Trying to connect an Ethernet service
391 will result in an error if no cable is plugged in. All connection attempts
392 can fail for one reason or another. Application should be able to handle
393 such errors and will also be notified of changes via signals.
395 In future versions Connection Manager will interact with an agent to confirm
396 certain transactions with the user. This functionality is currently not
399 To monitor the current status of a service the state property can be used. It
400 gives detailed information about the current progress.
402 properties = service.GetProperties()
404 print properties["State"]
406 All state changes are also sent via the PropertyChanged signal on the
407 service interface. This allows asynchronous monitoring without having to poll
408 Connection Manager for changes.