Module connman_dbus
Get information about your network devices using Connman and DBus.
Requiring this module will return the Connman Manager singleton.
Proxy obejcts are updated in real time, provided that the code runs in a GLib main loop (such as the Awesome Window Manager).
NOTE: connman objects do not implement
org.freedesktop.DBus.Properties.PropertiesChanged
.
Info:
- Copyright: 2017 Stefano Mazzucco
- License: Apache License, version 2.0
- Author: Stefano Mazzucco
Functions
Manager:enable_offline_mode (is_offline) | Set the global offline mode. |
Manager:toggle_offline_mode () | Toggle the global offline mode. |
Manager:refresh_services () | Refresh the Manager.services table. |
Manager:refresh_technologies () | Refresh the Manager.technologies table. |
Tables
Manager | The Connman Manager singleton. |
Manager.services | Available Services. |
Manager.technologies | Available Technologies. |
_service Functions
Service:enable_autoconnect (should_autoconnect) | Set whether the service should connect automatically. |
Service:toggle_autoconnect () | Toggle the AutoConnect property. |
Service:configure_nameservers (nameservers) | Manually configure the domain name (DNS) servers. |
Service:configure_timeservers (timeservers) | Manually configure the time servers. |
Service:configure_search_domains (searchdomains) | Manually configure the search domains (instead of using DHCP or VPN). |
Service:configure_ipv4 (config) | Configure IPv4. |
Service:configure_ipv6 (config) | Configure IPv6. |
Service:configure_proxy (config) | Configure the proxy server. |
Service:enable_mdns (use_mdns) | Set whether Multicast DNS (mDNS) should be enabled for this service. |
_technology Functions
Technology:enable_power (is_powered) | Set whether the Technology should be powered. |
Technology:toggle_power () | Toggle the power state. |
Technology:enable_tethering (is_tethered) | Whether tethering should be enabled. |
Technology:toggle_tethering () | Toggle the tethering state. |
Technology:set_tethering_identifier (id) | Set the tethering broadcasted identifier. |
Technology:set_tethering_passphrase (secret) | Set the tethering connection passphrase (sensitive!). |
Functions
- Manager:enable_offline_mode (is_offline)
-
Set the global offline mode.
The offline mode indicates the global setting for switching all radios on or off. Changing offline mode to true results in powering down all devices. When leaving offline mode the individual policy of each device decides to switch the radio back on or not.
During offline mode, it is still possible to switch certain technologies manually back on. For example the limited usage of WiFi or Bluetooth devices might be allowed in some situations.
Parameters:
- is_offline boolean whether offline mode should be turned on
- Manager:toggle_offline_mode ()
-
Toggle the global offline mode.
See also:
- Manager:refresh_services ()
- Refresh the Manager.services table.
- Manager:refresh_technologies ()
- Refresh the Manager.technologies table.
Tables
- Manager
-
The Connman Manager singleton. This table is returned when the module is loaded with
require
.You must use
Manager:SetProperty
to set the writeable properties (you will need to wrap the value of the properti in anlgi.GLib.Variant
), then update them withManager:update_properties
.Manager's properties:
- State: string. One of "offline", "idle", "ready" or "online".
- OfflineMode: boolean
- SessionMode: boolean (deprecated, always false)
For more information, see the connman Manager API documentation
- Manager.services
-
Available Services.
Table containing Service objects. They can be accessed either using a numeric index (e.g.
Manager.services[1]
) or using their object path (e.g.Manager.services["/net/connman/service/wifi_123_managed_psk"]
). The lower its numeric index, the higher the priority the service has.For more information, see the connman Service API documentation.
- Manager.technologies
-
Available Technologies.
Table containing Technology objects. They can be accessed either using a numeric index (e.g.
Manager.technologies[1]
) or using their object path (e.g.Manager.technologies["/net/connman/technology/wifi"]
).For more information, see the connman Technology API documentation.
_service Functions
- Service:enable_autoconnect (should_autoconnect)
-
Set whether the service should connect automatically.
If set to true, this service will auto-connect when no other connection is available.
The service won't auto-connect while roaming.
For favorite services it is possible to change this value to prevent or permit automatic connection attempts.
Parameters:
- should_autoconnect boolean whether the service should connect automatically.
- Service:toggle_autoconnect ()
-
Toggle the AutoConnect property.
See also:
- Service:configure_nameservers (nameservers)
-
Manually configure the domain name (DNS) servers.
Some cellular networks don't provide correct name servers and this allows for an override.
When using manual configuration and no global nameservers are configured, then it is useful to configure this setting.
Changes to the domain name servers can be done at any time. It will not cause a disconnect of the service. However there might be small window where name resolution might fail.
Parameters:
- nameservers {string,...} Array of strings. This array is sorted by priority and the first entry in the list represents the nameserver with the highest priority.
- Service:configure_timeservers (timeservers)
-
Manually configure the time servers.
When using manual configuration this setting is useful to override all the other timeserver settings. This is service specific, hence only the values for the default service are used.
Calling this method will result in restart of NTP query.
Parameters:
- timeservers {string,...} Array of strings. The first entry in the list represents the timeserver with the highest priority.
- Service:configure_search_domains (searchdomains)
-
Manually configure the search domains (instead of using DHCP or VPN).
Parameters:
- searchdomains {string,...} Array of strings.
- Service:configure_ipv4 (config)
-
Configure IPv4.
Calling this method will cause a state change of the service. The service will become unavailable until the new configuration has been successfully installed.
Parameters:
- config
table
table with the following fields:
Method
(string) Possible values aredhcp
,manual
,auto
andoff
.Address
(string) The IPv4 address.Netmask
(string) The IPv4 netmask.Gateway
(string) The IPv4 gateway.
- config
table
- Service:configure_ipv6 (config)
-
Configure IPv6.
Calling this method will cause a state change of the service. The service will become unavailable until the new configuration has been successfully installed.
Parameters:
- config
table
table with the following fields:
Method
(string) Possible values areauto
,manual
, andoff
.Address
(string) The IPv6 address.PrefixLength
(number) The prefix length of the IPv6 address.Gateway
(string) The IPv6 gateway.Privacy
(string) Set the IPv6 privacy extension as described in RFC4941. The value has only meaning ifMethod
is set toauto
. Possible values aredisabled
,enabled
andpreferred
.
- config
table
- Service:configure_proxy (config)
-
Configure the proxy server.
Parameters:
- config
table
table with the following fields:
Method
(string) Possible values aredirect
,auto
andmanual
. In case ofauto
method, the URL file can be provided by theURL
field (unless you want to let DHCP/WPAD auto-discover to be tried). For themanual
method theServers
field must be set, theExcludes
field is optional.URL
(string) Automatic proxy configuration URL. Needed whenMethod
is set toauto
.Servers
({string,...}) List of proxy URIs. The URI without a protocol will be interpreted as the generic proxy URI. All others will target a specific protocol and only once. This field must be set ifMethod
is set tomanual
. For example, a generic proxy URI may look likeserver.example.com:911
.Excludes
({string,...}) List of hosts which can be accessed without the need of a proxy. This field is optionally used whenMethod
is set toauto
.
- config
table
- Service:enable_mdns (use_mdns)
-
Set whether Multicast DNS (mDNS) should
be enabled for this service.
Note: mDNS requires a DNS backend which supports it. Currently the only DNS backend which supports mDNS is
systemd-resolved
.Parameters:
- use_mdns boolean Whether mDNS should be used.
_technology Functions
- Technology:enable_power (is_powered)
-
Set whether the Technology should be powered.
Parameters:
- is_powered boolean Whether the Technology should be powered.
- Technology:toggle_power ()
-
Toggle the power state.
See also:
- Technology:enable_tethering (is_tethered)
-
Whether tethering should be enabled.
This method allows one to enable or disable the support for tethering. When tethering is enabled then the default service is bridged to all clients connected through the technology.
Parameters:
- is_tethered boolean Whether tethering is enabled.
- Technology:toggle_tethering ()
-
Toggle the tethering state.
See also:
- Technology:set_tethering_identifier (id)
-
Set the tethering broadcasted identifier.
This method is only valid for the WiFi technology, and is then mapped to the WiFi AP SSID clients will have to join in order to gain internet connectivity.
Parameters:
- id string The tethering identifier.
- Technology:set_tethering_passphrase (secret)
-
Set the tethering connection passphrase (sensitive!).
This method is only valid for the WiFi technology, and is then mapped to the WPA pre-shared key clients will have to use in order to establish a connection.
IMPORTANT SECURITY NOTE
Take extra care when using this method and the corresponding
TetheringPassphrase
field as connman does not make any security guarantee in regard!!!Parameters:
- secret string The tethering passphrase.