We have moved to a new Sailfish OS Forum. Please start new discussions there.
4

Starting and stopping tethering via the command line

asked 2015-05-18 20:46:22 +0200

rolandw gravatar image

I've been doing my best to work out dbus calls in order to come up with a command line to turn tethering off (OK, I turn it on and then forget to turn it off and it would be cool to have Situations remember to do it for me when I connect to WiFi).

A call to DBus to find out what is there gives me this:

[root@Jolla /]# dbus-send --session --print-reply --dest="org.freedesktop.DBus" /org/freedesktop/DBus org.freedesktop.DBus.ListActivatableNames
method return sender=org.freedesktop.DBus -> dest=:1.113 reply_serial=2
   array [
      string "org.freedesktop.DBus"
      string "org.freedesktop.thumbnails.Manager1"
      string "org.freedesktop.systemd1"
      string "org.freedesktop.Tracker1.Miner.Extract"
      string "com.jolla.ambienced"
      string "org.freedesktop.Geoclue.Providers.Here"
      string "org.freedesktop.ohm_session_agent"
      string "com.nokia.asbackup"
      string "org.freedesktop.Geoclue.Master"
      string "org.freedesktop.thumbnails.Cache1"
      string "harbour.jollagram.client"
      string "com.nokia.singlesignonui"
      string "org.gnome.GConf"
      string "com.nokia.SingleSignOn.Backup"
      string "com.jolla.csd"
      string "org.freedesktop.thumbnails.Thumbnailer1"
      string "org.nemo.transferengine"
      string "org.freedesktop.Tracker1.Writeback"
      string "org.bluez.obex.client"
      string "ca.desrt.dconf"
      string "com.nokia.NonGraphicFeedback1.Backend"
      string "org.freedesktop.Telepathy.ConnectionManager.gabble"
      string "org.bluez.obex"
      string "org.freedesktop.Tracker1.Miner.Applications"
      string "org.freedesktop.Tracker1"
      string "com.google.code.AccountsSSO.SingleSignOn"
      string "org.freedesktop.Telepathy.Client.SaslSignonAuth"
      string "com.jolla.settings"
      string "com.jolla.notes"
      string "org.freedesktop.Geoclue.Providers.Hybris"
      string "com.jolla.jollastore"
      string "com.jolla.camera"
      string "com.jolla.email.ui"
      string "com.jolla.calendar.ui"
      string "org.freedesktop.Telepathy.Client.qmlmessages"
      string "com.jolla.mediaplayer"
      string "com.nokia.asdbus"
      string "org.maliit.server"
      string "org.freedesktop.Telepathy.AccountManager"
      string "com.jolla.ObexCallData"
      string "org.sailfishos.maps"
      string "com.jolla.clock"
      string "com.jolla.contacts.ui"
      string "org.sailfishos.browser"
      string "com.jolla.voicecall.ui"
      string "org.nemomobile.qmlmessages"
      string "com.jolla.gallery"
      string "com.nokia.profiled"
      string "harbour.mitakuuluu2.server"
      string "org.sailfish.office"
      string "org.freedesktop.Telepathy.MissionControl5"
      string "org.freedesktop.Telepathy.ConnectionManager.ring"
      string "org.freedesktop.Tracker1.Miner.Files"
      string "harbour.mitakuuluu2.client"
      string "com.nokia.voland"
      string "org.freedesktop.Tracker1.Miner.Userguides"
   ]

But looking at dbus-monitor as I click on the Tethering in Settings gives me this:

method call sender=:1.85 -> dest=com.jolla.Connectiond serial=99 path=/Connectiond; interface=com.jolla.Connectiond; member=stopTethering
boolean false

(Little tip in case you are doing some similar research, run dbus-monitor out to a file via "dbus-monitor > ~/monitor.txt" stopping it with the good old ctrl-C. Then you can search through that file for something sensible. dbus-monitor throws all sorts at you very fast and doesn't seem to like being piped through grep.)

Clearly com.jolla.Connectiond isn't in the list of available dBus calls. I've tried various combinations such as:

dbus-send --system --print-reply --dest=com.jolla.Connectiond /Connectiond com.jolla.connectionagent.stopTethering boolean:false

and only ever get told that either I have an error in my call or that there is no /Connectiond service.

Connectiond does exist in /usr/share/dbus-1/services/com.jolla.Connectiond.service and this seems to point to /usr/bin/connectionagent.

Can anyone point out my elementary error and tell me how to turn off tethering from the command line?

edit retag flag offensive close delete

Comments

Why can't it be done via the UI?

Aashish ( 2015-05-18 20:48:39 +0200 )edit
1

I'm human so I'm stupid - I could easily do it by taking the phone out of my pocket, double tapping it, entering my password, swiping up and then clicking on the "Settings" icon and then simply clicking on the "Tethering" favourite icon at the top to turn it off. But I don't. I forget. I remember to turn it on because I have to be able to get my emails during my commute to work. Frequently I forget to turn it off. I leave the phone in my pocket and forget when I'm in the office. Because I'm tethering it won't connect to the local network so I can't stop tethering by stopping internet services. Hence a requirement to use a timer in Situations or something similar to do it for me. If I leave tethering on then there frequently isn't enough juice at the end of the day to use tethering for my hour's journey back home!

rolandw ( 2015-05-18 21:17:25 +0200 )edit

1 Answer

Sort by » oldest newest most voted
4

answered 2015-05-19 01:22:11 +0200

jr gravatar image

connmanctl tether wifi off

edit flag offensive delete publish link more

Comments

connmanctl isn't installed by default:

[root@Jolla nemo]# connmanctl tether wifi on
bash: connmanctl: command not found

So having got to root (run devel-su) run:

[root@Jolla nemo]# pkcon install connman-tools

Now the tether command produces:

[root@Jolla ~]# connmanctl tether wifi on
bash: connmanctl: command not found

but running the command with the full path works:

[nemo@Jolla ~]# /usr/lib/connman/tools/connmanctl tether wifi on
Enabled tethering for wifi
[nemo@Jolla ~]# /usr/lib/connman/tools/connmanctl tether wifi off
Disabled tethering for wifi

So to do it without writing the full path, you need to add the path to the connman tools:

[nemo@Jolla ~]# echo 'export PATH=="${PATH}:/usr/lib/connman/tools/"' >> ~/.bashrc
[nemo@Jolla ~]# source ~/.bashrc

Do this for both nemo user and root and this command should persist through reboots.

Now try

[nemo@Jolla~]# connmanctl --help

And you should get all the details...

Much easier than dbus!

rolandw ( 2015-05-21 13:19:33 +0200 )edit
Login/Signup to Answer

Question tools

Follow
4 followers

Stats

Asked: 2015-05-18 20:46:22 +0200

Seen: 1,439 times

Last updated: May 19 '15