04-08-2013 12:09 PM
04-11-2013 05:31 AM
I'm also looking into this
a customer wants to integrate such a function to control the data traffic
04-11-2013 02:04 PM - edited 04-11-2013 03:14 PM
Well, its showing data usage that happened when the app was closed, and it resets after a reboot, so its likely either using program/lib included with the OS or its reading some log directly. It refreshes pretty quickly, so I don't think its parsing a log (most are not accessible anyway).
04-11-2013 06:29 PM - edited 04-11-2013 06:45 PM
Try this: ifconfig -v
It will show:
input: 233 packets, 98698 bytes
output: 492 packets, 197713 bytes
And they are separated by network type. You'll just have to figure out which is carrier vs wifi.
tiw_sta0 is WiFi
ecm0 is USB
bptp0 is carrier? (Probably not, I don't have a data plan, so I'm not sure)
You can match them up with the addresses that show under Settings -> About -> Network. There is a native API that will give you the list of interfaces, so maybe you can use that rather than hardcoding anything.
$ ifconfig -v lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 33192 input: 2582 packets, 515750 bytes output: 2582 packets, 515750 bytes inet 127.0.0.1 netmask 0xff000000 inet6 ::1 prefixlen 128 inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1 .. tiw_sta0: flags=8c43<UP,BROADCAST,RUNNING,OACTIVE,SIMPLEX,MU
LTICAST> mtu 1500 address: 40:6f:2a:68:33:55 input: 37576 packets, 7452193 bytes output: 3402 packets, 715738 bytes, 385 multicasts inet 10.2.250.11 netmask 0xfffff800 broadcast 10.2.255.255 inet6 fe80::426f:2aff:fe68:3355%tiw_sta0 prefixlen 64 scopeid 0x12 ... bptp0: flags=8043<UP,BROADCAST,RUNNING,MULTICAST> mtu 1357 input: 233 packets, 98698 bytes output: 492 packets, 197713 bytes inet6 fe80::426f:2aff:fe68:3355%bptp0 prefixlen 64 scopeid 0x2e inet6 fd20:c356:6e81:8b81:733b:42c:e51f:5f1b prefixlen 8 ecm0: flags=8a43<UP,BROADCAST,RUNNING,ALLMULTI,SIMPLEX,M ULTICAST> mtu 1500 address: 42:6f:2a:68:33:55 input: 3460 packets, 377825 bytes, 367 multicasts output: 2279 packets, 398960 bytes, 165 multicasts inet 169.254.0.1 netmask 0xfffffffc broadcast 169.254.0.3 inet6 fe80::406f:2aff:fe68:3355%ecm0 prefixlen 64 scopeid 0x18
04-12-2013 01:49 AM
thx for your info about ifconfig -v
as I understand it right this gives you the trafffic since last boot
...but I would have no idea howto get these values from Cascades ;-)
04-12-2013 03:25 AM
04-12-2013 04:28 AM
That seems to do the trick, good find Martin!
Ekke, it should be easy to do from Cascades, just read the values from a c++ utility class using Q_PROPERTY.
its more the question howto get the values from the command into c++