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

I would like to toggle internet connectivity via terminal (with dbus?) [answered]

asked 2014-09-19 16:27:36 +0200

LVPVS gravatar image

Hej,

I tried digging TJC for a terminal command to control internet connectivity from terminal, but was not able to find anything. I would like to use systemd.timer to toggle the internet connectivity on/off on my Jolla. No, not Flight Mode. I want to be able to be reached via phone, I just want mobile data and wifi off. Could somebody please help me?

I need something like this (this one is for Bluetooth):

dbus-send --system --print-reply --dest=net.connman /net/connman/technology/bluetooth net.connman.Technology.SetProperty string:"Powered" variant:boolean:true/false

Thanks, LVPVS

edit retag flag offensive reopen delete

The question has been closed for the following reason "the question is answered, an answer was accepted" by eric
close date 2014-09-23 10:29:25.159004

2 Answers

Sort by » oldest newest most voted
8

answered 2014-09-19 17:47:09 +0200

Philippe De Swert gravatar image

updated 2014-09-19 17:57:57 +0200

For wifi:

Turn off:

/bin/dbus-send --print-reply --type=method_call --system --dest=net.connman /net/connman/technology/wifi net.connman.Technology.SetProperty string:Powered variant:boolean:false

Turn on:

/bin/dbus-send --print-reply --type=method_call --system --dest=net.connman /net/connman/technology/wifi net.connman.Technology.SetProperty string:Powered variant:boolean:true

For cellular:

(complex method but not sure what happens if you disable the technology.) First you need to find the service:

/bin/dbus-send --system --type=method_call --print-reply --dest=net.connman / net.connman.Manager.GetServices

Its service path will be something with cellular_<lots_of_numbers>_context1</lots_of_numbers>

/bin/dbus-send --system --type=method_call --print-reply --dest=net.connman /net/connman/service/cellular_<blah>_<blah> net.connman.Service.Disconnect

And same with Connect if you want it to reconnect

Otherwise:

off:

/bin/dbus-send --print-reply --type=method_call --system --dest=net.connman /net/connman/technology/cellular net.connman.Technology.SetProperty string:Powered variant:boolean:false

on:

/bin/dbus-send --print-reply --type=method_call --system --dest=net.connman /net/connman/technology/cellular net.connman.Technology.SetProperty string:Powered variant:boolean:false

There should also be a connman tool to make things easier.

edit flag offensive delete publish link more

Comments

Thanks a lot! As I look at it, it seems so straight-forward I feel quite dumb not trying it myself. 8D Cheers!

LVPVS ( 2014-09-20 20:45:47 +0200 )edit
2

answered 2014-09-21 03:00:49 +0200

Schturman gravatar image

This is how I did it in my app: https://openrepos.net/content/schturman/quick-internet-onoff

wifi off:

dbus-send --system --print-reply --dest=net.connman /net/connman/technology/wifi net.connman.Technology.SetProperty string:"Powered" variant:boolean:false

wifi on:

dbus-send --system --print-reply --dest=net.connman /net/connman/technology/wifi net.connman.Technology.SetProperty string:"Powered" variant:boolean:true

3G off:

cell=$(/usr/lib/qt5/bin/qdbus --system net.connman|grep service|grep cell)
dbus-send --system --print-reply --dest=net.connman $cell net.connman.Service.SetProperty string:"AutoConnect" variant:boolean:false

3G on:

cell=$(/usr/lib/qt5/bin/qdbus --system net.connman|grep service|grep cell)
dbus-send --system --print-reply --dest=net.connman $cell net.connman.Service.SetProperty string:"AutoConnect" variant:boolean:true
edit flag offensive delete publish link more

Question tools

Follow
5 followers

Stats

Asked: 2014-09-19 16:27:36 +0200

Seen: 2,427 times

Last updated: Sep 21 '14